[polari/wip/fmuellner/remove-close-confirmation-dialog: 2/2] mainWindow: Remove close confirmation dialog



commit b8c255c949b264973f32ea33b2875c1ac4953b59
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Nov 1 13:23:20 2018 +0100

    mainWindow: Remove close confirmation dialog
    
    Now that the run-in-background setting no longer affects autostart,
    the checkbox in the menu is self-explanatory enough and we no longer
    need a one-time dialog to explain the feature.
    
    As an added benefit the feature becomes less intrusive, as users
    can discover it at their own pace rather than having a choice
    forced upon them when using the app for the first time.
    
    https://gitlab.gnome.org/GNOME/polari/issues/89

 data/resources/main-window.ui | 26 --------------------------
 src/mainWindow.js             | 42 +-----------------------------------------
 2 files changed, 1 insertion(+), 67 deletions(-)
---
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/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]