def on_accounts_failure(failure): log.debug("Failed to get accounts!!! %s", failure) iter = self.accounts.append() self.accounts.set_value(iter, 0, client.get_auth_user()) self.glade.get_widget('OwnerCombobox').set_active(0) self.glade.get_widget('OwnerCombobox').set_sensitive(False)
def load_options(self, options): self.glade.get_widget('enabled').set_active(options.get('enabled', True)) self.glade.get_widget('append_extension_toggle').set_active( options.get('append_extension_toggle', False) ) self.glade.get_widget('append_extension').set_text( options.get('append_extension', '.added') ) self.glade.get_widget('download_location_toggle').set_active( options.get('download_location_toggle', False) ) self.glade.get_widget('copy_torrent_toggle').set_active( options.get('copy_torrent_toggle', False) ) self.glade.get_widget('delete_copy_torrent_toggle').set_active( options.get('delete_copy_torrent_toggle', False) ) self.accounts.clear() self.labels.clear() combobox = self.glade.get_widget('OwnerCombobox') combobox_render = gtk.CellRendererText() combobox.pack_start(combobox_render, True) combobox.add_attribute(combobox_render, 'text', 0) combobox.set_model(self.accounts) label_widget = self.glade.get_widget('label') label_widget.child.set_text(options.get('label', '')) label_widget.set_model(self.labels) label_widget.set_text_column(0) self.glade.get_widget('label_toggle').set_active(options.get('label_toggle', False)) for id in self.spin_ids + self.spin_int_ids: self.glade.get_widget(id).set_value(options.get(id, 0)) self.glade.get_widget(id+'_toggle').set_active(options.get(id+'_toggle', False)) for id in self.chk_ids: self.glade.get_widget(id).set_active(bool(options.get(id, True))) self.glade.get_widget(id+'_toggle').set_active(options.get(id+'_toggle', False)) if not options.get('add_paused', True): self.glade.get_widget('isnt_add_paused').set_active(True) if not options.get('queue_to_top', True): self.glade.get_widget('isnt_queue_to_top').set_active(True) if not options.get('auto_managed', True): self.glade.get_widget('isnt_auto_managed').set_active(True) for field in ['move_completed_path', 'path', 'download_location', 'copy_torrent']: if client.is_localhost(): self.glade.get_widget(field+"_chooser").set_current_folder( options.get(field, os.path.expanduser("~")) ) self.glade.get_widget(field+"_chooser").show() self.glade.get_widget(field+"_entry").hide() else: self.glade.get_widget(field+"_entry").set_text( options.get(field, "") ) self.glade.get_widget(field+"_entry").show() self.glade.get_widget(field+"_chooser").hide() self.set_sensitive() def on_core_config(config): if client.is_localhost(): self.glade.get_widget('download_location_chooser').set_current_folder( options.get('download_location', config["download_location"]) ) if options.get('move_completed_toggle', config["move_completed"]): self.glade.get_widget('move_completed_toggle').set_active(True) self.glade.get_widget('move_completed_path_chooser').set_current_folder( options.get('move_completed_path', config["move_completed_path"]) ) if options.get('copy_torrent_toggle', config["copy_torrent_file"]): self.glade.get_widget('copy_torrent_toggle').set_active(True) self.glade.get_widget('copy_torrent_chooser').set_current_folder( options.get('copy_torrent', config["torrentfiles_location"]) ) else: self.glade.get_widget('download_location_entry').set_text( options.get('download_location', config["download_location"]) ) if options.get('move_completed_toggle', config["move_completed"]): self.glade.get_widget('move_completed_toggle').set_active( options.get('move_completed_toggle', False) ) self.glade.get_widget('move_completed_path_entry').set_text( options.get('move_completed_path', config["move_completed_path"]) ) if options.get('copy_torrent_toggle', config["copy_torrent_file"]): self.glade.get_widget('copy_torrent_toggle').set_active(True) self.glade.get_widget('copy_torrent_entry').set_text( options.get('copy_torrent', config["torrentfiles_location"]) ) if options.get('delete_copy_torrent_toggle', config["del_copy_torrent_file"]): self.glade.get_widget('delete_copy_torrent_toggle').set_active(True) if not options: client.core.get_config().addCallback(on_core_config) def on_accounts(accounts, owner): log.debug("Got Accounts") selected_iter = None for account in accounts: iter = self.accounts.append() self.accounts.set_value( iter, 0, account['username'] ) if account['username'] == owner: selected_iter = iter self.glade.get_widget('OwnerCombobox').set_active_iter(selected_iter) def on_accounts_failure(failure): log.debug("Failed to get accounts!!! %s", failure) iter = self.accounts.append() self.accounts.set_value(iter, 0, client.get_auth_user()) self.glade.get_widget('OwnerCombobox').set_active(0) self.glade.get_widget('OwnerCombobox').set_sensitive(False) def on_labels(labels): log.debug("Got Labels: %s", labels) for label in labels: self.labels.set_value(self.labels.append(), 0, label) label_widget = self.glade.get_widget('label') label_widget.set_model(self.labels) label_widget.set_text_column(0) def on_failure(failure): log.exception(failure) def on_get_enabled_plugins(result): if 'Label' in result: self.glade.get_widget('label_frame').show() client.label.get_labels().addCallback(on_labels).addErrback(on_failure) else: self.glade.get_widget('label_frame').hide() self.glade.get_widget('label_toggle').set_active(False) client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins) if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN: client.core.get_known_accounts().addCallback( on_accounts, options.get('owner', client.get_auth_user()) ).addErrback(on_accounts_failure) else: iter = self.accounts.append() self.accounts.set_value(iter, 0, client.get_auth_user()) self.glade.get_widget('OwnerCombobox').set_active(0) self.glade.get_widget('OwnerCombobox').set_sensitive(False)
def on_accounts_failure(failure): log.debug('Failed to get accounts!!! %s', failure) acc_iter = self.accounts.append() self.accounts.set_value(acc_iter, 0, client.get_auth_user()) self.builder.get_object('OwnerCombobox').set_active(0) self.builder.get_object('OwnerCombobox').set_sensitive(False)