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, *args):
41 StackableWindow.__init__(self)
46 self.igw=IconGridWidget(True)
47 # self.igw.setSize(config.getSize())
55 # Now go for the right side
56 al=gtk.Alignment(yscale=0)
63 maxsz=config.getMaxSize()
65 # ----------------------------------------------
66 vbox.add(gtk.Label('Width:'))
72 self.butsSize=self.butsSizeX # For now
73 for i in xrange(maxsz[0]):
74 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
75 but.set_label("%s" % (i+1,))
76 but.connect('toggled', self.slotButtonSizeX, i)
78 self.butsSizeX.append(but)
82 # ----------------------------------------------
83 vbox.add(gtk.Label('Height:'))
89 for i in xrange(maxsz[1]):
90 but=hildon.GtkToggleButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
91 but.set_label("%s" % (i+1,))
92 but.connect('toggled', self.slotButtonSizeY, i)
94 self.butsSizeY.append(but)
98 but=hildon.CheckButton(
99 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
100 but.set_label("Rotate icons individually")
101 but.connect('toggled', self.slotButtonRotateIndividually)
102 self.buttonRotateIndividually=but
105 but=hildon.CheckButton(
106 gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT)
107 but.set_label("Require long press")
108 # but.connect('toggled', self.slotButtonLongpress)
109 self.buttonRequireLongpress=but
112 #self.igw.connect('long-press', self.slotLongpress)
113 self.igw.connect('click', self.slotLongpress)
115 self.ignore_toggle=False
117 self.setSize(config.getSize())
118 self.setIndiv(config.getIndiv())
119 self.setLongpress(config.getLongpress())
121 def slotLongpress(self, sender, icon):
124 def slotButtonSizeX(self, sender, id):
133 def slotButtonSizeY(self, sender, id):
138 def slotButtonRotateIndividually(self, sender):
139 but=self.buttonRotateIndividually
140 self.setIndiv(but.get_active())
142 # def slotButtonLongpress(self, sender):
143 # but=self.buttonRequireLongpress
146 def setSize(self, sz):
147 if self.ignore_toggle:
150 self.ignore_toggle=True
152 maxsz=config.getMaxSize()
156 for i in xrange(maxsz[0]):
157 but=self.butsSizeX[i]
158 but.set_active(i==id)
162 for i in xrange(maxsz[1]):
163 but=self.butsSizeY[i]
164 but.set_active(i==id)
166 self.ignore_toggle=False
170 self.igw.queue_draw()
173 return(self.igw.getSize())
176 ret=self.buttonRotateIndividually.get_active()
180 def setIndiv(self, indiv):
182 for i in self.butsSizeY:
183 i.set_sensitive(True)
185 for i in self.butsSizeY:
186 i.set_sensitive(False)
191 self.setSize((szx, szx))
193 self.buttonRotateIndividually.set_active(indiv)
195 def setLongpress(self, lp):
196 self.buttonRequireLongpress.set_active(lp)
198 def doConfig(self, icon):
201 lst=[aps[x]['name'] for x in aps]
204 dialog=gtk.Dialog('App select', None,
205 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
207 selector=hildon.TouchSelectorEntry(text=True)
208 selector.set_column_selection_mode(
209 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
211 dialog.vbox.pack_start(selector, True, True, 0)
212 dialog.set_size_request(0,900)
213 dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
214 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
216 selector.append_text('None')
223 selector.append_text(app)
224 if icon.name!=None and aps[icon.name]['name']==app:
228 selector.set_active(0, idx)
236 if r==gtk.RESPONSE_OK:
237 cur=selector.get_current_text()
242 if aps[i]['name']==cur:
246 app['icon2']=getIcon(app['icon'])
259 for but in self.butsSizeX:
261 if but.get_active()==True:
264 for but in self.butsSizeY:
266 if but.get_active()==True:
276 for x in xrange(sz[0]):
277 for y in xrange(sz[1]):
278 ico=self.igw.get(x,y)
282 indiv=self.buttonRotateIndividually.get_active()
283 lp=self.buttonRequireLongpress.get_active()
294 if __name__=="__main__":
296 win.connect('delete-event', gtk.main_quit)
303 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: