Do not update UI when minimized or hidden.

This commit is contained in:
Andrew Resch 2008-01-30 12:56:50 +00:00
parent 2fba592e6c
commit 1653a72c7a
4 changed files with 35 additions and 13 deletions

1
TODO
View File

@ -13,7 +13,6 @@
* Add a health indication to the statusbar * Add a health indication to the statusbar
* Fix up preferences for when using a remote host.. the download folders, etc.. * Fix up preferences for when using a remote host.. the download folders, etc..
* Add decay items to statusbar.. items that will disappear after X seconds * Add decay items to statusbar.. items that will disappear after X seconds
* Do not update UI when minimized or hidden
* Add command line option to change config dir.. --config * Add command line option to change config dir.. --config
* Add method for plugins to add labels * Add method for plugins to add labels
* Add context menus for labels.. ie. setting options for all torrents in label * Add context menus for labels.. ie. setting options for all torrents in label

View File

@ -118,12 +118,15 @@ class ComponentRegistry:
def stop(self): def stop(self):
"""Stops all components""" """Stops all components"""
for component in self.components.keys(): for component in self.components.keys():
if self.components[component].get_state != \ self.stop_component(component)
COMPONENT_STATE.index("Stopped"):
log.debug("Stopping component %s..", component) def stop_component(self, component):
self.components[component].stop() if self.components[component].get_state != \
self.components[component]._stop() COMPONENT_STATE.index("Stopped"):
log.debug("Stopping component %s..", component)
self.components[component].stop()
self.components[component]._stop()
def update(self): def update(self):
"""Updates all components""" """Updates all components"""
for component in self.components.keys(): for component in self.components.keys():
@ -153,13 +156,19 @@ def register(name, obj, depend=None):
"""Registers a component with the registry""" """Registers a component with the registry"""
_ComponentRegistry.register(name, obj, depend) _ComponentRegistry.register(name, obj, depend)
def start(): def start(component=None):
"""Starts all components""" """Starts all components"""
_ComponentRegistry.start() if component == None:
_ComponentRegistry.start()
else:
_ComponentRegistry.start_component(component)
def stop(): def stop(component=None):
"""Stops all components""" """Stops all or specified components"""
_ComponentRegistry.stop() if component == None:
_ComponentRegistry.stop()
else:
_ComponentRegistry.stop_component(component)
def update(): def update():
"""Updates all components""" """Updates all components"""

View File

@ -1 +0,0 @@
2679

View File

@ -77,11 +77,19 @@ class MainWindow(component.Component):
self.show() self.show()
def show(self): def show(self):
try:
component.get("TorrentView").start()
component.get("StatusBar").start()
except:
pass
# Load the state prior to showing # Load the state prior to showing
self.load_window_state() self.load_window_state()
self.window.show() self.window.show()
def hide(self): def hide(self):
component.stop("TorrentView")
component.stop("StatusBar")
self.window.hide() self.window.hide()
def present(self): def present(self):
@ -128,9 +136,16 @@ class MainWindow(component.Component):
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED: if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED: if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
log.debug("MainWindow is minimized..") log.debug("MainWindow is minimized..")
component.stop("TorrentView")
component.stop("StatusBar")
self.is_minimized = True self.is_minimized = True
else: else:
log.debug("MainWindow is not minimized..") log.debug("MainWindow is not minimized..")
try:
component.start("TorrentView")
component.start("StatusBar")
except:
pass
self.is_minimized = False self.is_minimized = False
return False return False