Exemple #1
0
 def on_cleanup_button_clicked(self, widget):
     i = len(self.model) - 1
     while i >= 0:
         iter_ = self.model.get_iter((i))
         sid = self.model[iter_][C_SID]
         file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
         if is_transfer_stopped(file_props):
             self._remove_transfer(iter_, sid, file_props)
         i -= 1
     self.tree.get_selection().unselect_all()
     self.set_all_insensitive()
Exemple #2
0
 def find_transfer_by_jid(self, account, jid):
     """
     Find all transfers with peer 'jid' that belong to 'account'
     """
     active_transfers = [[], []] # ['senders', 'receivers']
     allfp = FilesProp.getAllFileProp()
     for file_props in allfp:
         if file_props.type_ == 's' and file_props.tt_account == account:
             # 'account' is the sender
             receiver_jid = file_props.receiver.split('/')[0]
             if jid == receiver_jid and not is_transfer_stopped(file_props):
                 active_transfers[0].append(file_props)
         elif file_props.type_ == 'r' and file_props.tt_account == account:
             # 'account' is the recipient
             sender_jid = file_props.sender.split('/')[0]
             if jid == sender_jid and not is_transfer_stopped(file_props):
                 active_transfers[1].append(file_props)
         else:
             raise Exception('file_props has no type')
     return active_transfers
Exemple #3
0
 def on_cleanup_button_clicked(self, widget):
     i = len(self.model) - 1
     while i >= 0:
         iter_ = self.model.get_iter((i))
         sid = self.model[iter_][Column.SID]
         file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
         if is_transfer_stopped(file_props):
             self._remove_transfer(iter_, sid, file_props)
         i -= 1
     self.tree.get_selection().unselect_all()
     self.set_all_insensitive()
Exemple #4
0
 def find_transfer_by_jid(self, account, jid):
     """
     Find all transfers with peer 'jid' that belong to 'account'
     """
     active_transfers = [[], []] # ['senders', 'receivers']
     allfp = FilesProp.getAllFileProp()
     for file_props in allfp:
         if file_props.type_ == 's' and file_props.tt_account == account:
             # 'account' is the sender
             receiver_jid = file_props.receiver.split('/')[0]
             if jid == receiver_jid and not is_transfer_stopped(file_props):
                 active_transfers[0].append(file_props)
         elif file_props.type_ == 'r' and file_props.tt_account == account:
             # 'account' is the recipient
             sender_jid = file_props.sender.split('/')[0]
             if jid == sender_jid and not is_transfer_stopped(file_props):
                 active_transfers[1].append(file_props)
         else:
             raise Exception('file_props has no type')
     return active_transfers
Exemple #5
0
 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][C_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:
         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
Exemple #6
0
 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:
         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