User-visible rotation config and persistence of rotation config
authorEd Page <eopage@byu.net>
Wed, 24 Mar 2010 01:42:52 +0000 (20:42 -0500)
committerEd Page <eopage@byu.net>
Wed, 24 Mar 2010 01:42:52 +0000 (20:42 -0500)
src/multilist_gtk.py
src/settings.py
support/builddeb.py

index 8503552..171d1e6 100755 (executable)
@@ -24,6 +24,7 @@ Copyright (C) 2008 Christoph Würstle
 
 import os
 import logging
 
 import os
 import logging
+import ConfigParser
 
 import gtk
 
 
 import gtk
 
@@ -80,8 +81,8 @@ class Multilist(hildonize.get_app_class()):
                                raise
 
                self.db = libspeichern.Speichern()
                                raise
 
                self.db = libspeichern.Speichern()
-               self.window_in_fullscreen = False #The window isn't in full screen mode initially.
-               self.__isLandscape = True
+               self.__window_in_fullscreen = False #The window isn't in full screen mode initially.
+               self.__isPortrait = False
 
                #Haupt vbox für alle Elemente
                self.window = gtk.Window()
 
                #Haupt vbox für alle Elemente
                self.window = gtk.Window()
@@ -251,8 +252,52 @@ class Multilist(hildonize.get_app_class()):
 
                self.window.show_all()
                self._search.hide()
 
                self.window.show_all()
                self._search.hide()
+               self._load_settings()
                self._prepare_sync_dialog()
 
                self._prepare_sync_dialog()
 
+       def _save_settings(self):
+               config = ConfigParser.SafeConfigParser()
+               self.save_settings(config)
+               with open(self._user_settings, "wb") as configFile:
+                       config.write(configFile)
+
+       def save_settings(self, config):
+               config.add_section(constants.__pretty_app_name__)
+               config.set(constants.__pretty_app_name__, "portrait", str(self.__isPortrait))
+               config.set(constants.__pretty_app_name__, "fullscreen", str(self.__window_in_fullscreen))
+
+       def _load_settings(self):
+               config = ConfigParser.SafeConfigParser()
+               config.read(self._user_settings)
+               self.load_settings(config)
+
+       def load_settings(self, config):
+               isPortrait = False
+               window_in_fullscreen = False
+               try:
+                       isPortrait = config.getboolean(constants.__pretty_app_name__, "portrait")
+                       window_in_fullscreen = config.getboolean(constants.__pretty_app_name__, "fullscreen")
+               except ConfigParser.NoSectionError, e:
+                       _moduleLogger.info(
+                               "Settings file %s is missing section %s" % (
+                                       self._user_settings,
+                                       e.section,
+                               )
+                       )
+
+               if isPortrait ^ self.__isPortrait:
+                       if isPortrait:
+                               orientation = gtk.ORIENTATION_VERTICAL
+                       else:
+                               orientation = gtk.ORIENTATION_HORIZONTAL
+                       self.set_orientation(orientation)
+
+               self.__window_in_fullscreen = window_in_fullscreen
+               if self.__window_in_fullscreen:
+                       self.window.fullscreen()
+               else:
+                       self.window.unfullscreen()
+
        def _toggle_search(self):
                if self._search.get_property("visible"):
                        self._search.hide()
        def _toggle_search(self):
                if self._search.get_property("visible"):
                        self._search.hide()
@@ -264,23 +309,23 @@ class Multilist(hildonize.get_app_class()):
                        hildonize.window_to_portrait(self.window)
                        self.bottombar.set_orientation(gtk.ORIENTATION_VERTICAL)
                        self.selection.set_orientation(gtk.ORIENTATION_VERTICAL)
                        hildonize.window_to_portrait(self.window)
                        self.bottombar.set_orientation(gtk.ORIENTATION_VERTICAL)
                        self.selection.set_orientation(gtk.ORIENTATION_VERTICAL)
-                       self.__isLandscape = False
-               elif orientation == gtk.ORIENTATION_HORIZONTALt :
+                       self.__isPortrait = True
+               elif orientation == gtk.ORIENTATION_HORIZONTAL:
                        hildonize.window_to_landscape(self.window)
                        self.bottombar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
                        self.selection.set_orientation(gtk.ORIENTATION_HORIZONTAL)
                        hildonize.window_to_landscape(self.window)
                        self.bottombar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
                        self.selection.set_orientation(gtk.ORIENTATION_HORIZONTAL)
-                       self.__isLandscape = True
+                       self.__isPortrait = False
                else:
                        raise NotImplementedError(orientation)
 
        def get_orientation(self):
                else:
                        raise NotImplementedError(orientation)
 
        def get_orientation(self):
-               return gtk.ORIENTATION_HORIZONTAL if self.__isLandscape else gtk.ORIENTATION_VERTICAL
+               return gtk.ORIENTATION_VERTICAL if self.__isPortrait else gtk.ORIENTATION_HORIZONTAL
 
        def _toggle_rotate(self):
 
        def _toggle_rotate(self):
-               if self.__isLandscape:
-                       self.set_orientation(gtk.ORIENTATION_VERTICAL)
-               else:
+               if self.__isPortrait:
                        self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
                        self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
+               else:
+                       self.set_orientation(gtk.ORIENTATION_VERTICAL)
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_checkout_all(self, widget):
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_checkout_all(self, widget):
@@ -316,7 +361,7 @@ class Multilist(hildonize.get_app_class()):
                        event.keyval in RETURN_TYPES and isCtrl
                ):
                        # The "Full screen" hardware key has been pressed 
                        event.keyval in RETURN_TYPES and isCtrl
                ):
                        # The "Full screen" hardware key has been pressed 
-                       if self.window_in_fullscreen:
+                       if self.__window_in_fullscreen:
                                self.window.unfullscreen ()
                        else:
                                self.window.fullscreen ()
                                self.window.unfullscreen ()
                        else:
                                self.window.fullscreen ()
@@ -342,9 +387,9 @@ class Multilist(hildonize.get_app_class()):
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_window_state_change(self, widget, event, *args):
                if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN:
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_window_state_change(self, widget, event, *args):
                if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN:
-                       self.window_in_fullscreen = True
+                       self.__window_in_fullscreen = True
                else:
                else:
-                       self.window_in_fullscreen = False
+                       self.__window_in_fullscreen = False
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_sync_finished(self, data = None, data2 = None):
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_sync_finished(self, data = None, data2 = None):
@@ -383,6 +428,7 @@ class Multilist(hildonize.get_app_class()):
                        self.__settingsWindow.set_transient_for(self.window)
                        self.__settingsWindow.set_default_size(*self.window.get_size())
                        self.__settingsWindow.connect("delete-event", self._on_settings_delete)
                        self.__settingsWindow.set_transient_for(self.window)
                        self.__settingsWindow.set_default_size(*self.window.get_size())
                        self.__settingsWindow.connect("delete-event", self._on_settings_delete)
+               self.__settingsManager.set_portrait_state(self.__isPortrait)
                self.__settingsWindow.set_modal(True)
                self.__settingsWindow.show_all()
 
                self.__settingsWindow.set_modal(True)
                self.__settingsWindow.show_all()
 
@@ -396,12 +442,22 @@ class Multilist(hildonize.get_app_class()):
                self.__settingsManager.save(self.db)
                self.view.reload_view()
 
                self.__settingsManager.save(self.db)
                self.view.reload_view()
 
+               isPortrait = self.__settingsManager.is_portrait()
+               if isPortrait ^ self.__isPortrait:
+                       if isPortrait:
+                               orientation = gtk.ORIENTATION_VERTICAL
+                       else:
+                               orientation = gtk.ORIENTATION_HORIZONTAL
+                       self.set_orientation(orientation)
+
                return True
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_destroy(self, widget = None, data = None):
                try:
                        self.db.close()
                return True
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_destroy(self, widget = None, data = None):
                try:
                        self.db.close()
+                       self._save_settings()
+
                        try:
                                self._osso_c.close()
                        except AttributeError:
                        try:
                                self._osso_c.close()
                        except AttributeError:
index 8fbcbea..f88fa8e 100644 (file)
@@ -54,10 +54,19 @@ class SettingsDialog(object):
 
                        self.__columnsSection.pack_start(checkbutton)
 
 
                        self.__columnsSection.pack_start(checkbutton)
 
-               columnsFrame = gtk.Frame(_("Choose Columns"))
+               columnsFrame = gtk.Frame(_("Visible Columns"))
                columnsFrame.add(self.__columnsSection)
 
                columnsFrame.add(self.__columnsSection)
 
+               self.__rotationSection = gtk.VBox()
+
+               self.__isPortraitCheckbutton = gtk.CheckButton(_("Portrait Mode"))
+               self.__rotationSection.pack_start(self.__isPortraitCheckbutton)
+
+               rotationFrame = gtk.Frame(_("Rotation"))
+               rotationFrame.add(self.__rotationSection)
+
                settingsBox = gtk.VBox()
                settingsBox = gtk.VBox()
+               settingsBox.pack_start(rotationFrame)
                settingsBox.pack_start(columnsFrame)
                settingsView = gtk.Viewport()
                settingsView.add(settingsBox)
                settingsBox.pack_start(columnsFrame)
                settingsView = gtk.Viewport()
                settingsView.add(settingsBox)
@@ -68,6 +77,12 @@ class SettingsDialog(object):
 
                settingsScrollView = hildonize.hildonize_scrollwindow(settingsScrollView)
 
 
                settingsScrollView = hildonize.hildonize_scrollwindow(settingsScrollView)
 
+       def set_portrait_state(self, isPortrait):
+               self.__isPortraitCheckbutton.set_active(isPortrait)
+
+       def is_portrait(self):
+               return self.__isPortraitCheckbutton.get_active()
+
        def is_col_selected(self, icol):
                children = self.__columnsSection.get_children()
                if icol < len(children):
        def is_col_selected(self, icol):
                children = self.__columnsSection.get_children()
                if icol < len(children):
index cde7188..9593cde 100755 (executable)
@@ -21,6 +21,10 @@ __email__ = "n800@axique.net"
 __version__ = constants.__version__
 __build__ = constants.__build__
 __changelog__ = """
 __version__ = constants.__version__
 __build__ = constants.__build__
 __changelog__ = """
+0.3.4
+* Making rotation configurable in the Settings window
+* Persisting full-screen / rotation settings
+
 0.3.3
 * Rotation support
 * Turned the settings dialog into a window
 0.3.3
 * Rotation support
 * Turned the settings dialog into a window