from portrait import FremantleRotation
#from xdg.IconTheme import getIconPath
-#import config
+from config import dump
import apps
import icon
from icon import Icon
#
# 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
# 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((8,4))
+ 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
def setMode(self, mode):
if self.mode==mode:
- print "same mode"
+# print "same mode"
return
self.mode=mode
def iconAt(self, x, y):
""" Get icon at coordinates x,y. X and Y are in pixels """
- w=self.config.iconsize + self.config.iconspace
+ w=self.config.getIconSizeFull()
if self.mode=='l' or self.config.getIndiv():
x2=int(x / w)
def _draw(self, cr, event):
self.draw_pending=False
- w=self.config.iconsize + self.config.iconspace
+ w=self.config.getIconSizeFull()
for x,y in self.icons:
if self.mode=='l' or self.config.getIndiv():
- x2=x * (self.config.iconsize + self.config.iconspace)
- y2=y * (self.config.iconsize + self.config.iconspace)
+ #x2=x * (self.config.iconsize + self.config.iconspace)
+ #y2=y * (self.config.iconsize + self.config.iconspace)
+ x2=x * self.config.getIconSizeFull()
+ y2=y * self.config.getIconSizeFull()
else:
- x2=y * (self.config.iconsize + self.config.iconspace)
- y2=(self.size[1]-x-1) * \
- (self.config.iconsize + self.config.iconspace)
+ #x2=y * (self.config.iconsize + self.config.iconspace)
+ #y2=(self.size[1]-x-1) * \
+ # (self.config.iconsize + self.config.iconspace)
+ x2=y * self.config.getIconSizeFull()
+ y2=(self.size[1]-x-1) * self.config.getIconSizeFull()
# Only repaint the needed icons
rect=gdk.Rectangle(x2, y2, w, w)
ic=self.icons.get(x,y)
ic.clearAnimationCache()
+ def clearBgCache(self):
+ """ Clear backgrounds cache """
+ for x,y in self.icons:
+ ic=self.icons.get(x,y)
+ ic.clearBgCache()
+
def do_expose_event(self, event):
cr=self.window.cairo_create()
def reloadIcons(self):
self.icons.load()
+ self.lasticon=None
# def on_orientation_changed(self, orientation):
# print "orch:", orientation
self.setSize(self.size)
+# print "igw-init"
+
+# def __del__(self):
+# print "igw-del"
+
def setSize(self, size):
IconGrid.setSize(self, size)
- w=self.size[0] * (self.config.iconsize + self.config.iconspace)
- h=self.size[1] * (self.config.iconsize + self.config.iconspace)
+ w=self.size[0] * self.config.getIconSizeFull()
+ h=self.size[1] * self.config.getIconSizeFull()
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)
| 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(
# self.gc = self.style.fg_gc[gtk.STATE_NORMAL]
- #gtk.Widget.do_realize(self)
#HomePluginItem.do_realize(self)
# screen=self.get_screen()
# 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)