Reset the rotation mode on expose event in case the MCE accelerometer monitoring...
[drlaunch] / src / widget.py
index 15f99d5..6953b89 100755 (executable)
@@ -65,7 +65,8 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
     def __init__(self):
        IconGrid.__init__(self)
        HomePluginItem.__init__(self)
-       FremantleRotation.__init__(self, 'DrlaunchPlugin')
+       FremantleRotation.__init__(self, 'DrlaunchPlugin',
+           mode=FremantleRotation.AUTOMATIC, dontrotate=True)
 
        self.winConfig=None
 
@@ -74,6 +75,8 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
        self.id=None
        self.config=None
 
+       self.reset_mode()
+
     def get_id0(self):
        """If this is called from the constructor then the program
        core dumps """
@@ -128,6 +131,10 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
        HomePluginItem.do_realize(self)
 
     def on_orientation_changed(self, orientation):
+       # Avoid bugs
+       if orientation==None or len(orientation)==0:
+           return
+
        # Get the first character of the string (l/p)
        o=orientation[0]
        self.setMode(o)
@@ -136,6 +143,7 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
     def do_expose_event(self, event):
        IconGrid.do_expose_event(self, event)
        HomePluginItem.do_expose_event(self, event)
+       self.reset_mode()
 
     def slot_show_settings(self, dt):
        if self.winConfig!=None:
@@ -160,17 +168,24 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
        config.setIndiv(dt['indiv'])
        config.setLongpress(dt['longpress'])
        config.setAnimate(dt['animate'])
+       config.setNoBg(dt['nobg'])
+       config.setThemeBg(dt['themebg'])
        config.save()
        
        # Resize widget
        self.setSize(dt['size'])
        self.reloadIcons()
 
+       # Free memory that is used for animations if animations are disabled
+       if not dt['animate']:
+           self.clearAnimationCache()
+
        self.queue_draw()
 
     def handle_click(self, sender, icon):
        """ common handler for longpress and click """
        if icon.name!=None and icon.name!='':
+           print "name:", icon.name
            launcher.launch(icon.name)
 
     def signalLongpress(self, sender, icon):