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)
126 self.connect('notify', self.signalNotify)
128 HomePluginItem.do_realize(self)
130 def on_orientation_changed(self, orientation):
131 # Get the first character of the string (l/p)
136 def do_expose_event(self, event):
137 IconGrid.do_expose_event(self, event)
138 HomePluginItem.do_expose_event(self, event)
140 def slot_show_settings(self, dt):
141 if self.winConfig!=None:
143 # self.winConfig.show_all()
146 s=WinConfig(self.get_config())
148 s.connect('destroy', self.slotConfigDestroy)
151 def slotConfigDestroy(self, sender):
156 config=self.get_config()
158 config.setSize(dt['size'])
159 config.setApps(dt['apps'])
160 config.setIndiv(dt['indiv'])
161 config.setLongpress(dt['longpress'])
165 self.setSize(dt['size'])
170 def handle_click(self, sender, icon):
171 """ common handler for longpress and click """
172 if icon.name!=None and icon.name!='':
173 launcher.launch(icon.name)
175 def signalLongpress(self, sender, icon):
176 self.handle_click(sender, icon)
178 def signalClick(self, sender, icon):
179 config=self.get_config()
181 if not config.getLongpress():
182 self.handle_click(sender, icon)
184 def signalNotify(self, sender, property):
185 if property.name=='is-on-current-desktop':
186 v=self.get_property(property.name)
187 if v and self.draw_pending:
191 config=self.get_config()
193 w=(self.size[0] * config.iconsize) + \
194 (self.size[0] * config.iconspace)
195 h=(self.size[1] * config.iconsize) + \
196 (self.size[1] * config.iconspace)
197 self.set_size_request(w, h)
200 def setSize(self, size):
201 IconGrid.setSize(self, size)
204 hd_plugin_type = DrlaunchPlugin
206 if __name__=="__main__":
207 gobject.type_register(hd_plugin_type)
208 obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
214 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: