I am trying to make a box-oriented task selector similar to the style of nextstep. I am currently having problems painting the box background and application icon onto my window.
If I just use a normal gtk.Image widget it works fine, but that won't let me have both the box background AND the program icon. So I'm trying to get it to just paint the icon over the box background but the damn thing just won't paint.
Am I missing something here or better yet, is there an easier less-crazy way to do this?
The forums won't me upload tile.xpm, it is just a 64x64 xpm file that I borrowed from the windowmaker artwork.
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:
print window.get_name()
box = boxlet(window)
boxbg = gtk.Image()
boxbg.set_from_file("tile.xpm")
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 delete_event(self, widget, event, data=None):
print "delete event occurred"
return False
def destroy(self, widget, data=None):
print "destroy signal occurred"
gtk.main_quit()
def __init__(self, appw):
self.appw = appw
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
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.pix = gtk.DrawingArea()
self.pix.set_size_request(64, 64)
self.window.add(self.pix)
self.pix.realize()
self.window.realize()
self.pix.window.draw_pixbuf(None, boxbg.get_pixbuf(), 0, 0, 0, 0, -1, -1, gtk.gdk.RGB_DITHER_NONE, 0, 0)
self.pix.window.draw_pixbuf(self.pix.get_style().white_gc, appw.get_icon(), 0, 0, 0, 0, -1, -1, gtk.gdk.RGB_DITHER_NONE, 0, 0)
self.pix.show()
self.window.show()
if __name__ == "__main__":
run()