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
38 from about import DlgAbout
39 from portrait import FremantleRotation
41 class WinConfig(StackableWindow): #, FremantleRotation):
42 def __init__(self, config, *args):
43 StackableWindow.__init__(self)
44 # FremantleRotation.__init__(self, "DrlaunchPlugin",
45 # mode=FremantleRotation.AUTOMATIC)
53 self.pa Main Pannable Area
54 self.col1 A VBox for the first column
55 self.col2 A VBox for the second column
56 self.w_igw The IGW in an alignment
58 self.set_title("DrLaunch v" + config.version)
60 self.pa=hildon.PannableArea()
62 self.pa.set_property('mov-mode', hildon.MOVEMENT_MODE_HORIZ)
65 #1 self.pa.add_with_viewport(hbox)
67 # Add the first column of options
68 al=gtk.Alignment(yscale=0)
75 maxsz=self.config.getMaxSize()
77 # ----------------------------------------------
78 vbox.add(gtk.Label('Width:'))
84 self.butsSize=self.butsSizeX # For now
85 for i in xrange(maxsz[0]):
86 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
87 but.set_label("%s" % (i+1,))
88 but.connect('toggled', self.slotButtonSizeX, i)
90 self.butsSizeX.append(but)
94 # ----------------------------------------------
95 vbox.add(gtk.Label('Height:'))
101 for i in xrange(maxsz[1]):
102 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
103 but.set_label("%s" % (i+1,))
104 but.connect('toggled', self.slotButtonSizeY, i)
106 self.butsSizeY.append(but)
110 but=hildon.CheckButton(
111 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
112 but.set_label("Rotate icons individually")
113 but.connect('toggled', self.slotButtonRotateIndividually)
114 self.buttonRotateIndividually=but
117 but=hildon.CheckButton(
118 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
119 but.set_label("Require long press")
120 # but.connect('toggled', self.slotButtonLongpress)
121 self.buttonRequireLongpress=but
124 but=hildon.CheckButton(
125 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
126 but.set_label("Animate rotation")
127 self.buttonAnimateRotation=but
130 # -----------------------------------------------
131 # Second column of options
134 al=gtk.Alignment(xalign=0, yalign=1, xscale=1)
138 but=hildon.CheckButton(
139 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
140 but.set_label("No background")
141 #but.connect('toggled', self.slotButtonNoBackground)
142 self.buttonNoBackground=but
147 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
148 hildon.BUTTON_ARRANGEMENT_VERTICAL)
149 but.set_title("About")
150 but.connect("clicked", self.slotButtonAbout)
154 # -----------------------------------------------
156 self.igw=IconGridWidget(True, self.config, False)
157 # self.igw.do_realize()
158 # self.igw.setSize(config.getSize())
159 al=gtk.Alignment(xalign=0, xscale=0)
161 al.set_padding(0, 0, 20, 0)
165 self.igw.connect('long-press', self.slotLongpress)
166 self.igw.connect('click', self.slotLongpress)
168 self.ignore_toggle=False
170 self.setSize(self.config.getSize())
171 self.setIndiv(self.config.getIndiv())
172 self.setLongpress(self.config.getLongpress())
173 self.setAnimate(self.config.getAnimate())
174 self.setNoBg(self.config.getNoBg())
180 self.pa.add_with_viewport(hbox)
184 # def setupUi(self, orientation):
190 # if orientation=='l':
191 # hbox.add(self.col1)
192 # hbox.add(self.col2)
193 # hbox.add(self.w_igw)
197 # vbox.add(self.col1)
198 # vbox.add(self.col2)
199 # hbox.add(self.w_igw)
201 # self.pa.add_with_viewport(hbox)
203 # if self.get_child()!=None:
204 # self.remove(self.get_child())
208 def setLayoutPortrait(self):
214 self.col1.reparent(vbox)
215 self.col2.reparent(vbox)
216 self.w_igw.reparent(hbox)
218 r=self.pa.get_children()[0]
221 self.pa.add_with_viewport(hbox)
225 def setLayoutLandscape(self):
229 self.col1.reparent(hbox)
230 self.col2.reparent(hbox)
231 self.w_igw.reparent(hbox)
233 r=self.pa.get_children()[0]
236 self.pa.add_with_viewport(hbox)
240 def on_orientation_changed(self, orientation):
241 # This is disabled for now since I've not found any reliable
242 # way for supporting orientation changes (#$#%$#*&% GTK)
245 print "orch:", orientation
246 if orientation=='portrait':
247 self.setLayoutPortrait()
249 self.setLayoutLandscape()
251 def slotLongpress(self, sender, icon):
254 def slotButtonSizeX(self, sender, id):
263 def slotButtonSizeY(self, sender, id):
268 def slotButtonRotateIndividually(self, sender):
269 but=self.buttonRotateIndividually
270 self.setIndiv(but.get_active())
272 def slotButtonAbout(self, sender):
273 DlgAbout.present2(self)
275 # def slotButtonLongpress(self, sender):
276 # but=self.buttonRequireLongpress
279 def setSize(self, sz):
280 if self.ignore_toggle:
283 self.ignore_toggle=True
285 maxsz=self.config.getMaxSize()
289 for i in xrange(maxsz[0]):
290 but=self.butsSizeX[i]
291 but.set_active(i==id)
295 for i in xrange(maxsz[1]):
296 but=self.butsSizeY[i]
297 but.set_active(i==id)
299 self.ignore_toggle=False
303 self.igw.queue_draw()
306 return(self.igw.getSize())
309 ret=self.buttonRotateIndividually.get_active()
313 def setIndiv(self, indiv):
315 for i in self.butsSizeY:
316 i.set_sensitive(True)
317 for i in self.butsSizeX:
318 i.set_sensitive(True)
321 for i in self.butsSizeY:
322 i.set_sensitive(False)
325 for i in self.butsSizeX:
328 i.set_sensitive(False)
334 self.setSize((szx, szx))
336 self.buttonRotateIndividually.set_active(indiv)
338 def setLongpress(self, lp):
339 self.buttonRequireLongpress.set_active(lp)
341 def setAnimate(self, ar):
342 self.buttonAnimateRotation.set_active(ar)
344 def setNoBg(self, nobg):
345 self.buttonNoBackground.set_active(nobg)
347 def doConfig(self, icon):
350 lst=[aps[x]['name'] for x in aps]
353 dialog=gtk.Dialog('App select', None,
354 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
356 selector=hildon.TouchSelectorEntry(text=True)
357 selector.set_column_selection_mode(
358 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
360 dialog.vbox.pack_start(selector, True, True, 0)
361 dialog.set_size_request(0,900)
362 dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
363 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
365 selector.append_text('None')
372 selector.append_text(app)
373 if icon.name!=None and aps[icon.name]['name']==app:
377 selector.set_active(0, idx)
385 if r==gtk.RESPONSE_OK:
386 idx2=selector.get_active(0)
392 if aps[i]['name']==cur:
396 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
409 for but in self.butsSizeX:
411 if but.get_active()==True:
414 for but in self.butsSizeY:
416 if but.get_active()==True:
426 for x in xrange(sz[0]):
427 for y in xrange(sz[1]):
428 ico=self.igw.get(x,y)
432 indiv=self.buttonRotateIndividually.get_active()
433 lp=self.buttonRequireLongpress.get_active()
434 ar=self.buttonAnimateRotation.get_active()
435 nobg=self.buttonNoBackground.get_active()
448 if __name__=="__main__":
450 win.connect('delete-event', gtk.main_quit)
457 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: