[polari] app: Simplify ::window-removed handling
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] app: Simplify ::window-removed handling
- Date: Fri, 3 Sep 2021 09:45:13 +0000 (UTC)
commit 14b4183478a63386d629ada615fdc6192782e0b1
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Jul 26 21:05:44 2021 +0200
app: Simplify ::window-removed handling
When running initial setup, we connect a ::window-removed handler to
proceed to the main window when done, then disconnect it and connect
the regular handler when creating the main window.
It is simpler to just use a single handler that covers both cases.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/225>
src/application.js | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 6b56b664..bb123b2e 100644
--- a/src/application.js
+++ b/src/application.js
@@ -61,7 +61,8 @@ export default GObject.registerClass({
this._nickTrackData = new Map();
this._demons = [];
- this._windowRemovedId = 0;
+ this._windowRemovedId =
+ this.connect('window-removed', this._onWindowRemoved.bind(this));
this.add_main_option('start-client', 0,
GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
@@ -407,22 +408,10 @@ export default GObject.registerClass({
this.activate_action('start-client', null);
if (!this.active_window) {
- if (this._windowRemovedId)
- this.disconnect(this._windowRemovedId);
- this._windowRemovedId = 0;
-
if (this._needsInitialSetup()) {
new InitialSetupWindow({ application: this });
- this._windowRemovedId = this.connect('window-removed', () => {
- this.activate();
- });
} else {
let window = new MainWindow({ application: this });
- this._windowRemovedId = this.connect('window-removed', () => {
- if (this._settings.get_boolean('run-in-background'))
- return;
- this.emit('prepare-shutdown');
- });
window.connect('notify::active-room',
() => this.emit('room-focus-changed'));
window.connect('notify::is-active',
@@ -450,6 +439,13 @@ export default GObject.registerClass({
this._updateUserListAction();
}
+ _onWindowRemoved(app, window) {
+ if (!(window instanceof MainWindow))
+ this.activate();
+ else if (!this._settings.get_boolean('run-in-background'))
+ this.emit('prepare-shutdown');
+ }
+
vfunc_open(files) {
this.activate();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]