CSSU's portrait mode support - WIP
[drlaunch] / drlaunch / src / widget.py
index 35141bb..cff7575 100755 (executable)
@@ -29,6 +29,7 @@ __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
 import sys
 import os
 
+import gobject
 orig_path=sys.path[:]
 tmp_path=os.path.dirname( os.path.realpath( __file__ ) )
 sys.path.append(tmp_path)
@@ -36,8 +37,6 @@ sys.path.append(tmp_path)
 # End of hack
 
 import gtk
-import gobject
-import hildon
 from hildondesktop import *
 from gtk import gdk
 from math import pi
@@ -58,12 +57,16 @@ from icon import Icon
 from icongrid import IconGrid
 from sig import Disconnector
 
+import icons
+
 # 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, Disconnector):
+    __gtype_name__ = "DrlaunchPlugin"
+
     def __init__(self):
        IconGrid.__init__(self)
        HomePluginItem.__init__(self)
@@ -189,9 +192,21 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
        # In case of a rotating desktop, force orientation to be
        # 'landscape'
        if rd:
+           # CSSU Portrait mode?
+           if o=='p':
+               csp=True
+           else:
+               csp=False
+
            o='l'
 
+       self.setCSSUPortrait(csp)
+
+       if rd:
+           self.resize2()
+
        self.setMode(o)
+
 #      self.queue_draw()
 
     def do_expose_event(self, event):
@@ -282,8 +297,14 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
            (self.size[0] * config.getIconSpace())
        h=(self.size[1] * config.iconsize) + \
            (self.size[1] * config.getIconSpace())
+
+       if self.cssuportrait:
+           (w,h)=(h,w)
+
+       #print "w,h:", w, h
        self.set_size_request(w, h)
        self.resize(w, h)
+       self.queue_draw()
 
     def setSize(self, size):
        IconGrid.setSize(self, size)
@@ -292,7 +313,10 @@ class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
 hd_plugin_type = DrlaunchPlugin
 
 if __name__=="__main__":
-    gobject.type_register(hd_plugin_type)
+
+    icons.init_icons()
+
+    #gobject.type_register(hd_plugin_type)
     obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
     obj.show_all()
     gtk.main()