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',
69 mode=FremantleRotation.AUTOMATIC, dontrotate=True)
73 self.set_settings(True)
79 """If this is called from the constructor then the program
81 aid=self.get_applet_id()
83 # Get desktop activity if D.A.M. is present
85 act="/usr/bin/activity"
87 if os.path.exists(act):
88 r=Popen([act, "current"], stdout=PIPE).communicate()
93 ret="%s-%s" % (aid, activity)
99 self.id=self.get_id0()
103 def get_config(self):
104 if self.config==None:
106 self.config=config.Config(id)
110 def do_realize(self):
112 config=self.get_config()
115 IconGrid.do_realize(self, config)
117 self.setSize(config.getSize())
120 screen=self.get_screen()
121 self.set_colormap(screen.get_rgba_colormap())
122 self.set_app_paintable(True)
124 self.connect('show-settings', self.slot_show_settings)
125 self.connect('long-press', self.signalLongpress)
126 self.connect('click', self.signalClick)
127 self.connect('notify', self.signalNotify)
129 HomePluginItem.do_realize(self)
131 def on_orientation_changed(self, orientation):
132 # Get the first character of the string (l/p)
137 def do_expose_event(self, event):
138 IconGrid.do_expose_event(self, event)
139 HomePluginItem.do_expose_event(self, event)
141 def slot_show_settings(self, dt):
142 if self.winConfig!=None:
144 # self.winConfig.show_all()
147 s=WinConfig(self.get_config())
149 s.connect('destroy', self.slotConfigDestroy)
152 def slotConfigDestroy(self, sender):
157 config=self.get_config()
159 config.setSize(dt['size'])
160 config.setApps(dt['apps'])
161 config.setIndiv(dt['indiv'])
162 config.setLongpress(dt['longpress'])
163 config.setAnimate(dt['animate'])
164 config.setNoBg(dt['nobg'])
168 self.setSize(dt['size'])
171 # Free memory that is used for animations if animations are disabled
172 if not dt['animate']:
173 self.clearAnimationCache()
177 def handle_click(self, sender, icon):
178 """ common handler for longpress and click """
179 if icon.name!=None and icon.name!='':
180 print "name:", icon.name
181 launcher.launch(icon.name)
183 def signalLongpress(self, sender, icon):
184 self.handle_click(sender, icon)
186 def signalClick(self, sender, icon):
187 config=self.get_config()
189 if not config.getLongpress():
190 self.handle_click(sender, icon)
192 def signalNotify(self, sender, property):
193 if property.name=='is-on-current-desktop':
194 v=self.get_property(property.name)
195 if v and self.draw_pending:
199 config=self.get_config()
201 w=(self.size[0] * config.iconsize) + \
202 (self.size[0] * config.iconspace)
203 h=(self.size[1] * config.iconsize) + \
204 (self.size[1] * config.iconspace)
205 self.set_size_request(w, h)
208 def setSize(self, size):
209 IconGrid.setSize(self, size)
212 hd_plugin_type = DrlaunchPlugin
214 if __name__=="__main__":
215 gobject.type_register(hd_plugin_type)
216 obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
222 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: