Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hggtk: make ctrl-d shortcut for visual diff

Changeset 97640e72f46d

Parent 5eb521beaac7

by Steve Borho

Changes to 5 files · Browse files at 97640e72f46d Showing diff from parent 5eb521beaac7 Diff from another changeset...

 
459
460
461
 
462
463
464
 
492
493
494
 
 
 
 
 
 
 
 
 
 
495
496
497
 
616
617
618
 
 
 
 
 
 
 
 
 
 
 
619
620
621
 
459
460
461
462
463
464
465
 
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
 
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
@@ -459,6 +459,7 @@
  return _menu     def get_body(self): + self.curfile = None   if self.repo.ui.configbool('tortoisehg', 'copyhash'):   sel = (os.name == 'nt') and 'CLIPBOARD' or 'PRIMARY'   self.clipboard = gtk.Clipboard(selection=sel) @@ -492,6 +493,16 @@
  filelist_tree.connect('row-activated', self._file_row_act)   filelist_tree.set_search_equal_func(self.search_filelist)   + accelgroup = gtk.AccelGroup() + if self.glog_parent: + self.glog_parent.add_accel_group(accelgroup) + else: + self.add_accel_group(accelgroup) + key, modifier = gtk.accelerator_parse('<Control>d') + filelist_tree.add_accelerator('thg-diff', accelgroup, key, + modifier, gtk.ACCEL_VISIBLE) + filelist_tree.connect('thg-diff', self.thgdiff) +   self._filelist = gtk.ListStore(   gobject.TYPE_STRING, # MAR status   gobject.TYPE_STRING, # filename (utf-8 encoded) @@ -616,6 +627,17 @@
  self._save_menu.set_sensitive(has_filelog)   return True   + def thgdiff(self, treeview): + # Do not steal ctrl-d from changelog treeview + if not treeview.is_focus() and self.glog_parent: + w = self.glog_parent.get_focus() + if isinstance(w, gtk.TreeView): + w.emit('thg-diff') + return False + if self.curfile is None: + return False + self._diff_file('M', self.curfile) +   def _file_row_act(self, tree, path, column) :   """Default action is the first entry in the context menu   """
Change 1 of 1 Show Entire File hggtk/​hgtk.py Stacked
 
24
25
26
27
28
29
30
31
32
 
 
 
 
 
 
33
34
35
 
24
25
26
 
 
 
 
 
 
27
28
29
30
31
32
33
34
35
@@ -24,12 +24,12 @@
   nonrepo_commands = 'userconfig clone debugcomplete init about help version'   -if 'copy-clipboard' not in gobject.signal_list_names(gtk.TreeView): - gobject.signal_new('copy-clipboard', gtk.TreeView, - gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) - gobject.signal_new('thg-exit', gtk.Window, - gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) - gobject.signal_new('thg-close', gtk.Window, +# Add TortoiseHg signals, hooked to key accelerators in shlib +for sig in ('copy-clipboard', 'thg-diff'): + gobject.signal_new(sig, gtk.TreeView, + gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) +for sig in ('thg-exit', 'thg-close', 'thg-refresh'): + gobject.signal_new(sig, gtk.Window,   gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ())    def dispatch(args):
Change 1 of 2 Show Entire File hggtk/​history.py Stacked
 
385
386
387
 
 
 
 
 
 
 
388
389
390
 
432
433
434
 
 
 
435
436
437
 
385
386
387
388
389
390
391
392
393
394
395
396
397
 
439
440
441
442
443
444
445
446
447
@@ -385,6 +385,13 @@
  self.tree.connect('row-activated', self._tree_row_act)   #self.tree.modify_font(pango.FontDescription(self.fontlist))   + accelgroup = gtk.AccelGroup() + self.add_accel_group(accelgroup) + key, modifier = gtk.accelerator_parse('<Control>d') + self.tree.add_accelerator('thg-diff', accelgroup, key, + modifier, gtk.ACCEL_VISIBLE) + self.tree.connect('thg-diff', self.thgdiff) +   hbox = gtk.HBox()   hbox.pack_start(self.graphview, True, True, 0)   vbox = gtk.VBox() @@ -432,6 +439,9 @@
    return vbox   + def thgdiff(self, treeview): + self._vdiff_change(None) +   def _strip_rev(self, menuitem):   rev = self.currow[treemodel.REVID]   res = Confirm(_('Strip Revision(s)'), [], self,
Change 1 of 1 Show Entire File hggtk/​shlib.py Stacked
 
132
133
134
 
 
 
135
136
137
138
 
 
 
 
 
 
 
 
 
 
139
140
141
142
143
144
145
 
132
133
134
135
136
137
138
139
140
 
141
142
143
144
145
146
147
148
149
150
151
 
 
 
152
153
154
@@ -132,14 +132,23 @@
  if ico: window.set_icon_from_file(ico)    def set_tortoise_keys(window): + 'Set default TortoiseHg keyboard accelerators' + from hgtk import thgexit +   accelgroup = gtk.AccelGroup()   window.add_accel_group(accelgroup)   key, modifier = gtk.accelerator_parse('<Control>w') - window.add_accelerator('thg-close', accelgroup, key, modifier, gtk.ACCEL_VISIBLE) + window.add_accelerator('thg-close', accelgroup, key, modifier, + gtk.ACCEL_VISIBLE) + key, modifier = gtk.accelerator_parse('<Control>q') + window.add_accelerator('thg-exit', accelgroup, key, modifier, + gtk.ACCEL_VISIBLE) + key, modifier = gtk.accelerator_parse('F5') + window.add_accelerator('thg-refresh', accelgroup, key, modifier, + gtk.ACCEL_VISIBLE) + + # connect ctrl-w and ctrl-q to every window   window.connect('thg-close', thgclose) - key, modifier = gtk.accelerator_parse('<Control>q') - window.add_accelerator('thg-exit', accelgroup, key, modifier, gtk.ACCEL_VISIBLE) - from hgtk import thgexit   window.connect('thg-exit', thgexit)    def thgclose(window):
Change 1 of 4 Show Entire File hggtk/​status.py Stacked
 
257
258
259
260
 
 
 
 
 
 
 
 
261
262
263
 
329
330
331
332
333
334
335
336
337
338
339
340
 
341
 
342
343
344
 
403
404
405
 
 
 
 
 
 
406
407
408
 
1233
1234
1235
1236
 
1237
1238
1239
 
257
258
259
 
260
261
262
263
264
265
266
267
268
269
270
 
336
337
338
 
339
 
340
341
 
 
342
 
343
344
345
346
347
348
 
407
408
409
410
411
412
413
414
415
416
417
418
 
1243
1244
1245
 
1246
1247
1248
1249
@@ -257,7 +257,14 @@
  self.filetree.set_rubber_banding(True)   self.filetree.modify_font(pango.FontDescription(self.fontlist))   self.filetree.set_headers_clickable(True) - + + accelgroup = gtk.AccelGroup() + self.add_accel_group(accelgroup) + key, modifier = gtk.accelerator_parse('<Control>d') + self.filetree.add_accelerator('thg-diff', accelgroup, key, + modifier, gtk.ACCEL_VISIBLE) + self.filetree.connect('thg-diff', self.thgdiff) +   toggle_cell = gtk.CellRendererToggle()   toggle_cell.connect('toggled', self._select_toggle)   toggle_cell.set_property('activatable', True) @@ -329,16 +336,13 @@
  self.diff_model = gtk.ListStore(bool, str, str, str, bool, int,   pango.FontDescription)   - newsigname = 'copy-clipboard'   self.diff_tree = gtk.TreeView(self.diff_model) - self.diff_tree.connect(newsigname, self.copy_to_clipboard)     # set CTRL-c accelerator for copy-clipboard - accelgroup = gtk.AccelGroup() - self.add_accel_group(accelgroup)   key, modifier = gtk.accelerator_parse('<Control>c') - self.diff_tree.add_accelerator(newsigname, accelgroup, key, + self.diff_tree.add_accelerator('copy-clipboard', accelgroup, key,   modifier, gtk.ACCEL_VISIBLE) + self.diff_tree.connect('copy-clipboard', self.copy_to_clipboard)     self.diff_tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)   self.diff_tree.set_headers_visible(False) @@ -403,6 +407,12 @@
  return False   return True   + def thgdiff(self, treeview): + selection = treeview.get_selection() + model, paths = selection.get_selected_rows() + row = model[paths[0]] + self._diff_file(row[FM_STATUS], row[FM_PATH]) +   def copy_to_clipboard(self, treeview):   'Write highlighted hunks to the clipboard'   if not treeview.is_focus(): @@ -1233,7 +1243,7 @@
    model, paths = selection.get_selected_rows()   path = paths[0] - handler(model[path][1], model[path][3]) + handler(model[path][FM_STATUS], model[path][FM_PATH])   return True