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)
81 """If this is called from the constructor then the program
83 aid=self.get_applet_id()
85 # Get desktop activity if D.A.M. is present
87 act="/usr/bin/activity"
89 if os.path.exists(act):
90 r=Popen([act, "current"], stdout=PIPE).communicate()
95 ret="%s-%s" % (aid, activity)
101 self.id=self.get_id0()
105 def get_config(self):
106 if self.config==None:
108 self.config=config.Config(id)
112 def do_realize(self):
114 config=self.get_config()
117 IconGrid.do_realize(self, config)
119 self.setSize(config.getSize())
122 screen=self.get_screen()
123 self.set_colormap(screen.get_rgba_colormap())
124 self.set_app_paintable(True)
126 self.connect('show-settings', self.slot_show_settings)
127 self.connect('long-press', self.signalLongpress)
128 self.connect('click', self.signalClick)
129 self.connect('notify', self.signalNotify)
131 HomePluginItem.do_realize(self)
133 def on_orientation_changed(self, orientation):
135 if orientation==None or len(orientation)==0:
138 # Get the first character of the string (l/p)
143 def do_expose_event(self, event):
144 IconGrid.do_expose_event(self, event)
145 HomePluginItem.do_expose_event(self, event)
148 def slot_show_settings(self, dt):
149 if self.winConfig!=None:
151 # self.winConfig.show_all()
154 s=WinConfig(self.get_config())
156 s.connect('destroy', self.slotConfigDestroy)
159 def slotConfigDestroy(self, sender):
164 config=self.get_config()
166 config.setSize(dt['size'])
167 config.setApps(dt['apps'])
168 config.setIndiv(dt['indiv'])
169 config.setLongpress(dt['longpress'])
170 config.setAnimate(dt['animate'])
171 config.setNoBg(dt['nobg'])
172 config.setThemeBg(dt['themebg'])
173 config.setIconSize(dt['iconsize'])
174 config.setIconPadding(dt['iconpadding'])
175 config.setIconMargin(dt['iconmargin'])
179 self.setSize(dt['size'])
181 self.icons.resizeMax()
183 # Free memory that is used for animations if animations are disabled
184 if not dt['animate']:
185 self.clearAnimationCache()
187 # Free memory of backgrounds in case they changed
192 def handle_click(self, sender, icon):
193 """ common handler for longpress and click """
194 if icon.name!=None and icon.name!='':
195 launcher.launch(icon.name)
197 def signalLongpress(self, sender, icon):
198 self.handle_click(sender, icon)
200 def signalClick(self, sender, icon):
201 config=self.get_config()
203 if not config.getLongpress():
204 self.handle_click(sender, icon)
206 def signalNotify(self, sender, property):
207 if property.name=='is-on-current-desktop':
208 v=self.get_property(property.name)
209 if v and self.draw_pending:
213 config=self.get_config()
215 w=(self.size[0] * config.iconsize) + \
216 (self.size[0] * config.getIconSpace())
217 h=(self.size[1] * config.iconsize) + \
218 (self.size[1] * config.getIconSpace())
219 self.set_size_request(w, h)
222 def setSize(self, size):
223 IconGrid.setSize(self, size)
226 hd_plugin_type = DrlaunchPlugin
228 if __name__=="__main__":
229 gobject.type_register(hd_plugin_type)
230 obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
236 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: