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

history: receive DnD event of patch files/dir in graphview

When dropped files/dir, it opens Import dialog with paths.

Changeset 80927c81dcda

Parent b72986b686f4

by Yuki KODAMA

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

 
38
39
40
 
 
 
41
42
43
 
1320
1321
1322
 
 
 
 
 
 
 
1323
1324
1325
 
1421
1422
1423
1424
1425
1426
1427
 
 
 
1428
1429
1430
 
1929
1930
1931
1932
 
1933
1934
1935
 
1942
1943
1944
1945
 
1946
1947
1948
 
1989
1990
1991
1992
1993
 
 
1994
 
1995
1996
1997
1998
 
 
 
 
 
 
 
 
 
 
 
1999
2000
2001
2002
2003
2004
 
2005
2006
2007
 
38
39
40
41
42
43
44
45
46
 
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
 
1431
1432
1433
 
1434
 
 
1435
1436
1437
1438
1439
1440
 
1939
1940
1941
 
1942
1943
1944
1945
 
1952
1953
1954
 
1955
1956
1957
1958
 
1999
2000
2001
 
 
2002
2003
2004
2005
2006
2007
2008
 
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
 
 
 
 
 
2021
2022
2023
2024
@@ -38,6 +38,9 @@
   HIST_DND_URI_LIST = 1024   +DND_DEST_GRAPHVIEW = 0 +DND_DEST_PATHENTRY = 1 +  class FilterBar(gtklib.SlimToolbar):   'Filter Toolbar for repository log'   @@ -1320,6 +1323,13 @@
  limit = self.get_graphlimit(self.opts['limit'])   self.graphview = LogTreeView(self.repo, limit, self.stbar)   + # dnd setup for TreeView + targets = [('text/uri-list', 0, HIST_DND_URI_LIST)] + self.graphview.drag_dest_set(gtk.DEST_DEFAULT_MOTION | \ + gtk.DEST_DEFAULT_DROP, targets, gtk.gdk.ACTION_MOVE) + self.graphview.connect('drag-data-received', self.dnd_received, + DND_DEST_GRAPHVIEW) +   # Allocate ChangeSet instance to use internally   self.changeview = changeset.ChangeSet(self.ui, self.repo, self.cwd, [],   self.opts, self.stbar) @@ -1421,10 +1431,10 @@
  syncbox.append_widget(urlcombo, expand=True)     ## dnd setup for path entry - self.dnd_targets = [('text/uri-list', 0, HIST_DND_URI_LIST)]   self.pathentry.drag_dest_set(gtk.DEST_DEFAULT_MOTION | \ - gtk.DEST_DEFAULT_DROP, self.dnd_targets, gtk.gdk.ACTION_MOVE) - self.pathentry.connect('drag-data-received', self.dnd_received) + gtk.DEST_DEFAULT_DROP, targets, gtk.gdk.ACTION_MOVE) + self.pathentry.connect('drag-data-received', self.dnd_received, + DND_DEST_PATHENTRY)     self.update_urllist()   @@ -1929,7 +1939,7 @@
  def stop_clicked(self, toolbutton):   self.runner.stop()   - def import_clicked(self, toolbutton): + def import_clicked(self, widget, paths=None):   oldlen = len(self.repo)   enabled = hasattr(self, 'mqpaned')   if enabled: @@ -1942,7 +1952,7 @@
  if enabled and oldnum < self.mqwidget.get_num_patches():   self.mqwidget.refresh()   self.enable_mqpanel(enable=True) - dialog = thgimport.ImportDialog(self.repo) + dialog = thgimport.ImportDialog(self.repo, sources=paths)   dialog.set_notify_func(import_completed)   self.show_dialog(dialog)   @@ -1989,19 +1999,26 @@
  self.ppullcombo.set_active_iter(row.iter)   break   - def dnd_received(self, widget, context, x, y, sel, target_type, *args): - if target_type == HIST_DND_URI_LIST: + def dnd_received(self, widget, context, x, y, sel, target, tm, dest): + if target == HIST_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:])) - break + paths.append(path) + if not paths: + return + if dest == DND_DEST_PATHENTRY: + path = paths[0] # use only first path + if os.path.isfile(path): + self.set_bundlefile(path) + else: + self.pathentry.set_text(path) + elif dest == DND_DEST_GRAPHVIEW: + self.import_clicked(None, paths)   else: - return - if os.path.isfile(path): - self.set_bundlefile(path) - else: - self.pathentry.set_text(path) + raise _('unknown dnd dest: %s') % dest     def realize_settings(self):   self.vpaned.set_position(self.setting_vpos)