[polari/wip/fmuellner/software-not-as-service: 11/11] app: Turn run-in-background feature into an explicit action
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/software-not-as-service: 11/11] app: Turn run-in-background feature into an explicit action
- Date: Wed, 5 Dec 2018 17:48:45 +0000 (UTC)
commit 97ebdf62cd84a80ddb25ce832a876599b38d3bd3
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Nov 1 13:23:20 2018 +0100
app: Turn run-in-background feature into an explicit action
As we are reducing the ambiguity with services, it makes more sense
to expose the run-in-background feature as an action the user can
select on a case-by-case basis than having a setting that modifies
the behavior when the window is closed.
This will also remove the need of continuing to expose the quit action
when we drop the app menu, as quit becomes again synonym with closing
the main window.
https://gitlab.gnome.org/GNOME/polari/merge_requests/77
data/org.gnome.Polari.gschema.xml | 5 -----
data/resources/main-window.ui | 26 ------------------------
data/resources/menus.ui | 2 +-
src/application.js | 22 ++++++++++++++------
src/mainWindow.js | 42 +--------------------------------------
5 files changed, 18 insertions(+), 79 deletions(-)
---
diff --git a/data/org.gnome.Polari.gschema.xml b/data/org.gnome.Polari.gschema.xml
index 2d561e8..adaefa2 100644
--- a/data/org.gnome.Polari.gschema.xml
+++ b/data/org.gnome.Polari.gschema.xml
@@ -6,11 +6,6 @@
<summary>Saved channel list</summary>
<description>List of channels to restore on startup</description>
</key>
- <key type="b" name="run-in-background">
- <default>false</default>
- <summary>Run in Background</summary>
- <description>Keep running in background when closed.</description>
- </key>
<key type="ai" name="window-size">
<default>[800,500]</default>
<summary>Window size</summary>
diff --git a/data/resources/main-window.ui b/data/resources/main-window.ui
index e0675cb..4d8d142 100644
--- a/data/resources/main-window.ui
+++ b/data/resources/main-window.ui
@@ -9,32 +9,6 @@
<class name="polari-user-list"/>
</style>
</object>
- <object class="GtkMessageDialog" id="closeConfirmationDialog">
- <property name="message-type">question</property>
- <property name="text" translatable="yes">Run Polari in the Background?</property>
- <property name="secondary-text" translatable="yes">Polari will continue to run when closed.</property>
- <property name="destroy-with-parent">true</property>
- <property name="modal">true</property>
- <signal name="delete-event" handler="hide_on_delete"/>
- <child type="action">
- <object class="GtkButton" id="quitButton">
- <property name="label" translatable="yes">_Quit</property>
- <property name="visible">true</property>
- <property name="use-underline">true</property>
- </object>
- </child>
- <child type="action">
- <object class="GtkButton" id="backgroundButton">
- <property name="label" translatable="yes">_Run in background</property>
- <property name="visible">true</property>
- <property name="use-underline">true</property>
- </object>
- </child>
- <action-widgets>
- <action-widget response="close">quitButton</action-widget>
- <action-widget response="accept">backgroundButton</action-widget>
- </action-widgets>
- </object>
<template class="Gjs_MainWindow">
<property name="title" translatable="yes">Polari</property>
<property name="icon-name">org.gnome.Polari</property>
diff --git a/data/resources/menus.ui b/data/resources/menus.ui
index eff8d78..ee7d434 100644
--- a/data/resources/menus.ui
+++ b/data/resources/menus.ui
@@ -2,7 +2,7 @@
<menu id="app-menu">
<section>
<item>
- <attribute name="action">app.run-in-background</attribute>
+ <attribute name="action">app.hide</attribute>
<attribute name="label" translatable="yes">Run in Background</attribute>
</item>
</section>
diff --git a/src/application.js b/src/application.js
index 33ca652..91706de 100644
--- a/src/application.js
+++ b/src/application.js
@@ -33,6 +33,7 @@ var Application = GObject.registerClass({
this._demons = [];
this._windowRemovedId = 0;
+ this._runHidden = false;
this.add_main_option('start-client', 0,
GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
@@ -226,6 +227,8 @@ var Application = GObject.registerClass({
accels: ['F1'] },
{ name: 'about',
activate: this._onShowAbout.bind(this) },
+ { name: 'hide',
+ activate: this._onHide.bind(this) },
{ name: 'quit',
activate: this._onQuit.bind(this),
accels: ['<Primary>q'] },
@@ -264,13 +267,10 @@ var Application = GObject.registerClass({
this.add_action(action);
});
- this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
- let action = this._settings.create_action('run-in-background');
- this.add_action(action);
-
for (let i = 1; i < 10; i++)
this.set_accels_for_action(`app.nth-room(${i})`, [`<Alt>${i}`]);
+ this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
this._telepathyClient = null;
this._roomManager = RoomManager.getDefault();
@@ -346,7 +346,7 @@ var Application = GObject.registerClass({
} else {
let window = new MainWindow({ application: this });
this._windowRemovedId = this.connect('window-removed', () => {
- if (this._settings.get_boolean('run-in-background'))
+ if (this._runHidden)
return;
this.emit('prepare-shutdown');
});
@@ -358,6 +358,7 @@ var Application = GObject.registerClass({
}
this.active_window.present();
+ this._runHidden = false;
}
vfunc_window_added(window) {
@@ -813,12 +814,21 @@ var Application = GObject.registerClass({
});
}
- _onQuit() {
+ _closeWindows() {
if (this._windowRemovedId)
this.disconnect(this._windowRemovedId);
this._windowRemovedId = 0;
this.get_windows().reverse().forEach(w => { w.destroy(); });
+ }
+
+ _onHide() {
+ this._runHidden = true;
+ this._closeWindows();
+ }
+
+ _onQuit() {
+ this._closeWindows();
this.emit('prepare-shutdown');
}
});
diff --git a/src/mainWindow.js b/src/mainWindow.js
index dd65c51..560521b 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -87,8 +87,7 @@ var MainWindow = GObject.registerClass({
'userListPopover',
'roomListRevealer',
'overlay',
- 'roomStack',
- 'closeConfirmationDialog'],
+ 'roomStack'],
Properties: {
subtitle: GObject.ParamSpec.string('subtitle',
'subtitle',
@@ -184,19 +183,9 @@ var MainWindow = GObject.registerClass({
this._updateDecorations.bind(this));
this._updateDecorations();
- this._closeConfirmationDialog.transient_for = this;
- this._closeConfirmationDialog.connect('response', (w, r) => {
- if (r == Gtk.ResponseType.DELETE_EVENT)
- return;
-
- this._settings.set_boolean('run-in-background', r == Gtk.ResponseType.ACCEPT);
- this.destroy();
- });
-
this.connect('window-state-event', this._onWindowStateEvent.bind(this));
this.connect('size-allocate', this._onSizeAllocate.bind(this));
this.connect('destroy', this._onDestroy.bind(this));
- this.connect('delete-event', this._onDeleteEvent.bind(this));
this.connect('notify::active-room', () => {
this._updateUserListLabel();
});
@@ -255,35 +244,6 @@ var MainWindow = GObject.registerClass({
this._overlay.remove(this.application.commandOutputQueue);
}
- _touchFile(file) {
- try {
- file.get_parent().make_directory_with_parents(null);
- } catch (e) {
- if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS))
- throw e;
- // not an error, carry on
- }
-
- let stream = file.create(0, null);
- stream.close(null);
- }
-
- _onDeleteEvent() {
- let f = Gio.File.new_for_path(
- `${GLib.get_user_cache_dir()}/polari/close-confirmation-shown`
- );
- try {
- this._touchFile(f);
- } catch (e) {
- if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS))
- return Gdk.EVENT_PROPAGATE; // the dialog has been shown
- log(`Failed to mark confirmation dialog as shown: ${e.message}`);
- }
-
- this._closeConfirmationDialog.show();
- return Gdk.EVENT_STOP;
- }
-
_onAccountsChanged() {
let hasAccounts = this._accountsMonitor.visibleAccounts.length > 0;
this._roomListRevealer.reveal_child = hasAccounts;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]