apps-menu: update patch for GNOME 3.38
Emilio Pozuelo Monfort
3 years ago
7 | 7 | extensions/apps-menu/extension.js | 167 ++++++++++++++++++++++++++++++-------- |
8 | 8 | 1 file changed, 134 insertions(+), 33 deletions(-) |
9 | 9 | |
10 | diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js | |
11 | index 9d46506..939d1b4 100644 | |
12 | 10 | --- a/extensions/apps-menu/extension.js |
13 | 11 | +++ b/extensions/apps-menu/extension.js |
14 | @@ -97,30 +97,36 @@ class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem { | |
12 | @@ -97,30 +97,36 @@ class ApplicationMenuItem extends PopupM | |
15 | 13 | }); |
16 | 14 | |
17 | 15 | var CategoryMenuItem = GObject.registerClass( |
61 | 59 | } |
62 | 60 | |
63 | 61 | _isNavigatingSubmenu([x, y]) { |
64 | @@ -208,11 +214,61 @@ class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { | |
65 | if (!this.active) | |
62 | @@ -209,10 +215,60 @@ class CategoryMenuItem extends PopupMenu | |
66 | 63 | return; |
67 | 64 | |
68 | + this._button.selectCategory(this._category); | |
65 | this._button.selectCategory(this._category); | |
69 | 66 | + //this._button.scrollToCatButton(this); |
70 | 67 | + } |
71 | 68 | +}); |
87 | 84 | + } |
88 | 85 | + |
89 | 86 | + activate(event) { |
90 | this._button.selectCategory(this._category); | |
87 | + this._button.selectCategory(this._category); | |
91 | 88 | this._button.scrollToCatButton(this); |
92 | 89 | + super.activate(event); |
93 | 90 | + } |
123 | 120 | class ApplicationsMenu extends PopupMenu.PopupMenu { |
124 | 121 | constructor(sourceActor, arrowAlignment, arrowSide, button) { |
125 | 122 | super(sourceActor, arrowAlignment, arrowSide); |
126 | @@ -412,7 +468,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
123 | @@ -412,7 +468,7 @@ class ApplicationsButton extends PanelMe | |
127 | 124 | _onTreeChanged() { |
128 | 125 | if (this.menu.isOpen) { |
129 | 126 | this._redisplay(); |
132 | 129 | } else { |
133 | 130 | this.reloadFlag = true; |
134 | 131 | } |
135 | @@ -477,7 +533,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
132 | @@ -477,7 +533,7 @@ class ApplicationsButton extends PanelMe | |
136 | 133 | this._redisplay(); |
137 | 134 | this.reloadFlag = false; |
138 | 135 | } |
141 | 138 | } |
142 | 139 | super._onOpenStateChanged(menu, open); |
143 | 140 | } |
144 | @@ -490,13 +546,14 @@ class ApplicationsButton extends PanelMenu.Button { | |
141 | @@ -490,13 +546,14 @@ class ApplicationsButton extends PanelMe | |
145 | 142 | |
146 | 143 | _redisplay() { |
147 | 144 | this.applicationsBox.destroy_all_children(); |
158 | 155 | while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { |
159 | 156 | if (nextType === GMenu.TreeItemType.ENTRY) { |
160 | 157 | let entry = iter.get_entry(); |
161 | @@ -515,8 +572,17 @@ class ApplicationsButton extends PanelMenu.Button { | |
158 | @@ -515,8 +572,17 @@ class ApplicationsButton extends PanelMe | |
162 | 159 | this.applicationsByCategory[categoryId].push('separator'); |
163 | 160 | } else if (nextType === GMenu.TreeItemType.DIRECTORY) { |
164 | 161 | let subdir = iter.get_directory(); |
178 | 175 | } |
179 | 176 | } |
180 | 177 | } |
181 | @@ -537,8 +603,8 @@ class ApplicationsButton extends PanelMenu.Button { | |
178 | @@ -537,8 +603,8 @@ class ApplicationsButton extends PanelMe | |
182 | 179 | } |
183 | 180 | |
184 | 181 | scrollToCatButton(button) { |
189 | 186 | let currentScrollValue = catsScrollBoxAdj.get_value(); |
190 | 187 | let boxHeight = catsScrollBoxAlloc.y2 - catsScrollBoxAlloc.y1; |
191 | 188 | let buttonAlloc = button.get_allocation_box(); |
192 | @@ -554,8 +620,9 @@ class ApplicationsButton extends PanelMenu.Button { | |
189 | @@ -554,8 +620,9 @@ class ApplicationsButton extends PanelMe | |
193 | 190 | _createLayout() { |
194 | 191 | let section = new PopupMenu.PopupMenuSection(); |
195 | 192 | this.menu.addMenuItem(section); |
201 | 198 | this.applicationsScrollBox = new St.ScrollView({ |
202 | 199 | style_class: 'apps-menu vfade', |
203 | 200 | x_expand: true, |
204 | @@ -568,6 +635,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
201 | @@ -568,6 +635,7 @@ class ApplicationsButton extends PanelMe | |
205 | 202 | vscroll.connect('scroll-stop', () => { |
206 | 203 | this.menu.passEvents = false; |
207 | 204 | }); |
209 | 206 | this.categoriesScrollBox = new St.ScrollView({ |
210 | 207 | style_class: 'vfade', |
211 | 208 | }); |
212 | @@ -576,9 +644,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
209 | @@ -576,9 +644,10 @@ class ApplicationsButton extends PanelMe | |
213 | 210 | vscroll.connect('scroll-start', () => (this.menu.passEvents = true)); |
214 | 211 | vscroll.connect('scroll-stop', () => (this.menu.passEvents = false)); |
215 | 212 | this.leftBox.add_child(this.categoriesScrollBox); |
221 | 218 | this.categoriesBox = new St.BoxLayout({ vertical: true }); |
222 | 219 | this.categoriesScrollBox.add_actor(this.categoriesBox); |
223 | 220 | |
224 | @@ -586,19 +655,33 @@ class ApplicationsButton extends PanelMenu.Button { | |
221 | @@ -586,19 +655,29 @@ class ApplicationsButton extends PanelMe | |
225 | 222 | this.mainBox.add_child(this._createVertSeparator()); |
226 | 223 | this.mainBox.add_child(this.applicationsScrollBox); |
227 | 224 | section.actor.add_actor(this.mainBox); |
230 | 227 | + vscroll = this.categoriesBox.actor.get_vscroll_bar(); |
231 | 228 | + vscroll.connect('scroll-start', () => { this.menu.passEvents = true; }); |
232 | 229 | + vscroll.connect('scroll-stop', () => { this.menu.passEvents = false; }); |
233 | + this.leftBox.actor.add(this.categoriesBox.actor, { expand: true, | |
234 | + x_fill: true, y_fill: true, | |
235 | + y_align: St.Align.START }); | |
230 | + this.leftBox.actor.add_actor(this.categoriesBox.actor); | |
236 | 231 | + this.mainBox.addMenuItem(this.leftBox); |
237 | + this.mainBox.actor.add(this._createVertSeparator(), { expand: false, | |
238 | + x_fill: false, y_fill: true}); | |
239 | + this.mainBox.actor.add(this.applicationsScrollBox, { expand: true, | |
240 | + x_fill: true, y_fill: true }); | |
232 | + this.mainBox.actor.add_actor(this._createVertSeparator()); | |
233 | + this.mainBox.actor.add_actor(this.applicationsScrollBox); | |
241 | 234 | + section.addMenuItem(this.mainBox); |
242 | 235 | } |
243 | 236 | |
258 | 251 | let iter = root.iter(); |
259 | 252 | let nextType; |
260 | 253 | while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { |
261 | @@ -611,10 +694,13 @@ class ApplicationsButton extends PanelMenu.Button { | |
254 | @@ -611,10 +690,13 @@ class ApplicationsButton extends PanelMe | |
262 | 255 | |
263 | 256 | let categoryId = dir.get_menu_id(); |
264 | 257 | this.applicationsByCategory[categoryId] = []; |
276 | 269 | } |
277 | 270 | } |
278 | 271 | |
279 | @@ -623,9 +709,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
272 | @@ -623,9 +705,10 @@ class ApplicationsButton extends PanelMe | |
280 | 273 | |
281 | 274 | let themeContext = St.ThemeContext.get_for_stage(global.stage); |
282 | 275 | let scaleFactor = themeContext.scale_factor; |
289 | 282 | } |
290 | 283 | |
291 | 284 | selectCategory(dir) { |
292 | @@ -640,6 +727,20 @@ class ApplicationsButton extends PanelMenu.Button { | |
285 | @@ -640,6 +723,20 @@ class ApplicationsButton extends PanelMe | |
293 | 286 | this._displayButtons(this._listApplications(dir.get_menu_id())); |
294 | 287 | else |
295 | 288 | this._displayButtons(this._listApplications(null)); |