X-Git-Url: http://git.maemo.org/git/?p=gonvert;a=blobdiff_plain;f=src%2Fgonvert_glade.py;h=5dd5580dfa3ffaf9981feccb7a79a3056b582c49;hp=ea8cd382cc631faece88d8ff93a957b228abeb5c;hb=989d15b85b8a64aa7b213f165b99001159ae6c1c;hpb=f312cd342f006d25ed896f3ae7139f07de08394d diff --git a/src/gonvert_glade.py b/src/gonvert_glade.py index ea8cd38..5dd5580 100755 --- a/src/gonvert_glade.py +++ b/src/gonvert_glade.py @@ -28,7 +28,8 @@ else: _ = gettext.gettext -_moduleLogger = logging.getLogger("gonvert_glade") +_moduleLogger = logging.getLogger(__name__) + if gettext is not None: gettext.bindtextdomain('gonvert', '/usr/share/locale') @@ -70,9 +71,8 @@ class Gonvert(object): _glade_files = [ os.path.join(os.path.dirname(__file__), "gonvert.glade"), os.path.join(os.path.dirname(__file__), "../data/gonvert.glade"), - os.path.join(os.path.dirname(__file__), "../lib/gonvert.glade"), + os.path.join(os.path.dirname(__file__), "../share/gonvert.glade"), '/usr/share/gonvert/gonvert.glade', - '/usr/lib/gonvert/gonvert.glade', ] UNITS_NAME_IDX = 0 @@ -86,6 +86,7 @@ class Gonvert(object): self._unit_sort_direction = False self._value_sort_direction = False self._units_sort_direction = False + self.__isPortrait = False self._isFullScreen = False self._clipboard = gtk.clipboard_get() @@ -240,8 +241,10 @@ class Gonvert(object): ): scrollingWidget = widgets.get_widget(scrollingWidgetName) assert scrollingWidget is not None, scrollingWidgetName - hildonize.hildonize_scrollwindow(scrollingWidget) + scroller = hildonize.hildonize_scrollwindow(scrollingWidget) + scroller.show_all() + # Simplify the UI if hildonize.IS_HILDON_SUPPORTED or constants.FORCE_HILDON_LIKE: self._categoryView.get_parent().hide() self._unitsView.set_headers_visible(False) @@ -283,8 +286,8 @@ class Gonvert(object): if not hildonize.IS_HILDON_SUPPORTED: _moduleLogger.info("No hildonization support") - hildonize.set_application_title( - self._mainWindow, "%s - Unit Conversion Utility" % constants.__pretty_app_name__ + hildonize.set_application_name( + "%s - Unit Conversion Utility" % constants.__pretty_app_name__ ) iconPath = pixmapspath + '/gonvert.png' if os.path.exists(iconPath): @@ -306,6 +309,24 @@ class Gonvert(object): pass else: self._mainWindow.resize(a, b) + try: + isFullscreen = saved_window["isFullscreen"] + except KeyError: + pass + else: + if isFullscreen: + self._mainWindow.fullscreen() + try: + isPortrait = saved_window["isPortrait"] + except KeyError: + pass + else: + if isPortrait ^ self.__isPortrait: + if isPortrait: + orientation = gtk.ORIENTATION_VERTICAL + else: + orientation = gtk.ORIENTATION_HORIZONTAL + self.set_orientation(orientation) #Restore selections from previously saved settings if it exists and is valid. categoryIndex = 0 @@ -357,7 +378,9 @@ class Gonvert(object): #Get last size of app and save it window_settings = { - 'size': self._mainWindow.get_size() + 'size': self._mainWindow.get_size(), + "isFullscreen": self._isFullScreen, + "isPortrait": self.__isPortrait, } windowDatPath = "/".join((constants._data_path_, "window.dat")) pickle.dump(window_settings, open(windowDatPath, 'w')) @@ -588,6 +611,25 @@ class Gonvert(object): else: assert False, "Unknown column: %s" % (col.get_title(), ) + def set_orientation(self, orientation): + if orientation == gtk.ORIENTATION_VERTICAL: + hildonize.window_to_portrait(self._mainWindow) + self.__isPortrait = True + elif orientation == gtk.ORIENTATION_HORIZONTAL: + hildonize.window_to_landscape(self._mainWindow) + 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) + @gtk_toolbox.log_exception(_moduleLogger) def _on_key_press(self, widget, event, *args): """ @@ -609,6 +651,8 @@ class Gonvert(object): self._find_previous() elif event.keyval == gtk.keysyms.n and event.get_state() & gtk.gdk.CONTROL_MASK: self._find_next() + elif event.keyval == gtk.keysyms.o and event.get_state() & gtk.gdk.CONTROL_MASK: + self._toggle_rotate() elif ( event.keyval in (gtk.keysyms.w, gtk.keysyms.q) and event.get_state() & gtk.gdk.CONTROL_MASK @@ -629,12 +673,16 @@ class Gonvert(object): if event.keyval == gtk.keysyms.uparrow or event.keyval == gtk.keysyms.Up: index, column = self._unitsView.get_cursor() newIndex = max(index[0]-1, 0) - self._unitsView.set_cursor((newIndex, ), column, True) + path = (newIndex, ) + self._unitsView.set_cursor(path, column, True) + self._unitsView.scroll_to_cell(path, column, False, 0, 0) return True # override default behavior elif event.keyval == gtk.keysyms.downarrow or event.keyval == gtk.keysyms.Down: index, column = self._unitsView.get_cursor() newIndex = min(index[0]+1, len(self._unitModel)-1) - self._unitsView.set_cursor((newIndex, ), column, True) + path = (newIndex, ) + self._unitsView.set_cursor(path, column, True) + self._unitsView.scroll_to_cell(path, column, False, 0, 0) return True # override default behavior @gtk_toolbox.log_exception(_moduleLogger)