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 $"
30 from hildon import StackableWindow
31 #from portrait import FremantleRotation
32 #from xdg.IconTheme import getIconPath
36 from icon import Icon, getIcon
37 from icongrid import IconGridWidget
39 class WinConfig(StackableWindow):
40 def __init__(self, config, *args):
41 StackableWindow.__init__(self)
48 self.igw=IconGridWidget(True, self.config)
49 # self.igw.do_realize()
50 # self.igw.setSize(config.getSize())
52 self.pa=hildon.PannableArea()
54 self.pa.set_property('mov-mode', hildon.MOVEMENT_MODE_HORIZ)
57 self.pa.add_with_viewport(hbox)
59 # Now go for the right side
60 al=gtk.Alignment(yscale=0)
67 maxsz=self.config.getMaxSize()
69 # ----------------------------------------------
70 vbox.add(gtk.Label('Width:'))
76 self.butsSize=self.butsSizeX # For now
77 for i in xrange(maxsz[0]):
78 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
79 but.set_label("%s" % (i+1,))
80 but.connect('toggled', self.slotButtonSizeX, i)
82 self.butsSizeX.append(but)
86 # ----------------------------------------------
87 vbox.add(gtk.Label('Height:'))
93 for i in xrange(maxsz[1]):
94 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
95 but.set_label("%s" % (i+1,))
96 but.connect('toggled', self.slotButtonSizeY, i)
98 self.butsSizeY.append(but)
102 but=hildon.CheckButton(
103 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
104 but.set_label("Rotate icons individually")
105 but.connect('toggled', self.slotButtonRotateIndividually)
106 self.buttonRotateIndividually=but
109 but=hildon.CheckButton(
110 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
111 but.set_label("Require long press")
112 # but.connect('toggled', self.slotButtonLongpress)
113 self.buttonRequireLongpress=but
116 but=hildon.CheckButton(
117 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
118 but.set_label("Animate rotation")
119 self.buttonAnimateRotation=but
123 al=gtk.Alignment(xalign=0, xscale=0)
125 al.set_padding(0, 0, 20, 0)
128 self.igw.connect('long-press', self.slotLongpress)
129 self.igw.connect('click', self.slotLongpress)
131 self.ignore_toggle=False
133 self.setSize(self.config.getSize())
134 self.setIndiv(self.config.getIndiv())
135 self.setLongpress(self.config.getLongpress())
136 self.setAnimate(self.config.getAnimate())
138 def slotLongpress(self, sender, icon):
141 def slotButtonSizeX(self, sender, id):
150 def slotButtonSizeY(self, sender, id):
155 def slotButtonRotateIndividually(self, sender):
156 but=self.buttonRotateIndividually
157 self.setIndiv(but.get_active())
159 # def slotButtonLongpress(self, sender):
160 # but=self.buttonRequireLongpress
163 def setSize(self, sz):
164 if self.ignore_toggle:
167 self.ignore_toggle=True
169 maxsz=self.config.getMaxSize()
173 for i in xrange(maxsz[0]):
174 but=self.butsSizeX[i]
175 but.set_active(i==id)
179 for i in xrange(maxsz[1]):
180 but=self.butsSizeY[i]
181 but.set_active(i==id)
183 self.ignore_toggle=False
187 self.igw.queue_draw()
190 return(self.igw.getSize())
193 ret=self.buttonRotateIndividually.get_active()
197 def setIndiv(self, indiv):
199 for i in self.butsSizeY:
200 i.set_sensitive(True)
201 for i in self.butsSizeX:
202 i.set_sensitive(True)
205 for i in self.butsSizeY:
206 i.set_sensitive(False)
209 for i in self.butsSizeX:
212 i.set_sensitive(False)
218 self.setSize((szx, szx))
220 self.buttonRotateIndividually.set_active(indiv)
222 def setLongpress(self, lp):
223 self.buttonRequireLongpress.set_active(lp)
225 def setAnimate(self, ar):
226 self.buttonAnimateRotation.set_active(ar)
228 def doConfig(self, icon):
231 lst=[aps[x]['name'] for x in aps]
234 dialog=gtk.Dialog('App select', None,
235 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
237 selector=hildon.TouchSelectorEntry(text=True)
238 selector.set_column_selection_mode(
239 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
241 dialog.vbox.pack_start(selector, True, True, 0)
242 dialog.set_size_request(0,900)
243 dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
244 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
246 selector.append_text('None')
253 selector.append_text(app)
254 if icon.name!=None and aps[icon.name]['name']==app:
258 selector.set_active(0, idx)
266 if r==gtk.RESPONSE_OK:
267 idx2=selector.get_active(0)
273 if aps[i]['name']==cur:
277 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
290 for but in self.butsSizeX:
292 if but.get_active()==True:
295 for but in self.butsSizeY:
297 if but.get_active()==True:
307 for x in xrange(sz[0]):
308 for y in xrange(sz[1]):
309 ico=self.igw.get(x,y)
313 indiv=self.buttonRotateIndividually.get_active()
314 lp=self.buttonRequireLongpress.get_active()
315 ar=self.buttonAnimateRotation.get_active()
327 if __name__=="__main__":
329 win.connect('delete-event', gtk.main_quit)
336 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: