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 $"
28 from hildondesktop import *
34 from portrait import FremantleRotation
36 from xdg.IconTheme import getIconPath
51 fn=["maegirls", "wifieye"]*3
54 ico=getIconPath(dt['icon'], config.iconsize)
56 p=gtk.gdk.pixbuf_new_from_file_at_size(ico, config.iconsize,
62 self.icons[x][y].setApp(dt)
67 # self.icons.append(p)
69 print "end of Icons init"
71 def setMode(self, mode):
89 def timePressed(self):
90 """ return how much time a button is pressed """
91 dt=time.time() - self.lastpress
99 def draw(self, cr, x, y, mode):
107 cr.set_source_rgba(0.1, 0.1, 0.1, 1)
111 t=1.0 * min(self.timePressed(), self.presstime) / self.presstime
114 cr.set_source_rgba(0, g, b, 0.7)
116 cr.set_source_rgba(0.3, 0.3, 0.3, 0.7)
117 x3=x + (config.iconspace/6)
118 y3=y + (config.iconspace/6)
121 w=config.iconsize+(config.iconspace*2/3)
124 cr.arc(x3+w-r, y3+r, r, pi*1.5, pi*2)
125 cr.arc(x3+w-r, y3+w-r, r, 0, pi*0.5)
126 cr.arc(x3+r, y3+w-r, r, pi*0.5, pi)
127 cr.arc(x3+r, y3+r, r, pi, pi*1.5)
139 icon2=icon.rotate_simple(gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE)
142 x3=x + (config.iconspace/2)
143 y3=y + (config.iconspace/2)
144 cr.set_source_pixbuf(icon2, x3, y3)
148 def timerPressed(self):
150 if not self.ispressed:
155 if self.timePressed()>self.presstime:
162 # Double-time: time for pressed and time for not-pressed
163 if time.time() - self.lastpress > self.presstime*2:
166 self.lastpress=time.time()
168 gobject.timeout_add(20, self.timerPressed)
171 print "launch:", self.name
172 launcher.launch(self.name)
174 def doTrippleClick(self):
178 lst=[aps[x]['name'] for x in aps]
182 # Na doylevei o selector, na dialegei efarmogi kai na
183 # efarmozetai sto sygkekrimeno eikonidio
185 # Na brethei lysh kai gia ta kena
186 dialog=gtk.Dialog('App select', None,
187 gtk.DIALOG_DESTROY_WITH_PARENT, buttons=())
189 selector=hildon.TouchSelectorEntry(text=True)
190 selector.set_column_selection_mode(
191 hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
192 dialog.vbox.pack_start(selector, True, True, 0)
193 dialog.set_size_request(0,900)
198 selector.append_text(app)
204 # prog=hildon.Program.get_instance()
209 dt=time.time() - self.lastpress
211 if dt>self.presstime and dt<2:
213 elif dt<self.presstime:
215 if self.clickcount==3:
216 self.doTrippleClick()
222 def invalidate(self, window=None):
227 w=config.iconsize + config.iconspace
228 rect=gdk.Rectangle(self.x, self.y, w, w)
229 gdk.Window.invalidate_rect(window, rect, True)
231 class DrlaunchPlugin(HomePluginItem, Icons, FremantleRotation):
233 HomePluginItem.__init__(self)
235 FremantleRotation.__init__(self, 'DrlaunchPlugin')
241 w=config.size * config.iconsize + (config.size) * config.iconspace
242 self.set_size_request(w, w)
248 for y in xrange(config.size):
249 icons[x].append(Icon())
253 self.lasticon=None # The last icon that got selected
257 def iconAt(self, x, y):
258 """ Get icon at coordinates x,y. X and Y are in pixels """
260 w=config.iconsize + config.iconspace
266 x2=config.size - int(y/w) - 1
270 ret=self.icons[x2][y2]
278 # print "mode:", self.mode
279 # print "icons", len(self.icons)
285 x2=x * (config.iconsize + config.iconspace)
286 y2=y * (config.iconsize + config.iconspace)
288 x2=y * (config.iconsize + config.iconspace)
289 y2=(config.size-x-1) * (config.iconsize + config.iconspace)
291 # print "draw:", x, y
293 ico.draw(cr, x2, y2, self.mode)
300 def do_expose_event(self, event):
303 cr=self.window.cairo_create()
305 cr.rectangle(event.area.x, event.area.y,
306 event.area.width, event.area.height)
312 # HomePluginItem.do_expose_event(self, event)
314 def setLastIcon(self, icon):
315 if icon==self.lasticon:
318 if self.lasticon!=None:
319 self.lasticon.doCancel()
320 self.lasticon.invalidate(self.window)
323 def do_realize(self):
324 screen=self.get_screen()
325 self.set_colormap(screen.get_rgba_colormap())
326 self.set_app_paintable(True)
328 HomePluginItem.do_realize(self)
330 def do_button_press_event(self, event):
331 #print "press", event.type
332 icon=self.iconAt(event.x, event.y)
333 # rect=gdk.Rectangle(event.x,event.y,1,1)
334 # rect=gdk.Rectangle(0, 0, 100, 100)
336 icon.invalidate(self.window)
337 self.setLastIcon(icon)
339 # gdk.Window.invalidate_rect(self.window, rect, True)
343 def do_button_release_event(self, event):
345 icon=self.iconAt(event.x, event.y)
347 icon.invalidate(self.window)
348 self.setLastIcon(None)
351 def do_leave_notify_event(self, event):
352 #print "leave", event.x, event.y
353 self.setLastIcon(None)
356 def do_pproperty_notify_event(self, event):
358 icon=self.iconAt(event.x, event.y)
360 icon.invalidate(self.window)
363 def do_motion_notify_event(self, event):
365 self.setLastIcon(None)
366 # icon=self.iconAt(event.x, event.y)
368 # icon.invalidate(self.window)
371 def do_button_press_event_old(self, event):
373 if event.type==gdk.BUTTON_PRESS:
374 print "press", event.type
383 def do_event1(self, event):
384 print "event:", event, event.type
386 def butTest(self, arg):
389 def on_orientation_changed(self, orientation):
390 print "orch:", orientation
395 hd_plugin_type = DrlaunchPlugin
398 # gobject.type_register(MyQ)
399 gobject.type_register(hd_plugin_type)
400 obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
406 win.connect('delete-event', gtk.main_quit)
416 if __name__=="__main__":
421 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: