[meld] Respond to context menu signal for DirDiff treeviews



commit 6976fc464690fb209aed618078ce1e53658def0b
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Jan 15 12:07:10 2011 +1000

    Respond to context menu signal for DirDiff treeviews

 data/ui/dirdiff.ui |    3 +++
 meld/dirdiff.py    |   16 +++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/dirdiff.ui b/data/ui/dirdiff.ui
index f2841b0..0bb562c 100644
--- a/data/ui/dirdiff.ui
+++ b/data/ui/dirdiff.ui
@@ -54,6 +54,7 @@
                     <signal handler="on_treeview_button_press_event" last_modification_time="Wed, 19 Mar 2003 10:22:44 GMT" name="button_press_event"/>
                     <signal handler="on_treeview_cursor_changed" last_modification_time="Sun, 14 Dec 2003 21:04:29 GMT" name="cursor_changed"/>
                     <signal handler="on_treeview_key_press_event" last_modification_time="Sun, 14 Dec 2003 22:09:35 GMT" name="key_press_event"/>
+                    <signal handler="on_treeview_popup_menu" name="popup-menu"/>
                   </object>
                 </child>
               </object>
@@ -89,6 +90,7 @@
                     <signal handler="on_treeview_button_press_event" last_modification_time="Wed, 19 Mar 2003 10:22:58 GMT" name="button_press_event"/>
                     <signal handler="on_treeview_key_press_event" last_modification_time="Sun, 14 Dec 2003 22:15:38 GMT" name="key_press_event"/>
                     <signal handler="on_treeview_cursor_changed" last_modification_time="Sun, 14 Dec 2003 22:22:39 GMT" name="cursor_changed"/>
+                    <signal handler="on_treeview_popup_menu" name="popup-menu"/>
                   </object>
                 </child>
               </object>
@@ -244,6 +246,7 @@
                     <signal handler="on_treeview_button_press_event" last_modification_time="Wed, 19 Mar 2003 10:22:58 GMT" name="button_press_event"/>
                     <signal handler="on_treeview_key_press_event" last_modification_time="Sun, 14 Dec 2003 22:15:54 GMT" name="key_press_event"/>
                     <signal handler="on_treeview_cursor_changed" last_modification_time="Sun, 14 Dec 2003 22:22:48 GMT" name="cursor_changed"/>
+                    <signal handler="on_treeview_popup_menu" name="popup-menu"/>
                   </object>
                 </child>
               </object>
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 57296cd..b8a9980 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -790,13 +790,23 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                 self.model.set_state(it, j, tree.STATE_MISSING, True in one_isdir)
         return different
 
-    def popup_in_pane(self, pane):
+    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)
-        self.popup_menu.popup(None, None, None, 3, gtk.get_current_event_time())
+        if event:
+            button = event.button
+            time = event.time
+        else:
+            button = 0
+            time = gtk.get_current_event_time()
+        self.popup_menu.popup(None, None, None, button, time)
+
+    def on_treeview_popup_menu(self, treeview):
+        self.popup_in_pane(self.treeview.index(treeview), None)
+        return True
 
     def on_treeview_button_press_event(self, treeview, event):
         # unselect other panes
@@ -812,7 +822,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                 selected = self._get_selected_paths( self.treeview.index(treeview) )
                 if len(selected) <= 1 and event.state == 0:
                     treeview.set_cursor( path, col, 0)
-                self.popup_in_pane( self.treeview.index(treeview) )
+                self.popup_in_pane(self.treeview.index(treeview), event)
             return event.state==0
         return 0
 



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