Fix for config saving.
[drlaunch] / src / widget.py
index 409cb3c..1918367 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
 
@@ -123,10 +124,12 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
        self.connect('show-settings', self.slot_show_settings)
        self.connect('long-press', self.signalLongpress)
        self.connect('click', self.signalClick)
+       self.connect('notify', self.signalNotify)
 
        HomePluginItem.do_realize(self)
 
     def on_orientation_changed(self, orientation):
+       # Get the first character of the string (l/p)
        o=orientation[0]
        self.setMode(o)
 #      self.queue_draw()
@@ -157,17 +160,25 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
        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.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):
@@ -179,7 +190,13 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
        if not config.getLongpress():
            self.handle_click(sender, icon)
 
-    def resize(self):
+    def signalNotify(self, sender, property):
+       if property.name=='is-on-current-desktop':
+           v=self.get_property(property.name)
+           if v and self.draw_pending:
+               self.queue_draw()
+
+    def resize2(self):
        config=self.get_config()
 
        w=(self.size[0] * config.iconsize) + \
@@ -187,10 +204,11 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation):
        h=(self.size[1] * config.iconsize) + \
            (self.size[1] * config.iconspace)
        self.set_size_request(w, h)
+       self.resize(w, h)
 
     def setSize(self, size):
        IconGrid.setSize(self, size)
-       self.resize()
+       self.resize2()
 
 hd_plugin_type = DrlaunchPlugin