[kupfer] windows: Make workspaces non-dynamic



commit 5f44ea78a1a15da66704a39b2becc465d8836399
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Jan 8 02:25:42 2010 +0100

    windows: Make workspaces non-dynamic

 kupfer/plugin/windows.py |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/windows.py b/kupfer/plugin/windows.py
index 20b7733..6d42031 100644
--- a/kupfer/plugin/windows.py
+++ b/kupfer/plugin/windows.py
@@ -2,6 +2,7 @@ import gtk
 
 from kupfer.objects import Leaf, Action, Source
 from kupfer.ui import keybindings
+from kupfer.helplib import gobject_connect_weakly, PicklingHelperMixin
 
 __kupfer_name__ = _("Window List")
 __kupfer_sources__ = ("WindowsSource", "WorkspacesSource", )
@@ -214,14 +215,23 @@ class ActivateWorkspace (Action):
 		return "gtk-jump-to-ltr"
 
 
-class WorkspacesSource (Source):
+class WorkspacesSource (Source, PicklingHelperMixin):
 	def __init__(self):
 		Source.__init__(self, _("Workspaces"))
 		screen = wnck.screen_get_default()
 		screen.get_workspaces()
 
-	def is_dynamic(self):
-		return True
+	def pickle_prepare(self):
+		self.mark_for_update()
+
+	def initialize(self):
+		screen = wnck.screen_get_default()
+		gobject_connect_weakly(screen, "workspace-created", self._changed)
+		gobject_connect_weakly(screen, "workspace-destroyed", self._changed)
+
+	def _changed(self, screen, workspace):
+		self.mark_for_update()
+
 	def get_items(self):
 		# wnck should be "primed" now to return the true list
 		screen = wnck.screen_get_default()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]