X-Git-Url: http://git.maemo.org/git/?p=gonvert;a=blobdiff_plain;f=src%2Fgonvert_glade.py;h=0fc56cd7fdd234a66f55543a1b8f409a1e539222;hp=9fd3ee4c8654ce6021950240ea10419d08257b3c;hb=69448ac26b58425bf4541d288cbcae116379679e;hpb=c7988d4189e32912af9c23c07e7854bcad7e2ec0 diff --git a/src/gonvert_glade.py b/src/gonvert_glade.py index 9fd3ee4..0fc56cd 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,9 @@ class Gonvert(object): ): scrollingWidget = widgets.get_widget(scrollingWidgetName) assert scrollingWidget is not None, scrollingWidgetName - hildonize.hildonize_scrollwindow(scrollingWidget) + hildonize.hildonize_scrollwindow_with_viewport(scrollingWidget) + # Simplify the UI if hildonize.IS_HILDON_SUPPORTED or constants.FORCE_HILDON_LIKE: self._categoryView.get_parent().hide() self._unitsView.set_headers_visible(False) @@ -261,20 +264,20 @@ class Gonvert(object): button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, None) button.set_label("Name") menu.add_filter(button) - button.connect("click", self._on_click_menu_filter, self._unitNameColumn) + button.connect("clicked", self._on_click_menu_filter, self._unitNameColumn) button.set_mode(False) filterGroup = button button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, filterGroup) button.set_label("Value") menu.add_filter(button) - button.connect("click", self._on_click_menu_filter, self._unitIntegerColumn) + button.connect("clicked", self._on_click_menu_filter, self._unitIntegerColumn) button.set_mode(False) button = hildonize.hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, filterGroup) button.set_label("Unit") menu.add_filter(button) - button.connect("click", self._on_click_menu_filter, self._unitSymbolColumn) + button.connect("clicked", self._on_click_menu_filter, self._unitSymbolColumn) button.set_mode(False) menu.show_all() @@ -305,6 +308,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 +377,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 +610,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 +650,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