Skip to content

Commit 2b039a3

Browse files
committed
Merge branch 'develop'
2 parents 92ed794 + 0696960 commit 2b039a3

File tree

3 files changed

+152
-46
lines changed

3 files changed

+152
-46
lines changed

.travis.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
language: node_js
2-
32
env:
4-
- secure: "ZqWi5+UtHF6OVhY+cIxdUtbIomrXBex0URSV8dSihjmAQkZ812HddwFbK9+vb8z+IZ/nmOvA6WkUnW0QfMs0kKr0Sp/y7DzhTr1ResDiOGsDE2csX9nsNaHwaL+nggAo/fYrqzvtuI2LjG7fCaCl5VgWDvuEYyTsLjvrZjy9KRE="
5-
3+
- secure: ZqWi5+UtHF6OVhY+cIxdUtbIomrXBex0URSV8dSihjmAQkZ812HddwFbK9+vb8z+IZ/nmOvA6WkUnW0QfMs0kKr0Sp/y7DzhTr1ResDiOGsDE2csX9nsNaHwaL+nggAo/fYrqzvtuI2LjG7fCaCl5VgWDvuEYyTsLjvrZjy9KRE=
64
install: make deps
7-
85
script: make all publish
9-
106
notifications:
117
email:
128
recipients:
13-
- secure: h1GEDEutgLEHdft95f0AsDeIUKBb4FbX0NJNDlIec8f/wXkWpWUjlSTQOnSCFIYzeon1d3kCxGoIM9lBtP/6uM5L71Dtm8EHQTGqqFQ8cszfyJCPRfB+wvnyZvOAMG/V3H/4NECUqOES6DEcrpQTMuz5dDpMGeHnoLK63pttIok=
9+
- secure: h1GEDEutgLEHdft95f0AsDeIUKBb4FbX0NJNDlIec8f/wXkWpWUjlSTQOnSCFIYzeon1d3kCxGoIM9lBtP/6uM5L71Dtm8EHQTGqqFQ8cszfyJCPRfB+wvnyZvOAMG/V3H/4NECUqOES6DEcrpQTMuz5dDpMGeHnoLK63pttIok=
1410
on_success: always
15-
11+
deploy:
12+
provider: releases
13+
api_key:
14+
secure: pVieeKuVBwtfvo3hadF3J+xH5yP5+SWV+tkXe1LGTqTd0uc6TbhnPIf7rcjgG8ujfoQqYrkIthJMeQ2Fyz3YisEinY2rYXaaDQk/4X8OEw1+6Qo/FNogycn0GeAu7vnUrlW2RcZxIa1KFweRkCZ553CaqMHurOWar8VukskTzRk=
15+
file: remove-dropdown-arrows@mpdeimos.com.zip
16+
skip_cleanup: true
17+
on:
18+
repo: mpdeimos/gnome-shell-remove-dropdown-arrows
19+
tags: true

extension.js

Lines changed: 140 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,166 @@
11
/* jshint esnext:true */
22

3+
const GLib = imports.gi.GLib;
34
const Main = imports.ui.main;
4-
const Lang = imports.lang;
5-
const ExtensionSystem = imports.ui.extensionSystem;
5+
const Mainloop = imports.mainloop;
66

7-
let _extensionChangedId;
87

9-
function init()
8+
const MAX_RECURSE_DEPTH = 3;
9+
10+
let signalConnections = [];
11+
let dropdowns = [];
12+
13+
14+
/**
15+
* Try hide a single dropdown actor.
16+
*
17+
* Return true on success.
18+
*/
19+
function _apply(actor)
1020
{
11-
/* no initialization required */
21+
if (!actor.has_style_class_name || !actor.has_style_class_name('popup-menu-arrow'))
22+
{
23+
return false;
24+
}
25+
26+
actor.hide();
27+
28+
if (dropdowns.indexOf(actor) < 0)
29+
{
30+
let connection = {
31+
object: actor,
32+
id: actor.connect('destroy', function()
33+
{
34+
let index;
35+
36+
index = signalConnections.indexOf(connection);
37+
if (index >= 0)
38+
{
39+
signalConnections.splice(index, 1);
40+
}
41+
42+
index = dropdowns.indexOf(actor);
43+
if (index >= 0)
44+
{
45+
dropdowns.splice(index, 1);
46+
}
47+
})
48+
};
49+
signalConnections.push(connection);
50+
dropdowns.push(actor);
51+
}
52+
53+
return true;
1254
}
1355

14-
function enable()
56+
/**
57+
* Similar function to _recursiveApply(), but intended for containers.
58+
*/
59+
function _recursiveApplyInternal(actor, depth)
60+
{
61+
if (typeof actor.get_children === 'undefined')
62+
{
63+
return false;
64+
}
65+
66+
let children = actor.get_children();
67+
68+
// If there are no children then it's possible that actor hasn't been fully initialized yet.
69+
// Shedule to check later.
70+
if (children.length == 0)
71+
{
72+
_scheduleApply(actor);
73+
return false;
74+
}
75+
76+
// Check actor immediate children before using recursion
77+
for (let index = 0; index < children.length; index++)
78+
{
79+
if (_apply(children[index]))
80+
{
81+
return true;
82+
}
83+
}
84+
85+
// Check children recursively
86+
if (depth < MAX_RECURSE_DEPTH)
87+
{
88+
for (let index = 0; index < children.length; index++)
89+
{
90+
if (_recursiveApplyInternal(children[index], depth + 1))
91+
{
92+
return true;
93+
}
94+
}
95+
}
96+
97+
return false;
98+
}
99+
100+
function _scheduleApply(actor)
15101
{
16-
edit(true);
17-
_extensionChangedId = ExtensionSystem.connect('extension-state-changed', onExtensionStateChanged);
102+
let actorAddedId, destroyId, timeoutId;
103+
actorAddedId = actor.connect('actor-added', function(child)
104+
{
105+
if (_recursiveApply(child))
106+
{
107+
actor.disconnect(actorAddedId);
108+
actor.disconnect(destroyId);
109+
Mainloop.source_remove(timeoutId);
110+
actorAddedId = destroyId = timeoutId = 0;
111+
}
112+
});
113+
destroyId = actor.connect('destroy', function()
114+
{
115+
if (timeoutId != 0) {
116+
Mainloop.source_remove(timeoutId);
117+
timeoutId = 0;
118+
}
119+
});
120+
timeoutId = Mainloop.idle_add(function()
121+
{
122+
actor.disconnect(actorAddedId);
123+
actor.disconnect(destroyId);
124+
actorAddedId = destroyId = timeoutId = 0;
125+
return GLib.SOURCE_REMOVE;
126+
});
18127
}
19128

20-
function disable()
129+
function _recursiveApply(actor)
21130
{
22-
ExtensionSystem.disconnect(_extensionChangedId);
23-
edit(false);
131+
return _apply(actor) || _recursiveApplyInternal(actor, 0);
24132
}
25133

26-
function onExtensionStateChanged()
134+
function init()
27135
{
28-
edit(true);
136+
// no initialization required
29137
}
30138

31-
function edit(hide)
139+
function enable()
32140
{
33-
for (let id in Main.panel.statusArea)
34-
{
35-
let item = Main.panel.statusArea[id];
36-
if (typeof item.actor !== 'undefined')
37-
{
38-
recursiveEdit(item.actor, hide);
39-
}
40-
}
141+
Main.panel.actor.get_children().forEach(
142+
function(actor)
143+
{
144+
signalConnections.push({
145+
object: actor,
146+
id: actor.connect('actor-added', _recursiveApply)
147+
});
148+
149+
actor.get_children().forEach(_recursiveApply);
150+
});
41151
}
42152

43-
function recursiveEdit(widget, hide)
153+
function disable()
44154
{
45-
if (widget.text === '\u25BE' || widget.text === '\u25B4' || // regular text drop down arrow (3.10)
46-
(widget.has_style_class_name && widget.has_style_class_name('popup-menu-arrow'))) // image drop down arrow (3.12)
155+
while (signalConnections.length > 0)
47156
{
48-
if (hide)
49-
{
50-
widget.hide();
51-
}
52-
else
53-
{
54-
widget.show();
55-
}
56-
57-
return;
157+
let connection = signalConnections.pop();
158+
connection.object.disconnect(connection.id);
58159
}
59-
60-
if (typeof widget.get_children !== 'undefined')
160+
161+
while (dropdowns.length > 0)
61162
{
62-
widget.get_children().forEach(function(child) { recursiveEdit(child, hide); });
163+
let actor = dropdowns.pop();
164+
actor.show();
63165
}
64166
}

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"name": "Remove Dropdown Arrows",
55
"description": "Removes the dropdown arrows which were introduced in Gnome 3.10 from the App Menu, System Menu, Input Menu, Access Menu, Places Menu, Applications Menu and any other extension that wants to add dropdown arrows.",
66
"url": "http://github.com/mpdeimos/gnome-shell-remove-dropdown-arrows",
7-
"shell-version": ["3.10","3.12","3.14", "3.16", "3.18", "3.20", "3.22"]
7+
"shell-version": ["3.12","3.14", "3.16", "3.18", "3.20", "3.22", "3.24", "3.26", "3.28"]
88
}

0 commit comments

Comments
 (0)