[meld/ui-next: 18/35] Pass the window through to tab switch handlers



commit 016d4dbe9d85615870dcf58851aeb427d03ae43e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Jan 28 07:53:44 2019 +1000

    Pass the window through to tab switch handlers
    
    We need to attach per-view GActions to the top-level window in order to
    show them in e.g., the headerbar or hamburger menu, and this is the
    cleanest way I can see to get the appropriate window context to the
    right place.

 meld/dirdiff.py    | 8 ++++----
 meld/filediff.py   | 8 ++++----
 meld/melddoc.py    | 4 ++--
 meld/meldwindow.py | 4 ++--
 meld/vcview.py     | 8 ++++----
 5 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 5b95bda2..b2d5ddaa 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -591,14 +591,14 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
             self.filter_menu_button.props.label)
         self.filter_menu_button.set_label_widget(label)
 
-    def on_container_switch_in_event(self, ui):
-        MeldDoc.on_container_switch_in_event(self, ui)
+    def on_container_switch_in_event(self, ui, window):
+        MeldDoc.on_container_switch_in_event(self, ui, window)
         self._create_filter_menu_button(ui)
         self.ui_manager = ui
 
-    def on_container_switch_out_event(self, ui):
+    def on_container_switch_out_event(self, ui, window):
         self._cleanup_filter_menu_button(ui)
-        MeldDoc.on_container_switch_out_event(self, ui)
+        MeldDoc.on_container_switch_out_event(self, ui, window)
 
     def on_file_filters_changed(self, app):
         self._cleanup_filter_menu_button(self.ui_manager)
diff --git a/meld/filediff.py b/meld/filediff.py
index 19fc0c82..bb5b8a05 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -350,21 +350,21 @@ class FileDiff(Gtk.VBox, MeldDoc):
 
         self.connect("notify::ignore-blank-lines", self.refresh_comparison)
 
-    def on_container_switch_in_event(self, ui):
-        MeldDoc.on_container_switch_in_event(self, ui)
+    def on_container_switch_in_event(self, ui, window):
+        MeldDoc.on_container_switch_in_event(self, ui, window)
 
         accel_group = ui.get_accel_group()
         for accel, callback in self.extra_accels:
             keyval, mask = Gtk.accelerator_parse(accel)
             accel_group.connect(keyval, mask, 0, callback)
 
-    def on_container_switch_out_event(self, ui):
+    def on_container_switch_out_event(self, ui, window):
         accel_group = ui.get_accel_group()
         for accel, callback in self.extra_accels:
             keyval, mask = Gtk.accelerator_parse(accel)
             accel_group.disconnect_key(keyval, mask)
 
-        MeldDoc.on_container_switch_out_event(self, ui)
+        MeldDoc.on_container_switch_out_event(self, ui, window)
 
     def get_keymask(self):
         return self._keymask
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 0207940e..37077d5f 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -200,7 +200,7 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
     def set_labels(self, lst):
         pass
 
-    def on_container_switch_in_event(self, uimanager):
+    def on_container_switch_in_event(self, uimanager, window):
         """Called when the container app switches to this tab.
         """
         self.ui_merge_id = uimanager.add_ui_from_file(self.ui_file)
@@ -213,7 +213,7 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
         if hasattr(self, "focus_pane") and self.focus_pane:
             self.scheduler.add_task(self.focus_pane.grab_focus)
 
-    def on_container_switch_out_event(self, uimanager):
+    def on_container_switch_out_event(self, uimanager, window):
         """Called when the container app switches away from this tab.
         """
         uimanager.remove_action_group(self.actiongroup)
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index abc6a202..c7942a1d 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -304,7 +304,7 @@ class MeldWindow(Gtk.ApplicationWindow):
     def handle_current_doc_switch(self, page):
         if self.diff_handler is not None:
             page.disconnect(self.diff_handler)
-        page.on_container_switch_out_event(self.ui)
+        page.on_container_switch_out_event(self.ui, self)
         if self.undo_handlers:
             undoseq = page.undosequence
             for handler in self.undo_handlers:
@@ -355,7 +355,7 @@ class MeldWindow(Gtk.ApplicationWindow):
     @Template.Callback()
     def after_switch_page(self, notebook, page, which):
         newdoc = notebook.get_nth_page(which)
-        newdoc.on_container_switch_in_event(self.ui)
+        newdoc.on_container_switch_in_event(self.ui, self)
         self._update_page_action_sensitivity()
 
     @Template.Callback()
diff --git a/meld/vcview.py b/meld/vcview.py
index 85cc576e..380ef46b 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -246,14 +246,14 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
         except AttributeError:
             pass
 
-    def on_container_switch_in_event(self, ui):
-        super().on_container_switch_in_event(ui)
+    def on_container_switch_in_event(self, ui, window):
+        super().on_container_switch_in_event(ui, window)
         self._set_external_action_sensitivity(True)
         self.scheduler.add_task(self.on_treeview_cursor_changed)
 
-    def on_container_switch_out_event(self, ui):
+    def on_container_switch_out_event(self, ui, window):
         self._set_external_action_sensitivity(False)
-        super().on_container_switch_out_event(ui)
+        super().on_container_switch_out_event(ui, window)
 
     def populate_vcs_for_location(self, location):
         """Display VC plugin(s) that can handle the location"""


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