Exemple #1
0
    def start(self):
        for widget in self.change_sensitivity:
            self.main_builder.get_object(widget).set_sensitive(True)

        # Only show open_folder menuitem and separator if connected to a localhost daemon.
        localhost_items = [
            'menuitem_open_folder',
            'separator4'
        ]
        if client.is_localhost():
            for widget in localhost_items:
                self.builder.get_object(widget).show()
                self.builder.get_object(widget).set_no_show_all(False)
        else:
            for widget in localhost_items:
                self.builder.get_object(widget).hide()
                self.builder.get_object(widget).set_no_show_all(True)

        self.main_builder.get_object('separatormenuitem').set_visible(not self.config['standalone'])
        self.main_builder.get_object('menuitem_quitdaemon').set_visible(not self.config['standalone'])
        self.main_builder.get_object('menuitem_connectionmanager').set_visible(not self.config['standalone'])

        # Show the Torrent menu because we're connected to a host
        self.menu_torrent.show()

        if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN:
            # Get known accounts to allow changing ownership
            client.core.get_known_accounts().addCallback(
                self._on_known_accounts).addErrback(self._on_known_accounts_fail)

        client.register_event_handler('TorrentStateChangedEvent', self.on_torrentstatechanged_event)
        client.register_event_handler('TorrentResumedEvent', self.on_torrentresumed_event)
        client.register_event_handler('SessionPausedEvent', self.on_sessionpaused_event)
        client.register_event_handler('SessionResumedEvent', self.on_sessionresumed_event)
Exemple #2
0
 def on_menuitem_move_activate(self, data=None):
     log.debug("on_menuitem_move_activate")
     if client.is_localhost():
         from deluge.configmanager import ConfigManager
         config = ConfigManager("gtkui.conf")
         chooser = gtk.FileChooserDialog(
             _("Choose a directory to move files to"),
             component.get("MainWindow").window,
             gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
             buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                      gtk.STOCK_OK, gtk.RESPONSE_OK)
         )
         chooser.set_local_only(True)
         if not deluge.common.windows_check():
             chooser.set_icon(common.get_deluge_icon())
             chooser.set_property("skip-taskbar-hint", True)
         chooser.set_current_folder(config["choose_directory_dialog_path"])
         if chooser.run() == gtk.RESPONSE_OK:
             result = chooser.get_filename()
             config["choose_directory_dialog_path"] = result
             client.core.move_storage(
                 component.get("TorrentView").get_selected_torrents(), result)
         chooser.destroy()
     else:
         component.get("SessionProxy").get_torrent_status(
             component.get("TorrentView").get_selected_torrent(),
             ["save_path"]).addCallback(self.show_move_storage_dialog)
Exemple #3
0
    def start(self):
        for widget in self.change_sensitivity:
            self.window.main_glade.get_widget(widget).set_sensitive(True)

        # Hide the Open Folder menuitem and separator if not connected to a
        # localhost.
        non_remote_items = [
            "menuitem_open_folder",
            "separator4"
        ]
        if not client.is_localhost():
            for widget in non_remote_items:
                self.torrentmenu_glade.get_widget(widget).hide()
                self.torrentmenu_glade.get_widget(widget).set_no_show_all(True)
        else:
            for widget in non_remote_items:
                self.torrentmenu_glade.get_widget(widget).show()
                self.torrentmenu_glade.get_widget(widget).set_no_show_all(False)

        self.window.main_glade.get_widget("separatormenuitem").set_visible(not self.config["classic_mode"])
        self.window.main_glade.get_widget("menuitem_quitdaemon").set_visible(not self.config["classic_mode"])
        self.window.main_glade.get_widget("menuitem_connectionmanager").set_visible(not self.config["classic_mode"])

        # Show the Torrent menu because we're connected to a host
        self.menu_torrent.show()
Exemple #4
0
        def on_get_config(config):
            if client.is_localhost():
                self.glade.get_widget('folderchooser_path').set_current_folder(config['extract_path'])
            else:
                self.glade.get_widget('entry_path').set_text(config['extract_path'])

            self.glade.get_widget('chk_use_name').set_active(config['use_name_folder'])
Exemple #5
0
 def on_menuitem_move_activate(self, data=None):
     log.debug("on_menuitem_move_activate")
     if client.is_localhost():
         from deluge.configmanager import ConfigManager
         config = ConfigManager("gtkui.conf")
         chooser = gtk.FileChooserDialog(
             _("Choose a directory to move files to"),
             component.get("MainWindow").window,
             gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
             buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                      gtk.RESPONSE_OK))
         chooser.set_local_only(True)
         if not deluge.common.windows_check():
             chooser.set_icon(common.get_deluge_icon())
             chooser.set_property("skip-taskbar-hint", True)
         chooser.set_current_folder(config["choose_directory_dialog_path"])
         if chooser.run() == gtk.RESPONSE_OK:
             result = chooser.get_filename()
             config["choose_directory_dialog_path"] = result
             client.core.move_storage(
                 component.get("TorrentView").get_selected_torrents(),
                 result)
         chooser.destroy()
     else:
         component.get("SessionProxy").get_torrent_status(
             component.get("TorrentView").get_selected_torrent(),
             ["save_path"]).addCallback(self.show_move_storage_dialog)
    def generate_opts(self):
        # generate options dict based on gtk objects
        options = {}
        options['enabled'] = self.glade.get_widget('enabled').get_active()
        if client.is_localhost():
            options['path'] = self.glade.get_widget('path_chooser').get_filename()
            options['download_location'] = self.glade.get_widget('download_location_chooser').get_filename()
            options['move_completed_path'] = self.glade.get_widget('move_completed_path_chooser').get_filename()
        else:
            options['path'] = self.glade.get_widget('path_entry').get_text()
            options['download_location'] = self.glade.get_widget('download_location_entry').get_text()
            options['move_completed_path'] = self.glade.get_widget('move_completed_path_entry').get_text()
        options['append_extension_toggle'] = self.glade.get_widget('append_extension_toggle').get_active()
        options['append_extension'] = self.glade.get_widget('append_extension').get_text()
        options['download_location_toggle'] = self.glade.get_widget('download_location_toggle').get_active()
        options['label'] = self.glade.get_widget('label').get_text().lower()
        options['label_toggle'] = self.glade.get_widget('label_toggle').get_active()

        for id in self.spin_ids:
            options[id] = self.glade.get_widget(id).get_value()
            options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
        for id in self.spin_int_ids:
            options[id] = self.glade.get_widget(id).get_value_as_int()
            options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
        for id in self.chk_ids:
            options[id] = self.glade.get_widget(id).get_active()
            options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
        return options
 def _on_button_apply_clicked(self, button):
     if self.spin_max_download.get_value() != self.prev_status["max_download_speed"]:
         client.core.set_torrent_max_download_speed(self.prev_torrent_id, self.spin_max_download.get_value())
     if self.spin_max_upload.get_value() != self.prev_status["max_upload_speed"]:
         client.core.set_torrent_max_upload_speed(self.prev_torrent_id, self.spin_max_upload.get_value())
     if self.spin_max_connections.get_value_as_int() != self.prev_status["max_connections"]:
         client.core.set_torrent_max_connections(self.prev_torrent_id, self.spin_max_connections.get_value_as_int())
     if self.spin_max_upload_slots.get_value_as_int() != self.prev_status["max_upload_slots"]:
         client.core.set_torrent_max_upload_slots(self.prev_torrent_id, self.spin_max_upload_slots.get_value_as_int())
     if self.chk_prioritize_first_last.get_active() != self.prev_status["prioritize_first_last"]:
         client.core.set_torrent_prioritize_first_last(self.prev_torrent_id, self.chk_prioritize_first_last.get_active())
     if self.chk_auto_managed.get_active() != self.prev_status["is_auto_managed"]:
         client.core.set_torrent_auto_managed(self.prev_torrent_id, self.chk_auto_managed.get_active())
     if self.chk_stop_at_ratio.get_active() != self.prev_status["stop_at_ratio"]:
         client.core.set_torrent_stop_at_ratio(self.prev_torrent_id, self.chk_stop_at_ratio.get_active())
     if self.spin_stop_ratio.get_value() != self.prev_status["stop_ratio"]:
         client.core.set_torrent_stop_ratio(self.prev_torrent_id, self.spin_stop_ratio.get_value())
     if self.chk_remove_at_ratio.get_active() != self.prev_status["remove_at_ratio"]:
         client.core.set_torrent_remove_at_ratio(self.prev_torrent_id, self.chk_remove_at_ratio.get_active())
     if self.chk_move_completed.get_active() != self.prev_status["move_on_completed"]:
         client.core.set_torrent_move_completed(self.prev_torrent_id, self.chk_move_completed.get_active())
     if self.chk_move_completed.get_active():
         if client.is_localhost():
             path = self.filechooser_move_completed.get_current_folder()
         else:
             path = self.entry_move_completed.get_text()
         client.core.set_torrent_move_completed_path(self.prev_torrent_id, path)
Exemple #8
0
 def _on_button_apply_clicked(self, button):
     if self.spin_max_download.get_value() != self.prev_status["max_download_speed"]:
         client.core.set_torrent_max_download_speed(
             self.prev_torrent_id, self.spin_max_download.get_value()
         )
     if self.spin_max_upload.get_value() != self.prev_status["max_upload_speed"]:
         client.core.set_torrent_max_upload_speed(
             self.prev_torrent_id, self.spin_max_upload.get_value()
         )
     if self.spin_max_connections.get_value_as_int() != self.prev_status["max_connections"]:
         client.core.set_torrent_max_connections(
             self.prev_torrent_id, self.spin_max_connections.get_value_as_int()
         )
     if self.spin_max_upload_slots.get_value_as_int() != self.prev_status["max_upload_slots"]:
         client.core.set_torrent_max_upload_slots(
             self.prev_torrent_id, self.spin_max_upload_slots.get_value_as_int()
         )
     if self.chk_prioritize_first_last.get_active() != \
                     self.prev_status["prioritize_first_last"] and \
                                             not self.prev_status["compact"]:
         client.core.set_torrent_prioritize_first_last(
             self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
         )
     if self.chk_sequential_download.get_active() != \
                     self.prev_status["sequential_download"] and \
                                             not self.prev_status["compact"]:
         client.core.set_torrent_sequential_download(
             self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
         )
     if self.chk_auto_managed.get_active() != self.prev_status["is_auto_managed"]:
         client.core.set_torrent_auto_managed(
             self.prev_torrent_id, self.chk_auto_managed.get_active()
         )
     if self.chk_stop_at_ratio.get_active() != self.prev_status["stop_at_ratio"]:
         client.core.set_torrent_stop_at_ratio(
             self.prev_torrent_id, self.chk_stop_at_ratio.get_active()
         )
     if self.spin_stop_ratio.get_value() != self.prev_status["stop_ratio"]:
         client.core.set_torrent_stop_ratio(
             self.prev_torrent_id, self.spin_stop_ratio.get_value()
         )
     if self.chk_remove_at_ratio.get_active() != self.prev_status["remove_at_ratio"]:
         client.core.set_torrent_remove_at_ratio(
             self.prev_torrent_id, self.chk_remove_at_ratio.get_active()
         )
     if self.chk_move_completed.get_active() != self.prev_status["move_on_completed"]:
         client.core.set_torrent_move_completed(
             self.prev_torrent_id, self.chk_move_completed.get_active()
         )
     if self.chk_move_completed.get_active():
         if client.is_localhost():
             path = self.filechooser_move_completed.get_filename()
         else:
             path = self.entry_move_completed.get_text()
         client.core.set_torrent_move_completed_path(self.prev_torrent_id, path)
     if self.chk_shared.get_active() != self.prev_status["shared"]:
         client.core.set_torrents_shared(
             self.prev_torrent_id, self.chk_shared.get_active()
         )
     self.button_apply.set_sensitive(False)
Exemple #9
0
    def on_apply_prefs(self):
        log.debug("Applying prefs for Copy Completed")
        if client.is_localhost():
            path = self.glade.get_widget(
                "folderchooser_path").get_current_folder()
        else:
            path = self.glade.get_widget("entry_path").get_text()

        umask = ''.join(
            map(str, [
                0,
                self.glade.get_widget("spinbutton_umask1").get_value_as_int(),
                self.glade.get_widget("spinbutton_umask2").get_value_as_int(),
                self.glade.get_widget("spinbutton_umask3").get_value_as_int()
            ]))

        label = {
            "copy_to": path,
            "umask": umask,
            "move_to":
            self.glade.get_widget("radiobutton_move_to").get_active()
        }

        config = {
            "No Label": label,
        }

        client.copycompleted.set_config(config)
Exemple #10
0
    def on_show_prefs(self):
        if client.is_localhost():
            self.glade.get_widget("folderchooser_path").show()
            self.glade.get_widget("entry_path").hide()
        else:
            self.glade.get_widget("folderchooser_path").hide()
            self.glade.get_widget("entry_path").show()

        def on_get_config(config):
            label = config["No Label"]

            if client.is_localhost():
                self.glade.get_widget("folderchooser_path").set_current_folder(
                    label["copy_to"])
            else:
                self.glade.get_widget("entry_path").set_text(label["copy_to"])

            umask = map(int, str(label["umask"]))
            self.glade.get_widget("spinbutton_umask1").set_value(umask[1])
            self.glade.get_widget("spinbutton_umask2").set_value(umask[2])
            self.glade.get_widget("spinbutton_umask3").set_value(umask[3])
            self.glade.get_widget("radiobutton_move_to").set_active(
                label["move_to"])

        client.copycompleted.get_config().addCallback(on_get_config)
Exemple #11
0
 def on_get_config(config):
     if client.is_localhost():
         self.glade.get_widget("folderchooser_path").set_current_folder(config["extract_path"])
     else:
         self.glade.get_widget("entry_path").set_text(config["extract_path"])
     
     self.glade.get_widget("chk_use_name").set_active(config["use_name_folder"])
    def on_ok(self, event=None):
        "save options.."
        options = {}

        for id in self.spin_ids:
            options[id] = self.glade.get_widget(id).get_value()
        for id in self.spin_int_ids:
            options[id] = self.glade.get_widget(id).get_value_as_int()
        for id in self.chk_ids:
            options[id] = self.glade.get_widget(id).get_active()

        if client.is_localhost():
            options["move_completed_path"] = self.glade.get_widget(
                "move_completed_path").get_filename()
        else:
            options["move_completed_path"] = self.glade.get_widget(
                "move_completed_path_entry").get_text()

        buff = self.glade.get_widget(
            "auto_add_trackers").get_buffer()  #sometimes I hate gtk...
        tracker_lst = buff.get_text(buff.get_start_iter(),
                                    buff.get_end_iter()).strip().split("\n")
        options["auto_add_trackers"] = [x for x in tracker_lst
                                        if x]  #filter out empty lines.

        log.debug(options)
        client.label.set_options(self.label, options)
        self.dialog.destroy()
Exemple #13
0
    def __init__(self, parent):
        QtGui.QDialog.__init__(
            self, parent,
            QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setupUi(self)

        self.ui_config = ConfigManager("qtui.conf")
        self.default_options = {}
        self._selected_item = None

        self.download_location_browse.setVisible(client.is_localhost())

        self.EMPTY_FILE_MODEL = TorrentFileModel([], self)
        self.tree_files.setModel(self.EMPTY_FILE_MODEL)
        header = self.tree_files.header()
        header.setStretchLastSection(False)
        header.setMinimumSectionSize(header.fontMetrics().width("M") * 10)
        header.setResizeMode(0, QtGui.QHeaderView.Stretch)
        header.setResizeMode(
            1, QtGui.QHeaderView.Fixed)  # NB: ResizeToContents is slow

        HeightFixItemDelegate.install(self.tree_files)

        self._update_default_options()
Exemple #14
0
    def start(self):
        for widget in self.change_sensitivity:
            self.window.main_glade.get_widget(widget).set_sensitive(True)

        # Hide the Open Folder menuitem and separator if not connected to a
        # localhost.
        non_remote_items = [
            "menuitem_open_folder",
            "separator4"
        ]
        if not client.is_localhost():
            for widget in non_remote_items:
                self.torrentmenu_glade.get_widget(widget).hide()
                self.torrentmenu_glade.get_widget(widget).set_no_show_all(True)
        else:
            for widget in non_remote_items:
                self.torrentmenu_glade.get_widget(widget).set_no_show_all(False)

        if not self.config["classic_mode"]:
            self.window.main_glade.get_widget("separatormenuitem").show()
            self.window.main_glade.get_widget("menuitem_quitdaemon").show()

        # Show the Torrent menu because we're connected to a host
        self.menu_torrent.show()

        if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN:
            # Get known accounts to allow changing ownership
            client.core.get_known_accounts().addCallback(
                self._on_known_accounts).addErrback(self._on_known_accounts_fail
            )
Exemple #15
0
    def start(self):
        for widget in self.change_sensitivity:
            self.window.main_glade.get_widget(widget).set_sensitive(True)

        # Hide the Open Folder menuitem and separator if not connected to a
        # localhost.
        non_remote_items = ["menuitem_open_folder", "separator4"]
        if not client.is_localhost():
            for widget in non_remote_items:
                self.torrentmenu_glade.get_widget(widget).hide()
                self.torrentmenu_glade.get_widget(widget).set_no_show_all(True)
        else:
            for widget in non_remote_items:
                self.torrentmenu_glade.get_widget(widget).set_no_show_all(
                    False)

        if not self.config["classic_mode"]:
            self.window.main_glade.get_widget("separatormenuitem").show()
            self.window.main_glade.get_widget("menuitem_quitdaemon").show()

        # Show the Torrent menu because we're connected to a host
        self.menu_torrent.show()

        if client.get_auth_level() == deluge.common.AUTH_LEVEL_ADMIN:
            # Get known accounts to allow changing ownership
            client.core.get_known_accounts().addCallback(
                self._on_known_accounts).addErrback(
                    self._on_known_accounts_fail)
    def on_button_plugin_install(self):
        filter = "%s (%s);;%s (%s)" % (_("Plugin Eggs"), "*.egg",
                                       _("All files"), "*")
        filename = QtGui.QFileDialog.getOpenFileName(self,
                                                     _("Select the Plugin"),
                                                     None, filter)
        if filename:
            import shutil
            import os.path

            filename = QtCore.QDir.toNativeSeparators(filename)
            basename = os.path.basename(filename)
            shutil.copyfile(
                filename,
                os.path.join(configmanager.get_config_dir(), "plugins",
                             basename))

            component.get("PluginManager").scan_for_plugins()

            if not client.is_localhost():
                # We need to send this plugin to the daemon
                import base64
                with open(filename, 'rb') as f:
                    filedump = base64.encodestring(f.read())
                client.core.upload_plugin(basename, filedump)

            client.core.rescan_plugins()
            self._update_plugins()
 def start(self):
     if client.is_localhost():
         self.filechooser_move_completed.show()
         self.entry_move_completed.hide()
     else:
         self.filechooser_move_completed.hide()
         self.entry_move_completed.show()
Exemple #18
0
    def on_options_ok(self, event=None):
        'save options..'
        options = {}

        for spin_id in self.spin_ids:
            options[spin_id] = self.builder.get_object(spin_id).get_value()
        for spin_int_id in self.spin_int_ids:
            options[spin_int_id] = self.builder.get_object(
                spin_int_id).get_value_as_int()
        for chk_id in self.chk_ids:
            options[chk_id] = self.builder.get_object(chk_id).get_active()

        if client.is_localhost():
            options['move_completed_path'] = self.builder.get_object(
                'move_completed_path').get_filename()
        else:
            options['move_completed_path'] = self.builder.get_object(
                'move_completed_path_entry').get_text()

        buff = self.builder.get_object(
            'auto_add_trackers').get_buffer()  # sometimes I hate gtk...
        tracker_lst = buff.get_text(buff.get_start_iter(),
                                    buff.get_end_iter()).strip().split('\n')
        options['auto_add_trackers'] = [x for x in tracker_lst
                                        if x]  # filter out empty lines.

        log.debug(options)
        client.label.set_options(self.label, options)
        self.dialog.destroy()
Exemple #19
0
 def start(self):
     if client.is_localhost():
         self.filechooser_move_completed.show()
         self.entry_move_completed.hide()
     else:
         self.filechooser_move_completed.hide()
         self.entry_move_completed.show()
Exemple #20
0
    def upload_plugin(self, filename, path):
        """Upload a plugin to config."""
        main_deferred = Deferred()

        shutil.copyfile(path,
                        os.path.join(get_config_dir(), 'plugins', filename))
        component.get('Web.PluginManager').scan_for_plugins()

        if client.is_localhost():
            client.core.rescan_plugins()
            return True
        with open(path, 'rb') as _file:
            plugin_data = b64encode(_file.read())

        def on_upload_complete(*args):
            client.core.rescan_plugins()
            component.get('Web.PluginManager').scan_for_plugins()
            main_deferred.callback(True)

        def on_upload_error(*args):
            main_deferred.callback(False)

        d = client.core.upload_plugin(filename, plugin_data)
        d.addCallback(on_upload_complete)
        d.addErrback(on_upload_error)
        return main_deferred
Exemple #21
0
    def _on_get_torrent_status(self, status):
        # We only want to update values that have been applied in the core.  This
        # is so we don't overwrite the user changes that haven't been applied yet.
        if self.prev_status == None:
            self.prev_status = {}.fromkeys(status.keys(), None)

        if status != self.prev_status:
            if status["max_download_speed"] != self.prev_status["max_download_speed"]:
                self.spin_max_download.set_value(status["max_download_speed"])
            if status["max_upload_speed"] != self.prev_status["max_upload_speed"]:
                self.spin_max_upload.set_value(status["max_upload_speed"])
            if status["max_connections"] != self.prev_status["max_connections"]:
                self.spin_max_connections.set_value(status["max_connections"])
            if status["max_upload_slots"] != self.prev_status["max_upload_slots"]:
                self.spin_max_upload_slots.set_value(status["max_upload_slots"])
            if status["private"] != self.prev_status["private"]:
                self.chk_private.set_active(status["private"])
            if status["prioritize_first_last"] != self.prev_status["prioritize_first_last"]:
                self.chk_prioritize_first_last.set_active(status["prioritize_first_last"])
            if status["is_auto_managed"] != self.prev_status["is_auto_managed"]:
                self.chk_auto_managed.set_active(status["is_auto_managed"])
            if status["stop_at_ratio"] != self.prev_status["stop_at_ratio"]:
                self.chk_stop_at_ratio.set_active(status["stop_at_ratio"])
                self.spin_stop_ratio.set_sensitive(status["stop_at_ratio"])
                self.chk_remove_at_ratio.set_sensitive(status["stop_at_ratio"])
            if status["stop_ratio"] != self.prev_status["stop_ratio"]:
                self.spin_stop_ratio.set_value(status["stop_ratio"])
            if status["remove_at_ratio"] != self.prev_status["remove_at_ratio"]:
                self.chk_remove_at_ratio.set_active(status["remove_at_ratio"])
            if status["move_on_completed"] != self.prev_status["move_on_completed"]:
                self.chk_move_completed.set_active(status["move_on_completed"])
            if status["move_on_completed_path"] != self.prev_status["move_on_completed_path"]:
                if client.is_localhost():
                    self.filechooser_move_completed.set_current_folder(status["move_on_completed_path"])
                else:
                    self.entry_move_completed.set_text(status["move_on_completed_path"])
            if status["shared"] != self.prev_status["shared"]:
                self.chk_shared.set_active(status["shared"])

            if status["compact"]:
                self.chk_prioritize_first_last.set_sensitive(False)
                if self.chk_sequential_download.get_property("visible"):
                    self.chk_prioritize_first_last.hide()
                self.chk_sequential_download.set_sensitive(False)
                if self.chk_sequential_download.get_property("visible"):
                    self.chk_sequential_download.hide()
            else:
                if status["prioritize_first_last"] != self.prev_status["prioritize_first_last"]:
                    self.chk_prioritize_first_last.set_active(status["prioritize_first_last"])
                    if not self.chk_prioritize_first_last.get_property("visible"):
                        self.chk_prioritize_first_last.show()
                if status["sequential_download"] != self.prev_status["sequential_download"]:
                    self.chk_sequential_download.set_active(status["sequential_download"])
                    if not self.chk_sequential_download.get_property("visible"):
                        self.chk_sequential_download.show()

            if self.button_apply.is_sensitive():
                self.button_apply.set_sensitive(False)

            self.prev_status = status
Exemple #22
0
    def on_show_prefs(self):
        if client.is_localhost():
            self.get_folder_chooser_object().show()
            self.get_entry_path_object().hide()
        else:
            self.get_folder_chooser_object().hide()
            self.get_entry_path_object().show()

        def on_get_config(config):
            if client.is_localhost():
                self.get_folder_chooser_object().set_current_folder(
                    config[CONFIG_EXTRACT_PATH])
            else:
                self.get_entry_path_object().set_text(
                    config[CONFIG_EXTRACT_PATH])

            self.get_supported_labels_object().set_text(
                config[CONFIG_SUPPORTED_LABELS])
            self.get_use_name_folder_object().set_active(
                config[CONFIG_NAME_FOLDER])
            self.get_in_place_extract_object().set_active(
                config[CONFIG_IN_PLACE_EXTRACT])
            config.get_pvr_support_object().set_active(
                config[CONFIG_PVR_SUPPORT])

        client.pvrextractor.get_config().addCallback(on_get_config)
Exemple #23
0
        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)
Exemple #24
0
    def load_options(self, options):
        log.debug(list(options))

        for spin_id in self.spin_ids + self.spin_int_ids:
            self.builder.get_object(spin_id).set_value(options[spin_id])
        for chk_id in self.chk_ids:
            self.builder.get_object(chk_id).set_active(bool(options[chk_id]))

        if client.is_localhost():
            self.builder.get_object('move_completed_path').set_filename(
                options['move_completed_path']
            )
            self.builder.get_object('move_completed_path').show()
            self.builder.get_object('move_completed_path_entry').hide()
        else:
            self.builder.get_object('move_completed_path_entry').set_text(
                options['move_completed_path']
            )
            self.builder.get_object('move_completed_path_entry').show()
            self.builder.get_object('move_completed_path').hide()

        self.builder.get_object('auto_add_trackers').get_buffer().set_text(
            '\n'.join(options['auto_add_trackers'])
        )

        self.apply_sensitivity()
Exemple #25
0
    def generate_opts(self):
        # generate options dict based on gtk objects
        options = {}
        options['enabled'] = self.glade.get_widget('enabled').get_active()
        if client.is_localhost():
            options['path'] = self.glade.get_widget(
                'path_chooser').get_filename()
            options['download_location'] = self.glade.get_widget(
                'download_location_chooser').get_filename()
            options['move_completed_path'] = self.glade.get_widget(
                'move_completed_path_chooser').get_filename()
            options['copy_torrent'] = self.glade.get_widget(
                'copy_torrent_chooser').get_filename()
        else:
            options['path'] = self.glade.get_widget('path_entry').get_text()
            options['download_location'] = self.glade.get_widget(
                'download_location_entry').get_text()
            options['move_completed_path'] = self.glade.get_widget(
                'move_completed_path_entry').get_text()
            options['copy_torrent'] = self.glade.get_widget(
                'copy_torrent_entry').get_text()

        options['label'] = self.glade.get_widget(
            'label').child.get_text().lower()
        options['append_extension'] = self.glade.get_widget(
            'append_extension').get_text()
        options['owner'] = self.accounts[self.glade.get_widget(
            'OwnerCombobox').get_active()][0]

        for key in [
                'append_extension_toggle', 'download_location_toggle',
                'label_toggle', 'copy_torrent_toggle',
                'delete_copy_torrent_toggle', 'seed_mode'
        ]:
            options[key] = self.glade.get_widget(key).get_active()

        for spin_id in self.spin_ids:
            options[spin_id] = self.glade.get_widget(spin_id).get_value()
            options[spin_id +
                    '_toggle'] = self.glade.get_widget(spin_id +
                                                       '_toggle').get_active()
        for spin_int_id in self.spin_int_ids:
            options[spin_int_id] = self.glade.get_widget(
                spin_int_id).get_value_as_int()
            options[spin_int_id +
                    '_toggle'] = self.glade.get_widget(spin_int_id +
                                                       '_toggle').get_active()
        for chk_id in self.chk_ids:
            options[chk_id] = self.glade.get_widget(chk_id).get_active()
            options[chk_id +
                    '_toggle'] = self.glade.get_widget(chk_id +
                                                       '_toggle').get_active()

        if options['copy_torrent_toggle'] and options['path'] == options[
                'copy_torrent']:
            raise IncompatibleOption(
                _('"Watch Folder" directory and "Copy of .torrent'
                  ' files to" directory cannot be the same!'))
        return options
 def setup_move_completed_combobox(self):
     move_completed_box = self.get_object("move_completed_box")
     self.move_completed_path_chooser = PathChooser("move_completed_paths_list")
     self.move_completed_path_chooser.set_filechooser_button_visible(client.is_localhost())
     self.move_completed_path_chooser.set_enable_properties(False)
     self.move_completed_path_chooser.set_enable_properties(True)
     move_completed_box.add(self.move_completed_path_chooser)
     move_completed_box.show_all()
 def setup_move_completed_combobox(self):
     move_completed_box = self.glade.get_widget("move_completed_box")
     self.move_completed_path_chooser = PathChooser("move_completed_paths_list")
     self.move_completed_path_chooser.set_filechooser_visible(client.is_localhost())
     self.move_completed_path_chooser.set_enable_properties(False)
     self.move_completed_path_chooser.set_enable_properties(True)
     move_completed_box.add(self.move_completed_path_chooser)
     move_completed_box.show_all()
Exemple #28
0
 def start(self):
     if client.is_localhost():
         self.filechooser_move_completed.show()
         self.entry_move_completed.hide()
     else:
         self.filechooser_move_completed.hide()
         self.entry_move_completed.show()
         self.entry_move_completed.connect("changed", self._on_entry_move_completed_changed)
Exemple #29
0
 def setup_download_location_combobox(self):
     download_location_box = self.glade.get_widget("download_location_box")
     self.download_location_path_chooser = PathChooser(
         "download_location_paths_list")
     self.download_location_path_chooser.set_filechooser_button_visible(
         client.is_localhost())
     download_location_box.add(self.download_location_path_chooser)
     download_location_box.show_all()
    def _on_chk_move_completed_toggled(self, widget):
        value = self.chk_move_completed.get_active()
        if client.is_localhost():
            widget = self.filechooser_move_completed
        else:
            widget = self.entry_move_completed

        widget.set_sensitive(value)
Exemple #31
0
    def _on_chk_move_completed_toggled(self, widget):
        value = self.chk_move_completed.get_active()
        if client.is_localhost():
            widget = self.filechooser_move_completed
        else:
            widget = self.entry_move_completed

        widget.set_sensitive(value)
Exemple #32
0
        def on_get_config(config):
            if client.is_localhost():
                self.glade.get_widget("folderchooser_path").set_current_folder(config['extract_path'])
            else:
                self.glade.get_widget("entry_path").set_text(config['extract_path'])

            self.glade.get_widget("chk_use_name").set_active(config['use_name_folder'])
            self.glade.get_widget("chk_in_place_extraction").set_active(config['in_place_extraction'])
Exemple #33
0
            def on_get_torrent_status(status):
                """Gets called with torrent status, including file info.
                Sets the torrent options which require knowledge of the current status of the torrent."""

                main_file_dlist = []

                # Determine where the file should be
                move_now_path = None
                if opts.get('movedone'):
                    if status['progress'] == 100:
                        move_now_path = opts['movedone']
                    else:
                        # Deluge will unset the move completed option if we move the storage, forgo setting proper
                        # path, in favor of leaving proper final location.
                        log.debug('Not moving storage for %s, as this will prevent movedone.' % entry['title'])
                elif opts.get('path'):
                    move_now_path = opts['path']

                if move_now_path and os.path.normpath(move_now_path) != os.path.normpath(status['save_path']):
                    main_file_dlist.append(version_deferred.addCallback(create_path, move_now_path))
                    log.debug('Moving storage for %s to %s' % (entry['title'], move_now_path))
                    main_file_dlist.append(client.core.move_storage([torrent_id], move_now_path))

                if opts.get('content_filename') or opts.get('main_file_only'):

                    def file_exists():
                        # Checks the download path as well as the move completed path for existence of the file
                        if os.path.exists(os.path.join(status['save_path'], filename)):
                            return True
                        elif status.get('move_on_completed') and status.get('move_on_completed_path'):
                            if os.path.exists(os.path.join(status['move_on_completed_path'], filename)):
                                return True
                        else:
                            return False

                    for file in status['files']:
                        # Only rename file if it is > 90% of the content
                        if file['size'] > (status['total_size'] * 0.9):
                            if opts.get('content_filename'):
                                filename = opts['content_filename'] + os.path.splitext(file['path'])[1]
                                counter = 1
                                if client.is_localhost():
                                    while file_exists():
                                        # Try appending a (#) suffix till a unique filename is found
                                        filename = ''.join([opts['content_filename'], '(', str(counter), ')', os.path.splitext(file['path'])[1]])
                                        counter += 1
                                else:
                                    log.debug('Cannot ensure content_filename is unique when adding to a remote deluge daemon.')
                                log.debug('File %s in %s renamed to %s' % (file['path'], entry['title'], filename))
                                main_file_dlist.append(client.core.rename_files(torrent_id, [(file['index'], filename)]))
                            if opts.get('main_file_only'):
                                file_priorities = [1 if f['index'] == file['index'] else 0 for f in status['files']]
                                main_file_dlist.append(client.core.set_torrent_file_priorities(torrent_id, file_priorities))
                            break
                    else:
                        log.warning('No files in %s are > 90%% of content size, no files renamed.' % entry['title'])

                return defer.DeferredList(main_file_dlist)
Exemple #34
0
            def on_get_torrent_status(status):
                """Gets called with torrent status, including file info.
                Sets the torrent options which require knowledge of the current status of the torrent."""

                main_file_dlist = []

                # Determine where the file should be
                move_now_path = None
                if opts.get('movedone'):
                    if status['progress'] == 100:
                        move_now_path = opts['movedone']
                    else:
                        # Deluge will unset the move completed option if we move the storage, forgo setting proper
                        # path, in favor of leaving proper final location.
                        log.debug('Not moving storage for %s, as this will prevent movedone.' % entry['title'])
                elif opts.get('path'):
                    move_now_path = opts['path']

                if move_now_path and os.path.normpath(move_now_path) != os.path.normpath(status['save_path']):
                    main_file_dlist.append(version_deferred.addCallback(create_path, move_now_path))
                    log.debug('Moving storage for %s to %s' % (entry['title'], move_now_path))
                    main_file_dlist.append(client.core.move_storage([torrent_id], move_now_path))

                if opts.get('content_filename') or opts.get('main_file_only'):

                    def file_exists():
                        # Checks the download path as well as the move completed path for existence of the file
                        if os.path.exists(os.path.join(status['save_path'], filename)):
                            return True
                        elif status.get('move_on_completed') and status.get('move_on_completed_path'):
                            if os.path.exists(os.path.join(status['move_on_completed_path'], filename)):
                                return True
                        else:
                            return False

                    for file in status['files']:
                        # Only rename file if it is > 90% of the content
                        if file['size'] > (status['total_size'] * 0.9):
                            if opts.get('content_filename'):
                                filename = opts['content_filename'] + os.path.splitext(file['path'])[1]
                                counter = 1
                                if client.is_localhost():
                                    while file_exists():
                                        # Try appending a (#) suffix till a unique filename is found
                                        filename = ''.join([opts['content_filename'], '(', str(counter), ')', os.path.splitext(file['path'])[1]])
                                        counter += 1
                                else:
                                    log.debug('Cannot ensure content_filename is unique when adding to a remote deluge daemon.')
                                log.debug('File %s in %s renamed to %s' % (file['path'], entry['title'], filename))
                                main_file_dlist.append(client.core.rename_files(torrent_id, [(file['index'], filename)]))
                            if opts.get('main_file_only'):
                                file_priorities = [1 if f['index'] == file['index'] else 0 for f in status['files']]
                                main_file_dlist.append(client.core.set_torrent_file_priorities(torrent_id, file_priorities))
                            break
                    else:
                        log.warning('No files in %s are > 90%% of content size, no files renamed.' % entry['title'])

                return defer.DeferredList(main_file_dlist)
Exemple #35
0
        def on_get_config(config):
            if client.is_localhost():
                self.glade.get_widget("folderchooser_path").set_current_folder(config["extract_path"])
            else:
                self.glade.get_widget("entry_path").set_text(config["extract_path"])

            self.glade.get_widget("chk_use_name").set_active(config["use_name_folder"])
            self.glade.get_widget("chk_in_place_extraction").set_active(config["in_place_extraction"])
            self.glade.get_widget("chk_sonarr_radarr_support").set_active(config["sonarr_radarr_support"])
Exemple #36
0
 def start(self):
     if client.is_localhost():
         self.filechooser_move_completed.show()
         self.entry_move_completed.hide()
     else:
         self.filechooser_move_completed.hide()
         self.entry_move_completed.show()
         self.entry_move_completed.connect(
             "changed", self._on_entry_move_completed_changed)
Exemple #37
0
    def on_apply_prefs(self):
        log.debug("applying prefs for Extractor")
        if client.is_localhost():
            path = self.glade.get_widget("folderchooser_path").get_current_folder()
        else:
            path = self.glade.get_widget("entry_path").get_text()

        config = {"extract_path": path, "use_name_folder": self.glade.get_widget("chk_use_name").get_active()}

        client.extractor.set_config(config)
Exemple #38
0
        def on_get_config(config):
            if client.is_localhost():
                self.glade.get_widget('folderchooser_path').set_current_folder(
                    config['extract_path'])
            else:
                self.glade.get_widget('entry_path').set_text(
                    config['extract_path'])

            self.glade.get_widget('chk_use_name').set_active(
                config['use_name_folder'])
Exemple #39
0
        def on_get_config(config):
            if client.is_localhost():
                self.glade.get_widget("folderchooser_path").set_current_folder(
                    config["extract_path"])
            else:
                self.glade.get_widget("entry_path").set_text(
                    config["extract_path"])

            self.glade.get_widget("chk_use_name").set_active(
                config["use_name_folder"])
Exemple #40
0
 def create_path(result, path):
     """Creates the specified path if deluge is older than 1.3"""
     from deluge.common import VersionSplit
     # Before 1.3, deluge would not create a non-existent move directory, so we need to.
     if VersionSplit('1.3.0') > VersionSplit(self.deluge_version):
         if client.is_localhost():
             if not os.path.isdir(path):
                 log.debug('path %s doesn\'t exist, creating' % path)
                 os.makedirs(path)
         else:
             log.warning('If path does not exist on the machine running the daemon, move will fail.')
Exemple #41
0
 def create_path(result, path):
     """Creates the specified path if deluge is older than 1.3"""
     from deluge.common import VersionSplit
     # Before 1.3, deluge would not create a non-existent move directory, so we need to.
     if VersionSplit('1.3.0') > VersionSplit(self.deluge_version):
         if client.is_localhost():
             if not os.path.isdir(path):
                 log.debug('path %s doesn\'t exist, creating' % path)
                 os.makedirs(path)
         else:
             log.warning('If path does not exist on the machine running the daemon, move will fail.')
Exemple #42
0
        def on_get_config(config):
            if client.is_localhost():
                self.builder.get_object('folderchooser_path').set_current_folder(
                    config['extract_path']
                )
            else:
                self.builder.get_object('entry_path').set_text(config['extract_path'])

            self.builder.get_object('chk_use_name').set_active(
                config['use_name_folder']
            )
			self.builder.get_object('chk_in_place_extraction').set_active(config['in_place_extraction'])
  def _load_state(self):

    if not client.is_localhost():
      for path_type in PATH_TYPES:
        self.__dict__["_btn_%s_browse" % path_type].hide()

    if self._plugin.initialized:
      expanded = self._plugin.config["common"]["prefs_state"]
      for exp in expanded:
        widget = getattr(self, "_" + exp, None)
        if widget:
          widget.set_expanded(True)
        def on_get_config(config):
            if client.is_localhost():
                self.glade.get_widget("folderchooser_path").set_current_folder(config["copy_to"])
            else:
                self.glade.get_widget("entry_path").set_text(config["copy_to"])


            umask = map(int, str(config["umask"]))
            self.glade.get_widget("spinbutton_umask1").set_value(umask[1])
            self.glade.get_widget("spinbutton_umask2").set_value(umask[2])
            self.glade.get_widget("spinbutton_umask3").set_value(umask[3])
            self.glade.get_widget("radiobutton_move_to").set_active(config["move_to"])
    def _load_state(self):

        if not client.is_localhost():
            for path_type in PATH_TYPES:
                self.__dict__["_btn_%s_browse" % path_type].hide()

        if self._plugin.initialized:
            expanded = self._plugin.config["common"]["prefs_state"]
            for exp in expanded:
                widget = getattr(self, "_" + exp, None)
                if widget:
                    widget.set_expanded(True)
Exemple #46
0
    def on_apply_prefs(self):
        log.debug('applying prefs for Extractor')
        if client.is_localhost():
            path = self.glade.get_widget('folderchooser_path').get_filename()
        else:
            path = self.glade.get_widget('entry_path').get_text()

        config = {
            'extract_path': path,
            'use_name_folder': self.glade.get_widget('chk_use_name').get_active()
        }

        client.extractor.set_config(config)
Exemple #47
0
 def unused_name(name):
     # If on local computer, tries appending a (#) suffix until a unique filename is found
     if client.is_localhost():
         counter = 2
         while file_exists(name):
             name = ''.join([os.path.splitext(name)[0],
                             " (", str(counter), ')',
                             os.path.splitext(name)[1]])
             counter += 1
     else:
         log.debug('Cannot ensure content_filename is unique '
                   'when adding to a remote deluge daemon.')
     return name
Exemple #48
0
 def unused_name(name):
     # If on local computer, tries appending a (#) suffix until a unique filename is found
     if client.is_localhost():
         counter = 2
         while file_exists(name):
             name = ''.join([os.path.splitext(name)[0],
                             " (", str(counter), ')',
                             os.path.splitext(name)[1]])
             counter += 1
     else:
         log.debug('Cannot ensure content_filename is unique '
                   'when adding to a remote deluge daemon.')
     return name
Exemple #49
0
    def on_apply_prefs(self):
        log.debug('applying prefs for Extractor')
        if client.is_localhost():
            path = self.glade.get_widget('folderchooser_path').get_filename()
        else:
            path = self.glade.get_widget('entry_path').get_text()

        config = {
            'extract_path': path,
            'use_name_folder':
            self.glade.get_widget('chk_use_name').get_active()
        }

        client.extractor.set_config(config)
Exemple #50
0
    def on_apply_prefs(self):
        log.debug("applying prefs for SimpleExtractor")
        if client.is_localhost():
            path = self.glade.get_widget("folderchooser_path").get_filename()
        else:
            path = self.glade.get_widget("entry_path").get_text()

        config = {
            "extract_path": path,
            "use_name_folder": self.glade.get_widget("chk_use_name").get_active(),
            "in_place_extraction": self.glade.get_widget("chk_in_place_extraction").get_active()
        }

        client.simpleextractor.set_config(config)
Exemple #51
0
    def on_show_prefs(self):
        if client.is_localhost():
            self.glade.get_widget("folderchooser_path").show()
            self.glade.get_widget("entry_path").hide()
        else:
            self.glade.get_widget("folderchooser_path").hide()
            self.glade.get_widget("entry_path").show()

        def on_get_config(config):
            if client.is_localhost():
                self.glade.get_widget("folderchooser_path").set_current_folder(config["extract_path"])
            else:
                self.glade.get_widget("entry_path").set_text(config["extract_path"])
            
            self.glade.get_widget("chk_use_name").set_active(config["use_name_folder"])

        client.extractor.get_config().addCallback(on_get_config)
Exemple #52
0
 def on_action_torrent_move_storage_triggered(self):
     if client.is_localhost():
         new_save_path = QtGui.QFileDialog.getExistingDirectory(
             self, _("Choose a directory to move files to"), self.ui_config["choose_directory_dialog_path"]
         )
         if new_save_path:
             self.ui_config["choose_directory_dialog_path"] = new_save_path
             client.core.move_storage(self.tree_torrents.selected_torrent_ids(), new_save_path)
     else:
         status = yield component.get("SessionProxy").get_torrent_status(
             self.tree_torrents.selected_torrent_id(), ["save_path"]
         )
         new_save_path = QtGui.QInputDialog.getText(
             self, _("Move Storage"), _("Destination:"), text=status["save_path"]
         )[0]
         if new_save_path:
             client.core.move_storage(self.tree_torrents.selected_torrent_ids(), new_save_path)
Exemple #53
0
    def generate_opts(self):
        # generate options dict based on gtk objects
        options = {}
        options['enabled'] = self.glade.get_widget('enabled').get_active()
        if client.is_localhost():
            options['path'] = self.glade.get_widget('path_chooser').get_filename()
            options['download_location'] = self.glade.get_widget(
                'download_location_chooser').get_filename()
            options['move_completed_path'] = self.glade.get_widget(
                'move_completed_path_chooser').get_filename()
            options['copy_torrent'] = self.glade.get_widget(
                'copy_torrent_chooser').get_filename()
        else:
            options['path'] = self.glade.get_widget('path_entry').get_text()
            options['download_location'] = self.glade.get_widget(
                'download_location_entry').get_text()
            options['move_completed_path'] = self.glade.get_widget(
                'move_completed_path_entry').get_text()
            options['copy_torrent'] = self.glade.get_widget(
                'copy_torrent_entry').get_text()

        options['label'] = self.glade.get_widget('label').child.get_text().lower()
        options['append_extension'] = self.glade.get_widget('append_extension').get_text()
        options['owner'] = self.accounts[
            self.glade.get_widget('OwnerCombobox').get_active()][0]

        for key in ['append_extension_toggle', 'download_location_toggle',
                    'label_toggle', 'copy_torrent_toggle',
                    'delete_copy_torrent_toggle']:
            options[key] = self.glade.get_widget(key).get_active()

        for id in self.spin_ids:
            options[id] = self.glade.get_widget(id).get_value()
            options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
        for id in self.spin_int_ids:
            options[id] = self.glade.get_widget(id).get_value_as_int()
            options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
        for id in self.chk_ids:
            options[id] = self.glade.get_widget(id).get_active()
            options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()

        if options['copy_torrent_toggle'] and options['path'] == options['copy_torrent']:
            raise IncompatibleOption(_("\"Watch Folder\" directory and \"Copy of .torrent"
                                       " files to\" directory cannot be the same!"))
        return options
Exemple #54
0
    def _on_button_plugin_install_clicked(self, widget):
        log.debug("_on_button_plugin_install_clicked")
        chooser = gtk.FileChooserDialog(
            _("Select the Plugin"),
            self.pref_dialog,
            gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK),
        )

        chooser.set_transient_for(self.pref_dialog)
        chooser.set_select_multiple(False)
        chooser.set_property("skip-taskbar-hint", True)

        file_filter = gtk.FileFilter()
        file_filter.set_name(_("Plugin Eggs"))
        file_filter.add_pattern("*." + "egg")
        chooser.add_filter(file_filter)

        # Run the dialog
        response = chooser.run()

        if response == gtk.RESPONSE_OK:
            filepath = chooser.get_filename()
        else:
            chooser.destroy()
            return

        import base64
        import shutil
        import os.path

        filename = os.path.split(filepath)[1]
        shutil.copyfile(filepath, os.path.join(deluge.configmanager.get_config_dir(), "plugins", filename))

        component.get("PluginManager").scan_for_plugins()

        if not client.is_localhost():
            # We need to send this plugin to the daemon
            filedump = base64.encodestring(open(filepath, "rb").read())
            client.core.upload_plugin(filename, filedump)

        client.core.rescan_plugins()
        chooser.destroy()
        # We need to re-show the preferences dialog to show the new plugins
        self.show()
    def load_options(self, options):
        log.debug(options.keys())

        for id in self.spin_ids + self.spin_int_ids:
            self.glade.get_widget(id).set_value(options[id])
        for id in self.chk_ids:
            self.glade.get_widget(id).set_active(bool(options[id]))

        if client.is_localhost():
            self.glade.get_widget("move_completed_path").set_filename(options["move_completed_path"])
            self.glade.get_widget("move_completed_path").show()
            self.glade.get_widget("move_completed_path_entry").hide()
        else:
            self.glade.get_widget("move_completed_path_entry").set_text(options["move_completed_path"])
            self.glade.get_widget("move_completed_path_entry").show()
            self.glade.get_widget("move_completed_path").hide()

        self.glade.get_widget("auto_add_trackers").get_buffer().set_text("\n".join(options["auto_add_trackers"]))

        self.apply_sensitivity()
Exemple #56
0
    def load_options(self, options):
        log.debug(list(options))

        for spin_id in self.spin_ids + self.spin_int_ids:
            self.builder.get_object(spin_id).set_value(options[spin_id])
        for chk_id in self.chk_ids:
            self.builder.get_object(chk_id).set_active(bool(options[chk_id]))

        if client.is_localhost():
            self.builder.get_object('move_completed_path').set_filename(options['move_completed_path'])
            self.builder.get_object('move_completed_path').show()
            self.builder.get_object('move_completed_path_entry').hide()
        else:
            self.builder.get_object('move_completed_path_entry').set_text(options['move_completed_path'])
            self.builder.get_object('move_completed_path_entry').show()
            self.builder.get_object('move_completed_path').hide()

        self.builder.get_object('auto_add_trackers').get_buffer().set_text('\n'.join(options['auto_add_trackers']))

        self.apply_sensitivity()
Exemple #57
0
    def on_apply_prefs(self):
        log.debug("Applying prefs for Copy Completed")
        if client.is_localhost():
            path = self.glade.get_widget("folderchooser_path").get_current_folder()
        else:
            path = self.glade.get_widget("entry_path").get_text()

        umask = ''.join(map(str, [
            0,
            self.glade.get_widget("spinbutton_umask1").get_value_as_int(),
            self.glade.get_widget("spinbutton_umask2").get_value_as_int(),
            self.glade.get_widget("spinbutton_umask3").get_value_as_int()
            ]))

        config = {
            "copy_to": path,
            "umask": umask,
            "move_to": self.glade.get_widget("radiobutton_move_to").get_active()
        }

        client.copycompleted.set_config(config)