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

gtklib: extract function to normalize DnD string

Changeset 51539fb51f45

Parent fc45fa1c1252

by Yuki KODAMA

Changes to 4 files · Browse files at 51539fb51f45 Showing diff from parent fc45fa1c1252 Diff from another changeset...

 
8
9
10
11
12
13
14
 
768
769
770
771
772
773
774
775
776
777
 
 
 
778
779
780
 
8
9
10
 
11
12
13
 
767
768
769
 
 
 
 
 
 
 
770
771
772
773
774
775
@@ -8,7 +8,6 @@
 import os  import gtk  import gobject -import urllib    from mercurial import hg, ui   @@ -768,13 +767,9 @@
  pos, start, end = self.get_item_pos(y, detail=True)   self.reorder_item(self.item_drag, end)   elif target_type == CSL_DND_URI_LIST: - files = [] - for line in sel.data.rstrip('\x00').splitlines(): - if line.startswith('file:'): - path = os.path.normpath(urllib.url2pathname(line[5:])) - files.append(path) - if files: - self.emit('files-dropped', files, sel.data) + paths = gtklib.normalize_dnd_paths(sel.data) + if paths: + self.emit('files-dropped', paths, sel.data)     def dnd_get(self, widget, context, sel, target_type, event_time):   pos = self.item_drag
 
10
11
12
13
14
 
15
16
17
 
144
145
146
 
 
 
 
 
 
 
 
147
148
149
 
10
11
12
 
13
14
15
16
17
 
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@@ -10,8 +10,8 @@
 import sys  import gtk  import gobject -import pango  import Queue +import urllib    from tortoisehg.util.i18n import _  from tortoisehg.util import paths, hglib, thread2 @@ -144,6 +144,14 @@
  img.set_from_pixbuf(pixbuf)   return img   +def normalize_dnd_paths(rawstr): + paths = [] + for line in rawstr.rstrip('\x00').splitlines(): + if line.startswith('file:'): + path = os.path.normpath(urllib.url2pathname(line[5:])) + paths.append(path) + return paths +  class MessageDialog(gtk.Dialog):   button_map = {   gtk.BUTTONS_NONE: None,
 
13
14
15
16
17
18
19
 
2005
2006
2007
2008
2009
2010
2011
2012
2013
 
2014
2015
2016
 
13
14
15
 
16
17
18
 
2004
2005
2006
 
 
 
 
 
 
2007
2008
2009
2010
@@ -13,7 +13,6 @@
 import shutil  import tempfile  import atexit -import urllib    from mercurial import ui, hg, cmdutil, commands, extensions, util, match, url  from mercurial import hbisect, error @@ -2005,12 +2004,7 @@
    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:])) - paths.append(path) + paths = gtklib.normalize_dnd_paths(sel.data)   if not paths:   return   if dest == DND_DEST_PATHENTRY:
 
10
11
12
13
14
15
16
 
814
815
816
817
818
819
820
821
822
 
823
824
825
 
10
11
12
 
13
14
15
 
813
814
815
 
 
 
 
 
 
816
817
818
819
@@ -10,7 +10,6 @@
 import gtk.keysyms  import gobject  import pango -import urllib    from mercurial import error   @@ -814,12 +813,7 @@
    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) + paths = gtklib.normalize_dnd_paths(sel.data)   if paths:   self.emit('files-dropped', paths, sel.data)