X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Ficongrid.py;h=96588d58b2cf9927e19f3223a0a1479170afa1ec;hb=6cf311bec98c1ccc0cf512ead71526e1ab223085;hp=e90bd9dc9f5abd8baa8f547e8fd9436432065cd4;hpb=2ce2f31557eb98311c886f58d0c9da1dd45897b6;p=drlaunch diff --git a/src/icongrid.py b/src/icongrid.py index e90bd9d..96588d5 100755 --- a/src/icongrid.py +++ b/src/icongrid.py @@ -34,7 +34,7 @@ import time from portrait import FremantleRotation #from xdg.IconTheme import getIconPath -#import config +from config import dump import apps import icon from icon import Icon @@ -46,10 +46,18 @@ from icons import Icons # # return(ret) +# IconGrid is the main class that implements tha drawing of the grid +# However, since it will be used both by the desktop plugin and the +# configuration window, it cannot derive either gtk.Widget or HomePluginItem. +# It is created here in a way that will allow it to work on both cases +# and it is inherited by appropriate classes (one for the plugin and one +# for the config widget) + #class IconGrid(gtk.Widget, FremantleRotation): -class IconGrid(object): #(gobject.GObject): +class IconGrid: #(gobject.GObject): def __init__(self, isconfig=False): # self.__gobject_init__() +# gtk.Widget.__init__(self) self.init_done=False @@ -72,19 +80,46 @@ class IconGrid(object): #(gobject.GObject): # Duration of the rotation effect self.rotation_time=0.8 +# print "ig-init" + +# def __del__(self): +# print "ig-del" + def do_realize(self, config): +# print "ig-realize" self.config=config + if self.icons!=None: + print + print + print + print "WTF??????????????????????" + print + print + print + self.icons=Icons(self.isconfig, self.config) + #print "self:", self + #self.icons.set_parent(self) self.setMode('l') self.setSize(config.getMaxSize()) self.reloadIcons() + def do_unrealize(self): +# print "ig-unrealize" + self.config=None + self.icons.finish() + self.icons=None + self.lasticon=None + def connect(self, what, *args): - if what in icon.signals: - self.icons.connect(what, *args) + if what in Icon.gsignals.keys(): + ret=self.icons.connect(what, *args) else: - super(IconGrid, self).connect(what, *args) + ret=gobject.GObject.connect(self, what, *args) + #ret=super(IconGrid, self).connect(what, *args) + + return(ret) def setSize(self, size): self.size=size @@ -96,7 +131,7 @@ class IconGrid(object): #(gobject.GObject): def setMode(self, mode): if self.mode==mode: - print "same mode" +# print "same mode" return self.mode=mode @@ -331,6 +366,7 @@ class IconGrid(object): #(gobject.GObject): def reloadIcons(self): self.icons.load() + self.lasticon=None # def on_orientation_changed(self, orientation): # print "orch:", orientation @@ -351,6 +387,11 @@ class IconGridWidget(IconGrid, gtk.Widget): self.setSize(self.size) +# print "igw-init" + +# def __del__(self): +# print "igw-del" + def setSize(self, size): IconGrid.setSize(self, size) @@ -360,12 +401,15 @@ class IconGridWidget(IconGrid, gtk.Widget): self.set_size_request(w, h) def reconfig(self): + self.clearBgCache() + self.clearAnimationCache() self.reloadIcons() self.setSize(self.size) self.icons.resizeMax() self.queue_draw() def do_realize(self): +# print "igw-realize" screen=self.get_screen() self.set_colormap(screen.get_rgba_colormap()) self.set_app_paintable(True) @@ -388,9 +432,21 @@ class IconGridWidget(IconGrid, gtk.Widget): | gdk.LEAVE_NOTIFY_MASK ) self.window.set_user_data(self) - self.style.attach(self.window) -# self.style.set_background(self.window, gtk.STATE_NORMAL) + # No matter what the pygtk widget demo says, this is NOT CORRECT!!! + # Don't call style.attach(self.window) or else the program will crash + # after some time! It seems that there is a style already. + # If we want to use the style the we use get_style() instead. + # This one was very hard to solve. Thanks to gnome2-globalmenu guys. + # It was solved by looking the commit 2666: + # see: + # svn diff -r2665:2666 http://gnome2-globalmenu.googlecode.com/svn/trunk + # which solved cse 490: + # http://code.google.com/p/gnome2-globalmenu/issues/detail?id=490 +# self.style.attach(self.window) + style=self.get_style() + +# style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) # self.pixmap, mask = gtk.gdk.pixmap_create_from_xpm_d( @@ -398,7 +454,6 @@ class IconGridWidget(IconGrid, gtk.Widget): # self.gc = self.style.fg_gc[gtk.STATE_NORMAL] - #gtk.Widget.do_realize(self) #HomePluginItem.do_realize(self) # screen=self.get_screen() @@ -406,8 +461,24 @@ class IconGridWidget(IconGrid, gtk.Widget): # self.set_app_paintable(True) def do_unrealize(self): - #self.window.set_user_data(None) +# print "igw-unrealize", self + IconGrid.do_unrealize(self) self.window.destroy() + self.window.set_user_data(None) + + def do_expose_event(self, event): + cr=self.window.cairo_create() + + cr.rectangle(event.area.x, event.area.y, + event.area.width, event.area.height) + cr.clip() + + style=self.get_style() + col=style.bg[gtk.STATE_NORMAL] + cr.set_source_color(col) + cr.paint() + + IconGrid.do_expose_event(self, event) #gobject.type_register(IconGrid) gobject.type_register(IconGridWidget)