[dconf-editor] Remove app-menu.



commit 22e04792972ed01d888ae177974f947a52a2d312
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Sep 6 18:45:25 2018 +0200

    Remove app-menu.
    
    https://wiki.gnome.org/Initiatives/GnomeGoals/AppMenuRetirement

 editor/dconf-editor-menu.ui       | 20 --------------------
 editor/dconf-editor.gresource.xml |  1 -
 editor/dconf-editor.vala          | 23 ++++++++++++++++-------
 editor/dconf-window.vala          | 23 +++++++++++++++++++++++
 editor/help-overlay.ui            | 18 ++++++++++++++++--
 editor/meson.build                |  1 -
 editor/modifications-handler.vala |  5 +++++
 7 files changed, 60 insertions(+), 31 deletions(-)
---
diff --git a/editor/dconf-editor.gresource.xml b/editor/dconf-editor.gresource.xml
index ba52b3e..d6db7d0 100644
--- a/editor/dconf-editor.gresource.xml
+++ b/editor/dconf-editor.gresource.xml
@@ -20,7 +20,6 @@
     <file preprocess="xml-stripblanks">registry-view.ui</file>
   </gresource>
   <gresource prefix="/ca/desrt/dconf-editor/gtk">
-    <file preprocess="xml-stripblanks" alias="menus.ui">dconf-editor-menu.ui</file>
     <file preprocess="xml-stripblanks">help-overlay.ui</file>
   </gresource>
 </gresources>
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index b6be8dc..6fe510c 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -144,10 +144,11 @@ private class ConfigurationEditor : Gtk.Application
     {
         // generic
         { "copy", copy_cb, "s" },   // TODO is that really the good way to do things? (see Taquin)
-
-        // app-menu
         { "about", about_cb },
-        { "quit", quit_cb }
+
+        // quit
+        { "quit",           quit_if_no_pending_changes },
+        { "apply-and-quit", apply_pending_changes_and_quit }
     };
 
     /*\
@@ -263,7 +264,9 @@ private class ConfigurationEditor : Gtk.Application
         Gtk.Window.set_default_icon_name ("ca.desrt.dconf-editor");
 
         add_action_entries (action_entries, this);
-        set_accels_for_action ("ui.copy-path", { "<Primary><Shift>c" });
+        set_accels_for_action ("ui.copy-path",          { "<Primary><Shift>c" });
+        set_accels_for_action ("app.quit",              { "<Primary>q" });
+        set_accels_for_action ("app.apply-and-quit",    { "<Primary><Shift>q" });
 
         Gtk.CssProvider css_provider = new Gtk.CssProvider ();
         css_provider.load_from_resource ("/ca/desrt/dconf-editor/ui/dconf-editor.css");
@@ -488,12 +491,18 @@ private class ConfigurationEditor : Gtk.Application
                                null);
     }
 
-    private void quit_cb ()
+    private void quit_if_no_pending_changes ()
     {
         Gtk.Window? window = get_active_window ();
-        if (window != null)
-            ((!) window).destroy ();
+        if (window == null || ((DConfWindow) (!) window).quit_if_no_pending_changes ())
+            base.quit ();
+    }
 
+    private void apply_pending_changes_and_quit ()
+    {
+        Gtk.Window? window = get_active_window ();
+        if (window != null)
+            ((DConfWindow) (!) window).apply_pending_changes_and_quit ();
         base.quit ();
     }
 }
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 2984479..ea0e764 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -353,6 +353,23 @@ private class DConfWindow : ApplicationWindow
         window_height = (!) _window_height;
     }
 
+    internal bool quit_if_no_pending_changes ()
+    {
+        if (modifications_handler.has_pending_changes ())
+        {
+            show_notification ("There are pending changes. Use <ctrl><shift>q to apply changes and quit.");
+            return false;
+        }
+        destroy ();
+        return true;
+    }
+
+    internal void apply_pending_changes_and_quit ()
+    {
+        modifications_handler.apply_delayed_settings ();
+        destroy ();
+    }
+
     [GtkCallback]
     private void on_destroy ()
     {
@@ -711,6 +728,12 @@ private class DConfWindow : ApplicationWindow
             menu.append_section (null, section);
         }
 
+        section = new GLib.Menu ();     // TODO not accessible in search mode
+        section.append (_("Keyboard Shortcuts"), "win.show-help-overlay");
+        section.append (_("About"), "app.about");   // TODO move as "win."
+        section.freeze ();
+        menu.append_section (null, section);
+
         menu.freeze ();
         info_button.set_menu_model ((MenuModel) menu);
     }
diff --git a/editor/help-overlay.ui b/editor/help-overlay.ui
index 23789f7..3f81f0b 100644
--- a/editor/help-overlay.ui
+++ b/editor/help-overlay.ui
@@ -172,13 +172,27 @@
                 <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;F1</property>
               </object>
             </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">True</property>
+            <property name="title" translatable="yes" context="shortcut window">Quit</property>
+            <!-- TODO missing "discard and quit", as <alt>F4 has a different behaviour when a dialog is 
opened (and is WM-specific) -->
             <child>
-              <object class="GtkShortcutsShortcut"> <!-- TODO doesn't quit if a KeyEditor dialog is opened 
-->
+              <object class="GtkShortcutsShortcut"> <!-- TODO doesn't quit if a dialog is opened -->
                 <property name="visible">True</property>
-                <property name="title" translatable="yes" context="shortcut window">Quit</property>
+                <property name="title" translatable="yes" context="shortcut window">Quit if there’s no 
pending changes</property>
                 <property name="accelerator">&lt;Primary&gt;q</property>
               </object>
             </child>
+            <child>
+              <object class="GtkShortcutsShortcut"> <!-- TODO doesn't quit if a dialog is opened -->
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Apply pending changes 
and quit</property>
+                <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;q</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/editor/meson.build b/editor/meson.build
index 64031bf..616853e 100644
--- a/editor/meson.build
+++ b/editor/meson.build
@@ -97,7 +97,6 @@ resource_data = files(
   'browser-stack.ui',
   'browser-view.ui',
   'dconf-editor.css',
-  'dconf-editor-menu.ui',
   'dconf-editor.ui',
   'delayed-setting-view.ui',
   'folder-list-box-row.ui',
diff --git a/editor/modifications-handler.vala b/editor/modifications-handler.vala
index 26a14f0..e71e1cf 100644
--- a/editor/modifications-handler.vala
+++ b/editor/modifications-handler.vala
@@ -55,6 +55,11 @@ private class ModificationsHandler : Object
     * * Public calls
     \*/
 
+    internal bool has_pending_changes ()
+    {
+        return dconf_changes_count + gsettings_changes_count != 0;
+    }
+
     internal bool get_current_delay_mode ()
     {
         return mode == ModificationsMode.DELAYED || behaviour == Behaviour.ALWAYS_DELAY;


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