Author: andar

Revision: 5845

Log:
        Pause the TorrentDetails component when the window is minimized.
Clean up the pause/resume component code in mainwindow

Diff:
Modified: trunk/deluge/ui/gtkui/mainwindow.py
===================================================================
--- trunk/deluge/ui/gtkui/mainwindow.py 2009-10-13 16:21:28 UTC (rev 5844)
+++ trunk/deluge/ui/gtkui/mainwindow.py 2009-10-14 15:49:55 UTC (rev 5845)
@@ -64,7 +64,7 @@
         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"]
 
@@ -103,20 +103,14 @@
 
     def show(self):
         try:
-            component.resume("TorrentView")
-            component.resume("StatusBar")
-            component.resume("TorrentDetails")
+            self.resume_components()
         except:
             pass
 
         self.window.show()
 
-
     def hide(self):
-        component.pause("TorrentView")
-        component.get("TorrentView").save_state()
-        component.pause("StatusBar")
-        component.pause("TorrentDetails")
+        self.pause_components()
         # Store the x, y positions for when we restore the window
         self.window_x_pos = self.window.get_position()[0]
         self.window_y_pos = self.window.get_position()[1]
@@ -130,15 +124,31 @@
         except:
             pass
         try:
-            component.resume("TorrentView")
-            component.resume("StatusBar")
-            component.resume("TorrentDetails")
+            self.resume_components()
         except:
             pass
 
         self.window.present()
         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):
         """Returns True if the window is active, False if not."""
         return self.window.is_active()
@@ -181,14 +191,12 @@
         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.pause_components()
                 self.is_minimized = True
             else:
                 log.debug("MainWindow is not minimized..")
                 try:
-                    component.resume("TorrentView")
-                    component.resume("StatusBar")
+                    self.resume_components()
                 except:
                     pass
                 self.is_minimized = False



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to