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

thgmq: add files/dirs drop signal

Changeset 6d8714e1f4b6

Parent 80927c81dcda

by Yuki KODAMA

Changes to one file · Browse files at 6d8714e1f4b6 Showing diff from parent 80927c81dcda Diff from another changeset...

 
10
11
12
 
13
14
15
 
35
36
37
 
 
 
38
39
40
 
77
78
79
80
 
 
 
 
 
81
82
83
 
150
151
152
 
 
 
 
 
 
153
154
155
 
798
799
800
 
 
 
 
 
 
 
 
 
 
 
801
802
803
 
10
11
12
13
14
15
16
 
36
37
38
39
40
41
42
43
44
 
81
82
83
 
84
85
86
87
88
89
90
91
 
158
159
160
161
162
163
164
165
166
167
168
169
 
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
@@ -10,6 +10,7 @@
 import gtk.keysyms  import gobject  import pango +import urllib    from mercurial import error   @@ -35,6 +36,9 @@
 MOVE_DOWN = 3  MOVE_BOTTOM = 4   +# DnD target constans +MQ_DND_URI_LIST = 1024 +  class MQWidget(gtk.VBox):     __gproperties__ = { @@ -77,7 +81,11 @@
  'patch-selected': (gobject.SIGNAL_RUN_FIRST,   gobject.TYPE_NONE,   (int, # revision number - str)) # patch name + str)), # patch name + 'files-dropped': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + (object, # list of dropped files/dirs + str)) # raw string data   }     def __init__(self, repo, accelgroup=None, tooltips=None): @@ -150,6 +158,12 @@
  self.list.connect('row-activated', self.list_row_activated)   self.list.connect('size-allocate', self.list_size_allocated)   + ### dnd setup for patch list + targets = [('text/uri-list', 0, MQ_DND_URI_LIST)] + self.list.drag_dest_set(gtk.DEST_DEFAULT_MOTION | \ + gtk.DEST_DEFAULT_DROP, targets, gtk.gdk.ACTION_MOVE) + self.list.connect('drag-data-received', self.dnd_received) +   self.cols = {}   self.cells = {}   @@ -798,6 +812,17 @@
  def pushall_clicked(self, toolbutton):   self.qpush(all=True)   + def dnd_received(self, widget, context, x, y, sel, target, *args): + if target == MQ_DND_URI_LIST: + # borrow from cslist.py + paths = [] + for line in sel.data.rstrip('\x00').splitlines(): + if line.startswith('file:'): + path = os.path.normpath(urllib.url2pathname(line[5:])) + paths.append(path) + if paths: + self.emit('files-dropped', paths, sel.data) +   ### context menu signal handlers ###     def goto_activated(self, menuitem, row):