import browser_emu
-_moduleLogger = logging.getLogger("gvoice")
+_moduleLogger = logging.getLogger(__name__)
class NetworkError(RuntimeError):
self._smsEntryWindow = None
self._isFullScreen = False
+ self.__isPortrait = False
self._app = hildonize.get_app_class()()
self._window = hildonize.hildonize_window(self._app, self._window)
hildonize.hildonize_text_entry(self._widgetTree.get_widget("usernameentry"))
self._accountViews[self._selectedBackendId].update()
self._refresh_active_tab()
+ self._refresh_orientation()
def load_settings(self, config):
"""
isFullscreen = config.getboolean(constants.__pretty_app_name__, "fullscreen")
if isFullscreen:
self._window.fullscreen()
+
+ isPortrait = config.getboolean(constants.__pretty_app_name__, "portrait")
+ if isPortrait ^ self.__isPortrait:
+ if isPortrait:
+ orientation = gtk.ORIENTATION_VERTICAL
+ else:
+ orientation = gtk.ORIENTATION_HORIZONTAL
+ self.set_orientation(orientation)
except ConfigParser.NoOptionError, e:
_moduleLogger.exception(
"Settings file %s is missing section %s" % (
),
)
- try:
- previousOrientation = config.getint(constants.__pretty_app_name__, "orientation")
- if previousOrientation == gtk.ORIENTATION_HORIZONTAL:
- hildonize.window_to_landscape(self._window)
- elif previousOrientation == gtk.ORIENTATION_VERTICAL:
- hildonize.window_to_portrait(self._window)
- except ConfigParser.NoOptionError, e:
- _moduleLogger.exception(
- "Settings file %s is missing section %s" % (
- constants._user_settings_,
- e.section,
- ),
- )
- except ConfigParser.NoSectionError, e:
- _moduleLogger.exception(
- "Settings file %s is missing section %s" % (
- constants._user_settings_,
- e.section,
- ),
- )
-
def save_settings(self, config):
"""
@note Thread Agnostic
config.add_section(constants.__pretty_app_name__)
config.set(constants.__pretty_app_name__, "active", str(backend))
- config.set(constants.__pretty_app_name__, "orientation", str(int(gtk_toolbox.get_screen_orientation())))
+ config.set(constants.__pretty_app_name__, "portrait", str(self.__isPortrait))
config.set(constants.__pretty_app_name__, "fullscreen", str(self._isFullScreen))
for i, value in enumerate(self._credentials):
blob = base64.b64encode(value)
if self._ledHandler is not None:
self._ledHandler.off()
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ hildonize.window_to_portrait(self._window)
+ self._notebook.set_property("tab-pos", gtk.POS_BOTTOM)
+ self.__isPortrait = True
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ hildonize.window_to_landscape(self._window)
+ self._notebook.set_property("tab-pos", gtk.POS_LEFT)
+ self.__isPortrait = False
+ else:
+ raise NotImplementedError(orientation)
+
+ def get_orientation(self):
+ return gtk.ORIENTATION_VERTICAL if self.__isPortrait else gtk.ORIENTATION_HORIZONTAL
+
+ def _toggle_rotate(self):
+ if self.__isPortrait:
+ self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
+ else:
+ self.set_orientation(gtk.ORIENTATION_VERTICAL)
+
+ def _refresh_orientation(self):
+ """
+ Mostly meant to be used when switching backends
+ """
+ if self.__isPortrait:
+ self.set_orientation(gtk.ORIENTATION_VERTICAL)
+ else:
+ self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
+
@gtk_toolbox.log_exception(_moduleLogger)
def _on_close(self, *args, **kwds):
try:
event.get_state() & gtk.gdk.CONTROL_MASK
):
self._window.destroy()
+ elif event.keyval == gtk.keysyms.o and event.get_state() & gtk.gdk.CONTROL_MASK:
+ self._toggle_rotate()
+ return True
elif event.keyval == gtk.keysyms.r and event.get_state() & gtk.gdk.CONTROL_MASK:
self._refresh_active_tab()
elif event.keyval == gtk.keysyms.i and event.get_state() & gtk.gdk.CONTROL_MASK:
"""
pass
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
def _on_key_press(self, widget, event):
try:
if event.keyval == ord("v") and event.get_state() & gtk.gdk.CONTROL_MASK:
config.set(section, "notifyOnVoicemail", repr(self._notifyOnVoicemail))
config.set(section, "notifyOnSms", repr(self._notifyOnSms))
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
def _populate_callback_combo(self):
self._isPopulated = True
del self._callbackList[:]
"""
config.set(sectionName, "filter", self._selectedFilter)
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
def _is_history_visible(self, model, iter):
try:
action = model.get_value(iter, self.ACTION_IDX)
config.set(sectionName, "status", self._messageStatus)
config.set(sectionName, "type", self._messageType)
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
def _is_message_visible(self, model, iter):
try:
message = model.get_value(iter, self.MESSAGE_DATA_IDX)
def save_settings(self, config, sectionName):
config.set(sectionName, "selectedAddressbook", str(self._selectedComboIndex))
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
def _idly_populate_contactsview(self):
with gtk_toolbox.gtk_lock():
banner = hildonize.show_busy_banner_start(self._window, "Loading Contacts")
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):
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
"""
pass
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
class AccountInfo(object):
"""
pass
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
class CallHistoryView(object):
"""
pass
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
class MessagesView(object):
"""
pass
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)
+
class ContactsView(object):
@note Thread Agnostic
"""
pass
+
+ def set_orientation(self, orientation):
+ if orientation == gtk.ORIENTATION_VERTICAL:
+ pass
+ elif orientation == gtk.ORIENTATION_HORIZONTAL:
+ pass
+ else:
+ raise NotImplementedError(orientation)