added comments on some methods
This commit is contained in:
parent
98273d7aec
commit
5ed2e23097
|
@ -112,6 +112,7 @@ class FileTransfersWindow:
|
||||||
popup_xml.signal_autoconnect(self)
|
popup_xml.signal_autoconnect(self)
|
||||||
|
|
||||||
def show_completed(self, jid, file_props):
|
def show_completed(self, jid, file_props):
|
||||||
|
''' show a dialog saying that file (file_props) has been transferred'''
|
||||||
self.window.present()
|
self.window.present()
|
||||||
self.window.window.focus()
|
self.window.window.focus()
|
||||||
sectext = '\t' + _('Filename: %s') % \
|
sectext = '\t' + _('Filename: %s') % \
|
||||||
|
@ -166,12 +167,16 @@ class FileTransfersWindow:
|
||||||
self.tree.get_selection().unselect_all()
|
self.tree.get_selection().unselect_all()
|
||||||
|
|
||||||
def show_request_error(self, file_props):
|
def show_request_error(self, file_props):
|
||||||
|
''' show error dialog to the recipient saying that transfer
|
||||||
|
has been canceled'''
|
||||||
self.window.present()
|
self.window.present()
|
||||||
self.window.window.focus()
|
self.window.window.focus()
|
||||||
dialogs.InformationDialog(_('File transfer canceled'), _('Connection with peer cannot be established.'))
|
dialogs.InformationDialog(_('File transfer canceled'), _('Connection with peer cannot be established.'))
|
||||||
self.tree.get_selection().unselect_all()
|
self.tree.get_selection().unselect_all()
|
||||||
|
|
||||||
def show_send_error(self, file_props):
|
def show_send_error(self, file_props):
|
||||||
|
''' show error dialog to the sender saying that transfer
|
||||||
|
has been canceled'''
|
||||||
self.window.present()
|
self.window.present()
|
||||||
self.window.window.focus()
|
self.window.window.focus()
|
||||||
dialogs.InformationDialog(_('File transfer canceled'),
|
dialogs.InformationDialog(_('File transfer canceled'),
|
||||||
|
@ -214,6 +219,7 @@ _('Connection with peer cannot be established.'))
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
def send_file(self, account, contact, file_path):
|
def send_file(self, account, contact, file_path):
|
||||||
|
''' start the real transfer(upload) of the file '''
|
||||||
(file_dir, file_name) = os.path.split(file_path)
|
(file_dir, file_name) = os.path.split(file_path)
|
||||||
file_props = self.get_send_file_props(account, contact,
|
file_props = self.get_send_file_props(account, contact,
|
||||||
file_path, file_name)
|
file_path, file_name)
|
||||||
|
@ -221,6 +227,8 @@ _('Connection with peer cannot be established.'))
|
||||||
gajim.connections[account].send_file_request(file_props)
|
gajim.connections[account].send_file_request(file_props)
|
||||||
|
|
||||||
def show_file_request(self, account, contact, file_props):
|
def show_file_request(self, account, contact, file_props):
|
||||||
|
''' show dialog asking for comfirmation and store location of new
|
||||||
|
file requested by a contact'''
|
||||||
if file_props is None or not file_props.has_key('name'):
|
if file_props is None or not file_props.has_key('name'):
|
||||||
return
|
return
|
||||||
sec_text = '\t' + _('File: %s') % \
|
sec_text = '\t' + _('File: %s') % \
|
||||||
|
@ -270,6 +278,7 @@ _('Connection with peer cannot be established.'))
|
||||||
gajim.connections[account].send_file_rejection(file_props)
|
gajim.connections[account].send_file_rejection(file_props)
|
||||||
|
|
||||||
def set_images(self):
|
def set_images(self):
|
||||||
|
''' create pixbufs for status images in transfer rows'''
|
||||||
self.images = {}
|
self.images = {}
|
||||||
self.images['upload'] = self.window.render_icon(gtk.STOCK_GO_UP,
|
self.images['upload'] = self.window.render_icon(gtk.STOCK_GO_UP,
|
||||||
gtk.ICON_SIZE_MENU)
|
gtk.ICON_SIZE_MENU)
|
||||||
|
@ -287,6 +296,7 @@ _('Connection with peer cannot be established.'))
|
||||||
gtk.ICON_SIZE_MENU)
|
gtk.ICON_SIZE_MENU)
|
||||||
|
|
||||||
def set_status(self, typ, sid, status):
|
def set_status(self, typ, sid, status):
|
||||||
|
''' change the status of a transfer to state 'status' '''
|
||||||
iter = self.get_iter_by_sid(typ, sid)
|
iter = self.get_iter_by_sid(typ, sid)
|
||||||
if iter is None:
|
if iter is None:
|
||||||
return
|
return
|
||||||
|
@ -299,6 +309,7 @@ _('Connection with peer cannot be established.'))
|
||||||
self.model.set(iter, 0, self.images[status])
|
self.model.set(iter, 0, self.images[status])
|
||||||
|
|
||||||
def set_progress(self, typ, sid, transfered_size, iter = None):
|
def set_progress(self, typ, sid, transfered_size, iter = None):
|
||||||
|
''' change the progress of a transfer with new transfered size'''
|
||||||
if not self.files_props[typ].has_key(sid):
|
if not self.files_props[typ].has_key(sid):
|
||||||
return
|
return
|
||||||
file_props = self.files_props[typ][sid]
|
file_props = self.files_props[typ][sid]
|
||||||
|
@ -341,6 +352,7 @@ _('Connection with peer cannot be established.'))
|
||||||
iter = self.model.iter_next(iter)
|
iter = self.model.iter_next(iter)
|
||||||
|
|
||||||
def get_sid(self):
|
def get_sid(self):
|
||||||
|
''' create random string of length 16'''
|
||||||
rng = range(65, 90)
|
rng = range(65, 90)
|
||||||
rng.extend(range(48, 57))
|
rng.extend(range(48, 57))
|
||||||
char_sequence = map(lambda e:chr(e), rng)
|
char_sequence = map(lambda e:chr(e), rng)
|
||||||
|
@ -349,6 +361,8 @@ _('Connection with peer cannot be established.'))
|
||||||
sample(char_sequence, 16))
|
sample(char_sequence, 16))
|
||||||
|
|
||||||
def get_send_file_props(self, account, contact, file_path, file_name):
|
def get_send_file_props(self, account, contact, file_path, file_name):
|
||||||
|
''' create new file_props dict and set initial file transfer
|
||||||
|
properties in it'''
|
||||||
file_props = {'file-name' : file_path, 'name' : file_name,
|
file_props = {'file-name' : file_path, 'name' : file_name,
|
||||||
'type' : 's'}
|
'type' : 's'}
|
||||||
if os.path.exists(file_path) and os.path.isfile(file_path):
|
if os.path.exists(file_path) and os.path.isfile(file_path):
|
||||||
|
@ -364,6 +378,7 @@ _('Connection with peer cannot be established.'))
|
||||||
return file_props
|
return file_props
|
||||||
|
|
||||||
def add_transfer(self, account, contact, file_props):
|
def add_transfer(self, account, contact, file_props):
|
||||||
|
''' add new transfer to FT window and show the FT window '''
|
||||||
self.on_transfers_list_leave_notify_event(None)
|
self.on_transfers_list_leave_notify_event(None)
|
||||||
if file_props is None:
|
if file_props is None:
|
||||||
return
|
return
|
||||||
|
@ -460,6 +475,7 @@ _('Connection with peer cannot be established.'))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def set_all_insensitive(self):
|
def set_all_insensitive(self):
|
||||||
|
''' make all buttons/menuitems insensitive '''
|
||||||
self.pause_button.set_sensitive(False)
|
self.pause_button.set_sensitive(False)
|
||||||
self.pause_menuitem.set_sensitive(False)
|
self.pause_menuitem.set_sensitive(False)
|
||||||
self.continue_menuitem.set_sensitive(False)
|
self.continue_menuitem.set_sensitive(False)
|
||||||
|
@ -470,6 +486,8 @@ _('Connection with peer cannot be established.'))
|
||||||
self.open_folder_menuitem.set_sensitive(False)
|
self.open_folder_menuitem.set_sensitive(False)
|
||||||
|
|
||||||
def set_buttons_sensitive(self, path, is_row_selected):
|
def set_buttons_sensitive(self, path, is_row_selected):
|
||||||
|
''' make buttons/menuitems sensitive as appropriate to
|
||||||
|
the state of file transfer located at path 'path' '''
|
||||||
if path is None:
|
if path is None:
|
||||||
self.set_all_insensitive()
|
self.set_all_insensitive()
|
||||||
return
|
return
|
||||||
|
@ -507,6 +525,8 @@ _('Connection with peer cannot be established.'))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def selection_changed(self, args):
|
def selection_changed(self, args):
|
||||||
|
''' selection has changed - change the sensitivity of the
|
||||||
|
buttons/menuitems'''
|
||||||
selection = args
|
selection = args
|
||||||
selected = selection.get_selected_rows()
|
selected = selection.get_selected_rows()
|
||||||
if selected[1] != []:
|
if selected[1] != []:
|
||||||
|
|
Loading…
Reference in New Issue