Update patch for apps-menu
Daniel Ruiz de AlegrÃa
2 years ago
3 | 3 | |
4 | 4 | Bug-Kali: https://bugs.kali.org/view.php?id=2223 |
5 | 5 | Bug: https://bugzilla.gnome.org/show_bug.cgi?id=739480 |
6 | ||
6 | 7 | --- |
7 | extensions/apps-menu/extension.js | 163 ++++++++++++++++++++++++++++++-------- | |
8 | 1 file changed, 130 insertions(+), 33 deletions(-) | |
8 | extensions/apps-menu/extension.js | 166 ++++++++++++++++++++++++------ | |
9 | 1 file changed, 133 insertions(+), 33 deletions(-) | |
9 | 10 | |
10 | 11 | diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js |
11 | index 2cbb754..09105bf 100644 | |
12 | index cc1d697..58ac020 100644 | |
12 | 13 | --- a/extensions/apps-menu/extension.js |
13 | 14 | +++ b/extensions/apps-menu/extension.js |
14 | @@ -96,30 +96,36 @@ class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem { | |
15 | }); | |
16 | ||
17 | var CategoryMenuItem = GObject.registerClass( | |
15 | @@ -98,34 +98,40 @@ class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem { | |
16 | } | |
17 | } | |
18 | ||
18 | 19 | -class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { |
19 | - _init(button, category) { | |
20 | - super._init(); | |
21 | - this._category = category; | |
22 | - this._button = button; | |
23 | - | |
24 | - this._oldX = -1; | |
25 | - this._oldY = -1; | |
26 | 20 | +class CategoryMenuItem extends PopupMenu.PopupMenuItem { |
27 | 21 | + /* Kali patch note: the use of PopupMenuItem instead of |
28 | 22 | + * PopupBaseMenuItem means that all the code in _onMotionEvent and |
30 | 24 | + * be passed to the parent constructor instead of being added in the |
31 | 25 | + * menu item by ourselves. The _oldX/_oldY variables are not |
32 | 26 | + * initialized as they are only needed for isNavigatingSubmenu */ |
33 | ||
34 | + _init(button, category) { | |
27 | + | |
28 | static { | |
29 | GObject.registerClass(this); | |
30 | } | |
31 | ||
32 | constructor(button, category) { | |
33 | - super(); | |
34 | - this._category = category; | |
35 | - this._button = button; | |
36 | - | |
37 | - this._oldX = -1; | |
38 | - this._oldY = -1; | |
39 | - | |
35 | 40 | let name; |
36 | 41 | - if (this._category) |
37 | 42 | - name = this._category.get_name(); |
41 | 46 | name = _('Favorites'); |
42 | 47 | |
43 | 48 | - this.add_child(new St.Label({ text: name })); |
44 | + super._init(name); | |
49 | + super(name); | |
45 | 50 | + |
46 | 51 | + this._category = category; |
47 | 52 | + this._button = button; |
61 | 66 | } |
62 | 67 | |
63 | 68 | _isNavigatingSubmenu([x, y]) { |
64 | @@ -207,11 +213,61 @@ class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { | |
69 | @@ -217,11 +223,64 @@ class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { | |
65 | 70 | if (!this.active) |
66 | 71 | return; |
67 | 72 | |
68 | 73 | + this._button.selectCategory(this._category); |
69 | 74 | + //this._button.scrollToCatButton(this); |
70 | 75 | + } |
71 | +}); | |
72 | + | |
73 | +var ParentCategoryMenuItem = GObject.registerClass( | |
76 | +} | |
77 | + | |
74 | 78 | +class ParentCategoryMenuItem extends PopupMenu.PopupSubMenuMenuItem { |
75 | + _init(button, category) { | |
79 | + static { | |
80 | + GObject.registerClass(this); | |
81 | + } | |
82 | + | |
83 | + constructor(button, category) { | |
76 | 84 | + let name; |
77 | 85 | + if (category) |
78 | 86 | + name = category.get_name(); |
79 | 87 | + else |
80 | 88 | + name = _("Favorites"); |
81 | 89 | + |
82 | + super._init(name, false); | |
90 | + super(name, false); | |
83 | 91 | + |
84 | 92 | + this._category = category; |
85 | 93 | + this._button = button; |
98 | 106 | + //this._button.scrollToCatButton(this); |
99 | 107 | + } |
100 | 108 | } |
101 | }); | |
109 | } | |
102 | 110 | |
103 | 111 | +class PopupMenuScrollView extends PopupMenu.PopupMenuSection { |
104 | 112 | + constructor() { |
123 | 131 | class ApplicationsMenu extends PopupMenu.PopupMenu { |
124 | 132 | constructor(sourceActor, arrowAlignment, arrowSide, button) { |
125 | 133 | super(sourceActor, arrowAlignment, arrowSide); |
126 | @@ -410,7 +466,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
134 | @@ -423,7 +482,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
127 | 135 | _onTreeChanged() { |
128 | 136 | if (this.menu.isOpen) { |
129 | 137 | this._redisplay(); |
132 | 140 | } else { |
133 | 141 | this.reloadFlag = true; |
134 | 142 | } |
135 | @@ -471,20 +527,21 @@ class ApplicationsButton extends PanelMenu.Button { | |
143 | @@ -484,20 +543,21 @@ class ApplicationsButton extends PanelMenu.Button { | |
136 | 144 | this._redisplay(); |
137 | 145 | this.reloadFlag = false; |
138 | 146 | } |
157 | 165 | while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { |
158 | 166 | if (nextType === GMenu.TreeItemType.ENTRY) { |
159 | 167 | let entry = iter.get_entry(); |
160 | @@ -503,8 +560,17 @@ class ApplicationsButton extends PanelMenu.Button { | |
168 | @@ -516,8 +576,17 @@ class ApplicationsButton extends PanelMenu.Button { | |
161 | 169 | this.applicationsByCategory[categoryId].push('separator'); |
162 | 170 | } else if (nextType === GMenu.TreeItemType.DIRECTORY) { |
163 | 171 | let subdir = iter.get_directory(); |
177 | 185 | } |
178 | 186 | } |
179 | 187 | } |
180 | @@ -525,8 +591,8 @@ class ApplicationsButton extends PanelMenu.Button { | |
188 | @@ -538,8 +607,8 @@ class ApplicationsButton extends PanelMenu.Button { | |
181 | 189 | } |
182 | 190 | |
183 | 191 | scrollToCatButton(button) { |
188 | 196 | let currentScrollValue = catsScrollBoxAdj.get_value(); |
189 | 197 | let boxHeight = catsScrollBoxAlloc.y2 - catsScrollBoxAlloc.y1; |
190 | 198 | let buttonAlloc = button.get_allocation_box(); |
191 | @@ -542,8 +608,9 @@ class ApplicationsButton extends PanelMenu.Button { | |
199 | @@ -555,8 +624,9 @@ class ApplicationsButton extends PanelMenu.Button { | |
192 | 200 | _createLayout() { |
193 | 201 | let section = new PopupMenu.PopupMenuSection(); |
194 | 202 | this.menu.addMenuItem(section); |
200 | 208 | this.applicationsScrollBox = new St.ScrollView({ |
201 | 209 | style_class: 'apps-menu vfade', |
202 | 210 | x_expand: true, |
203 | @@ -556,6 +623,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
211 | @@ -569,6 +639,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
204 | 212 | vscroll.connect('scroll-stop', () => { |
205 | 213 | this.menu.passEvents = false; |
206 | 214 | }); |
208 | 216 | this.categoriesScrollBox = new St.ScrollView({ |
209 | 217 | style_class: 'vfade', |
210 | 218 | }); |
211 | @@ -564,9 +632,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
219 | @@ -577,9 +648,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
212 | 220 | vscroll.connect('scroll-start', () => (this.menu.passEvents = true)); |
213 | 221 | vscroll.connect('scroll-stop', () => (this.menu.passEvents = false)); |
214 | 222 | this.leftBox.add_child(this.categoriesScrollBox); |
220 | 228 | this.categoriesBox = new St.BoxLayout({ vertical: true }); |
221 | 229 | this.categoriesScrollBox.add_actor(this.categoriesBox); |
222 | 230 | |
223 | @@ -574,19 +643,29 @@ class ApplicationsButton extends PanelMenu.Button { | |
231 | @@ -587,19 +659,29 @@ class ApplicationsButton extends PanelMenu.Button { | |
224 | 232 | this.mainBox.add_child(this._createVertSeparator()); |
225 | 233 | this.mainBox.add_child(this.applicationsScrollBox); |
226 | 234 | section.actor.add_actor(this.mainBox); |
253 | 261 | let iter = root.iter(); |
254 | 262 | let nextType; |
255 | 263 | while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { |
256 | @@ -599,10 +678,13 @@ class ApplicationsButton extends PanelMenu.Button { | |
264 | @@ -612,10 +694,13 @@ class ApplicationsButton extends PanelMenu.Button { | |
257 | 265 | |
258 | 266 | let categoryId = dir.get_menu_id(); |
259 | 267 | this.applicationsByCategory[categoryId] = []; |
271 | 279 | } |
272 | 280 | } |
273 | 281 | |
274 | @@ -611,9 +693,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
282 | @@ -624,9 +709,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
275 | 283 | |
276 | 284 | let themeContext = St.ThemeContext.get_for_stage(global.stage); |
277 | 285 | let scaleFactor = themeContext.scale_factor; |
284 | 292 | } |
285 | 293 | |
286 | 294 | selectCategory(dir) { |
287 | @@ -628,6 +711,20 @@ class ApplicationsButton extends PanelMenu.Button { | |
295 | @@ -641,6 +727,20 @@ class ApplicationsButton extends PanelMenu.Button { | |
288 | 296 | this._displayButtons(this._listApplications(dir.get_menu_id())); |
289 | 297 | else |
290 | 298 | this._displayButtons(this._listApplications(null)); |