Skip to content

Commit

Permalink
remove mainloop usage from appmenu and windowbuttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Mar 24, 2018
1 parent da7d754 commit c2e229b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
15 changes: 6 additions & 9 deletions [email protected]/modules/appMenu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Lang = imports.lang;
const Main = imports.ui.main;
const Mainloop = imports.mainloop;
const Gtk = imports.gi.Gtk;
const Shell = imports.gi.Shell;
const WindowTracker = Shell.WindowTracker.get_default();
Expand Down Expand Up @@ -144,23 +143,21 @@ var AppMenu = new Lang.Class({

_activate: function() {
if (!this._activated) {
Mainloop.idle_add(Lang.bind(this, this._showMenu));
Mainloop.idle_add(Lang.bind(this, this._updateMenu));

this._activated = true;

this._updateMenu();
this._connectSignals();
}
},

destroy: function() {
if (this._activated) {
Mainloop.idle_add(Lang.bind(this, Lang.bind(this, function () {
this._showMenu();
delete this._appMenu._nonSensitive;
})));

this._activated = false;

this._showMenu();
this._disconnectSignals();

delete this._appMenu._nonSensitive;
}
}
});
16 changes: 8 additions & 8 deletions [email protected]/modules/windowButtons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const Mainloop = imports.mainloop;
const Panel = Main.panel;
const AppMenu = Panel.statusArea.appMenu;
const St = imports.gi.St;
Expand Down Expand Up @@ -208,22 +207,23 @@ var WindowButtons = new Lang.Class({

_activate: function() {
if (!this._activated) {
Mainloop.idle_add(Lang.bind(this, this._createButtons));
Mainloop.idle_add(Lang.bind(this, this._updateVisibility));

this._activated = true;
this._connectSignals();

this._createButtons();
this._loadTheme();
this._updateVisibility();
this._connectSignals();
}
},

destroy: function() {
if (this._activated) {
Mainloop.idle_add(Lang.bind(this, this._destroyButtons));
this._disconnectSignals();
this._activated = false;

this._destroyButtons();
this._unloadTheme();
this._disconnectSignals();

this._activated = false;
delete this._buttonsTheme;
}
}
Expand Down

0 comments on commit c2e229b

Please sign in to comment.