@@ -0,0 +1,224 @@
+diff -Nuar virt-manager-0.5.3.orig/src/virtManager/config.py virt-manager-0.5.3/src/virtManager/config.py
+--- virt-manager-0.5.3.orig/src/virtManager/config.py 2008-02-20 10:23:45.000000000 -0700
++++ virt-manager-0.5.3/src/virtManager/config.py 2008-02-20 10:58:37.000000000 -0700
+@@ -172,6 +172,8 @@
+ return 10
+ return history
+
++ def get_stats_minimize_minutes(self):
++ return self.conf.get_int(self.conf_dir + "/stats/minimize-minutes")
+
+ def set_stats_update_interval(self, interval):
+ self.conf.set_int(self.conf_dir + "/stats/update-interval", interval)
+@@ -179,6 +181,8 @@
+ def set_stats_history_length(self, length):
+ self.conf.set_int(self.conf_dir + "/stats/history-length", length)
+
++ def set_stats_minimize_minutes(self, minutes):
++ self.conf.set_int(self.conf_dir + "/stats/minimize-minutes", minutes)
+
+ def on_stats_update_interval_changed(self, callback):
+ self.conf.notify_add(self.conf_dir + "/stats/update-interval", callback)
+@@ -186,6 +190,9 @@
+ def on_stats_history_length_changed(self, callback):
+ self.conf.notify_add(self.conf_dir + "/stats/history-length", callback)
+
++ def on_stats_minimize_minutes_changed(self, callback):
++ self.conf.notify_add(self.conf_dir + "/stats/minimize-minutes", callback)
++
+ def on_console_popup_changed(self, callback):
+ self.conf.notify_add(self.conf_dir + "/console/popup", callback)
+
+diff -Nuar virt-manager-0.5.3.orig/src/virtManager/connection.py virt-manager-0.5.3/src/virtManager/connection.py
+--- virt-manager-0.5.3.orig/src/virtManager/connection.py 2008-02-20 10:23:45.000000000 -0700
++++ virt-manager-0.5.3/src/virtManager/connection.py 2008-02-20 11:53:08.000000000 -0700
+@@ -469,7 +469,7 @@
+ os.remove(frm)
+ return status
+
+- def tick(self, noStatsUpdate=False):
++ def tick(self, noStatsUpdate=False, sleeping=False):
+ if self.state != self.STATE_ACTIVE:
+ return
+
+@@ -490,11 +490,12 @@
+ logging.warn("Unable to list inactive networks")
+
+ # check of net devices
+- newPaths = []
+- if self.hal_iface:
+- newPaths = self.hal_iface.FindDeviceByCapability("net")
+- for newPath in newPaths:
+- self._device_added(newPath)
++ if sleeping == False:
++ newPaths = []
++ if self.hal_iface:
++ newPaths = self.hal_iface.FindDeviceByCapability("net")
++ for newPath in newPaths:
++ self._device_added(newPath)
+
+ for name in newActiveNetNames:
+ net = self.vmm.networkLookupByName(name)
+diff -Nuar virt-manager-0.5.3.orig/src/virtManager/engine.py virt-manager-0.5.3/src/virtManager/engine.py
+--- virt-manager-0.5.3.orig/src/virtManager/engine.py 2008-02-20 10:23:45.000000000 -0700
++++ virt-manager-0.5.3/src/virtManager/engine.py 2008-02-20 11:51:52.000000000 -0700
+@@ -149,7 +149,11 @@
+ def _tick(self):
+ for uri in self.connections.keys():
+ try:
+- self.connections[uri]["connection"].tick()
++ if self.windowManager != None:
++ sleeping= self.windowManager.timewatch.process_clock(self.windowManager.window.get_widget("vmm-manager"))
++ else:
++ sleeping= False
++ self.connections[uri]["connection"].tick(sleeping = sleeping)
+ except KeyboardInterrupt:
+ raise KeyboardInterrupt
+ except:
+diff -Nuar virt-manager-0.5.3.orig/src/virtManager/manager.py virt-manager-0.5.3/src/virtManager/manager.py
+--- virt-manager-0.5.3.orig/src/virtManager/manager.py 2008-02-20 10:23:45.000000000 -0700
++++ virt-manager-0.5.3/src/virtManager/manager.py 2008-02-20 12:11:22.000000000 -0700
+@@ -33,6 +33,8 @@
+ from virtManager.asyncjob import vmmAsyncJob
+ from virtManager.error import vmmErrorDialog
+
++import timex
++
+ VMLIST_SORT_ID = 1
+ VMLIST_SORT_NAME = 2
+ VMLIST_SORT_CPU_USAGE = 3
+@@ -101,6 +103,14 @@
+ self.connections = {}
+ self.prepare_vmlist()
+
++ self.timewatch= timex.timex()
++ if self.config.get_stats_minimize_minutes() == -1:
++ logging.debug("minimize_minutes value unset - defaulting to 120")
++ self.config.set_stats_minimize_minutes(120)
++ self.timewatch.set_timeout_minutes(self.config.get_stats_minimize_minutes())
++ self.config.on_stats_minimize_minutes_changed(self.reschedule_minimize)
++ logging.debug("minimize_minutes set to %s" % str(self.config.get_stats_minimize_minutes()))
++
+ self.config.on_vmlist_domain_id_visible_changed(self.toggle_domain_id_visible_widget)
+ self.config.on_vmlist_status_visible_changed(self.toggle_status_visible_widget)
+ self.config.on_vmlist_cpu_usage_visible_changed(self.toggle_cpu_usage_visible_widget)
+@@ -232,6 +242,15 @@
+ "on_menu_help_activate": self.show_help,
+ })
+
++ self.window.get_widget("vmm-manager" ).connect("window_state_event",self.timewatch.handle_window_state_event)
++ self.window.get_widget("vm-list" ).connect("button_press_event",self.timewatch.handle_reset_clock_event )
++ widget= self.window.get_widget("vmm-manager")
++ self.window.get_widget("vm-new" ).connect("clicked" ,self.timewatch.handle_reset_clock_event, widget )
++ self.window.get_widget("vm-open" ).connect("clicked" ,self.timewatch.handle_reset_clock_event, widget )
++ self.window.get_widget("vm-details" ).connect("clicked" ,self.timewatch.handle_reset_clock_event, widget )
++ self.window.get_widget("vm-delete" ).connect("clicked" ,self.timewatch.handle_reset_clock_event, widget )
++ self.window.get_widget("menu_edit_details" ).connect("activate" ,self.timewatch.handle_reset_clock_event, widget )
++
+ self.vm_selected(None)
+ self.window.get_widget("vm-list").get_selection().connect("changed", self.vm_selected)
+
+@@ -481,6 +500,9 @@
+
+
+ def vm_resources_sampled(self, vm):
++ if self.timewatch.process_clock(self.window.get_widget("vmm-manager")):
++ return
++
+ vmlist = self.window.get_widget("vm-list")
+ model = vmlist.get_model()
+
+@@ -519,6 +541,9 @@
+
+
+ def conn_refresh_resources(self, conn):
++ if self.timewatch.process_clock(self.window.get_widget("vmm-manager")):
++ return
++
+ vmlist = self.window.get_widget("vm-list")
+ model = vmlist.get_model()
+ row = self.rows[conn.get_uri()]
+@@ -1039,6 +1064,10 @@
+ dg.hide()
+ dg.destroy()
+
++ def reschedule_minimize(self,ignore1,ignore2,ignore3,ignore4):
++ self.timewatch.set_timeout_minutes(self.config.get_stats_minimize_minutes())
++ logging.debug("minimize_minutes rescheduled to %s" % str(self.config.get_stats_minimize_minutes()))
++
+ def _err_dialog(self, summary, details):
+ dg = vmmErrorDialog(None, 0, gtk.MESSAGE_ERROR,
+ gtk.BUTTONS_CLOSE, summary, details)
+diff -Nuar virt-manager-0.5.3.orig/src/virtManager/timex.py virt-manager-0.5.3/src/virtManager/timex.py
+--- virt-manager-0.5.3.orig/src/virtManager/timex.py 1969-12-31 17:00:00.000000000 -0700
++++ virt-manager-0.5.3/src/virtManager/timex.py 2008-02-20 10:24:05.000000000 -0700
+@@ -0,0 +1,44 @@
++import gtk
++import time
++
++class timex:
++
++ def __init__(self):
++ self.iconify_adjust_minutes= 0
++ self.iconify_time= 0
++ self.iconified= False
++ self.widgets = {}
++
++ # call with minutes= 0 to stop timer
++ def set_timeout_minutes(self,minutes):
++ self.iconify_adjust_minutes= minutes
++ if self.iconify_adjust_minutes == 0:
++ self.iconify_time= 0
++
++ def reset_clock(self):
++ if self.iconify_adjust_minutes:
++ self.iconify_time= time.time() + (self.iconify_adjust_minutes*60)
++
++ def handle_reset_clock_event(self,widget,event):
++ self.reset_clock()
++
++ def handle_window_state_event(self,widget,event):
++ new_state = event.new_window_state
++ if new_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
++ self.widgets[widget.get_name()]= True
++ else:
++ self.widgets[widget.get_name()] = False
++ self.reset_clock()
++
++ # return True if caller should skip processing
++ def process_clock(self,widget):
++ if self.widgets.has_key(widget.get_name()):
++ if self.widgets[widget.get_name()] == True:
++ return True
++ if self.iconify_time == 0:
++ return False
++ if time.time() <= self.iconify_time:
++ return False
++ widget.iconify()
++ return True
++
|