Switching some layout stuff for better hiding of features and adding those hidings
[gonvert] / src / gonvert_glade.py
index 227c21c..6ea0481 100755 (executable)
@@ -3,7 +3,6 @@
 
 import os
 import pickle
-import string
 import gettext
 import logging
 
@@ -13,11 +12,13 @@ import gtk.glade
 import gtk.gdk
 
 import constants
+import hildonize
 import unit_data
 
 
 _moduleLogger = logging.getLogger("gonvert_glade")
 PROFILE_STARTUP = False
+FORCE_HILDON_LIKE = True
 
 gettext.bindtextdomain('gonvert', '/usr/share/locale')
 gettext.textdomain('gonvert')
@@ -65,6 +66,8 @@ class Gonvert(object):
                        return
 
                self._mainWindow = widgets.get_widget('mainWindow')
+               self._app = hildonize.get_app_class()()
+               self._mainWindow = hildonize.hildonize_window(self._app, self._mainWindow)
 
                change_menu_label(widgets, 'fileMenuItem', _('File'))
                change_menu_label(widgets, 'exitMenuItem', _('Exit'))
@@ -82,16 +85,22 @@ class Gonvert(object):
                self._unitsView = widgets.get_widget('unitsView')
                self._unitsView.set_property('rules_hint', 1)
                self._unitsView_selection = self._unitsView.get_selection()
+               if hildonize.IS_HILDON_SUPPORTED or FORCE_HILDON_LIKE:
+                       self._unitsView.set_headers_visible(False)
 
                self._unitName = widgets.get_widget('unitName')
                self._unitValue = widgets.get_widget('unitValue')
                self._previousUnitName = widgets.get_widget('previousUnitName')
                self._previousUnitValue = widgets.get_widget('previousUnitValue')
+               if hildonize.IS_HILDON_SUPPORTED or FORCE_HILDON_LIKE:
+                       self._previousUnitName.get_parent().hide()
 
                self._unitSymbol = widgets.get_widget('unitSymbol')
                self._previousUnitSymbol = widgets.get_widget('previousUnitSymbol')
 
                self._unitDescription = widgets.get_widget('unitDescription')
+               if hildonize.IS_HILDON_SUPPORTED or FORCE_HILDON_LIKE:
+                       self._unitDescription.get_parent().get_parent().hide()
 
                self._searchLayout = widgets.get_widget('searchLayout')
                self._searchLayout.hide()
@@ -187,14 +196,6 @@ class Gonvert(object):
                        if 'size' in saved_window:
                                a, b = saved_window['size']
                                self._mainWindow.resize(a, b)
-                       else:
-                               #Maximize if no previous size was found
-                               #self._mainWindow.maximize()
-                               pass
-               else:
-                       #Maximize if no previous window.dat file was found
-                       #self._mainWindow.maximize()
-                       pass
 
                #Restore selections from previously saved settings if it exists and is valid.
                historical_catergory_found = False
@@ -264,7 +265,7 @@ class Gonvert(object):
        def _find_first(self):
                assert len(self._find_result) == 0
                assert self._findIndex == 0
-               findString = string.lower(string.strip(self._findEntry.get_text()))
+               findString = self._findEntry.get_text().strip().lower()
                if not findString:
                        return
 
@@ -290,18 +291,6 @@ class Gonvert(object):
                )
 
        def _find_next(self):
-               """
-               check if 'new find' or 'last find' or 'next-find'
-
-               new-find = run the find algorithm which also selects the first found unit
-                        = self._findIndex = 0 and self._find_result = []
-
-               last-find = restart from top again
-                         = self._findIndex = len(self._find_result)
-
-               next-find = continue to next found location
-                          = self._findIndex = 0 and len(self._find_result)>0
-               """
                if len(self._find_result) == 0:
                        self._find_first()
                else:
@@ -320,18 +309,6 @@ class Gonvert(object):
                        )
 
        def _find_previous(self):
-               """
-               check if 'new find' or 'last find' or 'next-find'
-
-               new-find = run the find algorithm which also selects the first found unit
-                        = self._findIndex = 0 and self._find_result = []
-
-               last-find = restart from top again
-                         = self._findIndex = len(self._find_result)
-
-               next-find = continue to next found location
-                          = self._findIndex = 0 and len(self._find_result)>0
-               """
                if len(self._find_result) == 0:
                        self._find_first()
                else:
@@ -577,6 +554,10 @@ class Gonvert(object):
                        buffer = self._unitDescription.get_buffer()
                        buffer.set_text(unit_spec[2])
                        self._unitSymbol.set_text(unit_spec[1]) # put units into label text
+                       if unit_spec[1]:
+                               self._unitSymbol.show()
+                       else:
+                               self._unitSymbol.hide()
 
                        if self._unitValue.get_text() == '':
                                if self._selectedCategoryName == "Computer Numbers":