Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

thgmq: support multi-patch commands in context menu

By this, it gets ability to select multiple patches.
If PyGTK >= 2.10, 'rubber banding' feature will be enabled.

Closes #874

Changeset c43250c3698d

Parent 54d1b90d1ce6

by Yuki KODAMA

Changes to one file · Browse files at c43250c3698d Showing diff from parent 54d1b90d1ce6 Diff from another changeset...

 
152
153
154
 
 
 
155
156
157
 
702
703
704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
706
707
 
784
785
786
 
787
788
789
 
793
794
795
 
 
 
 
 
 
 
 
796
797
798
799
800
801
802
 
 
 
 
 
 
 
803
804
 
 
 
805
806
807
 
152
153
154
155
156
157
158
159
160
 
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
 
816
817
818
819
820
821
822
 
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
 
 
 
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
@@ -152,6 +152,9 @@
  # To support old PyGTK (<2.12)   if hasattr(self.list, 'set_tooltip_column'):   self.list.set_tooltip_column(MQ_ESCAPED) + self.list.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + if hasattr(self.list, 'set_rubber_banding'): + self.list.set_rubber_banding(True)   self.list.connect('cursor-changed', self.list_sel_changed)   self.list.connect('button-press-event', self.list_pressed)   self.list.connect('button-release-event', self.list_released) @@ -702,6 +705,35 @@
  menu.show_all()   menu.popup(None, None, None, 0, 0)   + def show_patches_cmenu(self): + sel = self.list.get_selection() + patches = [] + for path in sel.get_selected_rows()[1]: + row = self.model[path] + if row[MQ_INDEX] in (INDEX_SEPARATOR, INDEX_QPARENT): + continue + patches.append(row[MQ_NAME]) + + incl_applied, incl_unapplied = False, False + for patch in patches: + if self.is_applied(patch): + incl_applied = True + else: + incl_unapplied = True + + m = gtklib.MenuBuilder() + if incl_unapplied: + m.append(_('_Delete'), lambda *a: self.qdelete(patches), + gtk.STOCK_DELETE) + if self.has_applied() and incl_unapplied: + m.append(_('F_old'), lambda *a: self.qfold(patches), + gtk.STOCK_DIRECTORY) + + menu = m.build() + if len(menu.get_children()) > 0: + menu.show_all() + menu.popup(None, None, None, 0, 0) +   def create_view_menu(self):   self.vmenu = {}   m = gtklib.MenuBuilder() @@ -784,6 +816,7 @@
  def list_pressed(self, list, event):   x, y = int(event.x), int(event.y)   pathinfo = list.get_path_at_pos(x, y) +   if event.button == 1:   if not pathinfo:   # HACK: clear selection after this function calling, @@ -793,15 +826,30 @@
  selection.unselect_all()   gtklib.idle_add_single_call(unselect)   + elif event.button == 3 and pathinfo: + sel = list.get_selection() + sel_rows = sel.get_selected_rows()[1] # list of paths + if pathinfo[0] not in sel_rows: + sel.unselect_all() + sel.select_path(pathinfo[0]) + return True +   def list_released(self, list, event):   if event.button != 3:   return   - x, y = int(event.x), int(event.y) - pathinfo = list.get_path_at_pos(x, y) - if pathinfo: + sel = list.get_selection() + count = sel.count_selected_rows() + if count == 1: + x, y = int(event.x), int(event.y) + pathinfo = list.get_path_at_pos(x, y) + if not pathinfo: + return   self.show_patch_cmenu(pathinfo[0])   + elif 1 < count: + self.show_patches_cmenu() +   def list_sel_changed(self, list):   path, focus = list.get_cursor()   row = self.model[path]