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
133 al=gtk.Alignment(xalign=0, yalign=1, xscale=1)
138 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
139 hildon.BUTTON_ARRANGEMENT_VERTICAL)
140 but.set_title("About")
141 but.connect("clicked", self.slotButtonAbout)
145 # -----------------------------------------------
147 self.igw=IconGridWidget(True, self.config, False)
148 # self.igw.do_realize()
149 # self.igw.setSize(config.getSize())
150 al=gtk.Alignment(xalign=0, xscale=0)
152 al.set_padding(0, 0, 20, 0)
156 self.igw.connect('long-press', self.slotLongpress)
157 self.igw.connect('click', self.slotLongpress)
159 self.ignore_toggle=False
161 self.setSize(self.config.getSize())
162 self.setIndiv(self.config.getIndiv())
163 self.setLongpress(self.config.getLongpress())
164 self.setAnimate(self.config.getAnimate())
170 self.pa.add_with_viewport(hbox)
174 # def setupUi(self, orientation):
180 # if orientation=='l':
181 # hbox.add(self.col1)
182 # hbox.add(self.col2)
183 # hbox.add(self.w_igw)
187 # vbox.add(self.col1)
188 # vbox.add(self.col2)
189 # hbox.add(self.w_igw)
191 # self.pa.add_with_viewport(hbox)
193 # if self.get_child()!=None:
194 # self.remove(self.get_child())
198 def setLayoutPortrait(self):
204 self.col1.reparent(vbox)
205 self.col2.reparent(vbox)
206 self.w_igw.reparent(hbox)
208 r=self.pa.get_children()[0]
211 self.pa.add_with_viewport(hbox)
215 def setLayoutLandscape(self):
219 self.col1.reparent(hbox)
220 self.col2.reparent(hbox)
221 self.w_igw.reparent(hbox)
223 r=self.pa.get_children()[0]
226 self.pa.add_with_viewport(hbox)
230 def on_orientation_changed(self, orientation):
231 # This is disabled for now since I've not found any reliable
232 # way for supporting orientation changes (#$#%$#*&% GTK)
235 print "orch:", orientation
236 if orientation=='portrait':
237 self.setLayoutPortrait()
239 self.setLayoutLandscape()
241 def slotLongpress(self, sender, icon):
244 def slotButtonSizeX(self, sender, id):
253 def slotButtonSizeY(self, sender, id):
258 def slotButtonRotateIndividually(self, sender):
259 but=self.buttonRotateIndividually
260 self.setIndiv(but.get_active())
262 def slotButtonAbout(self, sender):
263 DlgAbout.present2(self)
265 # def slotButtonLongpress(self, sender):
266 # but=self.buttonRequireLongpress
269 def setSize(self, sz):
270 if self.ignore_toggle:
273 self.ignore_toggle=True
275 maxsz=self.config.getMaxSize()
279 for i in xrange(maxsz[0]):
280 but=self.butsSizeX[i]
281 but.set_active(i==id)
285 for i in xrange(maxsz[1]):
286 but=self.butsSizeY[i]
287 but.set_active(i==id)
289 self.ignore_toggle=False
293 self.igw.queue_draw()
296 return(self.igw.getSize())
299 ret=self.buttonRotateIndividually.get_active()
303 def setIndiv(self, indiv):
305 for i in self.butsSizeY:
306 i.set_sensitive(True)
307 for i in self.butsSizeX:
308 i.set_sensitive(True)
311 for i in self.butsSizeY:
312 i.set_sensitive(False)
315 for i in self.butsSizeX:
318 i.set_sensitive(False)
324 self.setSize((szx, szx))
326 self.buttonRotateIndividually.set_active(indiv)
328 def setLongpress(self, lp):
329 self.buttonRequireLongpress.set_active(lp)
331 def setAnimate(self, ar):
332 self.buttonAnimateRotation.set_active(ar)
334 def doConfig(self, icon):
337 lst=[aps[x]['name'] for x in aps]
340 dialog=gtk.Dialog('App select', None,
341 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
343 selector=hildon.TouchSelectorEntry(text=True)
344 selector.set_column_selection_mode(
345 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
347 dialog.vbox.pack_start(selector, True, True, 0)
348 dialog.set_size_request(0,900)
349 dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
350 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
352 selector.append_text('None')
359 selector.append_text(app)
360 if icon.name!=None and aps[icon.name]['name']==app:
364 selector.set_active(0, idx)
372 if r==gtk.RESPONSE_OK:
373 idx2=selector.get_active(0)
379 if aps[i]['name']==cur:
383 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
396 for but in self.butsSizeX:
398 if but.get_active()==True:
401 for but in self.butsSizeY:
403 if but.get_active()==True:
413 for x in xrange(sz[0]):
414 for y in xrange(sz[1]):
415 ico=self.igw.get(x,y)
419 indiv=self.buttonRotateIndividually.get_active()
420 lp=self.buttonRequireLongpress.get_active()
421 ar=self.buttonAnimateRotation.get_active()
433 if __name__=="__main__":
435 win.connect('delete-event', gtk.main_quit)
442 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: