__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
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={}
+ self.maxsz=(0,0)
+
# setup allicons
- maxsz=4
- for x in xrange(maxsz):
- for y in xrange(maxsz):
- k=(x,y)
- ico=Icon(self.isconfig)
- self.allicons[k]=ico
- self.connect_one(ico)
+ self.resizeMax()
+
+ def resizeMax(self):
+ sz=self.maxsz
+ maxsz=self.config.getMaxSize()
+
+ # Create new entries in x
+ if maxsz[0]>sz[0]:
+ for x in xrange(maxsz[0]-sz[0]):
+ for y in xrange(sz[1]):
+ k=(x+sz[0],y)
+ ico=Icon(self.isconfig, self.config)
+ self.allicons[k]=ico
+ self.connect_one(ico)
+ sz=(maxsz[0], sz[1])
+ elif maxsz[0]<sz[0]:
+ for x in xrange(sz[0]-maxsz[0]):
+ for y in xrange(sz[1]):
+ k=(maxsz[0]+x,y)
+ self.allicons.pop(k)
+ sz=(maxsz[0], sz[1])
+
+ # Create new entries in y
+ if maxsz[1]>sz[1]:
+ for y in xrange(maxsz[1]-sz[1]):
+ for x in xrange(sz[0]):
+ k=(x,y+sz[1])
+ ico=Icon(self.isconfig, self.config)
+ self.allicons[k]=ico
+ self.connect_one(ico)
+ sz=(sz[0], maxsz[1])
+ elif maxsz[1]<sz[1]:
+ for y in xrange(sz[1]-maxsz[1]):
+ for x in xrange(sz[0]):
+ k=(x,y+maxsz[1])
+ self.allicons.pop(k)
+ sz=(sz[0], maxsz[1])
+
+ self.maxsz=sz
@classmethod
def register_signals(cls):
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
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):
# '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()
+ sz=self.getSize()
for k in wapps:
x,y=k
appname=wapps[k]
if appname!=None:
app=apps.readOne(appname)
- app['icon2']=getIcon(app['icon'])
- self.get(x,y).setApp(app)
+ if app!=None:
+ app['icon2']=getIcon(app['icon'], self.config.getIconSize())
+ self.get(x,y).setApp(app)
+ else:
+ ic=self.get(x,y)
+ ic.setApp(None)
+
+ # Reload icons to make sure backgrounds, etc are valid
+ for x in xrange(sz[0]):
+ for y in xrange(sz[1]):
+ ic=self.get(x,y)
+ ic.reload()
+
# for f in fn:
# dt=apps.readOne(f)
# y+=1
## self.icons.append(p)
- print "end of Icons init"
-
-
gobject.type_register(Icons)
Icons.register_signals()