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] sid = self.model[s_iter][Column.SID] file_props = FilesProp.getFilePropByType(sid[0], sid[1:]) if is_transfer_paused(file_props): file_props.last_time = time.time() file_props.paused = False types = {'r': 'download', 's': 'upload'} self.set_status(file_props, types[sid[0]]) self.toggle_pause_continue(True) if file_props.continue_cb: file_props.continue_cb() elif is_transfer_active(file_props): file_props.paused = True self.set_status(file_props, 'pause') # reset that to compute speed only when we resume file_props.transfered_size = [] self.toggle_pause_continue(False)
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: self.set_all_insensitive() return current_iter = self.model.get_iter(path) sid = self.model[current_iter][Column.SID] file_props = FilesProp.getFilePropByType(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 is_transfer_stopped(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 and file_props.continue_cb: if is_transfer_active(file_props): # file transfer is active self.toggle_pause_continue(True) self.pause_button.set_sensitive(True) elif 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