4 # Copyright (C) 2010 Stefanos Harhalakis
6 # This file is part of wifieye.
8 # wifieye is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # wifieye is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with wifieye. If not, see <http://www.gnu.org/licenses/>.
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
28 from icon import getIcon, Icon
29 from sig import Disconnector
35 def __init__(self, items):
36 self.iter=items.__iter__()
39 ret=self.iter.__iter__()
46 class Icons(Disconnector, gobject.GObject):
47 #class Icons(gtk.Widget, Disconnector):
48 __gtype_name__ = "DrlaunchIcons"
50 #__gsignals__=Icon.gsignals
51 def __init__(self, isconfig, config):
52 #self.__gobject_init__()
53 gobject.GObject.__init__(self)
54 #gtk.Widget.__init__(self)
55 Disconnector.__init__(self)
60 self.isconfig=isconfig
78 # print "icons-finish"
85 maxsz=self.config.getMaxSize()
87 # Create new entries in x
89 for x in xrange(maxsz[0]-sz[0]):
90 for y in xrange(sz[1]):
92 ico=Icon(self.isconfig, self.config)
97 for x in xrange(sz[0]-maxsz[0]):
98 for y in xrange(sz[1]):
100 t=self.allicons.pop(k)
101 self.disconnect_one(t)
104 # Create new entries in y
106 for y in xrange(maxsz[1]-sz[1]):
107 for x in xrange(sz[0]):
109 ico=Icon(self.isconfig, self.config)
111 self.connect_one(ico)
114 for y in xrange(sz[1]-maxsz[1]):
115 for x in xrange(sz[0]):
117 t=self.allicons.pop(k)
118 self.disconnect_one(t)
124 def register_signals(cls):
125 signals=Icon.gsignals
128 gobject.signal_new(s, cls, ss[0], ss[1], (Icon,))
129 # gobject.SIGNAL_RUN_FIRST,
130 # gobject.TYPE_NONE, (Icon,))
133 return(IconIter(self.icons))
135 def connect_one(self, which):
136 self.handlers[which]={
137 'longpress': self.c(which, 'long-press', self.signalLongpress),
138 'click': self.c(which, 'click', self.signalClick),
139 'tripple': self.c(which, 'tripple-click',
140 self.signalTrippleClick)
143 def disconnect_one(self, which):
144 for i in self.handlers[which]:
145 which.disconnect(self.handlers[which][i])
146 self.handlers.pop(which)
147 # which.disconnect(self.h[which]_longpress)
148 # which.disconnect(self.h_click)
149 # which.disconnect(self.h_tripple)
151 def setSize(self, sz):
152 # print "sz:", sz, self.size
160 for x in xrange(sz[0]):
161 for y in xrange(sz[1]):
166 # old.pop(k) # Re-used
168 # self.connect_one(ico)
172 # self.disconnect_one(old[i])
179 def setWindow(self, win):
180 """ Set the window for all icons """
186 def signalLongpress(self, icon):
187 #print "signalLongpress()", icon
188 self.emit('long-press', icon)
190 def signalClick(self, icon):
191 #print "signalClick()", icon
192 self.emit('click', icon)
194 def signalTrippleClick(self, icon):
195 #print "signalTrippleClick()", icon
196 self.emit('tripple-click', icon)
200 if self.icons.has_key(k):
210 # fn=["maegirls", "wifieye", 'battery-eye', 'image-viewer',
211 # 'tecnoballz', 'ncalc', 'rtcom-call-ui', 'rtcom-messaging-ui',
212 # 'extcalllog', 'browser', 'modest', 'osso-addressbook']
214 wapps=self.config.getApps()
215 #sz=self.config.getSize()
225 app=apps.readOne(appname)
227 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
228 self.get(x,y).setApp(app)
233 # Reload icons to make sure backgrounds, etc are valid
234 for x in xrange(sz[0]):
235 for y in xrange(sz[1]):
242 # dt['icon2']=getIcon(dt['icon'])
244 # self.get(x,y).setApp(dt)
246 # if x>=config.getSize(getSize()):
249 ## self.icons.append(p)
254 #gobject.type_register(icons_type)
255 print "bbbbbbbbbbbbbbBB"
256 # Icons.register_signals()
257 print "bbbbbbbbbbbbbbBB222222222"
259 Icons.register_signals()
260 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: