Change the max grid size before changing the size (fixes bug #12292). Don't rotate...
authoruser <user@Nokia-N900-42-11.(none)>
Tue, 15 Nov 2011 23:33:44 +0000 (23:33 +0000)
committeruser <user@Nokia-N900-42-11.(none)>
Tue, 15 Nov 2011 23:33:44 +0000 (23:33 +0000)
src/widget.py

index 6fc1430..35141bb 100755 (executable)
@@ -42,6 +42,7 @@ from hildondesktop import *
 from gtk import gdk
 from math import pi
 import cairo
+import gconf
 import time
 
 from subprocess import Popen,PIPE
@@ -72,6 +73,8 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
 
        self.winConfig=None
 
+       self.gconf=gconf.client_get_default()
+
        self.set_settings(True)
 
        self.id=None
@@ -111,6 +114,41 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
 
        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()
@@ -139,6 +177,20 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
 
        # 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()
 
@@ -186,9 +238,9 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
        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']: