Exemple #1
0
 def __init__(self):
     log.debug("CoreConfig init..")
     component.Component.__init__(self, "CoreConfig")
     self.config = {}
     def on_configvaluechanged_event(key, value):
         self.config[key] = value
     client.register_event_handler("ConfigValueChangedEvent", on_configvaluechanged_event)
Exemple #2
0
    def __init__(self,
                 config_key,
                 values,
                 parent=None,
                 suffix="",
                 custom_label=None,
                 custom_max=None):
        QtGui.QActionGroup.__init__(self, parent)

        self.config_key = config_key
        self.custom_label = custom_label
        self.custom_max = custom_max
        self.value = None

        for value in values:
            self.addAction(
                QtGui.QAction(unicode(value) + suffix,
                              self,
                              checkable=True,
                              triggered=self._value_triggered)).setData(value)

        self.addAction(
            QtGui.QAction(_("Unlimited"),
                          self,
                          checkable=True,
                          triggered=self._value_triggered)).setData(-1)
        self.addAction(QtGui.QAction(self)).setSeparator(True)
        self.custom_action = self.addAction(
            QtGui.QAction(_("Other..."),
                          self,
                          triggered=self._custom_triggered))

        client.register_event_handler("ConfigValueChangedEvent",
                                      self._client_configvaluechanged)
Exemple #3
0
    def __init__(self):
        component.Component.__init__(self, "Web.PluginManager")
        self.config = ConfigManager("web.conf")
        PluginManagerBase.__init__(self, "web.conf", "deluge.plugin.web")

        client.register_event_handler("PluginEnabledEvent", self._on_plugin_enabled_event)
        client.register_event_handler("PluginDisabledEvent", self._on_plugin_disabled_event)
 def __on_connect_success(self, result):
     '''
     : add event handlers
     '''
     LOG.info('Connection was successful')
     client.register_event_handler('TorrentFinishedEvent', self.__on_download_completed)
     return result
    def __init__(self):
        component.Component.__init__(self, 'Web.PluginManager')
        self.config = ConfigManager('web.conf')
        PluginManagerBase.__init__(self, 'web.conf', 'deluge.plugin.web')

        client.register_event_handler('PluginEnabledEvent', self._on_plugin_enabled_event)
        client.register_event_handler('PluginDisabledEvent', self._on_plugin_disabled_event)
Exemple #6
0
    def load(self):
        log.debug("Adding Execute Preferences page")
        self.glade = gtk.glade.XML(self.get_resource("execute_prefs.glade"))
        self.glade.signal_autoconnect({
            "on_add_button_clicked": self.on_add_button_clicked
        })

        events = self.glade.get_widget("event_combobox")

        store = gtk.ListStore(str, str)
        for event in EVENTS:
            event_label = EVENT_MAP[event]
            store.append((event_label, event))
        events.set_model(store)
        events.set_active(0)

        self.plugin.add_preferences_page(_("Execute"),
            self.glade.get_widget("execute_box"))
        self.plugin.register_hook("on_show_prefs", self.load_commands)
        self.plugin.register_hook("on_apply_prefs", self.on_apply_prefs)

        self.load_commands()

        client.register_event_handler("ExecuteCommandAddedEvent", self.on_command_added_event)
        client.register_event_handler("ExecuteCommandRemovedEvent", self.on_command_removed_event)
    def enable(self):
        self.create_prefs_page()

        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
        self.statusbar = component.get("StatusBar")
        self.status_item = self.statusbar.add_item(
            image=get_resource("green.png"),
            text="",
            callback=self.on_status_item_clicked,
            tooltip="MyScheduler")

        self.menu = gtk.CheckMenuItem(_("Force Start"))
        self.menu.connect("activate", self.on_menu_activated, None)        
        self.menu.show()
        
        torrentmenu = component.get("MenuBar").torrentmenu
        torrentmenu.connect("show", self.on_menu_show, None)
        torrentmenu.append(self.menu)

        def on_state_deferred(state):
            self.state = state
            self.on_scheduler_event(state)
        client.scheduler.get_state().addCallback(on_state_deferred)
        client.register_event_handler("SchedulerEvent", self.on_scheduler_event)
Exemple #8
0
    def __init__(self):
        component.Component.__init__(self, "PluginManager")
        PluginManagerBase.__init__(self, "qtui.conf", "deluge.plugin.qtui")

        client.register_event_handler("PluginEnabledEvent", self.enable_plugin)
        client.register_event_handler("PluginDisabledEvent",
                                      self.disable_plugin)
Exemple #9
0
    def enable(self):
        log.debug('Enabling %s FreeSpace', self.__class__.__name__)
        self.glade = gtk.glade.XML(get_resource("config.glade"))
        self.prefs = self.glade.get_widget('prefs_box')
        parent = self.prefs.get_parent()
        if parent:
            parent.remove(self.prefs)

        self.downloads_vbox = component.get("Preferences").builder.get_object('downloads_vbox')
        self.downloads_vbox.pack_start(self.prefs, False, True, 0)

        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)

        try:
            notifications = component.get("GtkPlugin.Notifications")
            notifications.register_custom_popup_notification(
                "LowDiskSpaceEvent", self.__custom_popup_notification
            )
            notifications.register_custom_blink_notification(
                "LowDiskSpaceEvent", self.__custom_blink_notification
            )
            notifications.register_custom_sound_notification(
                "LowDiskSpaceEvent", self.__custom_sound_notification
            )
        except KeyError:
            pass

        client.register_event_handler("PluginEnabledEvent", self.__on_plugin_enabled)
        client.register_event_handler("PluginDisabledEvent", self.__on_plugin_disabled)
Exemple #10
0
    def enable(self):
        self.create_prefs_page()

        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
        self.statusbar = component.get("StatusBar")
        self.status_item = self.statusbar.add_item(
            image=get_resource("green.png"),
            text="",
            callback=self.on_status_item_clicked,
            tooltip="MyScheduler")

        self.menu = gtk.CheckMenuItem(_("Force Start"))
        self.menu.connect("activate", self.on_menu_activated, None)        
        self.menu.show()
        
        torrentmenu = component.get("MenuBar").torrentmenu
        torrentmenu.connect("show", self.on_menu_show, None)
        torrentmenu.insert(self.menu, 4)

        def on_state_deferred(state):
            self.state = state
            self.on_scheduler_event(state)
        client.myscheduler.get_state().addCallback(on_state_deferred)
        client.register_event_handler("SchedulerEvent", self.on_scheduler_event)
Exemple #11
0
    def enable(self):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(get_resource('config.ui'))
        self.builder.connect_signals(self)
        self.opts_dialog = OptionsDialog()

        component.get('PluginManager').register_hook('on_apply_prefs',
                                                     self.on_apply_prefs)
        component.get('PluginManager').register_hook('on_show_prefs',
                                                     self.on_show_prefs)
        client.register_event_handler('AutoaddOptionsChangedEvent',
                                      self.on_options_changed_event)

        self.watchdirs = {}

        vbox = self.builder.get_object('watchdirs_vbox')
        sw = Gtk.ScrolledWindow()
        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)

        vbox.pack_start(sw, True, True, 0)

        self.store = self.create_model()

        self.treeView = Gtk.TreeView(self.store)
        self.treeView.connect('cursor-changed', self.on_listitem_activated)
        self.treeView.connect('row-activated', self.on_edit_button_clicked)
        self.treeView.set_rules_hint(True)

        self.create_columns(self.treeView)
        sw.add(self.treeView)
        sw.show_all()
        component.get('Preferences').add_page(
            _('AutoAdd'), self.builder.get_object('prefs_box'))
Exemple #12
0
    def load(self):
        log.debug('Adding Execute Preferences page')
        self.builder = Gtk.Builder()
        self.builder.add_from_file(common.get_resource('execute_prefs.ui'))
        self.builder.connect_signals(self)

        events = self.builder.get_object('event_combobox')

        store = Gtk.ListStore(str, str)
        for event in EVENTS:
            event_label = EVENT_MAP[event]
            store.append((event_label, event))
        events.set_model(store)
        events.set_active(0)

        self.plugin.add_preferences_page(
            _('Execute'), self.builder.get_object('execute_box'))
        self.plugin.register_hook('on_show_prefs', self.load_commands)
        self.plugin.register_hook('on_apply_prefs', self.on_apply_prefs)

        self.load_commands()

        client.register_event_handler('ExecuteCommandAddedEvent',
                                      self.on_command_added_event)
        client.register_event_handler('ExecuteCommandRemovedEvent',
                                      self.on_command_removed_event)
Exemple #13
0
    def load(self):
        log.debug("Adding Execute Preferences page")
        self.glade = gtk.glade.XML(self.get_resource("execute_prefs.glade"))
        self.glade.signal_autoconnect(
            {"on_add_button_clicked": self.on_add_button_clicked})

        events = self.glade.get_widget("event_combobox")

        store = gtk.ListStore(str, str)
        for event in EVENTS:
            event_label = EVENT_MAP[event]
            store.append((event_label, event))
        events.set_model(store)
        events.set_active(0)

        self.plugin.add_preferences_page(_("Execute"),
                                         self.glade.get_widget("execute_box"))
        self.plugin.register_hook("on_show_prefs", self.load_commands)
        self.plugin.register_hook("on_apply_prefs", self.on_apply_prefs)

        self.load_commands()

        client.register_event_handler("ExecuteCommandAddedEvent",
                                      self.on_command_added_event)
        client.register_event_handler("ExecuteCommandRemovedEvent",
                                      self.on_command_removed_event)
Exemple #14
0
    def enable(self):
        self.builder = gtk.Builder()
        self.builder.add_from_file(get_resource("config.ui"))
        self.builder.connect_signals({
            "on_button_clear_clicked":
            self.on_button_clear_clicked,
        })

        component.get("Preferences").add_page(
            "TrafficLimits", self.builder.get_object("prefs_box"))
        component.get("PluginManager").register_hook("on_apply_prefs",
                                                     self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs",
                                                     self.on_show_prefs)

        self.status_item = component.get("StatusBar").add_item(
            image=get_resource("monitor.png"),
            text="",
            callback=self.on_status_item_clicked,
            tooltip="TrafficLimits plugin")

        def on_get_state(state):
            self.set_status(*state)

        self.state_deferred = client.trafficlimits.get_state().addCallback(
            on_get_state)
        client.register_event_handler("TrafficLimitUpdate",
                                      self.on_trafficlimit_update)
Exemple #15
0
    def enable(self):
        self.glade = gtk.glade.XML(get_resource("config.glade"))

        component.get("Preferences").add_page(
            "uTorrentImport", self.glade.get_widget("prefs_box"))

        component.get("PluginManager").register_hook("on_apply_prefs",
                                                     self.on_apply_prefs)

        component.get("PluginManager").register_hook("on_show_prefs",
                                                     self.on_show_prefs)
        signal_dictionary = {
            'on_import_button_clicked': self.on_import_button_clicked,
            'on_resume_toggled': self.on_resume_toggled
        }
        log.debug('utorrentimport: signals hooked!')
        self.glade.signal_autoconnect(signal_dictionary)
        self.use_wine_mappings = self.glade.get_widget('use_wine_mappings')
        self.force_recheck = self.glade.get_widget('force_recheck')
        self.resume = self.glade.get_widget('resume')
        self.resume_dat_entry = self.glade.get_widget('resume_dat_entry')
        self.log_view = self.glade.get_widget('log_view')

        client.register_event_handler('uTorrentImportLoggingEvent',
                                      self.log_to_user)
    def enable(self):

        self.glade = gtk.glade.XML(get_resource("config.glade"))
        self.glade.signal_autoconnect({
            "on_add_button_clicked": self.on_add_button_clicked,
            "on_edit_button_clicked": self.on_edit_button_clicked,
            "on_remove_button_clicked": self.on_remove_button_clicked
        })
        self.opts_dialog = OptionsDialog()

        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
        client.register_event_handler("AutoaddPlusOptionsChangedEvent", self.on_options_changed_event)

        self.watchdirs = {}

        vbox = self.glade.get_widget("watchdirs_vbox")
        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        vbox.pack_start(sw, True, True, 0)

        self.store = self.create_model()

        self.treeView = gtk.TreeView(self.store)
        self.treeView.connect("cursor-changed", self.on_listitem_activated)
        self.treeView.connect("row-activated", self.on_edit_button_clicked)
        self.treeView.set_rules_hint(True)

        self.create_columns(self.treeView)
        sw.add(self.treeView)
        sw.show_all()
        component.get("Preferences").add_page(_("AutoAddPlus"), self.glade.get_widget("prefs_box"))
Exemple #17
0
    def enable(self):
        log.debug('Enabling %s FreeSpace', self.__class__.__name__)
        self.glade = gtk.glade.XML(get_resource("config.glade"))
        self.prefs = self.glade.get_widget('prefs_box')
        parent = self.prefs.get_parent()
        if parent:
            parent.remove(self.prefs)

        self.downloads_vbox = component.get("Preferences").builder.get_object(
            'downloads_vbox')
        self.downloads_vbox.pack_start(self.prefs, False, True, 0)

        component.get("PluginManager").register_hook("on_apply_prefs",
                                                     self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs",
                                                     self.on_show_prefs)

        try:
            notifications = component.get("GtkPlugin.Notifications")
            notifications.register_custom_popup_notification(
                "LowDiskSpaceEvent", self.__custom_popup_notification)
            notifications.register_custom_blink_notification(
                "LowDiskSpaceEvent", self.__custom_blink_notification)
            notifications.register_custom_sound_notification(
                "LowDiskSpaceEvent", self.__custom_sound_notification)
        except KeyError:
            pass

        client.register_event_handler("PluginEnabledEvent",
                                      self.__on_plugin_enabled)
        client.register_event_handler("PluginDisabledEvent",
                                      self.__on_plugin_disabled)
Exemple #18
0
 def __on_connect_success(self, result):
     """
     : add event handlers
     """
     LOG.info('Connection was successful')
     client.register_event_handler('TorrentFinishedEvent',
                                   self.__on_download_completed)
     return result
Exemple #19
0
 def enable(self):
     self.glade = gtk.glade.XML(get_resource("config.glade"))
     component.get("Preferences").add_page("XBMCUpdater", self.glade.get_widget("vbox1"))
     component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
     component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
     client.register_event_handler("ReplacementAddedEvent", self.on_replacement_added_event)
     client.register_event_handler("ReplacementRemovedEvent", self.on_replacement_removed_event)
     self.load()
Exemple #20
0
    def __init__(self):
        log.debug('CoreConfig init..')
        component.Component.__init__(self, 'CoreConfig')
        self.config = {}

        def on_configvaluechanged_event(key, value):
            self.config[key] = value
        client.register_event_handler('ConfigValueChangedEvent', on_configvaluechanged_event)
Exemple #21
0
 def enable(self):
     self.createUI()
     self.on_show_prefs(
     )  # Necessary for the first time when the plugin is installed
     client.register_event_handler("YARSSConfigChangedEvent",
                                   self.cb_on_config_changed_event)
     client.register_event_handler("GtkUILogMessageEvent",
                                   self.cb_on_log_message_arrived_event)
    def __init__(self):
        component.Component.__init__(self, "PluginManager")
        self.config = ConfigManager("gtkui.conf")
        deluge.pluginmanagerbase.PluginManagerBase.__init__(self, "gtkui.conf", "deluge.plugin.gtkui")

        self.hooks = {"on_apply_prefs": [], "on_show_prefs": []}

        client.register_event_handler("PluginEnabledEvent", self._on_plugin_enabled_event)
        client.register_event_handler("PluginDisabledEvent", self._on_plugin_disabled_event)
    def __init__(self):
        component.Component.__init__(self, "Web.PluginManager")
        self.config = ConfigManager("web.conf")
        PluginManagerBase.__init__(self, "web.conf", "deluge.plugin.web")

        client.register_event_handler("PluginEnabledEvent",
                                      self._on_plugin_enabled_event)
        client.register_event_handler("PluginDisabledEvent",
                                      self._on_plugin_disabled_event)
Exemple #24
0
    def __init__(self):
        component.Component.__init__(self, 'Web.PluginManager')
        self.config = ConfigManager('web.conf')
        PluginManagerBase.__init__(self, 'web.conf', 'deluge.plugin.web')

        client.register_event_handler('PluginEnabledEvent',
                                      self._on_plugin_enabled_event)
        client.register_event_handler('PluginDisabledEvent',
                                      self._on_plugin_disabled_event)
 def enable(self):
     self.last_config = None
     self.create_ui()
     self.on_show_prefs(
     )  # Necessary for the first time when the plugin is installed
     client.register_event_handler("IfaceWatchLogMessageEvent",
                                   self.cb_on_log_message_event)
     client.register_event_handler("IfaceWatchIPChangedEvent",
                                   self.cb_get_ip)
Exemple #26
0
    def enable(self):
        """Enables the system tray icon."""
        self.builder = Builder()
        self.builder.add_from_file(resource_filename('deluge.ui.gtkui', os.path.join(
            'glade', 'tray_menu.ui')))

        self.builder.connect_signals(self)

        self.tray_menu = self.builder.get_object('tray_menu')

        if appindicator and self.config['enable_appindicator']:
            log.debug('Enabling the Application Indicator...')
            self.indicator = appindicator.Indicator('deluge', 'deluge',
                                                    appindicator.CATEGORY_APPLICATION_STATUS)
            try:
                self.indicator.set_property('title', _('Deluge'))
            except TypeError:
                # Catch 'title' property error for previous appindicator versions
                pass
            # Pass the menu to the Application Indicator
            self.indicator.set_menu(self.tray_menu)

            # Make sure the status of the Show Window MenuItem is correct
            self._sig_win_hide = self.mainwindow.window.connect('hide', self._on_window_hide)
            self._sig_win_show = self.mainwindow.window.connect('show', self._on_window_show)
            if self.mainwindow.visible():
                self.builder.get_object('menuitem_show_deluge').set_active(True)
            else:
                self.builder.get_object('menuitem_show_deluge').set_active(False)

            # Show the Application Indicator
            self.indicator.set_status(appindicator.STATUS_ACTIVE)

        else:
            log.debug('Enabling the system tray icon..')
            if windows_check():
                self.tray = status_icon_new_from_pixbuf(get_logo(32))
            else:
                self.tray = status_icon_new_from_icon_name('deluge')

            self.tray.connect('activate', self.on_tray_clicked)
            self.tray.connect('popup-menu', self.on_tray_popup)

        self.builder.get_object('download-limit-image').set_from_file(get_pixmap('downloading16.png'))
        self.builder.get_object('upload-limit-image').set_from_file(get_pixmap('seeding16.png'))

        client.register_event_handler('ConfigValueChangedEvent', self.config_value_changed)
        if client.connected():
            # We're connected so we need to get some values from the core
            self.__start()
        else:
            # Hide menu widgets because we're not connected to a host.
            for widget in self.hide_widget_list:
                self.builder.get_object(widget).hide()
Exemple #27
0
    def __init__(self):
        component.Component.__init__(self, "PluginManager")
        self.config = ConfigManager("gtkui.conf")
        deluge.pluginmanagerbase.PluginManagerBase.__init__(
            self, "gtkui.conf", "deluge.plugin.gtkui")

        self.hooks = {"on_apply_prefs": [], "on_show_prefs": []}

        client.register_event_handler("PluginEnabledEvent",
                                      self._on_plugin_enabled_event)
        client.register_event_handler("PluginDisabledEvent",
                                      self._on_plugin_disabled_event)
Exemple #28
0
    def __init__(self, stdscr, encoding=None):

        self.batch_write = False
        self.lines = []

        # A list of strings to be displayed based on the offset (scroll)
        self.lines = []
        # The offset to display lines
        self.display_lines_offset = 0

        # Holds the user input and is cleared on 'enter'
        self.input = ""
        self.input_incomplete = ""
        # Keep track of where the cursor is
        self.input_cursor = 0
        # Keep a history of inputs
        self.input_history = []
        self.input_history_index = 0

        # Keep track of double-tabs
        self.tab_count = 0

        # Get a handle to the main console
        self.console = component.get("ConsoleUI")

        # show the cursor
        curses.curs_set(2)

        BaseMode.__init__(self, stdscr, encoding)

        # This gets fired once we have received the torrents list from the core
        self.started_deferred = defer.Deferred()

        # Maintain a list of (torrent_id, name) for use in tab completion
        self.torrents = []

        def on_session_state(result):
            def on_torrents_status(torrents):
                for torrent_id, status in torrents.items():
                    self.torrents.append((torrent_id, status["name"]))
                self.started_deferred.callback(True)

            client.core.get_torrents_status({
                "id": result
            }, ["name"]).addCallback(on_torrents_status)

        client.core.get_session_state().addCallback(on_session_state)

        # Register some event handlers to keep the torrent list up-to-date
        client.register_event_handler("TorrentAddedEvent",
                                      self.on_torrent_added_event)
        client.register_event_handler("TorrentRemovedEvent",
                                      self.on_torrent_removed_event)
Exemple #29
0
    def __init__(self):
        component.Component.__init__(self, 'PluginManager')
        self.config = ConfigManager('gtkui.conf')
        deluge.pluginmanagerbase.PluginManagerBase.__init__(
            self, 'gtkui.conf', 'deluge.plugin.gtkui')

        self.hooks = {'on_apply_prefs': [], 'on_show_prefs': []}

        client.register_event_handler('PluginEnabledEvent',
                                      self._on_plugin_enabled_event)
        client.register_event_handler('PluginDisabledEvent',
                                      self._on_plugin_disabled_event)
Exemple #30
0
    def __init__(self):
        if wnck:
            self.screen = wnck.screen_get_default()
        component.Component.__init__(self, 'MainWindow', interval=2)
        self.config = ConfigManager('gtkui.conf')
        self.main_builder = gtk.Builder()

        # Patch this GtkBuilder to avoid connecting signals from elsewhere
        #
        # Think about splitting up  mainwindow gtkbuilder file into the necessary parts
        # to avoid GtkBuilder monkey patch. Those parts would then need adding to mainwindow 'by hand'.
        self.gtk_builder_signals_holder = _GtkBuilderSignalsHolder()
        self.main_builder.prev_connect_signals = copy.deepcopy(self.main_builder.connect_signals)

        def patched_connect_signals(*a, **k):
            raise RuntimeError('In order to connect signals to this GtkBuilder instance please use '
                               '"component.get(\'MainWindow\').connect_signals()"')
        self.main_builder.connect_signals = patched_connect_signals

        # Get Gtk Builder files Main Window, New release dialog, and Tabs.
        for filename in ('main_window.ui', 'main_window.new_release.ui', 'main_window.tabs.ui',
                         'main_window.tabs.menu_file.ui', 'main_window.tabs.menu_peer.ui'):
            self.main_builder.add_from_file(
                resource_filename('deluge.ui.gtkui', os.path.join('glade', filename)))

        self.window = self.main_builder.get_object('main_window')
        self.window.set_icon(deluge.ui.gtkui.common.get_deluge_icon())
        self.vpaned = self.main_builder.get_object('vpaned')
        self.initial_vpaned_position = self.config['window_pane_position']

        # Keep a list of components to pause and resume when changing window state.
        self.child_components = ['TorrentView', 'StatusBar', 'TorrentDetails']

        # Load the window state
        self.load_window_state()

        # Keep track of window minimization state so we don't update UI when it is minimized.
        self.is_minimized = False
        self.restart = False

        self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0, 80)], ACTION_COPY)

        # Connect events
        self.window.connect('window-state-event', self.on_window_state_event)
        self.window.connect('configure-event', self.on_window_configure_event)
        self.window.connect('delete-event', self.on_window_delete_event)
        self.window.connect('drag-data-received', self.on_drag_data_received_event)
        self.vpaned.connect('notify::position', self.on_vpaned_position_event)
        self.window.connect('expose-event', self.on_expose_event)

        self.config.register_set_function('show_rate_in_title', self._on_set_show_rate_in_title, apply_now=False)

        client.register_event_handler('NewVersionAvailableEvent', self.on_newversionavailable_event)
    def __init__(self):
        component.Component.__init__(self, 'PluginManager')
        self.config = ConfigManager('gtkui.conf')
        deluge.pluginmanagerbase.PluginManagerBase.__init__(
            self, 'gtkui.conf', 'deluge.plugin.gtkui')

        self.hooks = {
            'on_apply_prefs': [],
            'on_show_prefs': []
        }

        client.register_event_handler('PluginEnabledEvent', self._on_plugin_enabled_event)
        client.register_event_handler('PluginDisabledEvent', self._on_plugin_disabled_event)
Exemple #32
0
    def enable(self):
        client.register_event_handler('PluginEnabledEvent', self._json.get_remote_methods)
        client.register_event_handler('PluginDisabledEvent', self._json.get_remote_methods)

        if client.is_standalone():
            component.get('Web.PluginManager').start()
        else:
            client.set_disconnect_callback(self._on_client_disconnect)
            default_host_id = component.get('DelugeWeb').config['default_daemon']
            if default_host_id:
                return self.connect(default_host_id)

        return defer.succeed(True)
Exemple #33
0
    def __init__(self, parent=None):
        QtGui.QStatusBar.__init__(self, parent)
        component.Component.__init__(self, "StatusBar", interval=3)

        self.status_not_connected = StatusBarItem(self,
                                                  text=_("Not Connected"),
                                                  toolTip=_("Not Connected"),
                                                  icon=IconLoader.themeIcon("network-offline"),
                                                  clicked=self._show_connection_dialog)
        self.status_connections = StatusBarItem(self,
                                                visible=False,
                                                toolTip=_("Connections"),
                                                icon=IconLoader.themeIcon("network-workgroup"),
                                                context_menu=component.get("MainWindow").menu_max_connections)
        self.status_download = StatusBarItem(self,
                                             visible=False,
                                             toolTip=_("Download Speed"),
                                             icon=IconLoader.customIcon("downloading16.png"),
                                             context_menu=component.get("MainWindow").menu_download_speed)
        self.status_upload = StatusBarItem(self,
                                           visible=False,
                                           toolTip=_("Upload Speed"),
                                           icon=IconLoader.customIcon("seeding16.png"),
                                           context_menu=component.get("MainWindow").menu_upload_speed)
        self.status_protocol = StatusBarItem(self,
                                             visible=False,
                                             toolTip=_("Protocol Traffic Download/Upload"),
                                             icon=IconLoader.customIcon("traffic16.png"),
                                             clicked=self._show_network_preferences)
        self.status_disk_space = StatusBarItem(self,
                                              visible=False,
                                              toolTip=_("Free Disk Space"),
                                              icon=IconLoader.themeIcon("drive-harddisk"),
                                              clicked=self._show_preferences)
        self.status_health = StatusBarItem(self,
                                           visible=False,
                                           text=_("No Incoming Connections!"),
                                           toolTip=_("No Incoming Connections!"),
                                           icon=IconLoader.themeIcon("dialog-error"),
                                           clicked=self._show_network_preferences)
        self.status_dht = StatusBarItem(self,
                                        visible=False,
                                        toolTip=_("DHT Nodes"),
                                        icon=IconLoader.customIcon("dht16.png"))

        self.status_items = self.findChildren(StatusBarItem)

        self.core_config = {}
        client.register_event_handler("ConfigValueChangedEvent", self.on_client_configvaluechanged)

        self._time_sent_recv = (time.time(), 0, 0)
Exemple #34
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 #35
0
    def enable(self):
        """Triggers when plugin is enabled."""
        self.glade = gtk.glade.XML(self.get_resource('config.glade'))

        self.tv_trackers = self.glade.get_widget('tv_tracker')
        self.ed_login = self.glade.get_widget('ed_login')
        self.ed_password = self.glade.get_widget('ed_password')

        component.get('Preferences').add_page(
            self.plugin_id, self.glade.get_widget('prefs_box'))
        pmanager = component.get('PluginManager')
        pmanager.register_hook('on_apply_prefs', self.on_apply_prefs)
        # TODO Cope with tv_tarckers repopulation on plugin reenable.
        pmanager.register_hook('on_show_prefs', self.on_show_prefs)
        self.add_context_menu_items()

        self.status_updator = LoopingCall(self.update_status_bar)
        self.status_updator.start(60)

        client.register_event_handler('UpdatorrUpdateDoneEvent',
                                      self.on_update_done_event)
        client.register_event_handler('UpdatorrErrorEvent',
                                      self.on_update_error_event)
        client.register_event_handler('UpdatorrUpdatesCheckStartedEvent',
                                      self.on_updates_started_event)
        client.register_event_handler('UpdatorrUpdatesCheckFinishedEvent',
                                      self.on_updates_finished_event)
Exemple #36
0
    def __init__(self):
        component.Component.__init__(self, 'StatusBar', interval=3)
        main_builder = component.get('MainWindow').get_builder()
        self.statusbar = main_builder.get_object('statusbar')
        self.config = ConfigManager('gtk3ui.conf')

        # Status variables that are updated via callback
        self.max_connections_global = -1
        self.num_connections = 0
        self.max_download_speed = -1.0
        self.download_rate = ''
        self.max_upload_speed = -1.0
        self.upload_rate = ''
        self.dht_nodes = 0
        self.dht_status = False
        self.health = False
        self.download_protocol_rate = 0.0
        self.upload_protocol_rate = 0.0

        self.config_value_changed_dict = {
            'max_connections_global': self._on_max_connections_global,
            'max_download_speed': self._on_max_download_speed,
            'max_upload_speed': self._on_max_upload_speed,
            'dht': self._on_dht,
        }
        self.current_warnings = []
        # Add hbox to the statusbar after removing the initial label widget
        self.hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, spacing=10)
        align = Gtk.Alignment()
        align.set_padding(2, 0, 3, 0)
        align.add(self.hbox)
        frame = self.statusbar.get_children()[0]
        frame.remove(frame.get_children()[0])
        frame.add(align)
        self.statusbar.show_all()
        # Create the not connected item
        self.not_connected_item = StatusBarItem(
            icon='network-offline-symbolic',
            text=_('Not Connected'),
            callback=self._on_notconnected_item_clicked,
        )
        # Show the not connected status bar
        self.show_not_connected()

        # Hide if necessary
        self.visible(self.config['show_statusbar'])

        client.register_event_handler(
            'ConfigValueChangedEvent', self.on_configvaluechanged_event
        )
Exemple #37
0
    def __init__(self, stdscr, encoding=None):

        self.batch_write = False
        self.lines = []

        # A list of strings to be displayed based on the offset (scroll)
        self.lines = []
        # The offset to display lines
        self.display_lines_offset = 0

        # Holds the user input and is cleared on 'enter'
        self.input = ""
        self.input_incomplete = ""
        # Keep track of where the cursor is
        self.input_cursor = 0
        # Keep a history of inputs
        self.input_history = []
        self.input_history_index = 0

        # Keep track of double-tabs
        self.tab_count = 0

        # Get a handle to the main console
        self.console = component.get("ConsoleUI")

        # show the cursor
        curses.curs_set(2)

        BaseMode.__init__(self, stdscr, encoding)

        # This gets fired once we have received the torrents list from the core
        self.started_deferred = defer.Deferred()

        # Maintain a list of (torrent_id, name) for use in tab completion
        self.torrents = []

        def on_session_state(result):
            def on_torrents_status(torrents):
                for torrent_id, status in torrents.items():
                    self.torrents.append((torrent_id, status["name"]))
                self.started_deferred.callback(True)

            client.core.get_torrents_status({"id": result}, ["name"]).addCallback(on_torrents_status)

        client.core.get_session_state().addCallback(on_session_state)

        # Register some event handlers to keep the torrent list up-to-date
        client.register_event_handler("TorrentAddedEvent", self.on_torrent_added_event)
        client.register_event_handler("TorrentRemovedEvent", self.on_torrent_removed_event)
Exemple #38
0
    def enable(self):
        self.create_prefs_page()

        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)

        self.status_item = component.get("StatusBar").add_item(
            image=get_resource("green.png"), text="", callback=self.on_status_item_clicked, tooltip="Scheduler"
        )

        def on_get_state(state):
            self.status_item.set_image_from_file(get_resource(state.lower() + ".png"))

        self.state_deferred = client.scheduler.get_state().addCallback(on_get_state)
        client.register_event_handler("SchedulerEvent", self.on_scheduler_event)
Exemple #39
0
    def __init__(self):
        if Wnck:
            self.screen = Wnck.Screen.get_default()
        component.Component.__init__(self, "MainWindow", interval=2)
        self.config = ConfigManager("gtkui.conf")
        # Get the glade file for the main window
        self.main_glade = Gtk.Builder()
        self.main_glade.add_from_file(
            pkg_resources.resource_filename("deluge.ui.gtkui",
                                            "builder/main_window.ui"))

        self.window_signals = {}

        self.window = self.main_glade.get_object("main_window")

        self.window.set_icon(common.get_deluge_icon())

        self.vpaned = self.main_glade.get_object("vpaned")
        self.initial_vpaned_position = self.config["window_pane_position"]

        # Load the window state
        self.load_window_state()

        # Keep track of window's minimization state so that we don't update the
        # UI when it is minimized.
        self.is_minimized = False

        self.window.drag_dest_set(
            Gtk.DestDefaults.ALL,
            [Gtk.TargetEntry.new('text/uri-list', 0, 80)], Gdk.DragAction.COPY)

        # Connect events
        self.window.connect("window-state-event", self.on_window_state_event)
        self.window.connect("configure-event", self.on_window_configure_event)
        self.window.connect("delete-event", self.on_window_delete_event)
        self.window.connect("drag-data-received",
                            self.on_drag_data_received_event)
        self.vpaned.connect("notify::position", self.on_vpaned_position_event)
        self.window.connect("draw", self.on_expose_event)

        self.config.register_set_function("show_rate_in_title",
                                          self._on_set_show_rate_in_title,
                                          apply_now=False)

        client.register_event_handler("NewVersionAvailableEvent",
                                      self.on_newversionavailable_event)
        client.register_event_handler("TorrentFinishedEvent",
                                      self.on_torrentfinished_event)
Exemple #40
0
    def enable(self):
        client.register_event_handler('PluginEnabledEvent',
                                      self._json.get_remote_methods)
        client.register_event_handler('PluginDisabledEvent',
                                      self._json.get_remote_methods)

        if client.is_standalone():
            component.get('Web.PluginManager').start()
        else:
            client.set_disconnect_callback(self._on_client_disconnect)
            default_host_id = component.get(
                'DelugeWeb').config['default_daemon']
            if default_host_id:
                return self.connect(default_host_id)

        return defer.succeed(True)
Exemple #41
0
 def _register_custom_provider(self, kind, eventtype, handler):
     if not self._handled_eventtype(eventtype, handler):
         return defer.succeed('Event not handled')
     if eventtype not in self.custom_notifications:
         def wrapper(*args, **kwargs):
             return self._handle_custom_providers(kind, eventtype, *args, **kwargs)
         self.custom_notifications[kind][eventtype] = (wrapper, handler)
     else:
         wrapper, handler = self.custom_notifications[kind][eventtype]
     try:
         component.get('EventManager').register_event_handler(
             eventtype, wrapper
         )
     except KeyError:
         from deluge.ui.client import client
         client.register_event_handler(eventtype, wrapper)
Exemple #42
0
    def __init__(self):
        component.Component.__init__(self, 'StatusBar', interval=3)
        main_builder = component.get('MainWindow').get_builder()
        self.statusbar = main_builder.get_object('statusbar')
        self.config = ConfigManager('gtkui.conf')

        # Status variables that are updated via callback
        self.max_connections_global = -1
        self.num_connections = 0
        self.max_download_speed = -1.0
        self.download_rate = ''
        self.max_upload_speed = -1.0
        self.upload_rate = ''
        self.dht_nodes = 0
        self.dht_status = False
        self.health = False
        self.download_protocol_rate = 0.0
        self.upload_protocol_rate = 0.0

        self.config_value_changed_dict = {
            'max_connections_global': self._on_max_connections_global,
            'max_download_speed': self._on_max_download_speed,
            'max_upload_speed': self._on_max_upload_speed,
            'dht': self._on_dht
        }
        self.current_warnings = []
        # Add a HBox to the statusbar after removing the initial label widget
        self.hbox = gtk.HBox()
        self.hbox.set_spacing(10)
        align = gtk.Alignment()
        align.set_padding(2, 0, 3, 0)
        align.add(self.hbox)
        frame = self.statusbar.get_children()[0]
        frame.remove(frame.get_children()[0])
        frame.add(align)
        self.statusbar.show_all()
        # Create the not connected item
        self.not_connected_item = StatusBarItem(
            stock=gtk.STOCK_STOP, text=_('Not Connected'),
            callback=self._on_notconnected_item_clicked)
        # Show the not connected status bar
        self.show_not_connected()

        # Hide if necessary
        self.visible(self.config['show_statusbar'])

        client.register_event_handler('ConfigValueChangedEvent', self.on_configvaluechanged_event)
Exemple #43
0
    def enable(self):
        self.create_prefs_page()

        component.get('PluginManager').register_hook('on_apply_prefs', self.on_apply_prefs)
        component.get('PluginManager').register_hook('on_show_prefs', self.on_show_prefs)
        self.statusbar = component.get('StatusBar')
        self.status_item = self.statusbar.add_item(
            image=get_resource('green.png'),
            text='',
            callback=self.on_status_item_clicked,
            tooltip='Scheduler')

        def on_state_deferred(state):
            self.state = state
            self.on_scheduler_event(state)
        client.scheduler.get_state().addCallback(on_state_deferred)
        client.register_event_handler('SchedulerEvent', self.on_scheduler_event)
Exemple #44
0
    def __init__(self):
        component.Component.__init__(self, "StatusBar", interval=3)
        self.window = component.get("MainWindow")
        self.statusbar = self.window.main_glade.get_widget("statusbar")
        self.config = ConfigManager("gtkui.conf")

        # Status variables that are updated via callback
        self.max_connections = -1
        self.num_connections = 0
        self.max_download_speed = -1.0
        self.download_rate = 0.0
        self.max_upload_speed = -1.0
        self.upload_rate = 0.0
        self.dht_nodes = 0
        self.dht_status = False
        self.health = False
        self.download_protocol_rate = 0.0
        self.upload_protocol_rate = 0.0

        self.config_value_changed_dict = {
            "max_connections_global": self._on_max_connections_global,
            "max_download_speed": self._on_max_download_speed,
            "max_upload_speed": self._on_max_upload_speed,
            "dht": self._on_dht
        }
        self.current_warnings = []
        # Add a HBox to the statusbar after removing the initial label widget
        self.hbox = gtk.HBox()
        self.hbox.set_spacing(10)
        frame = self.statusbar.get_children()[0]
        frame.remove(frame.get_children()[0])
        frame.add(self.hbox)
        self.statusbar.show_all()
        # Create the not connected item
        self.not_connected_item = StatusBarItem(
            stock=gtk.STOCK_STOP,
            text=_("Not Connected"),
            callback=self._on_notconnected_item_clicked)
        # Show the not connected status bar
        self.show_not_connected()

        # Hide if necessary
        self.visible(self.config["show_statusbar"])

        client.register_event_handler("ConfigValueChangedEvent",
                                      self.on_configvaluechanged_event)
Exemple #45
0
    def __init__(self):
        if wnck:
            self.screen = wnck.screen_get_default()
        component.Component.__init__(self, "MainWindow", interval=2)
        self.config = ConfigManager("gtkui.conf")
        # Get the glade file for the main window
        self.main_glade = gtk.glade.XML(
            pkg_resources.resource_filename("deluge.ui.gtkui",
                                            "glade/main_window.glade"))

        self.window = self.main_glade.get_widget("main_window")

        self.window.set_icon(common.get_deluge_icon())

        self.vpaned = self.main_glade.get_widget("vpaned")
        self.initial_vpaned_position = self.config["window_pane_position"]

        # Load the window state
        self.load_window_state()

        # Keep track of window's minimization state so that we don't update the
        # UI when it is minimized.
        self.is_minimized = False

        self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL,
                                  [('text/uri-list', 0, 80)],
                                  gtk.gdk.ACTION_COPY)

        # Connect events
        self.window.connect("window-state-event", self.on_window_state_event)
        self.window.connect("configure-event", self.on_window_configure_event)
        self.window.connect("delete-event", self.on_window_delete_event)
        self.window.connect("drag-data-received",
                            self.on_drag_data_received_event)
        self.vpaned.connect("notify::position", self.on_vpaned_position_event)
        self.window.connect("expose-event", self.on_expose_event)

        self.config.register_set_function("show_rate_in_title",
                                          self._on_set_show_rate_in_title,
                                          apply_now=False)

        client.register_event_handler("NewVersionAvailableEvent",
                                      self.on_newversionavailable_event)
        client.register_event_handler("TorrentFinishedEvent",
                                      self.on_torrentfinished_event)
Exemple #46
0
    def start(self):
        # This gets fired once we have received the torrents list from the core
        self.started_deferred = defer.Deferred()

        # Maintain a list of (torrent_id, name) for use in tab completion
        self.torrents = []
        def on_session_state(result):
            def on_torrents_status(torrents):
                for torrent_id, status in torrents.items():
                    self.torrents.append((torrent_id, status["name"]))
                self.started_deferred.callback(True)

            client.core.get_torrents_status({"id": result}, ["name"]).addCallback(on_torrents_status)
        client.core.get_session_state().addCallback(on_session_state)

        # Register some event handlers to keep the torrent list up-to-date
        client.register_event_handler("TorrentAddedEvent", self.on_torrent_added_event)
        client.register_event_handler("TorrentRemovedEvent", self.on_torrent_removed_event)
Exemple #47
0
    def start(self):
        # This gets fired once we have received the torrents list from the core
        self.started_deferred = defer.Deferred()

        # Maintain a list of (torrent_id, name) for use in tab completion
        self.torrents = []
        def on_session_state(result):
            def on_torrents_status(torrents):
                for torrent_id, status in torrents.items():
                    self.torrents.append((torrent_id, status["name"]))
                self.started_deferred.callback(True)

            client.core.get_torrents_status({"id": result}, ["name"]).addCallback(on_torrents_status)
        client.core.get_session_state().addCallback(on_session_state)

        # Register some event handlers to keep the torrent list up-to-date
        client.register_event_handler("TorrentAddedEvent", self.on_torrent_added_event)
        client.register_event_handler("TorrentRemovedEvent", self.on_torrent_removed_event)
Exemple #48
0
    def start(self):
        def on_session_state(result):
            self.torrents = []
            self.events = []

            def on_torrents_status(torrents):
                for torrent_id, status in torrents.items():
                    self.torrents.append((torrent_id, status['name']))
                self.started_deferred.callback(True)

            client.core.get_torrents_status({'id': result}, ['name']).addCallback(on_torrents_status)

        d = client.core.get_session_state().addCallback(on_session_state)

        # Register event handlers to keep the torrent list up-to-date
        client.register_event_handler('TorrentAddedEvent', self.on_torrent_added_event)
        client.register_event_handler('TorrentRemovedEvent', self.on_torrent_removed_event)
        return d
Exemple #49
0
    def __init__(self, config_key, values, parent=None, suffix="", custom_label=None, custom_max=None):
        QtGui.QActionGroup.__init__(self, parent)

        self.config_key = config_key
        self.custom_label = custom_label
        self.custom_max = custom_max
        self.value = None

        for value in values:
            self.addAction(
                QtGui.QAction(unicode(value) + suffix, self, checkable=True, triggered=self._value_triggered)
            ).setData(value)

        self.addAction(QtGui.QAction(_("Unlimited"), self, checkable=True, triggered=self._value_triggered)).setData(-1)
        self.addAction(QtGui.QAction(self)).setSeparator(True)
        self.custom_action = self.addAction(QtGui.QAction(_("Other..."), self, triggered=self._custom_triggered))

        client.register_event_handler("ConfigValueChangedEvent", self._client_configvaluechanged)
Exemple #50
0
    def __init__(self):
        component.Component.__init__(self, "StatusBar", interval=3)
        self.window = component.get("MainWindow")
        self.statusbar = self.window.main_glade.get_widget("statusbar")
        self.config = ConfigManager("gtkui.conf")

        # Status variables that are updated via callback
        self.max_connections = -1
        self.num_connections = 0
        self.max_download_speed = -1.0
        self.download_rate = 0.0
        self.max_upload_speed = -1.0
        self.upload_rate = 0.0
        self.dht_nodes = 0
        self.dht_status = False
        self.health = False
        self.download_protocol_rate = 0.0
        self.upload_protocol_rate = 0.0

        self.config_value_changed_dict = {
            "max_connections_global": self._on_max_connections_global,
            "max_download_speed": self._on_max_download_speed,
            "max_upload_speed": self._on_max_upload_speed,
            "dht": self._on_dht
        }
        self.current_warnings = []
        # Add a HBox to the statusbar after removing the initial label widget
        self.hbox = gtk.HBox()
        self.hbox.set_spacing(10)
        frame = self.statusbar.get_children()[0]
        frame.remove(frame.get_children()[0])
        frame.add(self.hbox)
        self.statusbar.show_all()
        # Create the not connected item
        self.not_connected_item = StatusBarItem(
            stock=gtk.STOCK_STOP, text=_("Not Connected"),
            callback=self._on_notconnected_item_clicked)
        # Show the not connected status bar
        self.show_not_connected()

        # Hide if necessary
        self.visible(self.config["show_statusbar"])

        client.register_event_handler("ConfigValueChangedEvent", self.on_configvaluechanged_event)
Exemple #51
0
    def enable(self):

        self.glade = gtk.glade.XML(get_resource("config.glade"))
        self.glade.signal_autoconnect({
            "on_add_button_clicked": self.on_add_button_clicked,
            "on_edit_button_clicked": self.on_edit_button_clicked,
            "on_remove_button_clicked": self.on_remove_button_clicked
        })
        self.opts_dialog = OptionsDialog()

        component.get("PluginManager").register_hook(
            "on_apply_prefs", self.on_apply_prefs
        )
        component.get("PluginManager").register_hook(
            "on_show_prefs", self.on_show_prefs
        )
        client.register_event_handler(
            "AutoaddOptionsChangedEvent", self.on_options_changed_event
        )

        self.watchdirs = {}

        vbox = self.glade.get_widget("watchdirs_vbox")
        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        vbox.pack_start(sw, True, True, 0)

        self.store = self.create_model()

        self.treeView = gtk.TreeView(self.store)
        self.treeView.connect("cursor-changed", self.on_listitem_activated)
        self.treeView.connect("row-activated", self.on_edit_button_clicked)
        self.treeView.set_rules_hint(True)

        self.create_columns(self.treeView)
        sw.add(self.treeView)
        sw.show_all()
        component.get("Preferences").add_page(
            "AutoAdd", self.glade.get_widget("prefs_box")
        )
        self.on_show_prefs()
Exemple #52
0
    def __init__(self):
        if Wnck:
            self.screen = Wnck.Screen.get_default()
        component.Component.__init__(self, "MainWindow", interval=2)
        self.config = ConfigManager("gtkui.conf")
        # Get the glade file for the main window
        self.main_glade = Gtk.Builder()
        self.main_glade.add_from_file(
                    pkg_resources.resource_filename("deluge.ui.gtkui",
                                                    "builder/main_window.ui"))

        self.window_signals = {}

        self.window = self.main_glade.get_object("main_window")

        self.window.set_icon(common.get_deluge_icon())

        self.vpaned = self.main_glade.get_object("vpaned")
        self.initial_vpaned_position = self.config["window_pane_position"]

        # Load the window state
        self.load_window_state()

        # Keep track of window's minimization state so that we don't update the
        # UI when it is minimized.
        self.is_minimized = False

        self.window.drag_dest_set(Gtk.DestDefaults.ALL, [Gtk.TargetEntry.new('text/uri-list', 0,
            80)], Gdk.DragAction.COPY)

        # Connect events
        self.window.connect("window-state-event", self.on_window_state_event)
        self.window.connect("configure-event", self.on_window_configure_event)
        self.window.connect("delete-event", self.on_window_delete_event)
        self.window.connect("drag-data-received", self.on_drag_data_received_event)
        self.vpaned.connect("notify::position", self.on_vpaned_position_event)
        self.window.connect("draw", self.on_expose_event)

        self.config.register_set_function("show_rate_in_title", self._on_set_show_rate_in_title, apply_now=False)

        client.register_event_handler("NewVersionAvailableEvent", self.on_newversionavailable_event)
        client.register_event_handler("TorrentFinishedEvent", self.on_torrentfinished_event)
Exemple #53
0
    def enable(self):
        self.create_prefs_page()

        component.get("PluginManager").register_hook("on_apply_prefs",
                                                     self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs",
                                                     self.on_show_prefs)
        self.statusbar = component.get("StatusBar")
        self.status_item = self.statusbar.add_item(
            image=get_resource("green.png"),
            text="",
            callback=self.on_status_item_clicked,
            tooltip="Scheduler")

        def on_state_deferred(state):
            self.state = state
            self.on_scheduler_event(state)

        client.scheduler.get_state().addCallback(on_state_deferred)
        client.register_event_handler("SchedulerEvent",
                                      self.on_scheduler_event)
Exemple #54
0
    def __init__(self):
        if wnck:
            self.screen = wnck.screen_get_default()
        component.Component.__init__(self, "MainWindow", interval=2)
        self.config = ConfigManager("gtkui.conf")
        # Get the glade file for the main window
        self.main_glade = gtk.glade.XML(
                    pkg_resources.resource_filename("deluge.ui.gtkui",
                                                    "glade/main_window.glade"))

        self.window = self.main_glade.get_widget("main_window")

        self.window.set_icon(common.get_deluge_icon())

        self.vpaned = self.main_glade.get_widget("vpaned")
        self.initial_vpaned_position = self.config["window_pane_position"]

        # Load the window state
        self.load_window_state()

        # Keep track of window's minimization state so that we don't update the
        # UI when it is minimized.
        self.is_minimized = False

        self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0,
            80)], gtk.gdk.ACTION_COPY)

        # Connect events
        self.window.connect("window-state-event", self.on_window_state_event)
        self.window.connect("configure-event", self.on_window_configure_event)
        self.window.connect("delete-event", self.on_window_delete_event)
        self.window.connect("drag-data-received", self.on_drag_data_received_event)
        self.vpaned.connect("notify::position", self.on_vpaned_position_event)
        self.window.connect("expose-event", self.on_expose_event)

        self.config.register_set_function("show_rate_in_title", self._on_set_show_rate_in_title, apply_now=False)

        client.register_event_handler("NewVersionAvailableEvent", self.on_newversionavailable_event)
        client.register_event_handler("TorrentFinishedEvent", self.on_torrentfinished_event)
Exemple #55
0
    def add_listener(self, listener_id, event):
        """
        Add a listener to the event queue.

        :param listener_id: A unique id for the listener
        :type listener_id: string
        :param event: The event name
        :type event: string
        """
        if event not in self.__events:

            def on_event(*args):
                for listener in self.__events[event]:
                    if listener not in self.__queue:
                        self.__queue[listener] = []
                    self.__queue[listener].append((event, args))

            client.register_event_handler(event, on_event)
            self.__handlers[event] = on_event
            self.__events[event] = [listener_id]
        elif listener_id not in self.__events[event]:
            self.__events[event].append(listener_id)
Exemple #56
0
    def enable(self):
        self.builder = gtk.Builder();
        self.builder.add_from_file(get_resource("config.ui"))
        self.builder.connect_signals({
                "on_button_clear_clicked": self.on_button_clear_clicked,
                });

        component.get("Preferences").add_page("TrafficLimits", self.builder.get_object("prefs_box"))
        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)

        self.status_item = component.get("StatusBar").add_item(
            image=get_resource("monitor.png"),
            text="",
            callback=self.on_status_item_clicked,
            tooltip="TrafficLimits plugin"
        )

        def on_get_state(state):
            self.set_status(*state)

        self.state_deferred = client.trafficlimits.get_state().addCallback(on_get_state)
        client.register_event_handler("TrafficLimitUpdate", self.on_trafficlimit_update)
Exemple #57
0
    def start(self):
        client.register_event_handler("TorrentStateChangedEvent", self.on_torrent_state_changed)
        client.register_event_handler("TorrentRemovedEvent", self.on_torrent_removed)
        client.register_event_handler("TorrentAddedEvent", self.on_torrent_added)

        def on_get_session_state(torrent_ids):
            for torrent_id in torrent_ids:
                # Let's at least store the torrent ids with empty statuses
                # so that upcoming queries or status updates don't throw errors.
                self.torrents.setdefault(torrent_id, [time.time(), {}])
                self.cache_times.setdefault(torrent_id, {})
        return client.core.get_session_state().addCallback(on_get_session_state)