[meld/ui-next] Move version control console visibility to GAction



commit bc7eaf32f29a0c68997ddb4871f17362c32a7976
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Feb 24 06:28:31 2019 +1000

    Move version control console visibility to GAction

 data/ui/meldapp-ui.xml      |  2 --
 data/ui/vcview-ui.xml       |  3 ---
 meld/accelerators.py        |  1 +
 meld/resources/gtk/menus.ui |  4 ++++
 meld/resources/ui/vcview.ui |  7 -------
 meld/vcview.py              | 14 ++++++++++----
 6 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index 9c6bcee7..706c0f3b 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -18,8 +18,6 @@
       <placeholder name="ChangesActions" />
     </menu>
     <menu action="ViewMenu">
-      <placeholder name="ViewUtilityPlaceholder" />
-      <separator/>
       <placeholder name="ViewPlaceholder" />
       <separator/>
       <menu action="FileStatus" />
diff --git a/data/ui/vcview-ui.xml b/data/ui/vcview-ui.xml
index cc252eb5..bd43b8cd 100644
--- a/data/ui/vcview-ui.xml
+++ b/data/ui/vcview-ui.xml
@@ -17,9 +17,6 @@
       </placeholder>
     </menu>
     <menu action="ViewMenu">
-      <placeholder name="ViewUtilityPlaceholder">
-        <menuitem action="VcConsoleVisible" />
-      </placeholder>
       <placeholder name="ViewPlaceholder">
         <menuitem action="VcFlatten" />
       </placeholder>
diff --git a/meld/accelerators.py b/meld/accelerators.py
index 3e196987..3d67f919 100644
--- a/meld/accelerators.py
+++ b/meld/accelerators.py
@@ -12,6 +12,7 @@ def register_accels(app: Gtk.Application):
         ('view.save-all', '<Primary><Shift>L'),
         ('view.save-as', '<Primary><Shift>S'),
         ('view.undo', '<Primary>Z'),
+        ('view.vc-console-visible', 'F9'),
         ('win.close', '<Primary>W'),
         ("win.stop", "Escape"),
     )
diff --git a/meld/resources/gtk/menus.ui b/meld/resources/gtk/menus.ui
index c848a3b3..e974673c 100644
--- a/meld/resources/gtk/menus.ui
+++ b/meld/resources/gtk/menus.ui
@@ -48,6 +48,10 @@
             <attribute name="label" translatable="yes">Overview Map</attribute>
             <attribute name="action">view.show-sourcemap</attribute>
           </item>
+          <item>
+            <attribute name="label" translatable="yes">Version control console</attribute>
+            <attribute name="action">view.vc-console-visible</attribute>
+          </item>
           <item>
             <attribute name="label">Lock scrolling</attribute>
             <attribute name="action">view.lock-scrolling</attribute>
diff --git a/meld/resources/ui/vcview.ui b/meld/resources/ui/vcview.ui
index 1b6c4376..958d9871 100644
--- a/meld/resources/ui/vcview.ui
+++ b/meld/resources/ui/vcview.ui
@@ -76,13 +76,6 @@
         <signal name="activate" handler="on_button_delete_clicked" swapped="no"/>
       </object>
     </child>
-    <child>
-      <object class="GtkToggleAction" id="VcConsoleVisible">
-        <property name="label" translatable="yes">Console</property>
-        <property name="tooltip" translatable="yes">Show or hide the version control console output 
pane</property>
-      </object>
-      <accelerator key="F9"/>
-    </child>
     <child>
       <object class="GtkToggleAction" id="VcFlatten">
         <property name="label" translatable="yes">_Flatten</property>
diff --git a/meld/vcview.py b/meld/vcview.py
index f5a16105..eda93fc1 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -193,6 +193,16 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
         self.actiongroup = self.VcviewActions
         self.actiongroup.set_translation_domain("meld")
 
+        # Set up per-view action group for top-level menu insertion
+        self.view_action_group = Gio.SimpleActionGroup()
+
+        property_actions = (
+            ('vc-console-visible', self.console_vbox, 'visible'),
+        )
+        for action_name, obj, prop_name in property_actions:
+            action = Gio.PropertyAction.new(action_name, obj, prop_name)
+            self.view_action_group.add_action(action)
+
         # Manually handle GAction additions
         actions = (
             ('next-change', self.action_next_change),
@@ -200,7 +210,6 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
             ('previous-change', self.action_previous_change),
             ('refresh', self.action_refresh),
         )
-        self.view_action_group = Gio.SimpleActionGroup()
         for name, callback in actions:
             action = Gio.SimpleAction.new(name, None)
             action.connect('activate', callback)
@@ -239,9 +248,6 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
         self.location = None
         self.vc = None
 
-        settings.bind('vc-console-visible',
-                      self.actiongroup.get_action('VcConsoleVisible'),
-                      'active', Gio.SettingsBindFlags.DEFAULT)
         settings.bind('vc-console-visible', self.console_vbox, 'visible',
                       Gio.SettingsBindFlags.DEFAULT)
         settings.bind('vc-console-pane-position', self.vc_console_vpaned,


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