It works! :-)
[drlaunch] / icongrid.py
index 4502207..1308bb0 100755 (executable)
@@ -52,6 +52,8 @@ class IconGrid(object):       #(gobject.GObject):
     def __init__(self, isconfig=False):
 #      self.__gobject_init__()
 
+       self.size=0
+
        self.isconfig=isconfig
 
        self.icons=Icons(isconfig)
@@ -59,14 +61,16 @@ class IconGrid(object):     #(gobject.GObject):
        self.setMode('l')
 
        # Maybe fix those:
-       w=config.size * config.iconsize + (config.size) * config.iconspace
+#      w=(config.getSize() * config.iconsize) + \
+#          (config.getSize()) * config.iconspace
        #self.set_size_request(w, w)
 
-       self.icons.setSize(config.size)
+#      self.setSize(config.getSize())
+       self.setSize(4)
 
        self.lasticon=None  # The last icon that got selected
 
-       self.icons.load()
+       self.reloadIcons()
 
     def connect(self, what, *args):
        if what in icon.signals:
@@ -74,9 +78,16 @@ class IconGrid(object):      #(gobject.GObject):
        else:
            super(IconGrid, self).connect(what, *args)
 
+    def setSize(self, size):
+       print "igw::setSize", size
+#      config.setSize(size)
+       self.size=size
+       self.icons.setSize(size)
+
     def setMode(self, mode):
        self.mode=mode
-       self.queue_draw()
+       if isinstance(self, gtk.Widget):
+           self.queue_draw()
 
     def iconAt(self, x, y):
        """ Get icon at coordinates x,y. X and Y are in pixels """
@@ -87,11 +98,16 @@ class IconGrid(object):     #(gobject.GObject):
            x2=int(x / w)
            y2=int(y / w)
        else:
-           x2=config.size - int(y/w) - 1
+           x2=self.size - int(y/w) - 1
            y2=int(x/w)
 
        print "x2,y2", x2, y2
-       ret=self.icons.get(x2,y2)
+       ret=self.get(x2,y2)
+
+       return(ret)
+
+    def get(self, x, y):
+       ret=self.icons.get(x,y)
 
        return(ret)
 
@@ -108,7 +124,7 @@ class IconGrid(object):     #(gobject.GObject):
                y2=y * (config.iconsize + config.iconspace)
            else:
                x2=y * (config.iconsize + config.iconspace)
-               y2=(config.size-x-1) * (config.iconsize + config.iconspace)
+               y2=(self.size-x-1) * (config.iconsize + config.iconspace)
 
            # Only repaint the needed icons
            rect=gdk.Rectangle(x2, y2, w, w)
@@ -208,6 +224,9 @@ class IconGrid(object):     #(gobject.GObject):
     def butTest(self, arg):
        print "but", arg
 
+    def reloadIcons(self):
+       self.icons.load()
+
 #    def on_orientation_changed(self, orientation):
 #      print "orch:", orientation
 #      o=orientation[0]
@@ -218,6 +237,13 @@ class IconGridWidget(IconGrid, gtk.Widget):
        IconGrid.__init__(self, isconfig)
        gtk.Widget.__init__(self)
 
+       if isconfig:
+           w=4 * (config.iconsize + config.iconspace)
+       else:
+           w=self.size * (config.iconsize + config.iconspace)
+
+       self.set_size_request(w, w)
+
     def do_realize(self):
        screen=self.get_screen()
        self.set_colormap(screen.get_rgba_colormap())