[meld] dirdiff: Fix menu focus issues by removing a *lot* of code



commit 4e46baee3b5d5e038a686b2868f98ba204c02b60
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Jan 1 08:33:49 2019 +1000

    dirdiff: Fix menu focus issues by removing a *lot* of code
    
    The actual reason I went to change this was that if you tried to use the
    menu bar items, the main actions (i.e., compare, copy, delete) were all
    insensitive. This happens because we unset their sensitivity on treeview
    focus loss. I suspect that the intention here was to keep consistent
    action state, but in reality we can just invoke the action based on the
    last focus pane, which is what the user expects.
    
    When doing this, I found that the focus handler block/unblock around
    popup handling was doing nothing useful, and then that the popup menu
    handling was actually slightly confused with the custom filter menu
    code, so... now it's mostly deleted.

 data/ui/dirdiff.ui |  3 +++
 meld/dirdiff.py    | 33 ---------------------------------
 2 files changed, 3 insertions(+), 33 deletions(-)
---
diff --git a/data/ui/dirdiff.ui b/data/ui/dirdiff.ui
index 3476023a..b5b3a12e 100644
--- a/data/ui/dirdiff.ui
+++ b/data/ui/dirdiff.ui
@@ -383,6 +383,7 @@
                         <property name="headers_visible">False</property>
                         <signal name="button-press-event" handler="on_treeview_button_press_event" 
swapped="no"/>
                         <signal name="cursor-changed" handler="on_treeview_cursor_changed" swapped="no"/>
+                        <signal name="focus-in-event" handler="on_treeview_focus_in_event" swapped="no"/>
                         <signal name="row-expanded" handler="on_treeview_row_expanded" swapped="no"/>
                         <signal name="key-press-event" handler="on_treeview_key_press_event" swapped="no"/>
                         <signal name="row-activated" handler="on_treeview_row_activated" swapped="no"/>
@@ -440,6 +441,7 @@
                         <property name="headers_visible">False</property>
                         <signal name="button-press-event" handler="on_treeview_button_press_event" 
swapped="no"/>
                         <signal name="cursor-changed" handler="on_treeview_cursor_changed" swapped="no"/>
+                        <signal name="focus-in-event" handler="on_treeview_focus_in_event" swapped="no"/>
                         <signal name="row-expanded" handler="on_treeview_row_expanded" swapped="no"/>
                         <signal name="key-press-event" handler="on_treeview_key_press_event" swapped="no"/>
                         <signal name="row-activated" handler="on_treeview_row_activated" swapped="no"/>
@@ -497,6 +499,7 @@
                         <property name="headers_visible">False</property>
                         <signal name="button-press-event" handler="on_treeview_button_press_event" 
swapped="no"/>
                         <signal name="cursor-changed" handler="on_treeview_cursor_changed" swapped="no"/>
+                        <signal name="focus-in-event" handler="on_treeview_focus_in_event" swapped="no"/>
                         <signal name="row-expanded" handler="on_treeview_row_expanded" swapped="no"/>
                         <signal name="key-press-event" handler="on_treeview_key_press_event" swapped="no"/>
                         <signal name="row-activated" handler="on_treeview_row_activated" swapped="no"/>
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 2fffadc7..6fb8eb52 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -392,19 +392,10 @@ class DirDiff(MeldDoc, Component):
         self.model.on_style_updated(self.widget)
 
         self.do_to_others_lock = False
-        self.focus_in_events = []
-        self.focus_out_events = []
         for treeview in self.treeview:
-            handler_id = treeview.connect(
-                "focus-in-event", self.on_treeview_focus_in_event)
-            self.focus_in_events.append(handler_id)
-            handler_id = treeview.connect(
-                "focus-out-event", self.on_treeview_focus_out_event)
-            self.focus_out_events.append(handler_id)
             treeview.set_search_equal_func(tree.treeview_search_cb, None)
         self.force_cursor_recalculate = False
         self.current_path, self.prev_path, self.next_path = None, None, None
-        self.on_treeview_focus_out_event(None, None)
         self.focus_pane = None
         self.row_expansions = set()
 
@@ -532,8 +523,6 @@ class DirDiff(MeldDoc, Component):
                                     Gtk.get_current_event_time())
 
     def _cleanup_filter_menu_button(self, ui):
-        if self.popup_deactivate_id:
-            self.popup_menu.disconnect(self.popup_deactivate_id)
         if self.custom_merge_id:
             ui.remove_ui(self.custom_merge_id)
         if self.filter_actiongroup in ui.get_action_groups():
@@ -544,8 +533,6 @@ class DirDiff(MeldDoc, Component):
         self.custom_merge_id = ui.new_merge_id()
         for x in self.filter_ui:
             ui.add_ui(self.custom_merge_id, *x)
-        self.popup_deactivate_id = self.popup_menu.connect(
-            "deactivate", self.on_popup_deactivate_event)
         self.custom_popup = ui.get_widget("/CustomPopup")
         self.filter_menu_button = ui.get_widget(
             "/Toolbar/FilterActions/CustomFilterMenu")
@@ -1210,28 +1197,12 @@ class DirDiff(MeldDoc, Component):
         self._do_to_others(view, self.treeview, "collapse_row", (path,))
         self._update_diffmaps()
 
-    def on_popup_deactivate_event(self, popup):
-        for (treeview, inid, outid) in zip(
-                self.treeview, self.focus_in_events, self.focus_out_events):
-            treeview.handler_unblock(inid)
-            treeview.handler_unblock(outid)
-
     def on_treeview_focus_in_event(self, tree, event):
         self.focus_pane = tree
         pane = self.treeview.index(tree)
         self.on_treeview_selection_changed(tree.get_selection(), pane)
         tree.emit("cursor-changed")
 
-    def on_treeview_focus_out_event(self, tree, event):
-        for action in ("DirCompare", "DirCopyLeft", "DirCopyRight",
-                       "DirDelete", "Hide"):
-            self.actiongroup.get_action(action).set_sensitive(False)
-        try:
-            self.main_actiongroup.get_action("OpenExternal").set_sensitive(
-                False)
-        except AttributeError:
-            pass
-
     def run_diff_from_iter(self, it):
         row_paths = self.model.value_paths(it)
         gfiles = [Gio.File.new_for_path(p)
@@ -1473,10 +1444,6 @@ class DirDiff(MeldDoc, Component):
         return different
 
     def popup_in_pane(self, pane, event):
-        for (treeview, inid, outid) in zip(
-                self.treeview, self.focus_in_events, self.focus_out_events):
-            treeview.handler_block(inid)
-            treeview.handler_block(outid)
         self.actiongroup.get_action("DirCopyLeft").set_sensitive(pane > 0)
         self.actiongroup.get_action("DirCopyRight").set_sensitive(
             pane + 1 < self.num_panes)


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