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(gobject.GObject, Disconnector):
47 #class Icons(gtk.Widget, Disconnector):
49 #__gsignals__=Icon.gsignals
50 def __init__(self, isconfig, config):
51 self.__gobject_init__()
52 #gobject.GObject.__init__(self)
53 #gtk.Widget.__init__(self)
54 Disconnector.__init__(self)
59 self.isconfig=isconfig
77 # print "icons-finish"
84 maxsz=self.config.getMaxSize()
86 # Create new entries in x
88 for x in xrange(maxsz[0]-sz[0]):
89 for y in xrange(sz[1]):
91 ico=Icon(self.isconfig, self.config)
96 for x in xrange(sz[0]-maxsz[0]):
97 for y in xrange(sz[1]):
99 t=self.allicons.pop(k)
100 self.disconnect_one(t)
103 # Create new entries in y
105 for y in xrange(maxsz[1]-sz[1]):
106 for x in xrange(sz[0]):
108 ico=Icon(self.isconfig, self.config)
110 self.connect_one(ico)
113 for y in xrange(sz[1]-maxsz[1]):
114 for x in xrange(sz[0]):
116 t=self.allicons.pop(k)
117 self.disconnect_one(t)
123 def register_signals(cls):
124 signals=Icon.gsignals
127 gobject.signal_new(s, cls, ss[0], ss[1], (Icon,))
128 # gobject.SIGNAL_RUN_FIRST,
129 # gobject.TYPE_NONE, (Icon,))
132 return(IconIter(self.icons))
134 def connect_one(self, which):
135 self.handlers[which]={
136 'longpress': self.c(which, 'long-press', self.signalLongpress),
137 'click': self.c(which, 'click', self.signalClick),
138 'tripple': self.c(which, 'tripple-click',
139 self.signalTrippleClick)
142 def disconnect_one(self, which):
143 for i in self.handlers[which]:
144 which.disconnect(self.handlers[which][i])
145 self.handlers.pop(which)
146 # which.disconnect(self.h[which]_longpress)
147 # which.disconnect(self.h_click)
148 # which.disconnect(self.h_tripple)
150 def setSize(self, sz):
151 # print "sz:", sz, self.size
159 for x in xrange(sz[0]):
160 for y in xrange(sz[1]):
165 # old.pop(k) # Re-used
167 # self.connect_one(ico)
171 # self.disconnect_one(old[i])
178 def setWindow(self, win):
179 """ Set the window for all icons """
185 def signalLongpress(self, icon):
186 #print "signalLongpress()", icon
187 self.emit('long-press', icon)
189 def signalClick(self, icon):
190 #print "signalClick()", icon
191 self.emit('click', icon)
193 def signalTrippleClick(self, icon):
194 #print "signalTrippleClick()", icon
195 self.emit('tripple-click', icon)
199 if self.icons.has_key(k):
209 # fn=["maegirls", "wifieye", 'battery-eye', 'image-viewer',
210 # 'tecnoballz', 'ncalc', 'rtcom-call-ui', 'rtcom-messaging-ui',
211 # 'extcalllog', 'browser', 'modest', 'osso-addressbook']
213 wapps=self.config.getApps()
214 #sz=self.config.getSize()
224 app=apps.readOne(appname)
226 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
227 self.get(x,y).setApp(app)
232 # Reload icons to make sure backgrounds, etc are valid
233 for x in xrange(sz[0]):
234 for y in xrange(sz[1]):
241 # dt['icon2']=getIcon(dt['icon'])
243 # self.get(x,y).setApp(dt)
245 # if x>=config.getSize(getSize()):
248 ## self.icons.append(p)
250 gobject.type_register(Icons)
251 Icons.register_signals()
253 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: