X-Git-Url: http://git.maemo.org/git/?p=gonvert;a=blobdiff_plain;f=src%2Fgonvert_glade.py;h=e42b1e49264199a71d6ff88f555e75f944051ae8;hp=5855eee9f2e99c5fe5e156c9359e60445e09e0ff;hb=02ba18393b5daeab0cb00479a300b2597f7dc2f1;hpb=2337b77d463b4987d43cff03e695a829df4ddb50 diff --git a/src/gonvert_glade.py b/src/gonvert_glade.py index 5855eee..e42b1e4 100755 --- a/src/gonvert_glade.py +++ b/src/gonvert_glade.py @@ -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() @@ -116,7 +117,6 @@ class Gonvert(object): change_menu_label(widgets, 'exitMenuItem', _('Exit')) change_menu_label(widgets, 'helpMenuItem', _('Help')) change_menu_label(widgets, 'aboutMenuItem', _('About')) - change_menu_label(widgets, 'findButton', _('Find')) self._categorySelectionButton = widgets.get_widget("categorySelectionButton") self._categoryView = widgets.get_widget('categoryView') @@ -140,6 +140,7 @@ class Gonvert(object): self._findEntry = widgets.get_widget('findEntry') self._findLabel = widgets.get_widget('findLabel') self._findButton = widgets.get_widget('findButton') + self._closeSearchButton = widgets.get_widget('closeSearchButton') self._unitsNameRenderer = gtk.CellRendererText() self._unitsNameRenderer.set_property("scale", 0.75) @@ -224,6 +225,7 @@ class Gonvert(object): self._findButton.connect("clicked", self._on_find_activate) self._findEntry.connect("activate", self._on_find_activate) self._findEntry.connect("changed", self._on_findEntry_changed) + self._closeSearchButton.connect("clicked", self._on_toggle_search) self._previousUnitValue.connect("changed", self._on_previous_unit_value_changed) self._unitValue.connect("changed", self._on_unit_value_changed) self._unitValue.connect("key-press-event", self._on_browse_key_press) @@ -239,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) @@ -282,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): @@ -305,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 @@ -356,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')) @@ -587,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): """ @@ -608,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 @@ -628,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)