[meld/ui-next: 19/35] filediff: Add a view menu item to show/hide the sourcemap



commit a7dbd5d2323b458ac9b4163946b0997936e7e9cb
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Jan 28 07:55:37 2019 +1000

    filediff: Add a view menu item to show/hide the sourcemap

 meld/filediff.py            |  6 ++++++
 meld/melddoc.py             |  7 +++++++
 meld/resources/gtk/menus.ui | 12 ++++++++++++
 3 files changed, 25 insertions(+)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index bb5b8a05..4a7731ff 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -268,6 +268,12 @@ class FileDiff(Gtk.VBox, MeldDoc):
             prop_action_group.add_action(action)
         self.insert_action_group('view', prop_action_group)
 
+        # Set up per-view action group for top-level menu insertion
+        self.view_action_group = Gio.SimpleActionGroup()
+        action = Gio.PropertyAction.new(
+            'show-overview-map', self.sourcemap_hbox, 'visible')
+        self.view_action_group.add_action(action)
+
         for buf in self.textbuffer:
             buf.undo_sequence = self.undosequence
             buf.connect("notify::has-selection",
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 37077d5f..5ccec46b 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -210,6 +210,10 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
         self.main_actiongroup = [
             a for a in action_groups if a.get_name() == "MainActions"][0]
         uimanager.ensure_update()
+
+        if hasattr(self, "view_action_group"):
+            window.insert_action_group('view', self.view_action_group)
+
         if hasattr(self, "focus_pane") and self.focus_pane:
             self.scheduler.add_task(self.focus_pane.grab_focus)
 
@@ -222,6 +226,9 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
         self.popup_menu = None
         self.ui_merge_id = None
 
+        if hasattr(self, "view_action_group"):
+            window.insert_action_group('view', None)
+
     def on_delete_event(self):
         """Called when the docs container is about to close.
 
diff --git a/meld/resources/gtk/menus.ui b/meld/resources/gtk/menus.ui
index cd985ab5..2f822b3c 100644
--- a/meld/resources/gtk/menus.ui
+++ b/meld/resources/gtk/menus.ui
@@ -1,6 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <menu id="gear-menu">
+    <section>
+      <submenu>
+        <attribute name="label" translatable="yes">View</attribute>
+        <section>
+          <attribute name="id">view-section</attribute>
+          <item>
+            <attribute name="label" translatable="yes">Overview Map</attribute>
+            <attribute name="action">view.show-overview-map</attribute>
+          </item>
+        </section>
+      </submenu>
+    </section>
     <section>
       <attribute name="id">preferences-section</attribute>
       <item>


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