mmxbass 2 Light Poster

How can I make my pygtk windows switch to another workspace. I'm working on a box-oriented task selector and I need my boxes to follow windows to their new workspaces when they change workspace.

This is my code thus far:

import wnck
import pygtk
pygtk.require('2.0')

import gtk
import gobject
#import os

def run():
	screen = wnck.screen_get_default()
	screen.force_update()
	for w in screen.get_windows():
		spawnw(screen, w)
	screen.connect("window-opened", spawnw)
	gtk.main()

def spawnw(screen, window):
	if window.get_window_type() == 0:
		boxlet(window)

class boxlet:

	def on_button_press(self, widget, event):
		self.appw.set_icon_geometry(self.window.get_position()[0],self.window.get_position()[1],self.window.get_size()[0],self.window.get_size()[1])
		if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
			if self.appw.is_minimized():
				self.appw.unminimize(event.time)
			else:
				self.appw.minimize()
		elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
			mnuw = wnck.create_window_action_menu(self.appw)
			mnuw.popup(None, None, None, event.button, event.time, event)
		elif event.button == 1:
			self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
	
	def winclose_event(self, screen, window):
		if self.appw.get_xid() == window.get_xid():
			self.window.destroy()
			return True
		return False
	
	def winspace_event(self, window):
		if window.is_pinned():
			self.window.stick()
		else:
			self.window.unstick()
		print "do something"
	
	def __init__(self, appw):
		self.appw = appw
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.window.set_geometry_hints(None,64,64,64,64,64,64,0,0,1,1)
		self.window.set_decorated(False)
		self.window.set_keep_below(True)
		self.window.set_gravity(gtk.gdk.GRAVITY_CENTER)
		self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLBAR)
		
		self.appw.set_icon_geometry(self.window.get_position()[0],self.window.get_position()[1],self.window.get_size()[0],self.window.get_size()[1])
		
		self.window.add_events(gtk.gdk.BUTTON_PRESS_MASK)
		self.window.add_events(gtk.gdk._2BUTTON_PRESS)
		self.window.connect("button-press-event", self.on_button_press)
		
		self.appw.get_screen().connect("window-closed", self.winclose_event)
		self.appw.connect("workspace-changed", self.winspace_event)
		
		self.window.set_app_paintable(True)
		self.window.realize()
		
		self.boxbg = gtk.Image()
		self.boxbg.set_from_file("tile.xpm")
		
		self.image = gtk.Image()
		self.image.set_from_pixbuf(appw.get_icon())
		self.window.add(self.image)
		self.image.show()
		
		self.window.window.set_back_pixmap(self.boxbg.get_pixbuf().render_pixmap_and_mask()[0] , False) 
		
		self.window.show()

if __name__ == "__main__":
	run()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.