2005-08-15 01:52:12 +02:00
|
|
|
## filetransfers_window.py
|
|
|
|
##
|
2006-03-15 02:40:10 +01:00
|
|
|
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
|
|
|
## Copyright (C) 2005
|
2005-12-10 00:30:28 +01:00
|
|
|
## Dimitur Kirov <dkirov@gmail.com>
|
|
|
|
## Travis Shirk <travis@pobox.com>
|
|
|
|
## Norman Rasmussen <norman@rasmussen.co.za>
|
2006-03-15 02:40:10 +01:00
|
|
|
## Copyright (C) 2004-2005 Vincent Hanquez <tab@snarc.org>
|
2005-08-15 01:52:12 +02:00
|
|
|
##
|
|
|
|
## This program is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 2 only.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
import gobject
|
2005-09-07 18:44:00 +02:00
|
|
|
import pango
|
2005-08-15 01:52:12 +02:00
|
|
|
import os
|
2005-09-09 00:12:14 +02:00
|
|
|
import time
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
import gtkgui_helpers
|
|
|
|
import tooltips
|
|
|
|
import dialogs
|
|
|
|
|
|
|
|
from common import gajim
|
|
|
|
from common import helpers
|
|
|
|
from common import i18n
|
|
|
|
|
|
|
|
_ = i18n._
|
|
|
|
APP = i18n.APP
|
|
|
|
gtk.glade.bindtextdomain (APP, i18n.DIR)
|
|
|
|
gtk.glade.textdomain (APP)
|
|
|
|
|
|
|
|
GTKGUI_GLADE = 'gtkgui.glade'
|
2005-09-09 00:12:14 +02:00
|
|
|
|
|
|
|
C_IMAGE = 0
|
|
|
|
C_LABELS = 1
|
|
|
|
C_FILE = 2
|
2005-09-09 00:19:26 +02:00
|
|
|
C_TIME = 3
|
|
|
|
C_PROGRESS = 4
|
|
|
|
C_PERCENT = 5
|
2005-09-09 00:12:14 +02:00
|
|
|
C_SID = 6
|
|
|
|
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
class FileTransfersWindow:
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-08-15 01:52:12 +02:00
|
|
|
self.files_props = {'r' : {}, 's': {}}
|
|
|
|
self.height_diff = 0
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'file_transfers_window', APP)
|
|
|
|
self.window = self.xml.get_widget('file_transfers_window')
|
|
|
|
self.tree = self.xml.get_widget('transfers_list')
|
|
|
|
self.cancel_button = self.xml.get_widget('cancel_button')
|
|
|
|
self.pause_button = self.xml.get_widget('pause_restore_button')
|
2005-09-03 16:23:53 +02:00
|
|
|
self.cleanup_button = self.xml.get_widget('cleanup_button')
|
2005-08-15 01:52:12 +02:00
|
|
|
self.notify_ft_checkbox = self.xml.get_widget(
|
|
|
|
'notify_ft_complete_checkbox')
|
|
|
|
notify = gajim.config.get('notify_on_file_complete')
|
|
|
|
if notify:
|
|
|
|
self.notify_ft_checkbox.set_active(True)
|
|
|
|
else:
|
|
|
|
self.notify_ft_checkbox.set_active(False)
|
2005-09-09 00:19:26 +02:00
|
|
|
self.model = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, str, int, str)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.tree.set_model(self.model)
|
|
|
|
col = gtk.TreeViewColumn()
|
|
|
|
|
|
|
|
render_pixbuf = gtk.CellRendererPixbuf()
|
|
|
|
|
|
|
|
col.pack_start(render_pixbuf, expand = True)
|
|
|
|
render_pixbuf.set_property('xpad', 3)
|
|
|
|
render_pixbuf.set_property('ypad', 3)
|
|
|
|
render_pixbuf.set_property('yalign', .0)
|
|
|
|
col.add_attribute(render_pixbuf, 'pixbuf', 0)
|
|
|
|
self.tree.append_column(col)
|
|
|
|
|
|
|
|
col = gtk.TreeViewColumn(_('File'))
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer, expand=False)
|
2005-09-09 00:12:14 +02:00
|
|
|
col.add_attribute(renderer, 'markup' , C_LABELS)
|
2005-08-15 01:52:12 +02:00
|
|
|
renderer.set_property('yalign', 0.)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer, expand=True)
|
2005-09-09 00:12:14 +02:00
|
|
|
col.add_attribute(renderer, 'markup' , C_FILE)
|
2005-08-15 01:52:12 +02:00
|
|
|
renderer.set_property('xalign', 0.)
|
|
|
|
renderer.set_property('yalign', 0.)
|
2005-09-07 18:44:00 +02:00
|
|
|
renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
|
2005-08-15 01:52:12 +02:00
|
|
|
col.set_resizable(True)
|
|
|
|
col.set_expand(True)
|
|
|
|
self.tree.append_column(col)
|
|
|
|
|
2005-09-09 00:12:14 +02:00
|
|
|
col = gtk.TreeViewColumn(_('Time'))
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer, expand=False)
|
|
|
|
col.add_attribute(renderer, 'markup' , C_TIME)
|
|
|
|
renderer.set_property('yalign', 0.5)
|
|
|
|
renderer.set_property('xalign', 0.5)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
|
|
|
|
col.set_resizable(True)
|
|
|
|
col.set_expand(False)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.tree.append_column(col)
|
2005-09-09 00:12:14 +02:00
|
|
|
|
2005-09-09 00:19:26 +02:00
|
|
|
col = gtk.TreeViewColumn(_('Progress'))
|
|
|
|
renderer = gtk.CellRendererProgress()
|
|
|
|
renderer.set_property('yalign', 0.5)
|
|
|
|
renderer.set_property('xalign', 0.5)
|
|
|
|
col.pack_start(renderer, expand = False)
|
|
|
|
col.add_attribute(renderer, 'text' , C_PROGRESS)
|
|
|
|
col.add_attribute(renderer, 'value' , C_PERCENT)
|
|
|
|
col.set_resizable(True)
|
2005-10-07 14:00:33 +02:00
|
|
|
col.set_expand(False)
|
2005-09-09 00:19:26 +02:00
|
|
|
self.tree.append_column(col)
|
2005-09-09 00:12:14 +02:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
self.set_images()
|
|
|
|
self.tree.get_selection().set_mode(gtk.SELECTION_SINGLE)
|
|
|
|
self.tree.get_selection().connect('changed', self.selection_changed)
|
|
|
|
self.tooltip = tooltips.FileTransfersTooltip()
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
popup_xml = gtk.glade.XML(GTKGUI_GLADE, 'file_transfers_menu',
|
|
|
|
APP)
|
|
|
|
self.file_transfers_menu = popup_xml.get_widget('file_transfers_menu')
|
|
|
|
self.open_folder_menuitem = popup_xml.get_widget('open_folder_menuitem')
|
|
|
|
self.cancel_menuitem = popup_xml.get_widget('cancel_menuitem')
|
|
|
|
self.pause_menuitem = popup_xml.get_widget('pause_menuitem')
|
|
|
|
self.continue_menuitem = popup_xml.get_widget('continue_menuitem')
|
2005-09-07 19:17:33 +02:00
|
|
|
self.continue_menuitem.hide()
|
|
|
|
self.continue_menuitem.set_no_show_all(True)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.remove_menuitem = popup_xml.get_widget('remove_menuitem')
|
|
|
|
popup_xml.signal_autoconnect(self)
|
|
|
|
|
2005-08-23 23:50:18 +02:00
|
|
|
def find_transfer_by_jid(self, account, jid):
|
|
|
|
''' find all transfers with peer 'jid' that belong to 'account' '''
|
|
|
|
active_transfers = [[],[]] # ['senders', 'receivers']
|
|
|
|
|
|
|
|
# 'account' is the sender
|
|
|
|
for file_props in self.files_props['s'].values():
|
|
|
|
if file_props['tt_account'] == account:
|
2005-08-26 02:52:44 +02:00
|
|
|
receiver_jid = unicode(file_props['receiver']).split('/')[0]
|
2005-08-23 23:50:18 +02:00
|
|
|
if jid == receiver_jid:
|
|
|
|
if not self.is_transfer_stoped(file_props):
|
|
|
|
active_transfers[0].append(file_props)
|
|
|
|
|
|
|
|
# 'account' is the recipient
|
|
|
|
for file_props in self.files_props['r'].values():
|
|
|
|
if file_props['tt_account'] == account:
|
2005-08-26 02:52:44 +02:00
|
|
|
sender_jid = unicode(file_props['sender']).split('/')[0]
|
2005-08-23 23:50:18 +02:00
|
|
|
if jid == sender_jid:
|
|
|
|
if not self.is_transfer_stoped(file_props):
|
|
|
|
active_transfers[1].append(file_props)
|
|
|
|
return active_transfers
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def show_completed(self, jid, file_props):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' show a dialog saying that file (file_props) has been transferred'''
|
2005-08-15 01:52:12 +02:00
|
|
|
self.window.present()
|
|
|
|
self.window.window.focus()
|
2006-04-02 18:11:21 +02:00
|
|
|
|
|
|
|
def on_open(widget, file_props):
|
|
|
|
self.dialog.destroy()
|
|
|
|
if not file_props.has_key('file-name'):
|
|
|
|
return
|
|
|
|
(path, file) = os.path.split(file_props['file-name'])
|
|
|
|
if os.path.exists(path) and os.path.isdir(path):
|
|
|
|
helpers.launch_file_manager(path)
|
|
|
|
self.tree.get_selection().unselect_all()
|
|
|
|
|
2005-08-23 23:50:18 +02:00
|
|
|
if file_props['type'] == 'r':
|
2005-08-25 13:12:37 +02:00
|
|
|
# file path is used below in 'Save in'
|
2005-08-23 23:50:18 +02:00
|
|
|
(file_path, file_name) = os.path.split(file_props['file-name'])
|
|
|
|
else:
|
|
|
|
file_name = file_props['name']
|
2005-08-15 01:52:12 +02:00
|
|
|
sectext = '\t' + _('Filename: %s') % \
|
2005-08-23 23:50:18 +02:00
|
|
|
gtkgui_helpers.escape_for_pango_markup(file_name)
|
2005-08-15 01:52:12 +02:00
|
|
|
sectext += '\n\t' + _('Size: %s') % \
|
|
|
|
helpers.convert_bytes(file_props['size'])
|
2005-08-17 16:34:42 +02:00
|
|
|
if file_props['type'] == 'r':
|
2005-08-26 02:52:44 +02:00
|
|
|
jid = unicode(file_props['sender']).split('/')[0]
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
sender_name = gajim.contacts.get_first_contact_from_jid(
|
2006-01-10 19:30:57 +01:00
|
|
|
file_props['tt_account'], jid).get_shown_name()
|
2005-08-17 17:35:36 +02:00
|
|
|
sender = gtkgui_helpers.escape_for_pango_markup(sender_name)
|
2005-08-17 16:34:42 +02:00
|
|
|
else:
|
2005-09-13 23:36:23 +02:00
|
|
|
#You is a reply of who sent a file
|
2005-08-23 14:52:16 +02:00
|
|
|
sender = _('You')
|
2005-08-17 16:34:42 +02:00
|
|
|
sectext += '\n\t' +_('Sender: %s') % sender
|
|
|
|
sectext += '\n\t' +_('Recipient: ')
|
|
|
|
if file_props['type'] == 's':
|
2005-08-26 02:52:44 +02:00
|
|
|
jid = unicode(file_props['receiver']).split('/')[0]
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
receiver_name = gajim.contacts.get_first_contact_from_jid(
|
2006-01-10 19:30:57 +01:00
|
|
|
file_props['tt_account'], jid).get_shown_name()
|
2005-08-17 17:35:36 +02:00
|
|
|
recipient = gtkgui_helpers.escape_for_pango_markup(receiver_name)
|
2005-08-17 16:34:42 +02:00
|
|
|
else:
|
2005-08-24 14:47:09 +02:00
|
|
|
#You is a reply of who received a file
|
2005-09-13 23:36:23 +02:00
|
|
|
recipient = _('You')
|
2005-08-17 16:34:42 +02:00
|
|
|
sectext += recipient
|
2005-08-15 01:52:12 +02:00
|
|
|
if file_props['type'] == 'r':
|
|
|
|
sectext += '\n\t' +_('Saved in: %s') % \
|
2005-08-25 13:12:37 +02:00
|
|
|
gtkgui_helpers.escape_for_pango_markup(file_path)
|
2006-04-02 18:11:21 +02:00
|
|
|
self.dialog = dialogs.HigDialog(None, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE,
|
2005-09-10 14:16:08 +02:00
|
|
|
_('File transfer completed'), sectext)
|
2005-09-13 22:09:19 +02:00
|
|
|
if file_props['type'] == 'r':
|
2006-04-02 18:11:21 +02:00
|
|
|
button = gtk.Button(_('_Open Containing Folder'))
|
|
|
|
button.connect('clicked', on_open, file_props)
|
|
|
|
self.dialog.action_area.pack_start(button)
|
|
|
|
ok_button = self.dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
|
|
|
|
def on_ok(widget):
|
|
|
|
self.dialog.destroy()
|
|
|
|
ok_button.connect('clicked', on_ok)
|
|
|
|
self.dialog.show_all()
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def show_request_error(self, file_props):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' show error dialog to the recipient saying that transfer
|
|
|
|
has been canceled'''
|
2005-08-15 01:52:12 +02:00
|
|
|
self.window.present()
|
|
|
|
self.window.window.focus()
|
|
|
|
dialogs.InformationDialog(_('File transfer canceled'), _('Connection with peer cannot be established.'))
|
|
|
|
self.tree.get_selection().unselect_all()
|
2006-04-02 18:11:21 +02:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def show_send_error(self, file_props):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' show error dialog to the sender saying that transfer
|
|
|
|
has been canceled'''
|
2005-08-15 01:52:12 +02:00
|
|
|
self.window.present()
|
|
|
|
self.window.window.focus()
|
|
|
|
dialogs.InformationDialog(_('File transfer canceled'),
|
|
|
|
_('Connection with peer cannot be established.'))
|
|
|
|
self.tree.get_selection().unselect_all()
|
2006-04-02 18:11:21 +02:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def show_stopped(self, jid, file_props):
|
|
|
|
self.window.present()
|
|
|
|
self.window.window.focus()
|
2005-08-23 23:50:18 +02:00
|
|
|
if file_props['type'] == 'r':
|
2005-08-25 13:12:37 +02:00
|
|
|
file_name = os.path.basename(file_props['file-name'])
|
2005-08-23 23:50:18 +02:00
|
|
|
else:
|
|
|
|
file_name = file_props['name']
|
2005-08-15 01:52:12 +02:00
|
|
|
sectext = '\t' + _('Filename: %s') % \
|
2005-08-23 23:50:18 +02:00
|
|
|
gtkgui_helpers.escape_for_pango_markup(file_name)
|
2005-08-15 01:52:12 +02:00
|
|
|
sectext += '\n\t' + _('Sender: %s') % \
|
|
|
|
gtkgui_helpers.escape_for_pango_markup(jid)
|
|
|
|
dialogs.ErrorDialog(_('File transfer stopped by the contact of the other side'), \
|
2006-04-02 18:11:21 +02:00
|
|
|
sectext)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.tree.get_selection().unselect_all()
|
2006-04-02 18:11:21 +02:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def show_file_send_request(self, account, contact):
|
2005-08-23 15:22:14 +02:00
|
|
|
last_send_dir = gajim.config.get('last_send_dir')
|
2005-08-15 01:52:12 +02:00
|
|
|
dialog = gtk.FileChooserDialog(title=_('Choose File to Send...'),
|
|
|
|
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
|
|
|
|
butt = dialog.add_button(_('Send'), gtk.RESPONSE_OK)
|
|
|
|
butt.set_use_stock(True)
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
2005-08-23 16:00:28 +02:00
|
|
|
dialog.set_select_multiple(True) # we can select many files to send
|
2005-08-23 15:22:14 +02:00
|
|
|
if last_send_dir and os.path.isdir(last_send_dir):
|
|
|
|
dialog.set_current_folder(last_send_dir)
|
2005-08-23 15:04:07 +02:00
|
|
|
else:
|
2006-03-15 03:09:57 +01:00
|
|
|
dialog.set_current_folder(helpers.get_documents_path())
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = {}
|
2005-10-07 14:00:33 +02:00
|
|
|
while True:
|
|
|
|
response = dialog.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
file_dir = None
|
|
|
|
files_path_list = dialog.get_filenames()
|
2006-01-18 20:50:16 +01:00
|
|
|
files_path_list = gtkgui_helpers.decode_filechooser_file_paths(
|
|
|
|
files_path_list)
|
2005-10-07 14:00:33 +02:00
|
|
|
for file_path in files_path_list:
|
|
|
|
if self.send_file(account, contact, file_path) and file_dir is None:
|
|
|
|
file_dir = os.path.dirname(file_path)
|
|
|
|
if file_dir:
|
|
|
|
gajim.config.set('last_send_dir', file_dir)
|
|
|
|
dialog.destroy()
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
dialog.destroy()
|
|
|
|
break
|
2006-04-02 18:11:21 +02:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def send_file(self, account, contact, file_path):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' start the real transfer(upload) of the file '''
|
2005-11-01 21:01:14 +01:00
|
|
|
if gtkgui_helpers.file_is_locked(file_path):
|
|
|
|
pritext = _('Gajim cannot access this file')
|
|
|
|
sextext = _('This file is being used by another process.')
|
2006-04-02 18:11:21 +02:00
|
|
|
dialogs.ErrorDialog(pritext, sextext)
|
2005-11-01 21:01:14 +01:00
|
|
|
return
|
2006-04-02 18:11:21 +02:00
|
|
|
|
2005-11-01 21:01:14 +01:00
|
|
|
if isinstance(contact, str):
|
2005-08-24 01:41:23 +02:00
|
|
|
if contact.find('/') == -1:
|
|
|
|
return
|
2005-11-01 21:01:14 +01:00
|
|
|
(jid, resource) = contact.split('/', 1)
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
contact = gajim.contacts.create_contact(jid = jid,
|
|
|
|
resource = resource)
|
2005-08-15 01:52:12 +02:00
|
|
|
(file_dir, file_name) = os.path.split(file_path)
|
|
|
|
file_props = self.get_send_file_props(account, contact,
|
|
|
|
file_path, file_name)
|
2005-10-07 14:00:33 +02:00
|
|
|
if file_props is None:
|
|
|
|
return False
|
2005-08-15 01:52:12 +02:00
|
|
|
self.add_transfer(account, contact, file_props)
|
|
|
|
gajim.connections[account].send_file_request(file_props)
|
2005-10-07 14:00:33 +02:00
|
|
|
return True
|
2006-04-02 18:11:21 +02:00
|
|
|
|
Merged revisions 5017-5020,5022-5029 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r5017 | asterix | 2006-01-06 01:55:51 -0700 (Fri, 06 Jan 2006) | 2 lines
use escape for pango markup
........
r5018 | asterix | 2006-01-06 02:21:39 -0700 (Fri, 06 Jan 2006) | 2 lines
missing new contacts function
........
r5019 | asterix | 2006-01-06 11:03:07 -0700 (Fri, 06 Jan 2006) | 2 lines
handle the click on toggle_gpg_encryption menuitem
........
r5020 | asterix | 2006-01-06 11:14:14 -0700 (Fri, 06 Jan 2006) | 2 lines
use the saved size even if a chat window is already opened
........
r5022 | asterix | 2006-01-07 03:43:47 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now resume filetransfert
........
r5023 | asterix | 2006-01-07 03:56:31 -0700 (Sat, 07 Jan 2006) | 2 lines
[Knuckles] Google E-Mail Notification
........
r5024 | asterix | 2006-01-07 04:02:16 -0700 (Sat, 07 Jan 2006) | 2 lines
better string
........
r5025 | asterix | 2006-01-07 04:14:32 -0700 (Sat, 07 Jan 2006) | 2 lines
fix a TB
........
r5026 | asterix | 2006-01-07 05:36:55 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now drag a file on a contact in the roster to send him a file
........
r5027 | asterix | 2006-01-07 06:26:28 -0700 (Sat, 07 Jan 2006) | 2 lines
contact.groups is always a list, even if emtpy
........
r5028 | asterix | 2006-01-07 06:54:30 -0700 (Sat, 07 Jan 2006) | 2 lines
make all buttons insensitive on a category row in disco
........
r5029 | asterix | 2006-01-07 07:19:25 -0700 (Sat, 07 Jan 2006) | 2 lines
auto open groupchat configuration window when we create a new room
........
2006-01-07 18:25:35 +01:00
|
|
|
def confirm_overwrite_cb(self, dialog, file_props):
|
|
|
|
file_path = dialog.get_filename()
|
2006-01-18 20:50:16 +01:00
|
|
|
file_path = gtkgui_helpers.decode_filechooser_file_paths((file_path,))[0]
|
Merged revisions 5017-5020,5022-5029 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r5017 | asterix | 2006-01-06 01:55:51 -0700 (Fri, 06 Jan 2006) | 2 lines
use escape for pango markup
........
r5018 | asterix | 2006-01-06 02:21:39 -0700 (Fri, 06 Jan 2006) | 2 lines
missing new contacts function
........
r5019 | asterix | 2006-01-06 11:03:07 -0700 (Fri, 06 Jan 2006) | 2 lines
handle the click on toggle_gpg_encryption menuitem
........
r5020 | asterix | 2006-01-06 11:14:14 -0700 (Fri, 06 Jan 2006) | 2 lines
use the saved size even if a chat window is already opened
........
r5022 | asterix | 2006-01-07 03:43:47 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now resume filetransfert
........
r5023 | asterix | 2006-01-07 03:56:31 -0700 (Sat, 07 Jan 2006) | 2 lines
[Knuckles] Google E-Mail Notification
........
r5024 | asterix | 2006-01-07 04:02:16 -0700 (Sat, 07 Jan 2006) | 2 lines
better string
........
r5025 | asterix | 2006-01-07 04:14:32 -0700 (Sat, 07 Jan 2006) | 2 lines
fix a TB
........
r5026 | asterix | 2006-01-07 05:36:55 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now drag a file on a contact in the roster to send him a file
........
r5027 | asterix | 2006-01-07 06:26:28 -0700 (Sat, 07 Jan 2006) | 2 lines
contact.groups is always a list, even if emtpy
........
r5028 | asterix | 2006-01-07 06:54:30 -0700 (Sat, 07 Jan 2006) | 2 lines
make all buttons insensitive on a category row in disco
........
r5029 | asterix | 2006-01-07 07:19:25 -0700 (Sat, 07 Jan 2006) | 2 lines
auto open groupchat configuration window when we create a new room
........
2006-01-07 18:25:35 +01:00
|
|
|
if os.path.exists(file_path):
|
|
|
|
stat = os.stat(file_path)
|
|
|
|
dl_size = stat.st_size
|
|
|
|
file_size = file_props['size']
|
|
|
|
dl_finished = dl_size >= file_size
|
|
|
|
dialog = dialogs.FTOverwriteConfirmationDialog(
|
|
|
|
_('This file already exists'), _('What do you want to do?'),
|
|
|
|
not dl_finished)
|
|
|
|
response = dialog.get_response()
|
|
|
|
if response == gtk.RESPONSE_CANCEL:
|
|
|
|
return gtk.FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN
|
|
|
|
elif response == 100:
|
|
|
|
file_props['offset'] = dl_size
|
|
|
|
return gtk.FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def show_file_request(self, account, contact, file_props):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' show dialog asking for comfirmation and store location of new
|
|
|
|
file requested by a contact'''
|
2005-08-15 01:52:12 +02:00
|
|
|
if file_props is None or not file_props.has_key('name'):
|
|
|
|
return
|
2005-11-23 23:33:58 +01:00
|
|
|
sec_text = '\t' + _('File: %s') % file_props['name']
|
2005-08-15 01:52:12 +02:00
|
|
|
if file_props.has_key('size'):
|
|
|
|
sec_text += '\n\t' + _('Size: %s') % \
|
|
|
|
helpers.convert_bytes(file_props['size'])
|
|
|
|
if file_props.has_key('mime-type'):
|
2005-11-23 23:33:58 +01:00
|
|
|
sec_text += '\n\t' + _('Type: %s') % file_props['mime-type']
|
2005-08-15 01:52:12 +02:00
|
|
|
if file_props.has_key('desc'):
|
2005-11-23 23:33:58 +01:00
|
|
|
sec_text += '\n\t' + _('Description: %s') % file_props['desc']
|
2005-08-15 01:52:12 +02:00
|
|
|
prim_text = _('%s wants to send you a file:') % contact.jid
|
2006-04-02 18:11:21 +02:00
|
|
|
def on_response_ok(widet, account, contact, file_props):
|
|
|
|
self.dialog.destroy()
|
2005-08-15 01:52:12 +02:00
|
|
|
dialog = gtk.FileChooserDialog(title=_('Save File as...'),
|
|
|
|
action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
|
|
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
|
|
|
|
dialog.set_current_name(file_props['name'])
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
2005-09-04 20:21:54 +02:00
|
|
|
gtk28 = False
|
|
|
|
if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0):
|
|
|
|
dialog.props.do_overwrite_confirmation = True
|
Merged revisions 5017-5020,5022-5029 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r5017 | asterix | 2006-01-06 01:55:51 -0700 (Fri, 06 Jan 2006) | 2 lines
use escape for pango markup
........
r5018 | asterix | 2006-01-06 02:21:39 -0700 (Fri, 06 Jan 2006) | 2 lines
missing new contacts function
........
r5019 | asterix | 2006-01-06 11:03:07 -0700 (Fri, 06 Jan 2006) | 2 lines
handle the click on toggle_gpg_encryption menuitem
........
r5020 | asterix | 2006-01-06 11:14:14 -0700 (Fri, 06 Jan 2006) | 2 lines
use the saved size even if a chat window is already opened
........
r5022 | asterix | 2006-01-07 03:43:47 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now resume filetransfert
........
r5023 | asterix | 2006-01-07 03:56:31 -0700 (Sat, 07 Jan 2006) | 2 lines
[Knuckles] Google E-Mail Notification
........
r5024 | asterix | 2006-01-07 04:02:16 -0700 (Sat, 07 Jan 2006) | 2 lines
better string
........
r5025 | asterix | 2006-01-07 04:14:32 -0700 (Sat, 07 Jan 2006) | 2 lines
fix a TB
........
r5026 | asterix | 2006-01-07 05:36:55 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now drag a file on a contact in the roster to send him a file
........
r5027 | asterix | 2006-01-07 06:26:28 -0700 (Sat, 07 Jan 2006) | 2 lines
contact.groups is always a list, even if emtpy
........
r5028 | asterix | 2006-01-07 06:54:30 -0700 (Sat, 07 Jan 2006) | 2 lines
make all buttons insensitive on a category row in disco
........
r5029 | asterix | 2006-01-07 07:19:25 -0700 (Sat, 07 Jan 2006) | 2 lines
auto open groupchat configuration window when we create a new room
........
2006-01-07 18:25:35 +01:00
|
|
|
dialog.connect('confirm-overwrite', self.confirm_overwrite_cb,
|
|
|
|
file_props)
|
2005-09-04 20:21:54 +02:00
|
|
|
gtk28 = True
|
2006-04-02 18:11:21 +02:00
|
|
|
last_save_dir = gajim.config.get('last_save_dir')
|
2005-08-23 15:22:14 +02:00
|
|
|
if last_save_dir and os.path.isdir(last_save_dir):
|
|
|
|
dialog.set_current_folder(last_save_dir)
|
2005-08-23 15:04:07 +02:00
|
|
|
else:
|
2006-03-15 03:09:57 +01:00
|
|
|
dialog.set_current_folder(helpers.get_desktop_path())
|
2005-08-15 01:52:12 +02:00
|
|
|
while True:
|
|
|
|
response = dialog.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
file_path = dialog.get_filename()
|
2006-01-18 20:50:16 +01:00
|
|
|
file_path = gtkgui_helpers.decode_filechooser_file_paths(
|
|
|
|
(file_path,))[0]
|
2005-09-04 20:21:54 +02:00
|
|
|
if not gtk28 and os.path.exists(file_path):
|
2005-08-15 01:52:12 +02:00
|
|
|
primtext = _('This file already exists')
|
|
|
|
sectext = _('Would you like to overwrite it?')
|
|
|
|
dialog2 = dialogs.ConfirmationDialog(primtext, sectext)
|
|
|
|
if dialog2.get_response() != gtk.RESPONSE_OK:
|
|
|
|
continue
|
2005-08-23 16:00:28 +02:00
|
|
|
file_dir = os.path.dirname(file_path)
|
2005-08-15 01:52:12 +02:00
|
|
|
if file_dir:
|
2005-08-23 15:22:14 +02:00
|
|
|
gajim.config.set('last_save_dir', file_dir)
|
2005-09-01 15:11:22 +02:00
|
|
|
file_props['file-name'] = file_path
|
2005-08-15 01:52:12 +02:00
|
|
|
self.add_transfer(account, contact, file_props)
|
|
|
|
gajim.connections[account].send_file_approval(file_props)
|
|
|
|
else:
|
|
|
|
gajim.connections[account].send_file_rejection(file_props)
|
|
|
|
dialog.destroy()
|
|
|
|
break
|
2006-04-02 18:11:21 +02:00
|
|
|
|
|
|
|
def on_response_cancel(widget, account, file_props):
|
|
|
|
self.dialog.destroy()
|
2005-08-15 01:52:12 +02:00
|
|
|
gajim.connections[account].send_file_rejection(file_props)
|
2006-04-02 18:11:21 +02:00
|
|
|
|
|
|
|
self.dialog = dialogs.ConfirmationDialog(prim_text, sec_text,
|
|
|
|
on_response_ok = (on_response_ok, account, contact, file_props),
|
|
|
|
on_response_cancel = (on_response_cancel, account, file_props))
|
|
|
|
self.dialog.run()
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def set_images(self):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' create pixbufs for status images in transfer rows'''
|
2005-08-15 01:52:12 +02:00
|
|
|
self.images = {}
|
|
|
|
self.images['upload'] = self.window.render_icon(gtk.STOCK_GO_UP,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.images['download'] = self.window.render_icon(gtk.STOCK_GO_DOWN,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.images['stop'] = self.window.render_icon(gtk.STOCK_STOP,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.images['waiting'] = self.window.render_icon(gtk.STOCK_REFRESH,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.images['pause'] = self.window.render_icon(gtk.STOCK_MEDIA_PAUSE,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.images['continue'] = self.window.render_icon(gtk.STOCK_MEDIA_PLAY,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.images['ok'] = self.window.render_icon(gtk.STOCK_APPLY,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
|
|
|
|
def set_status(self, typ, sid, status):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' change the status of a transfer to state 'status' '''
|
2005-08-15 01:52:12 +02:00
|
|
|
iter = self.get_iter_by_sid(typ, sid)
|
|
|
|
if iter is None:
|
|
|
|
return
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[iter][C_SID].decode('utf-8')
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
|
|
|
if status == 'stop':
|
|
|
|
file_props['stopped'] = True
|
|
|
|
elif status == 'ok':
|
|
|
|
file_props['completed'] = True
|
2005-09-09 00:12:14 +02:00
|
|
|
self.model.set(iter, C_IMAGE, self.images[status])
|
|
|
|
|
|
|
|
def _format_percent(self, percent):
|
2005-09-08 22:05:28 +02:00
|
|
|
''' add extra spaces from both sides of the percent, so that
|
|
|
|
progress string has always a fixed size'''
|
|
|
|
_str = ' '
|
|
|
|
if percent != 100.:
|
|
|
|
_str += ' '
|
|
|
|
if percent < 10:
|
|
|
|
_str += ' '
|
|
|
|
_str += unicode(percent) + '% \n'
|
|
|
|
return _str
|
|
|
|
|
2005-09-09 00:12:14 +02:00
|
|
|
def _format_time(self, _time):
|
|
|
|
times = { 'hours': 0, 'minutes': 0, 'seconds': 0 }
|
|
|
|
_time = int(_time)
|
|
|
|
times['seconds'] = _time % 60
|
|
|
|
if _time >= 60:
|
|
|
|
_time /= 60
|
|
|
|
times['minutes'] = _time % 60
|
|
|
|
if _time >= 60:
|
|
|
|
times['hours'] = _time / 60
|
|
|
|
|
|
|
|
#Print remaining time in format 00:00:00
|
2005-10-07 14:00:33 +02:00
|
|
|
#You can change the places of (hours), (minutes), (seconds) -
|
2005-09-09 00:12:14 +02:00
|
|
|
#they are not translatable.
|
|
|
|
return _('%(hours)02.d:%(minutes)02.d:%(seconds)02.d') % times
|
|
|
|
|
|
|
|
def _get_eta_and_speed(self, full_size, transfered_size, elapsed_time):
|
|
|
|
if elapsed_time == 0:
|
|
|
|
return 0., 0.
|
|
|
|
speed = round(float(transfered_size) / elapsed_time)
|
|
|
|
if speed == 0.:
|
|
|
|
return 0., 0.
|
|
|
|
remaining_size = full_size - transfered_size
|
|
|
|
eta = remaining_size / speed
|
|
|
|
return eta, speed
|
|
|
|
|
2005-10-07 14:00:33 +02:00
|
|
|
def _remove_transfer(self, iter, sid, file_props):
|
|
|
|
self.model.remove(iter)
|
|
|
|
if file_props.has_key('tt_account'):
|
|
|
|
# file transfer is set
|
|
|
|
account = file_props['tt_account']
|
|
|
|
if gajim.connections.has_key(account):
|
|
|
|
# there is a connection to the account
|
|
|
|
gajim.connections[account].remove_transfer(file_props)
|
2006-03-02 12:14:45 +01:00
|
|
|
if file_props['type'] == 'r': # we receive a file
|
|
|
|
other = file_props['sender']
|
|
|
|
else: # we send a file
|
|
|
|
other = file_props['receiver']
|
|
|
|
if isinstance(other, unicode):
|
|
|
|
jid = gajim.get_jid_without_resource(other)
|
|
|
|
else: # It's a Contact instance
|
|
|
|
jid = other.jid
|
|
|
|
if gajim.awaiting_events[account].has_key(jid):
|
|
|
|
for event in gajim.awaiting_events[account][jid]:
|
|
|
|
if event[0] in ('file-error', 'file-completed',
|
|
|
|
'file-request-error', 'file-send-error', 'file-stopped') and \
|
|
|
|
event[1]['sid'] == file_props['sid']:
|
|
|
|
gajim.interface.remove_event(account, jid, event)
|
2005-10-07 14:00:33 +02:00
|
|
|
del(self.files_props[sid[0]][sid[1:]])
|
|
|
|
del(file_props)
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def set_progress(self, typ, sid, transfered_size, iter = None):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' change the progress of a transfer with new transfered size'''
|
2005-08-15 01:52:12 +02:00
|
|
|
if not self.files_props[typ].has_key(sid):
|
|
|
|
return
|
|
|
|
file_props = self.files_props[typ][sid]
|
|
|
|
full_size = int(file_props['size'])
|
|
|
|
if full_size == 0:
|
|
|
|
percent = 0
|
|
|
|
else:
|
|
|
|
percent = round(float(transfered_size) / full_size * 100)
|
|
|
|
if iter is None:
|
|
|
|
iter = self.get_iter_by_sid(typ, sid)
|
|
|
|
if iter is not None:
|
2005-09-09 00:12:14 +02:00
|
|
|
text = self._format_percent(percent)
|
2005-08-15 01:52:12 +02:00
|
|
|
if transfered_size == 0:
|
|
|
|
text += '0'
|
|
|
|
else:
|
|
|
|
text += helpers.convert_bytes(transfered_size)
|
|
|
|
text += '/' + helpers.convert_bytes(full_size)
|
2005-09-09 00:12:14 +02:00
|
|
|
# Kb/s
|
|
|
|
|
|
|
|
# remaining time
|
2006-01-21 22:26:29 +01:00
|
|
|
if file_props.has_key('offset') and file_props['offset']:
|
|
|
|
transfered_size -= file_props['offset']
|
|
|
|
full_size -= file_props['offset']
|
2005-09-09 00:12:14 +02:00
|
|
|
eta, speed = self._get_eta_and_speed(full_size, transfered_size,
|
|
|
|
file_props['elapsed-time'])
|
|
|
|
|
2005-09-09 00:27:00 +02:00
|
|
|
self.model.set(iter, C_PROGRESS, text)
|
|
|
|
self.model.set(iter, C_PERCENT, int(percent))
|
|
|
|
text = self._format_time(eta)
|
2005-10-07 14:00:33 +02:00
|
|
|
text += '\n'
|
2005-09-09 00:12:14 +02:00
|
|
|
#This should make the string Kb/s,
|
|
|
|
#where 'Kb' part is taken from %s.
|
2005-12-02 15:08:40 +01:00
|
|
|
#Only the 's' after / (which means second) should be translated.
|
2005-12-05 16:15:46 +01:00
|
|
|
text += _('(%(filesize_unit)s/s)') % {'filesize_unit':
|
2005-12-02 15:08:40 +01:00
|
|
|
helpers.convert_bytes(speed)}
|
2005-09-09 00:27:00 +02:00
|
|
|
self.model.set(iter, C_TIME, text)
|
2005-09-09 00:12:14 +02:00
|
|
|
|
2005-09-09 00:27:00 +02:00
|
|
|
# try to guess what should be the status image
|
2005-08-15 01:52:12 +02:00
|
|
|
if file_props['type'] == 'r':
|
|
|
|
status = 'download'
|
|
|
|
else:
|
|
|
|
status = 'upload'
|
|
|
|
if file_props.has_key('paused') and file_props['paused'] == True:
|
|
|
|
status = 'pause'
|
|
|
|
elif file_props.has_key('stalled') and file_props['stalled'] == True:
|
|
|
|
status = 'waiting'
|
|
|
|
if file_props.has_key('connected') and file_props['connected'] == False:
|
|
|
|
status = 'stop'
|
|
|
|
self.model.set(iter, 0, self.images[status])
|
|
|
|
if percent == 100:
|
|
|
|
self.set_status(typ, sid, 'ok')
|
|
|
|
|
|
|
|
def get_iter_by_sid(self, typ, sid):
|
|
|
|
'''returns iter to the row, which holds file transfer, identified by the
|
|
|
|
session id'''
|
|
|
|
iter = self.model.get_iter_root()
|
|
|
|
while iter:
|
2005-09-09 00:12:14 +02:00
|
|
|
if typ + sid == self.model[iter][C_SID].decode('utf-8'):
|
2005-08-15 01:52:12 +02:00
|
|
|
return iter
|
|
|
|
iter = self.model.iter_next(iter)
|
|
|
|
|
|
|
|
def get_send_file_props(self, account, contact, file_path, file_name):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' create new file_props dict and set initial file transfer
|
|
|
|
properties in it'''
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = {'file-name' : file_path, 'name' : file_name,
|
|
|
|
'type' : 's'}
|
2005-10-07 14:00:33 +02:00
|
|
|
if os.path.isfile(file_path):
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
stat = os.stat(file_path)
|
2005-10-07 14:00:33 +02:00
|
|
|
else:
|
2006-04-02 18:11:21 +02:00
|
|
|
dialogs.ErrorDialog(_('Invalid File'), _('File: ') + file_path)
|
2005-10-07 14:00:33 +02:00
|
|
|
return None
|
|
|
|
if stat[6] == 0:
|
|
|
|
dialogs.ErrorDialog(_('Invalid File'),
|
2006-04-02 18:11:21 +02:00
|
|
|
_('It is not possible to send empty files'))
|
2005-10-07 14:00:33 +02:00
|
|
|
return None
|
2005-09-09 00:12:14 +02:00
|
|
|
file_props['elapsed-time'] = 0
|
2005-08-26 02:52:44 +02:00
|
|
|
file_props['size'] = unicode(stat[6])
|
2006-03-20 22:24:10 +01:00
|
|
|
file_props['sid'] = helpers.get_random_string_16()
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props['completed'] = False
|
|
|
|
file_props['started'] = False
|
|
|
|
file_props['sender'] = account
|
|
|
|
file_props['receiver'] = contact
|
|
|
|
file_props['tt_account'] = account
|
|
|
|
return file_props
|
|
|
|
|
|
|
|
def add_transfer(self, account, contact, file_props):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' add new transfer to FT window and show the FT window '''
|
2005-08-15 01:52:12 +02:00
|
|
|
self.on_transfers_list_leave_notify_event(None)
|
|
|
|
if file_props is None:
|
|
|
|
return
|
2005-09-09 00:12:14 +02:00
|
|
|
file_props['elapsed-time'] = 0
|
2005-08-15 01:52:12 +02:00
|
|
|
self.files_props[file_props['type']][file_props['sid']] = file_props
|
|
|
|
iter = self.model.append()
|
|
|
|
text_labels = '<b>' + _('Name: ') + '</b>\n'
|
|
|
|
if file_props['type'] == 'r':
|
|
|
|
text_labels += '<b>' + _('Sender: ') + '</b>'
|
|
|
|
else:
|
|
|
|
text_labels += '<b>' + _('Recipient: ') + '</b>'
|
2005-08-23 23:50:18 +02:00
|
|
|
|
|
|
|
if file_props['type'] == 'r':
|
|
|
|
(file_path, file_name) = os.path.split(file_props['file-name'])
|
|
|
|
else:
|
|
|
|
file_name = file_props['name']
|
|
|
|
text_props = gtkgui_helpers.escape_for_pango_markup(file_name) + '\n'
|
2006-01-10 19:30:57 +01:00
|
|
|
text_props += gtkgui_helpers.escape_for_pango_markup(
|
|
|
|
contact.get_shown_name())
|
2005-11-13 20:31:47 +01:00
|
|
|
self.model.set(iter, 1, text_labels, 2, text_props, C_SID,
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props['type'] + file_props['sid'])
|
|
|
|
self.set_progress(file_props['type'], file_props['sid'], 0, iter)
|
|
|
|
if file_props.has_key('started') and file_props['started'] is False:
|
|
|
|
status = 'waiting'
|
|
|
|
elif file_props['type'] == 'r':
|
|
|
|
status = 'download'
|
|
|
|
else:
|
|
|
|
status = 'upload'
|
|
|
|
file_props['tt_account'] = account
|
|
|
|
self.set_status(file_props['type'], file_props['sid'], status)
|
2005-09-07 19:17:33 +02:00
|
|
|
self.set_cleanup_sensitivity()
|
2005-08-15 01:52:12 +02:00
|
|
|
self.window.show_all()
|
|
|
|
|
|
|
|
def on_transfers_list_motion_notify_event(self, widget, event):
|
|
|
|
pointer = self.tree.get_pointer()
|
|
|
|
orig = widget.window.get_origin()
|
|
|
|
props = widget.get_path_at_pos(int(event.x), int(event.y))
|
|
|
|
self.height_diff = pointer[1] - int(event.y)
|
|
|
|
if self.tooltip.timeout > 0:
|
|
|
|
if not props or self.tooltip.id != props[0]:
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
if props:
|
|
|
|
[row, col, x, y] = props
|
|
|
|
iter = None
|
|
|
|
try:
|
|
|
|
iter = self.model.get_iter(row)
|
|
|
|
except:
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
return
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[iter][C_SID].decode('utf-8')
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
|
|
|
if file_props is not None:
|
|
|
|
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
|
|
|
|
self.tooltip.id = row
|
|
|
|
self.tooltip.timeout = gobject.timeout_add(500,
|
|
|
|
self.show_tooltip, widget)
|
|
|
|
|
|
|
|
def on_transfers_list_leave_notify_event(self, widget = None, event = None):
|
|
|
|
if event is not None:
|
|
|
|
self.height_diff = int(event.y)
|
|
|
|
elif self.height_diff is 0:
|
|
|
|
return
|
|
|
|
pointer = self.tree.get_pointer()
|
|
|
|
props = self.tree.get_path_at_pos(pointer[0],
|
|
|
|
pointer[1] - self.height_diff)
|
|
|
|
if self.tooltip.timeout > 0:
|
|
|
|
if not props or self.tooltip.id == props[0]:
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
|
|
|
|
def on_transfers_list_row_activated(self, widget, path, col):
|
|
|
|
# try to open the containing folder
|
|
|
|
self.on_open_folder_menuitem_activate(widget)
|
|
|
|
|
|
|
|
def is_transfer_paused(self, file_props):
|
|
|
|
if file_props.has_key('stopped') and file_props['stopped']:
|
|
|
|
return False
|
|
|
|
if file_props.has_key('completed') and file_props['completed']:
|
|
|
|
return False
|
|
|
|
if not file_props.has_key('disconnect_cb'):
|
|
|
|
return False
|
|
|
|
return file_props['paused']
|
|
|
|
|
|
|
|
def is_transfer_active(self, file_props):
|
|
|
|
if file_props.has_key('stopped') and file_props['stopped']:
|
|
|
|
return False
|
|
|
|
if file_props.has_key('completed') and file_props['completed']:
|
|
|
|
return False
|
|
|
|
if not file_props.has_key('started') or not file_props['started']:
|
|
|
|
return False
|
|
|
|
if not file_props.has_key('paused'):
|
|
|
|
return True
|
|
|
|
return not file_props['paused']
|
|
|
|
|
|
|
|
def is_transfer_stoped(self, file_props):
|
|
|
|
if file_props.has_key('error') and file_props['error'] != 0:
|
|
|
|
return True
|
|
|
|
if file_props.has_key('completed') and file_props['completed']:
|
|
|
|
return True
|
2005-10-07 14:00:33 +02:00
|
|
|
if file_props.has_key('connected') and file_props['connected'] == False:
|
|
|
|
return True
|
|
|
|
if not file_props.has_key('stopped') or not file_props['stopped']:
|
2005-08-15 01:52:12 +02:00
|
|
|
return False
|
|
|
|
return True
|
2005-09-07 19:17:33 +02:00
|
|
|
|
|
|
|
def set_cleanup_sensitivity(self):
|
|
|
|
''' check if there are transfer rows and set cleanup_button
|
2005-10-07 14:00:33 +02:00
|
|
|
sensitive, or insensitive if model is empty'''
|
2005-09-07 19:17:33 +02:00
|
|
|
if len(self.model) == 0:
|
|
|
|
self.cleanup_button.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.cleanup_button.set_sensitive(True)
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def set_all_insensitive(self):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' make all buttons/menuitems insensitive '''
|
2005-08-15 01:52:12 +02:00
|
|
|
self.pause_button.set_sensitive(False)
|
|
|
|
self.pause_menuitem.set_sensitive(False)
|
|
|
|
self.continue_menuitem.set_sensitive(False)
|
|
|
|
self.remove_menuitem.set_sensitive(False)
|
|
|
|
self.cancel_button.set_sensitive(False)
|
|
|
|
self.cancel_menuitem.set_sensitive(False)
|
|
|
|
self.open_folder_menuitem.set_sensitive(False)
|
2005-09-07 19:17:33 +02:00
|
|
|
self.set_cleanup_sensitivity()
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
def set_buttons_sensitive(self, path, is_row_selected):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' make buttons/menuitems sensitive as appropriate to
|
|
|
|
the state of file transfer located at path 'path' '''
|
2005-08-15 01:52:12 +02:00
|
|
|
if path is None:
|
|
|
|
self.set_all_insensitive()
|
|
|
|
return
|
|
|
|
current_iter = self.model.get_iter(path)
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[current_iter][C_SID].decode('utf-8')
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
|
|
|
self.remove_menuitem.set_sensitive(is_row_selected)
|
|
|
|
self.open_folder_menuitem.set_sensitive(is_row_selected)
|
|
|
|
is_stopped = False
|
|
|
|
if self.is_transfer_stoped(file_props):
|
|
|
|
is_stopped = True
|
|
|
|
self.cancel_button.set_sensitive(not is_stopped)
|
|
|
|
self.cancel_menuitem.set_sensitive(not is_stopped)
|
|
|
|
if not is_row_selected:
|
|
|
|
# no selection, disable the buttons
|
|
|
|
self.set_all_insensitive()
|
|
|
|
elif not is_stopped:
|
|
|
|
if self.is_transfer_active(file_props):
|
|
|
|
# file transfer is active
|
|
|
|
self.toggle_pause_continue(True)
|
|
|
|
self.pause_button.set_sensitive(True)
|
|
|
|
elif self.is_transfer_paused(file_props):
|
|
|
|
# file transfer is paused
|
|
|
|
self.toggle_pause_continue(False)
|
|
|
|
self.pause_button.set_sensitive(True)
|
|
|
|
else:
|
|
|
|
self.pause_button.set_sensitive(False)
|
|
|
|
self.pause_menuitem.set_sensitive(False)
|
|
|
|
self.continue_menuitem.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.pause_button.set_sensitive(False)
|
|
|
|
self.pause_menuitem.set_sensitive(False)
|
|
|
|
self.continue_menuitem.set_sensitive(False)
|
|
|
|
return True
|
|
|
|
|
|
|
|
def selection_changed(self, args):
|
2005-08-17 18:28:32 +02:00
|
|
|
''' selection has changed - change the sensitivity of the
|
|
|
|
buttons/menuitems'''
|
2005-08-15 01:52:12 +02:00
|
|
|
selection = args
|
|
|
|
selected = selection.get_selected_rows()
|
|
|
|
if selected[1] != []:
|
|
|
|
selected_path = selected[1][0]
|
|
|
|
self.select_func(selected_path)
|
|
|
|
else:
|
|
|
|
self.set_all_insensitive()
|
|
|
|
|
|
|
|
def select_func(self, path):
|
|
|
|
is_selected = False
|
|
|
|
selected = self.tree.get_selection().get_selected_rows()
|
|
|
|
if selected[1] != []:
|
|
|
|
selected_path = selected[1][0]
|
|
|
|
if selected_path == path:
|
|
|
|
is_selected = True
|
|
|
|
self.set_buttons_sensitive(path, is_selected)
|
2005-09-07 19:17:33 +02:00
|
|
|
self.set_cleanup_sensitivity()
|
2005-08-15 01:52:12 +02:00
|
|
|
return True
|
|
|
|
|
2005-09-03 16:23:53 +02:00
|
|
|
def on_cleanup_button_clicked(self, widget):
|
|
|
|
i = len(self.model) - 1
|
|
|
|
while i >= 0:
|
|
|
|
iter = self.model.get_iter((i))
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[iter][C_SID].decode('utf-8')
|
2005-09-03 16:23:53 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
2005-10-07 14:00:33 +02:00
|
|
|
if self.is_transfer_stoped(file_props):
|
|
|
|
self._remove_transfer(iter, sid, file_props)
|
2005-09-03 16:23:53 +02:00
|
|
|
i -= 1
|
|
|
|
self.tree.get_selection().unselect_all()
|
2005-08-15 01:52:12 +02:00
|
|
|
self.set_all_insensitive()
|
|
|
|
|
|
|
|
def toggle_pause_continue(self, status):
|
|
|
|
if status:
|
|
|
|
label = _('Pause')
|
|
|
|
self.pause_button.set_label(label)
|
2005-09-03 16:23:53 +02:00
|
|
|
self.pause_button.set_image(gtk.image_new_from_stock(
|
|
|
|
gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU))
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
self.pause_menuitem.set_sensitive(True)
|
|
|
|
self.pause_menuitem.set_no_show_all(False)
|
|
|
|
self.continue_menuitem.hide()
|
|
|
|
self.continue_menuitem.set_no_show_all(True)
|
|
|
|
|
|
|
|
else:
|
|
|
|
label = _('_Continue')
|
|
|
|
self.pause_button.set_label(label)
|
2005-09-03 16:23:53 +02:00
|
|
|
self.pause_button.set_image(gtk.image_new_from_stock(
|
|
|
|
gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU))
|
2005-08-15 01:52:12 +02:00
|
|
|
self.pause_menuitem.hide()
|
|
|
|
self.pause_menuitem.set_no_show_all(True)
|
|
|
|
self.continue_menuitem.set_sensitive(True)
|
|
|
|
self.continue_menuitem.set_no_show_all(False)
|
|
|
|
|
|
|
|
def on_pause_restore_button_clicked(self, widget):
|
|
|
|
selected = self.tree.get_selection().get_selected()
|
|
|
|
if selected is None or selected[1] is None:
|
|
|
|
return
|
|
|
|
s_iter = selected[1]
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[s_iter][C_SID].decode('utf-8')
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
|
|
|
if self.is_transfer_paused(file_props):
|
2005-09-09 00:12:14 +02:00
|
|
|
file_props['last-time'] = time.time()
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props['paused'] = False
|
|
|
|
types = {'r' : 'download', 's' : 'upload'}
|
|
|
|
self.set_status(file_props['type'], file_props['sid'], types[sid[0]])
|
|
|
|
self.toggle_pause_continue(True)
|
2006-02-12 03:25:21 +01:00
|
|
|
file_props['continue_cb']()
|
2005-08-15 01:52:12 +02:00
|
|
|
elif self.is_transfer_active(file_props):
|
|
|
|
file_props['paused'] = True
|
|
|
|
self.set_status(file_props['type'], file_props['sid'], 'pause')
|
|
|
|
self.toggle_pause_continue(False)
|
|
|
|
|
|
|
|
def on_cancel_button_clicked(self, widget):
|
|
|
|
selected = self.tree.get_selection().get_selected()
|
|
|
|
if selected is None or selected[1] is None:
|
|
|
|
return
|
|
|
|
s_iter = selected[1]
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[s_iter][C_SID].decode('utf-8')
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
|
|
|
if not file_props.has_key('tt_account'):
|
|
|
|
return
|
|
|
|
account = file_props['tt_account']
|
|
|
|
if not gajim.connections.has_key(account):
|
|
|
|
return
|
|
|
|
gajim.connections[account].disconnect_transfer(file_props)
|
|
|
|
self.set_status(file_props['type'], file_props['sid'], 'stop')
|
|
|
|
|
|
|
|
def show_tooltip(self, widget):
|
|
|
|
if self.height_diff == 0:
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
return
|
|
|
|
pointer = self.tree.get_pointer()
|
|
|
|
props = self.tree.get_path_at_pos(pointer[0],
|
|
|
|
pointer[1] - self.height_diff)
|
2006-02-28 11:13:42 +01:00
|
|
|
# check if the current pointer is at the same path
|
|
|
|
# as it was before setting the timeout
|
2005-08-15 01:52:12 +02:00
|
|
|
if props and self.tooltip.id == props[0]:
|
|
|
|
iter = self.model.get_iter(props[0])
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[iter][C_SID].decode('utf-8')
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
2006-02-28 11:13:42 +01:00
|
|
|
# bounding rectangle of coordinates for the cell within the treeview
|
2005-08-15 01:52:12 +02:00
|
|
|
rect = self.tree.get_cell_area(props[0],props[1])
|
2006-02-28 11:13:42 +01:00
|
|
|
# position of the treeview on the screen
|
2005-08-15 01:52:12 +02:00
|
|
|
position = widget.window.get_origin()
|
2006-02-28 11:13:42 +01:00
|
|
|
self.tooltip.show_tooltip(file_props , rect.height,
|
|
|
|
position[1] + rect.y + self.height_diff)
|
2005-08-15 01:52:12 +02:00
|
|
|
else:
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
|
|
|
|
def on_notify_ft_complete_checkbox_toggled(self, widget):
|
|
|
|
gajim.config.set('notify_on_file_complete',
|
|
|
|
widget.get_active())
|
|
|
|
|
|
|
|
def on_file_transfers_dialog_delete_event(self, widget, event):
|
|
|
|
self.on_transfers_list_leave_notify_event(widget, None)
|
|
|
|
self.window.hide()
|
|
|
|
return True # do NOT destory window
|
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.hide()
|
|
|
|
|
|
|
|
def show_context_menu(self, event, iter):
|
|
|
|
# change the sensitive propery of the buttons and menuitems
|
|
|
|
path = None
|
|
|
|
if iter is not None:
|
|
|
|
path = self.model.get_path(iter)
|
|
|
|
self.set_buttons_sensitive(path, True)
|
|
|
|
|
2006-03-29 18:39:14 +02:00
|
|
|
event_button = gtkgui_helpers.get_possible_button_event(event)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.file_transfers_menu.popup(None, self.tree, None,
|
|
|
|
event_button, event.time)
|
|
|
|
self.file_transfers_menu.show_all()
|
|
|
|
|
|
|
|
def on_transfers_list_key_press_event(self, widget, event):
|
|
|
|
'''when a key is pressed in the treeviews'''
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
iter = None
|
|
|
|
try:
|
|
|
|
store, iter = self.tree.get_selection().get_selected()
|
|
|
|
except TypeError:
|
|
|
|
self.tree.get_selection().unselect_all()
|
|
|
|
|
|
|
|
if iter is not None:
|
|
|
|
path = self.model.get_path(iter)
|
|
|
|
self.tree.get_selection().select_path(path)
|
|
|
|
|
|
|
|
if event.keyval == gtk.keysyms.Menu:
|
|
|
|
self.show_context_menu(event, iter)
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def on_transfers_list_button_release_event(self, widget, event):
|
|
|
|
# hide tooltip, no matter the button is pressed
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
path = None
|
|
|
|
try:
|
|
|
|
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
|
|
|
|
int(event.y))
|
|
|
|
except TypeError:
|
|
|
|
self.tree.get_selection().unselect_all()
|
|
|
|
if path is None:
|
|
|
|
self.set_all_insensitive()
|
|
|
|
else:
|
|
|
|
self.select_func(path)
|
|
|
|
|
|
|
|
def on_transfers_list_button_press_event(self, widget, event):
|
|
|
|
# hide tooltip, no matter the button is pressed
|
|
|
|
self.tooltip.hide_tooltip()
|
|
|
|
path, iter = None, None
|
|
|
|
try:
|
|
|
|
path, column, x, y = self.tree.get_path_at_pos(int(event.x),
|
|
|
|
int(event.y))
|
|
|
|
except TypeError:
|
|
|
|
self.tree.get_selection().unselect_all()
|
|
|
|
if event.button == 3: # Right click
|
|
|
|
if path is not None:
|
|
|
|
self.tree.get_selection().select_path(path)
|
|
|
|
iter = self.model.get_iter(path)
|
|
|
|
self.show_context_menu(event, iter)
|
|
|
|
if path is not None:
|
|
|
|
return True
|
|
|
|
|
|
|
|
def on_open_folder_menuitem_activate(self, widget):
|
|
|
|
selected = self.tree.get_selection().get_selected()
|
|
|
|
if selected is None or selected[1] is None:
|
|
|
|
return
|
|
|
|
s_iter = selected[1]
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[s_iter][C_SID].decode('utf-8')
|
2005-08-15 01:52:12 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
|
|
|
if not file_props.has_key('file-name'):
|
|
|
|
return
|
|
|
|
(path, file) = os.path.split(file_props['file-name'])
|
|
|
|
if os.path.exists(path) and os.path.isdir(path):
|
|
|
|
helpers.launch_file_manager(path)
|
|
|
|
|
|
|
|
def on_cancel_menuitem_activate(self, widget):
|
|
|
|
self.on_cancel_button_clicked(widget)
|
|
|
|
|
|
|
|
def on_continue_menuitem_activate(self, widget):
|
|
|
|
self.on_pause_restore_button_clicked(widget)
|
|
|
|
|
|
|
|
def on_pause_menuitem_activate(self, widget):
|
|
|
|
self.on_pause_restore_button_clicked(widget)
|
|
|
|
|
|
|
|
def on_remove_menuitem_activate(self, widget):
|
2005-09-03 16:23:53 +02:00
|
|
|
selected = self.tree.get_selection().get_selected()
|
|
|
|
if selected is None or selected[1] is None:
|
|
|
|
return
|
|
|
|
s_iter = selected[1]
|
2005-09-09 00:12:14 +02:00
|
|
|
sid = self.model[s_iter][C_SID].decode('utf-8')
|
2005-09-03 16:23:53 +02:00
|
|
|
file_props = self.files_props[sid[0]][sid[1:]]
|
2005-10-07 14:00:33 +02:00
|
|
|
self._remove_transfer(s_iter, sid, file_props)
|
2005-09-03 16:23:53 +02:00
|
|
|
self.set_all_insensitive()
|
2005-08-15 14:45:19 +02:00
|
|
|
|
|
|
|
def on_file_transfers_window_key_press_event(self, widget, event):
|
|
|
|
if event.keyval == gtk.keysyms.Escape: # ESCAPE
|
|
|
|
self.window.hide()
|
|
|
|
|