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=1)
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)
112 al=gtk.Alignment(xalign=0, yalign=1, xscale=1)
119 but=hildon.CheckButton(
120 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
121 but.set_label("Rotate icons individually")
122 but.connect('toggled', self.slotButtonRotateIndividually)
123 self.buttonRotateIndividually=but
126 but=hildon.CheckButton(
127 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
128 but.set_label("Require long press")
129 # but.connect('toggled', self.slotButtonLongpress)
130 self.buttonRequireLongpress=but
133 but=hildon.CheckButton(
134 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
135 but.set_label("Animate rotation")
136 self.buttonAnimateRotation=but
139 # -----------------------------------------------
140 # Second column of options
143 al=gtk.Alignment(xalign=0, yalign=1, xscale=1)
147 but=hildon.CheckButton(
148 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
149 but.set_label("Theme background")
150 #but.connect('toggled', self.slotButtonNoBackground)
151 self.buttonThemeBackground=but
154 but=hildon.CheckButton(
155 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
156 but.set_label("No background")
157 #but.connect('toggled', self.slotButtonNoBackground)
158 self.buttonNoBackground=but
163 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
164 hildon.BUTTON_ARRANGEMENT_VERTICAL)
165 but.set_title("About")
166 but.connect("clicked", self.slotButtonAbout)
170 # -----------------------------------------------
172 self.igw=IconGridWidget(True, self.config, False)
173 # self.igw.do_realize()
174 # self.igw.setSize(config.getSize())
175 al=gtk.Alignment(xalign=0, xscale=0)
177 al.set_padding(0, 0, 20, 0)
181 self.igw.connect('long-press', self.slotLongpress)
182 self.igw.connect('click', self.slotLongpress)
184 self.ignore_toggle=False
186 self.setSize(self.config.getSize())
187 self.setIndiv(self.config.getIndiv())
188 self.setLongpress(self.config.getLongpress())
189 self.setAnimate(self.config.getAnimate())
190 self.setNoBg(self.config.getNoBg())
191 self.setThemeBg(self.config.getThemeBg())
197 self.pa.add_with_viewport(hbox)
201 # def setupUi(self, orientation):
207 # if orientation=='l':
208 # hbox.add(self.col1)
209 # hbox.add(self.col2)
210 # hbox.add(self.w_igw)
214 # vbox.add(self.col1)
215 # vbox.add(self.col2)
216 # hbox.add(self.w_igw)
218 # self.pa.add_with_viewport(hbox)
220 # if self.get_child()!=None:
221 # self.remove(self.get_child())
225 def setLayoutPortrait(self):
231 self.col1.reparent(vbox)
232 self.col2.reparent(vbox)
233 self.w_igw.reparent(hbox)
235 r=self.pa.get_children()[0]
238 self.pa.add_with_viewport(hbox)
242 def setLayoutLandscape(self):
246 self.col1.reparent(hbox)
247 self.col2.reparent(hbox)
248 self.w_igw.reparent(hbox)
250 r=self.pa.get_children()[0]
253 self.pa.add_with_viewport(hbox)
257 def on_orientation_changed(self, orientation):
258 # This is disabled for now since I've not found any reliable
259 # way for supporting orientation changes (#$#%$#*&% GTK)
262 print "orch:", orientation
263 if orientation=='portrait':
264 self.setLayoutPortrait()
266 self.setLayoutLandscape()
268 def slotLongpress(self, sender, icon):
271 def slotButtonSizeX(self, sender, id):
280 def slotButtonSizeY(self, sender, id):
285 def slotButtonRotateIndividually(self, sender):
286 but=self.buttonRotateIndividually
287 self.setIndiv(but.get_active())
289 def slotButtonAbout(self, sender):
290 DlgAbout.present2(self)
292 # def slotButtonLongpress(self, sender):
293 # but=self.buttonRequireLongpress
296 def setSize(self, sz):
297 if self.ignore_toggle:
300 self.ignore_toggle=True
302 maxsz=self.config.getMaxSize()
306 for i in xrange(maxsz[0]):
307 but=self.butsSizeX[i]
308 but.set_active(i==id)
312 for i in xrange(maxsz[1]):
313 but=self.butsSizeY[i]
314 but.set_active(i==id)
316 self.ignore_toggle=False
320 self.igw.queue_draw()
323 return(self.igw.getSize())
326 ret=self.buttonRotateIndividually.get_active()
330 def setIndiv(self, indiv):
332 for i in self.butsSizeY:
333 i.set_sensitive(True)
334 for i in self.butsSizeX:
335 i.set_sensitive(True)
338 for i in self.butsSizeY:
339 i.set_sensitive(False)
342 for i in self.butsSizeX:
345 i.set_sensitive(False)
351 self.setSize((szx, szx))
353 self.buttonRotateIndividually.set_active(indiv)
355 def setLongpress(self, lp):
356 self.buttonRequireLongpress.set_active(lp)
358 def setAnimate(self, ar):
359 self.buttonAnimateRotation.set_active(ar)
361 def setNoBg(self, nobg):
362 self.buttonNoBackground.set_active(nobg)
364 def setThemeBg(self, themebg):
365 self.buttonThemeBackground.set_active(themebg)
367 def doConfig(self, icon):
370 lst=[aps[x]['name'] for x in aps]
373 dialog=gtk.Dialog('App select', None,
374 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
376 selector=hildon.TouchSelectorEntry(text=True)
377 selector.set_column_selection_mode(
378 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
380 dialog.vbox.pack_start(selector, True, True, 0)
381 dialog.set_size_request(0,900)
382 dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
383 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
385 selector.append_text('None')
392 selector.append_text(app)
393 if icon.name!=None and aps[icon.name]['name']==app:
397 selector.set_active(0, idx)
405 if r==gtk.RESPONSE_OK:
406 idx2=selector.get_active(0)
412 if aps[i]['name']==cur:
416 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
429 for but in self.butsSizeX:
431 if but.get_active()==True:
434 for but in self.butsSizeY:
436 if but.get_active()==True:
446 for x in xrange(sz[0]):
447 for y in xrange(sz[1]):
448 ico=self.igw.get(x,y)
452 indiv=self.buttonRotateIndividually.get_active()
453 lp=self.buttonRequireLongpress.get_active()
454 ar=self.buttonAnimateRotation.get_active()
455 nobg=self.buttonNoBackground.get_active()
456 themebg=self.buttonThemeBackground.get_active()
470 if __name__=="__main__":
472 win.connect('delete-event', gtk.main_quit)
479 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: