(no commit message)
[drlaunch] / src / widget.py
1 #!/usr/bin/env python
2 # coding=UTF-8
3
4 # Copyright (C) 2010 Stefanos Harhalakis
5 #
6 # This file is part of wifieye.
7 #
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.
12 #
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.
17 #
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/>.
20 #
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
22
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
24
25 import gtk
26 import gobject
27 import hildon
28 from hildondesktop import *
29 from gtk import gdk
30 from math import pi
31 import cairo
32 import time
33
34 from portrait import FremantleRotation
35 import launcher
36 from xdg.IconTheme import getIconPath
37 from win_config import WinConfig
38
39 import config
40 import apps
41 from icon import Icon
42 from icongrid import IconGrid
43
44 # IconGrid must be before HomePluginItem for its connect()
45 # and do_button_*() to override those of HomePluginItem
46 class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
47     def __init__(self):
48         IconGrid.__init__(self)
49         HomePluginItem.__init__(self)
50         FremantleRotation.__init__(self, 'DrlaunchPlugin')
51
52         launcher.init()
53         config.load()
54         self.setSize(config.getSize())
55         self.reloadIcons()
56
57         self.set_settings(True)
58         self.connect('show-settings', self.slot_show_settings)
59         self.connect('long-press', self.signalLongpress)
60
61     def do_realize(self):
62         screen=self.get_screen()
63         self.set_colormap(screen.get_rgba_colormap())
64         self.set_app_paintable(True)
65
66         HomePluginItem.do_realize(self)
67
68     def on_orientation_changed(self, orientation):
69         print "orch:", orientation
70         o=orientation[0]
71         self.setMode(o)
72 #       self.queue_draw()
73
74     def do_expose_event(self, event):
75         IconGrid.do_expose_event(self, event)
76         HomePluginItem.do_expose_event(self, event)
77
78     def do_buttonn_press_event(self, event):
79         print "press0"
80
81     def slot_show_settings(self, dt):
82         print "settings", dt
83         s=WinConfig()
84         s.show_all()
85         s.connect('destroy', self.slotConfigDestroy)
86
87     def slotConfigDestroy(self, sender):
88         print "destroy", sender
89         dt=sender.getData()
90         print "dt:", dt
91         config.setSize(dt['size'])
92         config.setApps(dt['apps'])
93         config.save()
94         
95         # Resize widget
96         self.setSize(dt['size'])
97         self.reloadIcons()
98
99 #       self.queue_draw()
100
101     def signalLongpress(self, sender, icon):
102         print "launch:", icon.name
103         launcher.launch(icon.name)
104
105     def resize(self):
106         w=(self.size * config.iconsize) + \
107             (self.size * config.iconspace)
108         self.set_size_request(w, w)
109
110     def setSize(self, size):
111         IconGrid.setSize(self, size)
112         self.resize()
113
114 hd_plugin_type = DrlaunchPlugin
115
116 if __name__=="__main__":
117     gobject.type_register(hd_plugin_type)
118     obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
119     obj.show_all()
120     gtk.main()
121
122
123
124 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent:
125