Exemple #1
0
 def restore():
     # Restore the proper x,y coords for the window prior to showing it
     component.resume(self.child_components)
     self.window.present()
     if GdkX11:
         self.window.get_window().set_user_time(self.get_timestamp())
     self.load_window_state()
Exemple #2
0
 def restore():
     # Restore the proper x,y coords for the window prior to showing it
     component.resume(self.child_components)
     timestamp = self.get_timestamp()
     if windowing('X11'):
         # Use present with X11 set_user_time since
         # present_with_time is inconsistent.
         self.window.present()
         self.window.get_window().set_user_time(timestamp)
     else:
         self.window.present_with_time(timestamp)
     self.load_window_state()
Exemple #3
0
 def on_window_state_event(self, widget, event):
     if event.changed_mask & WindowState.ICONIFIED:
         if event.new_window_state & WindowState.ICONIFIED:
             log.debug('MainWindow is minimized..')
             component.get('TorrentView').save_state()
             component.pause(self.child_components)
             self.is_minimized = True
         else:
             log.debug('MainWindow is not minimized..')
             component.resume(self.child_components)
             self.is_minimized = False
     return False
Exemple #4
0
    def set_mode(self, mode_name, refresh=False):
        log.debug('Setting console mode: %s', mode_name)
        mode = self.modes.get(mode_name, None)
        if mode is None:
            log.error('Non-existent mode requested: %s', mode_name)
            return
        self.stdscr.erase()

        if self.active_mode:
            self.active_mode.pause()
            d = component.pause([self.active_mode.mode_name])

            def on_mode_paused(result, mode, *args):
                from deluge.ui.console.widgets.popup import PopupsHandler

                if isinstance(mode, PopupsHandler):
                    if mode.popup is not None:
                        # If popups are not removed, they are still referenced in the memory
                        # which can cause issues as the popup's screen will not be destroyed.
                        # This can lead to the popup border being visible for short periods
                        # while the current modes' screen is repainted.
                        log.error(
                            'Mode "%s" still has popups available after being paused.'
                            ' Ensure all popups are removed on pause!',
                            mode.popup.title,
                        )

            d.addCallback(on_mode_paused, self.active_mode)
            reactor.removeReader(self.active_mode)

        self.active_mode = mode
        self.statusbars.screen = self.active_mode

        # The Screen object is designed to run as a twisted reader so that it
        # can use twisted's select poll for non-blocking user input.
        reactor.addReader(self.active_mode)
        self.stdscr.clear()

        if self.active_mode._component_state == 'Stopped':
            component.start([self.active_mode.mode_name])
        else:
            component.resume([self.active_mode.mode_name])

        mode.resume()
        if refresh:
            mode.refresh()
        return mode
Exemple #5
0
 def on_window_state_event(self, widget, event):
     if event.changed_mask & WINDOW_STATE_MAXIMIZED:
         if event.new_window_state & WINDOW_STATE_MAXIMIZED:
             log.debug('pos: %s', self.window.get_position())
             self.config['window_maximized'] = True
         elif not event.new_window_state & WINDOW_STATE_WITHDRAWN:
             self.config['window_maximized'] = False
     if event.changed_mask & WINDOW_STATE_ICONIFIED:
         if event.new_window_state & WINDOW_STATE_ICONIFIED:
             log.debug('MainWindow is minimized..')
             component.get('TorrentView').save_state()
             component.pause(self.child_components)
             self.is_minimized = True
         else:
             log.debug('MainWindow is not minimized..')
             component.resume(self.child_components)
             self.is_minimized = False
     return False
Exemple #6
0
    def set_mode(self, mode_name, refresh=False):
        log.debug('Setting console mode: %s', mode_name)
        mode = self.modes.get(mode_name, None)
        if mode is None:
            log.error('Non-existent mode requested: %s', mode_name)
            return
        self.stdscr.erase()

        if self.active_mode:
            self.active_mode.pause()
            d = component.pause([self.active_mode.mode_name])

            def on_mode_paused(result, mode, *args):
                from deluge.ui.console.widgets.popup import PopupsHandler
                if isinstance(mode, PopupsHandler):
                    if mode.popup is not None:
                        # If popups are not removed, they are still referenced in the memory
                        # which can cause issues as the popup's screen will not be destroyed.
                        # This can lead to the popup border being visible for short periods
                        # while the current modes' screen is repainted.
                        log.error('Mode "%s" still has popups available after being paused.'
                                  ' Ensure all popups are removed on pause!', mode.popup.title)
            d.addCallback(on_mode_paused, self.active_mode)
            reactor.removeReader(self.active_mode)

        self.active_mode = mode
        self.statusbars.screen = self.active_mode

        # The Screen object is designed to run as a twisted reader so that it
        # can use twisted's select poll for non-blocking user input.
        reactor.addReader(self.active_mode)
        self.stdscr.clear()

        if self.active_mode._component_state == 'Stopped':
            component.start([self.active_mode.mode_name])
        else:
            component.resume([self.active_mode.mode_name])

        mode.resume()
        if refresh:
            mode.refresh()
        return mode
Exemple #7
0
 def on_window_state_event(self, widget, event):
     if event.changed_mask & gtk.gdk.WINDOW_STATE_MAXIMIZED:
         if event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED:
             log.debug("pos: %s", self.window.get_position())
             self.config["window_maximized"] = True
         elif not event.new_window_state & gtk.gdk.WINDOW_STATE_WITHDRAWN:
             self.config["window_maximized"] = False
     if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
         if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
             log.debug("MainWindow is minimized..")
             component.pause("TorrentView")
             component.pause("StatusBar")
             self.is_minimized = True
         else:
             log.debug("MainWindow is not minimized..")
             try:
                 component.resume("TorrentView")
                 component.resume("StatusBar")
             except:
                 pass
             self.is_minimized = False
     return False
Exemple #8
0
 def on_window_state_event(self, widget, event):
     if event.changed_mask & gtk.gdk.WINDOW_STATE_MAXIMIZED:
         if event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED:
             log.debug("pos: %s", self.window.get_position())
             self.config["window_maximized"] = True
         elif not event.new_window_state & gtk.gdk.WINDOW_STATE_WITHDRAWN:
             self.config["window_maximized"] = False
     if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
         if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
             log.debug("MainWindow is minimized..")
             component.pause("TorrentView")
             component.pause("StatusBar")
             self.is_minimized = True
         else:
             log.debug("MainWindow is not minimized..")
             try:
                 component.resume("TorrentView")
                 component.resume("StatusBar")
             except:
                 pass
             self.is_minimized = False
     return False
Exemple #9
0
 def show(self):
     try:
         component.resume("TorrentView")
         component.resume("StatusBar")
         component.resume("TorrentDetails")
     except:
         pass
     self.window.show()
Exemple #10
0
 def show(self):
     try:
         component.resume("TorrentView")
         component.resume("StatusBar")
         component.resume("TorrentDetails")
     except:
         pass
     self.main_glade.connect_signals(self.window_signals)
     self.window.show()
Exemple #11
0
 def show(self):
     try:
         component.resume("TorrentView")
         component.resume("StatusBar")
         component.resume("TorrentDetails")
     except:
         pass
     self.main_glade.connect_signals(self.window_signals)
     self.window.show()
Exemple #12
0
    def present(self):
        # Restore the proper x,y coords for the window prior to showing it
        try:
            self.config["window_x_pos"] = self.window_x_pos
            self.config["window_y_pos"] = self.window_y_pos
        except:
            pass
        try:
            component.resume("TorrentView")
            component.resume("StatusBar")
            component.resume("TorrentDetails")
        except:
            pass

        self.window.present()
        self.load_window_state()
Exemple #13
0
    def present(self):
        # Restore the proper x,y coords for the window prior to showing it
        try:
            self.config["window_x_pos"] = self.window_x_pos
            self.config["window_y_pos"] = self.window_y_pos
        except:
            pass
        try:
            component.resume("TorrentView")
            component.resume("StatusBar")
            component.resume("TorrentDetails")
        except:
            pass

        self.window.present()
        self.load_window_state()
Exemple #14
0
 def _on_autoadd_enable(self, key, value):
     log.debug("_on_autoadd_enable")
     if value:
         component.resume("AutoAdd")
     else:
         component.pause("AutoAdd")
Exemple #15
0
        # for this torrent being generated before a Torrent object is created.
        component.pause("AlertManager")

        handle = None
        try:
            if magnet:
                handle = lt.add_magnet_uri(self.session, utf8_encoded(magnet), add_torrent_params)
            else:
                handle = self.session.add_torrent(add_torrent_params)
        except RuntimeError, e:
            log.warning("Error adding torrent: %s", e)

        if not handle or not handle.is_valid():
            log.debug("torrent handle is invalid!")
            # The torrent was not added to the session
            component.resume("AlertManager")
            return

        log.debug("handle id: %s", str(handle.info_hash()))
        # Set auto_managed to False because the torrent is paused
        handle.auto_managed(False)
        # Create a Torrent object
        torrent = Torrent(handle, options, state, filename, magnet)
        # Add the torrent object to the dictionary
        self.torrents[torrent.torrent_id] = torrent
        if self.config["queue_new_to_top"]:
            handle.queue_position_top()

        component.resume("AlertManager")

        # Resume the torrent if needed
Exemple #16
0
 def _on_autoadd_enable(self, key, value):
     log.debug("_on_autoadd_enable")
     if value:
         component.resume("AutoAdd")
     else:
         component.pause("AutoAdd")
Exemple #17
0
 def restore():
     # Restore the proper x,y coords for the window prior to showing it
     component.resume(self.child_components)
     self.window.present()
     self.load_window_state()
Exemple #18
0
 def show(self):
     component.resume(self.child_components)
     self.window.show()
Exemple #19
0
 def changeEvent(self, event):
     if event.type() == QtCore.QEvent.WindowStateChange:
         if self.isMinimized():
             component.pause(self._pause_components)
         else:
             component.resume(self._pause_components)
Exemple #20
0
 def _on_autoadd_location(self, key, value):
     log.debug("_on_autoadd_location")
     # We need to resume the component just incase it was paused due to
     # an invalid autoadd location.
     if self.config["autoadd_enable"]:
         component.resume("AutoAdd")
Exemple #21
0
 def changeEvent(self, event):
     if event.type() == QtCore.QEvent.WindowStateChange:
         if self.isMinimized():
             component.pause(self._pause_components)
         else:
             component.resume(self._pause_components)
Exemple #22
0
 def _on_autoadd_location(self, key, value):
     log.debug("_on_autoadd_location")
     # We need to resume the component just incase it was paused due to
     # an invalid autoadd location.
     if self.config["autoadd_enable"]:
         component.resume("AutoAdd")