8 class FakeHildonModule(object):
14 except (ImportError, OSError):
15 hildon = FakeHildonModule
18 IS_HILDON = hildon is not FakeHildonModule
21 class FakeHildonProgram(object):
31 return FakeHildonProgram
35 def set_application_title(window, title):
38 def set_application_title(window, title):
39 window.set_title(title)
43 def hildonize_window(app, window):
45 newWindow = hildon.Window()
46 oldWindow.get_child().reparent(newWindow)
47 app.add_window(newWindow)
50 def hildonize_window(app, window):
55 def hildonize_menu(window, gtkMenu):
56 hildonMenu = gtk.Menu()
57 for child in gtkMenu.get_children():
58 child.reparent(hildonMenu)
59 window.set_menu(hildonMenu)
63 def hildonize_menu(window, gtkMenu):
68 def set_cell_thumb_selectable(renderer):
69 renderer.set_property("scale", 1.5)
71 def set_cell_thumb_selectable(renderer):
76 def hildonize_text_entry(textEntry):
77 textEntry.set_property('hildon-input-mode', 7)
79 def hildonize_text_entry(textEntry):
84 def mark_window_rotatable(window):
85 raise NotImplementedError("TODO distinguish between Diablo and Fremantle")
86 # gtk documentation is unclear whether this does a "=" or a "|="
87 window.set_flags(hildon.HILDON_PORTRAIT_MODE_SUPPORT)
89 def mark_window_rotatable(window):
94 def window_to_portrait(window):
95 raise NotImplementedError("TODO distinguish between Diablo and Fremantle")
96 # gtk documentation is unclear whether this does a "=" or a "|="
97 window.set_flags(hildon.HILDON_PORTRAIT_MODE_SUPPORT)
99 def window_to_landscape(window):
100 raise NotImplementedError("TODO distinguish between Diablo and Fremantle")
101 # gtk documentation is unclear whether this does a "=" or a "&= ~"
102 window.unset_flags(hildon.HILDON_PORTRAIT_MODE_REQUEST)
104 def window_to_portrait(window):
107 def window_to_landscape(window):
111 def get_device_orientation():
112 raise NotImplementedError()
113 bus = dbus.SystemBus()
115 rawMceRequest = bus.get_object("com.nokia.mce", "/com/nokia/mce/request")
116 mceRequest = dbus.Interface(rawMceRequest, dbus_interface="com.nokia.mce.request")
117 orientation, standState, faceState, xAxis, yAxis, zAxis = mceRequest.get_device_orientation()
118 except dbus.exception.DBusException:
119 # catching for documentation purposes that when a system doesn't
120 # support this, this is what to expect
123 if orientation == "":
124 return gtk.ORIENTATION_HORIZONTAL
125 elif orientation == "":
126 return gtk.ORIENTATION_VERTICAL
128 raise RuntimeError("Unknown orientation: %s" % orientation)
132 def hildonize_password_entry(textEntry):
133 textEntry.set_property('hildon-input-mode', 7 | (1 << 29))
135 def hildonize_password_entry(textEntry):
140 def hildonize_combo_entry(comboEntry):
141 comboEntry.set_property('hildon-input-mode', 1 << 4)
143 def hildonize_combo_entry(textEntry):
148 def set_thumb_scrollbar(scrolledWindow):
149 hildon.hildon_helper_set_thumb_scrollbar(scrolledWindow, True)
151 def set_thumb_scrollbar(scrolledWindow):
156 def request_number(parent, title, range, default):
157 spinner = hildon.NumberEditor(*range)
158 spinner.set_value(default)
163 gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
164 (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
166 dialog.set_default_response(gtk.RESPONSE_CANCEL)
167 dialog.get_child().add(spinner)
171 response = dialog.run()
175 if response == gtk.RESPONSE_OK:
176 return spinner.get_value()
177 elif response == gtk.RESPONSE_CANCEL or response == gtk.RESPONSE_DELETE_EVENT:
178 raise RuntimeError("User cancelled request")
180 raise RuntimeError("Unrecognized response %r", response)
182 def request_number(parent, title, range, default):
183 adjustment = gtk.Adjustment(default, range[0], range[1], 1, 5, 0)
184 spinner = gtk.SpinButton(adjustment, 0, 0)
185 spinner.set_wrap(False)
190 gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
191 (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
193 dialog.set_default_response(gtk.RESPONSE_CANCEL)
194 dialog.get_child().add(spinner)
198 response = dialog.run()
202 if response == gtk.RESPONSE_OK:
203 return spinner.get_value_as_int()
204 elif response == gtk.RESPONSE_CANCEL or response == gtk.RESPONSE_DELETE_EVENT:
205 raise RuntimeError("User cancelled request")
207 raise RuntimeError("Unrecognized response %r", response)