Fix exception on 3.34 when toggling submenu states
Emilio Pozuelo Monfort
4 years ago
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 | extensions/apps-menu/extension.js | 165 ++++++++++++++++++++++++++++++-------- | |
8 | 1 file changed, 133 insertions(+), 32 deletions(-) | |
7 | extensions/apps-menu/extension.js | 166 ++++++++++++++++++++++++++++++-------- | |
8 | 1 file changed, 134 insertions(+), 32 deletions(-) | |
9 | 9 | |
10 | 10 | diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js |
11 | index 70383af..294074a 100644 | |
11 | index 70383af..3fe01c7 100644 | |
12 | 12 | --- a/extensions/apps-menu/extension.js |
13 | 13 | +++ b/extensions/apps-menu/extension.js |
14 | 14 | @@ -97,30 +97,36 @@ class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem { |
61 | 61 | } |
62 | 62 | |
63 | 63 | _isNavigatingSubmenu([x, y]) { |
64 | @@ -208,11 +214,55 @@ class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { | |
64 | @@ -208,11 +214,61 @@ class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { | |
65 | 65 | if (!this.active) |
66 | 66 | return; |
67 | 67 | |
112 | 112 | + this.actor._delegate = this; |
113 | 113 | + this.actor.clip_to_allocation = true; |
114 | 114 | + } |
115 | + | |
116 | + _setOpenedSubMenu(menu) { | |
117 | + // We don't close the currently opened submenu so that nested submenus work | |
118 | + // https://mail.gnome.org/archives/gnome-shell-list/2014-January/msg00010.html | |
119 | + this.openChildMenu = menu; | |
120 | + } | |
115 | 121 | +}; |
116 | 122 | + |
117 | 123 | class ApplicationsMenu extends PopupMenu.PopupMenu { |
118 | 124 | constructor(sourceActor, arrowAlignment, arrowSide, button) { |
119 | 125 | super(sourceActor, arrowAlignment, arrowSide); |
120 | @@ -412,7 +462,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
126 | @@ -412,7 +468,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
121 | 127 | _onTreeChanged() { |
122 | 128 | if (this.menu.isOpen) { |
123 | 129 | this._redisplay(); |
126 | 132 | } else { |
127 | 133 | this.reloadFlag = true; |
128 | 134 | } |
129 | @@ -477,7 +527,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
135 | @@ -477,7 +533,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
130 | 136 | this._redisplay(); |
131 | 137 | this.reloadFlag = false; |
132 | 138 | } |
135 | 141 | } |
136 | 142 | super._onOpenStateChanged(menu, open); |
137 | 143 | } |
138 | @@ -490,13 +540,14 @@ class ApplicationsButton extends PanelMenu.Button { | |
144 | @@ -490,13 +546,14 @@ class ApplicationsButton extends PanelMenu.Button { | |
139 | 145 | |
140 | 146 | _redisplay() { |
141 | 147 | this.applicationsBox.destroy_all_children(); |
152 | 158 | while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { |
153 | 159 | if (nextType === GMenu.TreeItemType.ENTRY) { |
154 | 160 | let entry = iter.get_entry(); |
155 | @@ -515,8 +566,17 @@ class ApplicationsButton extends PanelMenu.Button { | |
161 | @@ -515,8 +572,17 @@ class ApplicationsButton extends PanelMenu.Button { | |
156 | 162 | this.applicationsByCategory[categoryId].push('separator'); |
157 | 163 | } else if (nextType === GMenu.TreeItemType.DIRECTORY) { |
158 | 164 | let subdir = iter.get_directory(); |
172 | 178 | } |
173 | 179 | } |
174 | 180 | } |
175 | @@ -537,8 +597,8 @@ class ApplicationsButton extends PanelMenu.Button { | |
181 | @@ -537,8 +603,8 @@ class ApplicationsButton extends PanelMenu.Button { | |
176 | 182 | } |
177 | 183 | |
178 | 184 | scrollToCatButton(button) { |
183 | 189 | let currentScrollValue = catsScrollBoxAdj.get_value(); |
184 | 190 | let boxHeight = catsScrollBoxAlloc.y2 - catsScrollBoxAlloc.y1; |
185 | 191 | let buttonAlloc = button.get_allocation_box(); |
186 | @@ -552,10 +612,16 @@ class ApplicationsButton extends PanelMenu.Button { | |
187 | } | |
188 | ||
192 | @@ -554,8 +620,9 @@ class ApplicationsButton extends PanelMenu.Button { | |
189 | 193 | _createLayout() { |
190 | + // https://mail.gnome.org/archives/gnome-shell-list/2014-January/msg00010.html | |
191 | + this.menu._setOpenedSubMenu = (submenu) => { | |
192 | + this._openedSubMenu = submenu; | |
193 | + }; | |
194 | + | |
195 | 194 | let section = new PopupMenu.PopupMenuSection(); |
196 | 195 | this.menu.addMenuItem(section); |
197 | 196 | - this.mainBox = new St.BoxLayout({ vertical: false }); |
202 | 201 | this.applicationsScrollBox = new St.ScrollView({ |
203 | 202 | x_fill: true, |
204 | 203 | y_fill: false, |
205 | @@ -570,6 +636,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
204 | @@ -570,6 +637,7 @@ class ApplicationsButton extends PanelMenu.Button { | |
206 | 205 | vscroll.connect('scroll-stop', () => { |
207 | 206 | this.menu.passEvents = false; |
208 | 207 | }); |
210 | 209 | this.categoriesScrollBox = new St.ScrollView({ |
211 | 210 | x_fill: true, |
212 | 211 | y_fill: false, |
213 | @@ -586,9 +653,11 @@ class ApplicationsButton extends PanelMenu.Button { | |
212 | @@ -586,9 +654,11 @@ class ApplicationsButton extends PanelMenu.Button { | |
214 | 213 | y_fill: true, |
215 | 214 | y_align: St.Align.START, |
216 | 215 | }); |
222 | 221 | this.categoriesBox = new St.BoxLayout({ vertical: true }); |
223 | 222 | this.categoriesScrollBox.add_actor(this.categoriesBox); |
224 | 223 | |
225 | @@ -604,19 +673,33 @@ class ApplicationsButton extends PanelMenu.Button { | |
224 | @@ -604,19 +674,33 @@ class ApplicationsButton extends PanelMenu.Button { | |
226 | 225 | y_fill: true, |
227 | 226 | }); |
228 | 227 | section.actor.add_actor(this.mainBox); |
259 | 258 | let iter = root.iter(); |
260 | 259 | let nextType; |
261 | 260 | while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { |
262 | @@ -629,10 +712,13 @@ class ApplicationsButton extends PanelMenu.Button { | |
261 | @@ -629,10 +713,13 @@ class ApplicationsButton extends PanelMenu.Button { | |
263 | 262 | |
264 | 263 | let categoryId = dir.get_menu_id(); |
265 | 264 | this.applicationsByCategory[categoryId] = []; |
277 | 276 | } |
278 | 277 | } |
279 | 278 | |
280 | @@ -641,9 +727,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
279 | @@ -641,9 +728,10 @@ class ApplicationsButton extends PanelMenu.Button { | |
281 | 280 | |
282 | 281 | let themeContext = St.ThemeContext.get_for_stage(global.stage); |
283 | 282 | let scaleFactor = themeContext.scale_factor; |
290 | 289 | } |
291 | 290 | |
292 | 291 | selectCategory(dir) { |
293 | @@ -658,6 +745,20 @@ class ApplicationsButton extends PanelMenu.Button { | |
292 | @@ -658,6 +746,20 @@ class ApplicationsButton extends PanelMenu.Button { | |
294 | 293 | this._displayButtons(this._listApplications(dir.get_menu_id())); |
295 | 294 | else |
296 | 295 | this._displayButtons(this._listApplications(null)); |