from gtk import gdk
from math import pi
import cairo
+import gconf
import time
from subprocess import Popen,PIPE
import apps
from icon import Icon
from icongrid import IconGrid
+from sig import Disconnector
# Restore path
sys.path=orig_path
# IconGrid must be before HomePluginItem for its connect()
# and do_button_*() to override those of HomePluginItem
-class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
+class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
def __init__(self):
IconGrid.__init__(self)
HomePluginItem.__init__(self)
FremantleRotation.__init__(self, 'DrlaunchPlugin',
mode=FremantleRotation.AUTOMATIC, dontrotate=True)
+ Disconnector.__init__(self)
self.winConfig=None
+ self.gconf=gconf.client_get_default()
+
self.set_settings(True)
self.id=None
return(self.config)
+ def get_desktop_orientation(self):
+ """
+ Return desktop orientation
+
+ NOTE: This is the desktop orientation as it was introduced in CSSU.
+ Not the device orientation.
+
+ @return "portrait" or "landscape"
+ """
+
+ sw=gdk.screen_width()
+ sh=gdk.screen_height()
+
+ if sw>=sh:
+ ret='landscape'
+ else:
+ ret='portrait'
+
+ return(ret)
+
+ def is_rotating_desktop(self):
+ """
+ Check whether the desktop will change to portrait mode, as
+ added in CSSU.
+
+ @return True/False
+ """
+
+ c=self.gconf
+
+ # This returns False if the key doesn't exist
+ ret=c.get_bool('/apps/osso/hildon-desktop/ui_can_rotate')
+
+ return(ret)
+
def do_realize(self):
launcher.init()
config=self.get_config()
self.set_colormap(screen.get_rgba_colormap())
self.set_app_paintable(True)
- self.connect('show-settings', self.slot_show_settings)
- self.connect('long-press', self.signalLongpress)
- self.connect('click', self.signalClick)
- self.connect('notify', self.signalNotify)
+ self.c(self, 'show-settings', self.slot_show_settings)
+ self.c(self, 'long-press', self.signalLongpress)
+ self.c(self, 'click', self.signalClick)
+ self.c(self, 'notify', self.signalNotify)
HomePluginItem.do_realize(self)
# Get the first character of the string (l/p)
o=orientation[0]
+
+ # Get desktop orientation
+ #do=self.get_desktop_orientation()
+
+ # Is desktop rotation (per CSSU) enabled?
+ rd=self.is_rotating_desktop()
+
+ #print "desktop: %s / %s, device: %s" % (do, rd, o)
+
+ # In case of a rotating desktop, force orientation to be
+ # 'landscape'
+ if rd:
+ o='l'
+
self.setMode(o)
# self.queue_draw()
s=WinConfig(self.get_config())
s.show_all()
- s.connect('destroy', self.slotConfigDestroy)
+ #s.c(s, 'delete-event', self.slotConfigDestroy)
+ self.c(s, 'delete-event', self.slotConfigDestroy)
+ #s.connect('destroy', self.slotConfigDestroy)
self.winConfig=s
- def slotConfigDestroy(self, sender):
- self.winConfig=None
-
+ def slotConfigDestroy(self, sender, event):
+# print "Sender:", sender
dt=sender.getData()
- config=self.get_config()
+ # Disconnect signals for that object in order to be deleted
+ self.dis_finish(self.winConfig)
+ #self.winConfig.finish()
+ #self.winConfig.destroy()
+
+ self.winConfig=None
- config.setSize(dt['size'])
- config.setApps(dt['apps'])
- config.setIndiv(dt['indiv'])
- config.setLongpress(dt['longpress'])
- config.setAnimate(dt['animate'])
- config.setNoBg(dt['nobg'])
- config.setThemeBg(dt['themebg'])
- config.setIconSize(dt['iconsize'])
- config.setIconPadding(dt['iconpadding'])
- config.setIconMargin(dt['iconmargin'])
- config.save()
+ cfg=self.get_config()
+
+ cfg.setSize(dt['size'])
+ cfg.setApps(dt['apps'])
+ cfg.setIndiv(dt['indiv'])
+ cfg.setLongpress(dt['longpress'])
+ cfg.setAnimate(dt['animate'])
+ cfg.setNoBg(dt['nobg'])
+ cfg.setThemeBg(dt['themebg'])
+ cfg.setIconSize(dt['iconsize'])
+ cfg.setIconPadding(dt['iconpadding'])
+ cfg.setIconMargin(dt['iconmargin'])
+ cfg.save()
# Resize widget
+ self.icons.resizeMax()
self.setSize(dt['size'])
self.reloadIcons()
- self.icons.resizeMax()
# Free memory that is used for animations if animations are disabled
if not dt['animate']:
self.queue_draw()
+# print "slot-config-destroy-end"
+
+ return(False)
+
def handle_click(self, sender, icon):
""" common handler for longpress and click """
- if icon.name!=None and icon.name!='':
- launcher.launch(icon.name)
+ if icon.appname!=None and icon.appname!='':
+ launcher.launch(icon.appname)
def signalLongpress(self, sender, icon):
self.handle_click(sender, icon)