Permalink
Browse files

Cambios para soportar drag&drop en KDE

  • Loading branch information...
1 parent a485e4d commit 474d7b4db08563b3d0ab2b8565cd2c67a8d51a68 @rastersoft committed Nov 25, 2011
Showing with 35 additions and 22 deletions.
  1. +11 −5 devede_main.py
  2. +24 −17 devede_newfiles.py
View
@@ -49,11 +49,10 @@ def __init__(self,global_vars,callback):
self.tree=devede_other.create_tree(self,"wmain",self.gladefile)
self.window=self.tree.get_object("wmain")
- if (sys.platform=="win32") or (sys.platform=="win64"):
- self.window.drag_dest_set(0,[],0)
- self.window.connect('drag_drop', self.drop_cb)
- else:
- self.window.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP,[ ( "text/plain", 0, 80), ( "video/*", 0, 81) ],gtk.gdk.ACTION_COPY)
+ self.window.drag_dest_set(0,[],0)
+ self.window.connect('drag_drop', self.drop_cb)
+ self.window.connect('drag_motion', self.motion_cb)
+
self.global_vars["main_window"]=self.window
self.list_titles=gtk.TreeStore(gobject.TYPE_PYOBJECT,gobject.TYPE_STRING)
@@ -94,6 +93,11 @@ def __init__(self,global_vars,callback):
self.window.show()
+ def motion_cb(self,wid, context, x, y, time):
+ context.drag_status(gtk.gdk.ACTION_COPY, time)
+ return True
+
+
def hide(self):
if self.window!=None:
self.window.hide()
@@ -377,6 +381,7 @@ def draganddrop(self,widget,drag_context, x, y, selection, info, time):
if len(filename)>6:
if filename[-7:]==".devede":
self.on_devede_open_activate(None, list[0])
+ drag_context.finish(True,False,time)
return
fine=True
@@ -400,6 +405,7 @@ def draganddrop(self,widget,drag_context, x, y, selection, info, time):
else:
error=devede_dialogs.show_error(self.gladefile,_("Some files weren't video files.\nNone added."))
error=None
+ drag_context.finish(True,False,time)
def on_default_pal_toggled(self,widget):
View
@@ -392,25 +392,32 @@ def split_dnd(self,data):
else:
length=7
+ cadena2=""
for elemento in data:
- if (elemento=="\n") and (item!=""):
- if item[:8]=="file:///":
- lista.append(item[length:])
- item=""
- continue
- if ord(elemento)<32:
- continue
- if mode==0:
- if elemento=="%":
- mode=1
- else:
- item+=elemento
- elif mode==1:
- tempo=elemento
- mode=2
+ if (ord(elemento)<32):
+ cadena2+="\n"
+ else:
+ cadena2+=elemento
+
+ while(True):
+ pos=cadena2.find("file:///")
+ if (pos==-1):
+ break
+ pos2=cadena2.find("\n",pos)
+ if (pos2==-1):
+ cadena=cadena2[pos+length:]
+ cadena2=""
else:
- mode=0
- item+=chr(int(tempo+elemento,16))
+ cadena=cadena2[pos+length:pos2]
+ cadena2=cadena2[pos2:]
+ while (True):
+ pos=cadena.find("%")
+ if (pos==-1):
+ break
+ cadena=cadena[:pos]+chr(int(cadena[pos+1:pos+3],16))+cadena[pos+3:]
+ lista.append(cadena)
+
+
print "Dragged files: "+str(lista)
return lista

0 comments on commit 474d7b4

Please sign in to comment.