Fix old-config loading.
[drlaunch] / src / icons.py
index 515a512..3f663d7 100755 (executable)
@@ -22,7 +22,7 @@
 
 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
 
-import config
+#import config
 import apps
 import icon
 from icon import getIcon, Icon
@@ -42,22 +42,23 @@ class IconIter:
        return(ret)
 
 class Icons(gobject.GObject):
-    def __init__(self, isconfig):
+    def __init__(self, isconfig, config):
        self.__gobject_init__()
        self.icons={}
        self.allicons={}
        self.size=0
        self.isconfig=isconfig
+       self.config=config
 
        # signal handlers
        self.h={}
 
        # setup allicons
-       maxsz=4
-       for x in xrange(maxsz):
-           for y in xrange(maxsz):
+       maxsz=self.config.getMaxSize()
+       for x in xrange(maxsz[0]):
+           for y in xrange(maxsz[1]):
                k=(x,y)
-               ico=Icon(self.isconfig)
+               ico=Icon(self.isconfig, self.config)
                self.allicons[k]=ico
                self.connect_one(ico)
 
@@ -96,8 +97,8 @@ class Icons(gobject.GObject):
        old=self.icons
        self.icons={}
 
-       for x in xrange(sz):
-           for y in xrange(sz):
+       for x in xrange(sz[0]):
+           for y in xrange(sz[1]):
                k=(x,y)
                ico=self.allicons[k]
                self.icons[k]=ico
@@ -112,16 +113,26 @@ class Icons(gobject.GObject):
 
        self.size=sz
 
+    def getSize(self):
+       return(self.size)
+
+    def setWindow(self, win):
+       """ Set the window for all icons """
+
+       for i in self.icons:
+           ic=self.icons[i]
+           ic.setWindow(win)
+
     def signalLongpress(self, icon):
-       print "signalLongpress()", icon
+       #print "signalLongpress()", icon
        self.emit('long-press', icon)
 
     def signalClick(self, icon):
-       print "signalClick()", icon
+       #print "signalClick()", icon
        self.emit('click', icon)
 
     def signalTrippleClick(self, icon):
-       print "signalTrippleClick()", icon
+       #print "signalTrippleClick()", icon
        self.emit('tripple-click', icon)
 
     def get(self, x, y):
@@ -140,8 +151,8 @@ class Icons(gobject.GObject):
 #          'tecnoballz', 'ncalc', 'rtcom-call-ui', 'rtcom-messaging-ui',
 #          'extcalllog', 'browser', 'modest', 'osso-addressbook']
 
-       wapps=config.getApps()
-       sz=config.getSize()
+       wapps=self.config.getApps()
+       sz=self.config.getSize()
 
        for k in wapps:
            x,y=k
@@ -152,8 +163,10 @@ class Icons(gobject.GObject):
            if appname!=None:
                app=apps.readOne(appname)
                if app!=None:
-                   app['icon2']=getIcon(app['icon'])
+                   app['icon2']=getIcon(app['icon'], self.config.getIconSize())
                    self.get(x,y).setApp(app)
+           else:
+               self.get(x,y).setApp(None)
 
 #      for f in fn:
 #          dt=apps.readOne(f)
@@ -166,9 +179,6 @@ class Icons(gobject.GObject):
 #              y+=1
 ##         self.icons.append(p)
 
-       print "end of Icons init"
-
-
 gobject.type_register(Icons)
 Icons.register_signals()