drop from xffm to gajim tab now works

This commit is contained in:
Nikos Kouremenos 2005-08-14 19:08:56 +00:00
parent 93293dfdc5
commit 56e0c6f3c3
2 changed files with 15 additions and 6 deletions

View File

@ -19,6 +19,7 @@
import sre
import os
import urllib
import gajim
from common import i18n
@ -260,3 +261,13 @@ def play_sound(event):
command = player + ' "' + path_to_soundfile + '" &'
#FIXME: when we require 2.4+ use subprocess module
os.system(command)
def get_file_path_from_dnd_dropped_uri(uri):
path = urllib.url2pathname(uri) # escape special chars
path = path.strip('\r\n\x00') # remove \r\n and NULL
# get the path to file
if path.startswith('file://'): # nautilus, rox
path = path[7:] # 7 is len('file://')
elif path.startswith('file:'): # xffm
path = path[5:] # 5 is len('file:')
return path

View File

@ -106,12 +106,10 @@ class TabbedChatWindow(chat.Chat):
timestamp, contact):
if target_type == self.TARGET_TYPE_URI_LIST:
uri = selection.data.strip()
path = urllib.url2pathname(uri) # escape special chars
if path.startswith('file://'): # get the path to file
path = path[7:] # 7 is len('file://')
if os.path.isfile(path): # is it file?
self.plugin.windows['file_transfers'].send_file(self.account,
contact, path)
path = helpers.get_file_path_from_dnd_dropped_uri(uri)
if os.path.isfile(path): # is it file?
self.plugin.windows['file_transfers'].send_file(self.account,
contact, path)
def draw_widgets(self, contact):
"""draw the widgets in a tab (status_image, contact_button ...)