[dconf-editor] Tweaks app launching, includes a Shell crasher.



commit c2c7b17049923776f03eae285cdfacd0588b7ad6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Oct 10 14:58:23 2015 +0200

    Tweaks app launching, includes a Shell crasher.

 editor/dconf-editor.ui   |    1 +
 editor/dconf-editor.vala |   49 +++++++++++++++++++--------------------------
 editor/dconf-window.vala |    3 +-
 3 files changed, 24 insertions(+), 29 deletions(-)
---
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index 129e697..cb4d752 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -77,6 +77,7 @@ be added here</property> <!-- line wrap wanted -->
     <signal name="key-press-event" handler="on_key_press_event"/>
     <signal name="window-state-event" handler="on_window_state_event"/>
     <signal name="size-allocate" handler="on_size_allocate"/>
+    <signal name="destroy" handler="on_destroy"/>
     <child type="titlebar">
       <object class="GtkHeaderBar">
         <property name="visible">True</property>
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index f85cbad..3871d75 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -17,32 +17,23 @@
 
 class ConfigurationEditor : Gtk.Application
 {
-    private DConfWindow window;
-
-    private const OptionEntry[] option_entries =
+    private const OptionEntry [] option_entries =
     {
         { "version", 'v', 0, OptionArg.NONE, null, N_("Print release version and exit"), null },
         { null }
     };
 
-    private const GLib.ActionEntry[] action_entries =
+    private const GLib.ActionEntry [] action_entries =
     {
         { "about", about_cb },
-        { "quit", quit }
+        { "quit", quit_cb }
     };
 
     /*\
     * * Application init
     \*/
 
-    public ConfigurationEditor ()
-    {
-        Object (application_id: "ca.desrt.dconf-editor", flags: ApplicationFlags.FLAGS_NONE);
-
-        add_main_option_entries (option_entries);
-    }
-
-    public static int main (string[] args)
+    public static int main (string [] args)
     {
         Intl.setlocale (LocaleCategory.ALL, "");
         Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
@@ -53,7 +44,14 @@ class ConfigurationEditor : Gtk.Application
         return app.run (args);
     }
 
-    protected override int handle_local_options (GLib.VariantDict options)
+    public ConfigurationEditor ()
+    {
+        Object (application_id: "ca.desrt.dconf-editor", flags: ApplicationFlags.FLAGS_NONE);
+
+        add_main_option_entries (option_entries);
+    }
+
+    protected override int handle_local_options (VariantDict options)
     {
         if (options.contains ("version"))
         {
@@ -61,8 +59,6 @@ class ConfigurationEditor : Gtk.Application
             stdout.printf ("%1$s %2$s\n", "dconf-editor", Config.VERSION);
             return Posix.EXIT_SUCCESS;
         }
-
-        /* Activate */
         return -1;
     }
 
@@ -74,20 +70,12 @@ class ConfigurationEditor : Gtk.Application
 
         add_action_entries (action_entries, this);
 
-        /* window */
-        window = new DConfWindow ();
-        add_window (window);
+        add_window (new DConfWindow ());
     }
 
     protected override void activate ()
     {
-        window.present ();
-    }
-
-    protected override void shutdown ()
-    {
-        base.shutdown ();
-        window.save_settings ();
+        get_active_window ().present ();
     }
 
     /*\
@@ -96,9 +84,9 @@ class ConfigurationEditor : Gtk.Application
 
     private void about_cb ()
     {
-        string[] authors = { "Robert Ancell", "Arnaud Bonatti", null };
+        string [] authors = { "Robert Ancell", "Arnaud Bonatti", null };
         string license = _("Dconf Editor is free software: you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of 
the License, or (at your option) any later version.\n\nDconf Editor is distributed in the hope that it will 
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy 
of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.");
-        Gtk.show_about_dialog (this.get_active_window (),
+        Gtk.show_about_dialog (get_active_window (),
                                "program-name", _("dconf Editor"),
                                "version", Config.VERSION,
                                "comments", _("Directly edit your entire configuration database"),
@@ -110,4 +98,9 @@ class ConfigurationEditor : Gtk.Application
                                "logo-icon-name", "dconf-editor",
                                null);
     }
+
+    private void quit_cb ()     // session crash (!) if a modal GtkMessageDialog/KeyEditorDialog is open
+    {
+        get_active_window ().destroy ();
+    }
 }
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 42ad51c..d4b1a33 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -91,7 +91,8 @@ class DConfWindow : ApplicationWindow
         window_height = allocation.height;
     }
 
-    public void save_settings ()
+    [GtkCallback]
+    private void on_destroy ()
     {
         settings.set_string ("saved-view", current_path);
         settings.set_int ("window-width", window_width);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]