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 $"
26 # Add the current module's directory to sys.path to bypass
27 # problems when running as widget.
28 # Restore the path at the end of the imports
33 tmp_path=os.path.dirname( os.path.realpath( __file__ ) )
34 sys.path.append(tmp_path)
41 from hildondesktop import *
47 from subprocess import Popen,PIPE
49 from portrait import FremantleRotation
51 from xdg.IconTheme import getIconPath
52 from win_config import WinConfig
57 from icongrid import IconGrid
62 # IconGrid must be before HomePluginItem for its connect()
63 # and do_button_*() to override those of HomePluginItem
64 class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
66 IconGrid.__init__(self)
67 HomePluginItem.__init__(self)
68 FremantleRotation.__init__(self, 'DrlaunchPlugin')
72 self.set_settings(True)
78 """If this is called from the constructor then the program
80 aid=self.get_applet_id()
82 # Get desktop activity if D.A.M. is present
84 act="/usr/bin/activity"
86 if os.path.exists(act):
87 r=Popen([act, "current"], stdout=PIPE).communicate()
92 ret="%s-%s" % (aid, activity)
98 self.id=self.get_id0()
102 def get_config(self):
103 if self.config==None:
105 self.config=config.Config(id)
109 def do_realize(self):
111 config=self.get_config()
114 IconGrid.do_realize(self, config)
116 self.setSize(config.getSize())
119 screen=self.get_screen()
120 self.set_colormap(screen.get_rgba_colormap())
121 self.set_app_paintable(True)
123 self.connect('show-settings', self.slot_show_settings)
124 self.connect('long-press', self.signalLongpress)
125 self.connect('click', self.signalClick)
127 HomePluginItem.do_realize(self)
129 def on_orientation_changed(self, orientation):
134 def do_expose_event(self, event):
135 IconGrid.do_expose_event(self, event)
136 HomePluginItem.do_expose_event(self, event)
138 def slot_show_settings(self, dt):
139 if self.winConfig!=None:
141 # self.winConfig.show_all()
144 s=WinConfig(self.get_config())
146 s.connect('destroy', self.slotConfigDestroy)
149 def slotConfigDestroy(self, sender):
154 config=self.get_config()
156 config.setSize(dt['size'])
157 config.setApps(dt['apps'])
158 config.setIndiv(dt['indiv'])
159 config.setLongpress(dt['longpress'])
163 self.setSize(dt['size'])
168 def handle_click(self, sender, icon):
169 """ common handler for longpress and click """
170 if icon.name!=None and icon.name!='':
171 launcher.launch(icon.name)
173 def signalLongpress(self, sender, icon):
174 self.handle_click(sender, icon)
176 def signalClick(self, sender, icon):
177 config=self.get_config()
179 if not config.getLongpress():
180 self.handle_click(sender, icon)
183 config=self.get_config()
185 w=(self.size[0] * config.iconsize) + \
186 (self.size[0] * config.iconspace)
187 h=(self.size[1] * config.iconsize) + \
188 (self.size[1] * config.iconspace)
189 self.set_size_request(w, h)
191 def setSize(self, size):
192 IconGrid.setSize(self, size)
195 hd_plugin_type = DrlaunchPlugin
197 if __name__=="__main__":
198 gobject.type_register(hd_plugin_type)
199 obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
205 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: