Fixing a bug with launching from a fresh system
[quicknote] / src / hildonize.py
index 22ec02f..77d585a 100755 (executable)
@@ -2,6 +2,7 @@
 
 """
 Open Issues
+       @bug not all of a message is shown
        @bug Buttons are too small
 """
 
@@ -91,16 +92,14 @@ except AttributeError:
                hildonize_window = _null_hildonize_window
 
 
-def _fremantle_hildonize_menu(window, gtkMenu, buttons):
+def _fremantle_hildonize_menu(window, gtkMenu):
        appMenu = hildon.AppMenu()
-       for button in buttons:
-               appMenu.append(button)
        window.set_app_menu(appMenu)
        gtkMenu.get_parent().remove(gtkMenu)
        return appMenu
 
 
-def _hildon_hildonize_menu(window, gtkMenu, ignoredButtons):
+def _hildon_hildonize_menu(window, gtkMenu):
        hildonMenu = gtk.Menu()
        for child in gtkMenu.get_children():
                child.reparent(hildonMenu)
@@ -109,7 +108,7 @@ def _hildon_hildonize_menu(window, gtkMenu, ignoredButtons):
        return hildonMenu
 
 
-def _null_hildonize_menu(window, gtkMenu, ignoredButtons):
+def _null_hildonize_menu(window, gtkMenu):
        return gtkMenu
 
 
@@ -189,6 +188,20 @@ else:
        set_cell_thumb_selectable = _null_set_cell_thumb_selectable
 
 
+def _hildon_set_pix_cell_thumb_selectable(renderer):
+       renderer.set_property("stock-size", 48)
+
+
+def _null_set_pix_cell_thumb_selectable(renderer):
+       pass
+
+
+if IS_HILDON_SUPPORTED:
+       set_pix_cell_thumb_selectable = _hildon_set_pix_cell_thumb_selectable
+else:
+       set_pix_cell_thumb_selectable = _null_set_pix_cell_thumb_selectable
+
+
 def _fremantle_show_information_banner(parent, message):
        hildon.hildon_banner_show_information(parent, "", message)
 
@@ -264,30 +277,16 @@ else:
        hildonize_text_entry = _null_hildonize_text_entry
 
 
-def _hildon_mark_window_rotatable(window):
-       # gtk documentation is unclear whether this does a "=" or a "|="
-       window.set_flags(hildon.HILDON_PORTRAIT_MODE_SUPPORT)
-
-
-def _null_mark_window_rotatable(window):
-       pass
-
-
-try:
-       hildon.HILDON_PORTRAIT_MODE_SUPPORT
-       mark_window_rotatable = _hildon_mark_window_rotatable
-except AttributeError:
-       mark_window_rotatable = _null_mark_window_rotatable
-
-
 def _hildon_window_to_portrait(window):
        # gtk documentation is unclear whether this does a "=" or a "|="
-       window.set_flags(hildon.HILDON_PORTRAIT_MODE_SUPPORT)
+       flags = hildon.PORTRAIT_MODE_SUPPORT | hildon.PORTRAIT_MODE_REQUEST
+       hildon.hildon_gtk_window_set_portrait_flags(window, flags)
 
 
 def _hildon_window_to_landscape(window):
        # gtk documentation is unclear whether this does a "=" or a "&= ~"
-       window.unset_flags(hildon.HILDON_PORTRAIT_MODE_REQUEST)
+       flags = hildon.PORTRAIT_MODE_SUPPORT
+       hildon.hildon_gtk_window_set_portrait_flags(window, flags)
 
 
 def _null_window_to_portrait(window):
@@ -299,8 +298,9 @@ def _null_window_to_landscape(window):
 
 
 try:
-       hildon.HILDON_PORTRAIT_MODE_SUPPORT
-       hildon.HILDON_PORTRAIT_MODE_REQUEST
+       hildon.PORTRAIT_MODE_SUPPORT
+       hildon.PORTRAIT_MODE_REQUEST
+       hildon.hildon_gtk_window_set_portrait_flags
 
        window_to_portrait = _hildon_window_to_portrait
        window_to_landscape = _hildon_window_to_landscape
@@ -708,12 +708,21 @@ if __name__ == "__main__":
        win = gtk.Window()
        win.add(label)
        win = hildonize_window(app, win)
-       if False:
+       if False and IS_FREMANTLE_SUPPORTED:
+               appMenu = hildon.AppMenu()
+               for i in xrange(5):
+                       b = gtk.Button(str(i))
+                       appMenu.append(b)
+               win.set_app_menu(appMenu)
+               win.show_all()
+               appMenu.show_all()
+               gtk.main()
+       elif False:
                print touch_selector(win, "Test", ["A", "B", "C", "D"], 2)
-       if True:
+       elif False:
                print touch_selector_entry(win, "Test", ["A", "B", "C", "D"], "C")
                print touch_selector_entry(win, "Test", ["A", "B", "C", "D"], "Blah")
-       if False:
+       elif False:
                import pprint
                name, value = "", ""
                goodLocals = [
@@ -721,11 +730,11 @@ if __name__ == "__main__":
                        if not name.startswith("_")
                ]
                pprint.pprint(goodLocals)
-       if False:
+       elif False:
                import time
                show_information_banner(win, "Hello World")
                time.sleep(5)
-       if False:
+       elif False:
                import time
                banner = show_busy_banner_start(win, "Hello World")
                time.sleep(5)