Pause the TorrentDetails component when the window is minimized.
Clean up the pause/resume component code in mainwindow
This commit is contained in:
parent
04217e16d4
commit
4ae439a99a
|
@ -64,7 +64,7 @@ class MainWindow(component.Component):
|
||||||
self.window = self.main_glade.get_widget("main_window")
|
self.window = self.main_glade.get_widget("main_window")
|
||||||
|
|
||||||
self.window.set_icon(common.get_deluge_icon())
|
self.window.set_icon(common.get_deluge_icon())
|
||||||
|
|
||||||
self.vpaned = self.main_glade.get_widget("vpaned")
|
self.vpaned = self.main_glade.get_widget("vpaned")
|
||||||
self.initial_vpaned_position = self.config["window_pane_position"]
|
self.initial_vpaned_position = self.config["window_pane_position"]
|
||||||
|
|
||||||
|
@ -103,20 +103,14 @@ class MainWindow(component.Component):
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
try:
|
try:
|
||||||
component.resume("TorrentView")
|
self.resume_components()
|
||||||
component.resume("StatusBar")
|
|
||||||
component.resume("TorrentDetails")
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
component.pause("TorrentView")
|
self.pause_components()
|
||||||
component.get("TorrentView").save_state()
|
|
||||||
component.pause("StatusBar")
|
|
||||||
component.pause("TorrentDetails")
|
|
||||||
# Store the x, y positions for when we restore the window
|
# Store the x, y positions for when we restore the window
|
||||||
self.window_x_pos = self.window.get_position()[0]
|
self.window_x_pos = self.window.get_position()[0]
|
||||||
self.window_y_pos = self.window.get_position()[1]
|
self.window_y_pos = self.window.get_position()[1]
|
||||||
|
@ -130,15 +124,31 @@ class MainWindow(component.Component):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
component.resume("TorrentView")
|
self.resume_components()
|
||||||
component.resume("StatusBar")
|
|
||||||
component.resume("TorrentDetails")
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.window.present()
|
self.window.present()
|
||||||
self.load_window_state()
|
self.load_window_state()
|
||||||
|
|
||||||
|
def pause_components(self):
|
||||||
|
"""
|
||||||
|
Pause certain components. This is useful when the main window is not
|
||||||
|
being shown to reduce cpu usage.
|
||||||
|
"""
|
||||||
|
component.pause("TorrentView")
|
||||||
|
component.get("TorrentView").save_state()
|
||||||
|
component.pause("StatusBar")
|
||||||
|
component.pause("TorrentDetails")
|
||||||
|
|
||||||
|
def resume_components(self):
|
||||||
|
"""
|
||||||
|
Resumes components that are paused in `:meth:pause_components`.
|
||||||
|
"""
|
||||||
|
component.resume("TorrentView")
|
||||||
|
component.resume("StatusBar")
|
||||||
|
component.resume("TorrentDetails")
|
||||||
|
|
||||||
def active(self):
|
def active(self):
|
||||||
"""Returns True if the window is active, False if not."""
|
"""Returns True if the window is active, False if not."""
|
||||||
return self.window.is_active()
|
return self.window.is_active()
|
||||||
|
@ -181,14 +191,12 @@ 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.pause("TorrentView")
|
self.pause_components()
|
||||||
component.pause("StatusBar")
|
|
||||||
self.is_minimized = True
|
self.is_minimized = True
|
||||||
else:
|
else:
|
||||||
log.debug("MainWindow is not minimized..")
|
log.debug("MainWindow is not minimized..")
|
||||||
try:
|
try:
|
||||||
component.resume("TorrentView")
|
self.resume_components()
|
||||||
component.resume("StatusBar")
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.is_minimized = False
|
self.is_minimized = False
|
||||||
|
|
Loading…
Reference in New Issue