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())
58 # Now go for the right side
59 al=gtk.Alignment(yscale=0)
66 maxsz=self.config.getMaxSize()
68 # ----------------------------------------------
69 vbox.add(gtk.Label('Width:'))
75 self.butsSize=self.butsSizeX # For now
76 for i in xrange(maxsz[0]):
77 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
78 but.set_label("%s" % (i+1,))
79 but.connect('toggled', self.slotButtonSizeX, i)
81 self.butsSizeX.append(but)
85 # ----------------------------------------------
86 vbox.add(gtk.Label('Height:'))
92 for i in xrange(maxsz[1]):
93 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
94 but.set_label("%s" % (i+1,))
95 but.connect('toggled', self.slotButtonSizeY, i)
97 self.butsSizeY.append(but)
101 but=hildon.CheckButton(
102 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
103 but.set_label("Rotate icons individually")
104 but.connect('toggled', self.slotButtonRotateIndividually)
105 self.buttonRotateIndividually=but
108 but=hildon.CheckButton(
109 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
110 but.set_label("Require long press")
111 # but.connect('toggled', self.slotButtonLongpress)
112 self.buttonRequireLongpress=but
115 #self.igw.connect('long-press', self.slotLongpress)
116 self.igw.connect('click', self.slotLongpress)
118 self.ignore_toggle=False
120 self.setSize(self.config.getSize())
121 self.setIndiv(self.config.getIndiv())
122 self.setLongpress(self.config.getLongpress())
124 def slotLongpress(self, sender, icon):
127 def slotButtonSizeX(self, sender, id):
136 def slotButtonSizeY(self, sender, id):
141 def slotButtonRotateIndividually(self, sender):
142 but=self.buttonRotateIndividually
143 self.setIndiv(but.get_active())
145 # def slotButtonLongpress(self, sender):
146 # but=self.buttonRequireLongpress
149 def setSize(self, sz):
150 if self.ignore_toggle:
153 self.ignore_toggle=True
155 maxsz=self.config.getMaxSize()
159 for i in xrange(maxsz[0]):
160 but=self.butsSizeX[i]
161 but.set_active(i==id)
165 for i in xrange(maxsz[1]):
166 but=self.butsSizeY[i]
167 but.set_active(i==id)
169 self.ignore_toggle=False
173 self.igw.queue_draw()
176 return(self.igw.getSize())
179 ret=self.buttonRotateIndividually.get_active()
183 def setIndiv(self, indiv):
185 for i in self.butsSizeY:
186 i.set_sensitive(True)
188 for i in self.butsSizeY:
189 i.set_sensitive(False)
194 self.setSize((szx, szx))
196 self.buttonRotateIndividually.set_active(indiv)
198 def setLongpress(self, lp):
199 self.buttonRequireLongpress.set_active(lp)
201 def doConfig(self, icon):
204 lst=[aps[x]['name'] for x in aps]
207 dialog=gtk.Dialog('App select', None,
208 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
210 selector=hildon.TouchSelectorEntry(text=True)
211 selector.set_column_selection_mode(
212 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
214 dialog.vbox.pack_start(selector, True, True, 0)
215 dialog.set_size_request(0,900)
216 dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
217 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
219 selector.append_text('None')
226 selector.append_text(app)
227 if icon.name!=None and aps[icon.name]['name']==app:
231 selector.set_active(0, idx)
239 if r==gtk.RESPONSE_OK:
240 cur=selector.get_current_text()
245 if aps[i]['name']==cur:
249 app['icon2']=getIcon(app['icon'])
262 for but in self.butsSizeX:
264 if but.get_active()==True:
267 for but in self.butsSizeY:
269 if but.get_active()==True:
279 for x in xrange(sz[0]):
280 for y in xrange(sz[1]):
281 ico=self.igw.get(x,y)
285 indiv=self.buttonRotateIndividually.get_active()
286 lp=self.buttonRequireLongpress.get_active()
297 if __name__=="__main__":
299 win.connect('delete-event', gtk.main_quit)
306 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: