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
40 class WinConfig(StackableWindow):
41 def __init__(self, config, *args):
42 StackableWindow.__init__(self)
49 self.set_title("DrLaunch Configuration")
51 self.pa=hildon.PannableArea()
53 self.pa.set_property('mov-mode', hildon.MOVEMENT_MODE_HORIZ)
56 self.pa.add_with_viewport(hbox)
58 # Add the first column of options
59 al=gtk.Alignment(yscale=0)
65 maxsz=self.config.getMaxSize()
67 # ----------------------------------------------
68 vbox.add(gtk.Label('Width:'))
74 self.butsSize=self.butsSizeX # For now
75 for i in xrange(maxsz[0]):
76 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
77 but.set_label("%s" % (i+1,))
78 but.connect('toggled', self.slotButtonSizeX, i)
80 self.butsSizeX.append(but)
84 # ----------------------------------------------
85 vbox.add(gtk.Label('Height:'))
91 for i in xrange(maxsz[1]):
92 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
93 but.set_label("%s" % (i+1,))
94 but.connect('toggled', self.slotButtonSizeY, i)
96 self.butsSizeY.append(but)
100 but=hildon.CheckButton(
101 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
102 but.set_label("Rotate icons individually")
103 but.connect('toggled', self.slotButtonRotateIndividually)
104 self.buttonRotateIndividually=but
107 but=hildon.CheckButton(
108 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
109 but.set_label("Require long press")
110 # but.connect('toggled', self.slotButtonLongpress)
111 self.buttonRequireLongpress=but
114 but=hildon.CheckButton(
115 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
116 but.set_label("Animate rotation")
117 self.buttonAnimateRotation=but
120 # -----------------------------------------------
121 # Second column of options
123 al=gtk.Alignment(xalign=0, yalign=1, xscale=1)
127 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
128 hildon.BUTTON_ARRANGEMENT_VERTICAL)
129 but.set_title("About")
130 but.connect("clicked", self.slotButtonAbout)
134 # -----------------------------------------------
136 self.igw=IconGridWidget(True, self.config, False)
137 # self.igw.do_realize()
138 # self.igw.setSize(config.getSize())
139 al=gtk.Alignment(xalign=0, xscale=0)
141 al.set_padding(0, 0, 20, 0)
144 self.igw.connect('long-press', self.slotLongpress)
145 self.igw.connect('click', self.slotLongpress)
147 self.ignore_toggle=False
149 self.setSize(self.config.getSize())
150 self.setIndiv(self.config.getIndiv())
151 self.setLongpress(self.config.getLongpress())
152 self.setAnimate(self.config.getAnimate())
154 def slotLongpress(self, sender, icon):
157 def slotButtonSizeX(self, sender, id):
166 def slotButtonSizeY(self, sender, id):
171 def slotButtonRotateIndividually(self, sender):
172 but=self.buttonRotateIndividually
173 self.setIndiv(but.get_active())
175 def slotButtonAbout(self, sender):
181 # def slotButtonLongpress(self, sender):
182 # but=self.buttonRequireLongpress
185 def setSize(self, sz):
186 if self.ignore_toggle:
189 self.ignore_toggle=True
191 maxsz=self.config.getMaxSize()
195 for i in xrange(maxsz[0]):
196 but=self.butsSizeX[i]
197 but.set_active(i==id)
201 for i in xrange(maxsz[1]):
202 but=self.butsSizeY[i]
203 but.set_active(i==id)
205 self.ignore_toggle=False
209 self.igw.queue_draw()
212 return(self.igw.getSize())
215 ret=self.buttonRotateIndividually.get_active()
219 def setIndiv(self, indiv):
221 for i in self.butsSizeY:
222 i.set_sensitive(True)
223 for i in self.butsSizeX:
224 i.set_sensitive(True)
227 for i in self.butsSizeY:
228 i.set_sensitive(False)
231 for i in self.butsSizeX:
234 i.set_sensitive(False)
240 self.setSize((szx, szx))
242 self.buttonRotateIndividually.set_active(indiv)
244 def setLongpress(self, lp):
245 self.buttonRequireLongpress.set_active(lp)
247 def setAnimate(self, ar):
248 self.buttonAnimateRotation.set_active(ar)
250 def doConfig(self, icon):
253 lst=[aps[x]['name'] for x in aps]
256 dialog=gtk.Dialog('App select', None,
257 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
259 selector=hildon.TouchSelectorEntry(text=True)
260 selector.set_column_selection_mode(
261 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
263 dialog.vbox.pack_start(selector, True, True, 0)
264 dialog.set_size_request(0,900)
265 dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
266 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
268 selector.append_text('None')
275 selector.append_text(app)
276 if icon.name!=None and aps[icon.name]['name']==app:
280 selector.set_active(0, idx)
288 if r==gtk.RESPONSE_OK:
289 idx2=selector.get_active(0)
295 if aps[i]['name']==cur:
299 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
312 for but in self.butsSizeX:
314 if but.get_active()==True:
317 for but in self.butsSizeY:
319 if but.get_active()==True:
329 for x in xrange(sz[0]):
330 for y in xrange(sz[1]):
331 ico=self.igw.get(x,y)
335 indiv=self.buttonRotateIndividually.get_active()
336 lp=self.buttonRequireLongpress.get_active()
337 ar=self.buttonAnimateRotation.get_active()
349 if __name__=="__main__":
351 win.connect('delete-event', gtk.main_quit)
358 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: