Keyboard shortcut for copying the log and attempts to clean up the column stuff
authorEd Page <eopage@byu.net>
Fri, 13 Nov 2009 02:30:55 +0000 (20:30 -0600)
committerEd Page <eopage@byu.net>
Fri, 13 Nov 2009 02:30:55 +0000 (20:30 -0600)
src/constants.py
src/gonvert.py
src/gonvert_glade.py

index f59990c..972722a 100644 (file)
@@ -7,3 +7,4 @@ __build__ = 2
 __app_magic__ = 0xdeadbeef
 _data_path_ = os.path.join(os.path.expanduser("~"), ".gonvert")
 _user_settings_ = "%s/settings.ini" % _data_path_
 __app_magic__ = 0xdeadbeef
 _data_path_ = os.path.join(os.path.expanduser("~"), ".gonvert")
 _user_settings_ = "%s/settings.ini" % _data_path_
+_user_logpath_ = "%s/gonvert.log" % _data_path_
index 494af65..6a535aa 100755 (executable)
@@ -19,8 +19,7 @@ except OSError, e:
        if e.errno != 17:
                raise
 
        if e.errno != 17:
                raise
 
-userLogPath = "%s/gonvert.log" % constants._data_path_
-logging.basicConfig(level=logging.DEBUG, filename=userLogPath)
+logging.basicConfig(level=logging.DEBUG, filename=constants._user_logpath_)
 _moduleLogger.info("gonvert %s-%s" % (constants.__version__, constants.__build__))
 
 
 _moduleLogger.info("gonvert %s-%s" % (constants.__version__, constants.__build__))
 
 
index 674bea4..c15ba8d 100755 (executable)
@@ -86,6 +86,7 @@ class Gonvert(object):
                self._value_sort_direction = False
                self._units_sort_direction = False
                self._isFullScreen = False
                self._value_sort_direction = False
                self._units_sort_direction = False
                self._isFullScreen = False
+               self._clipboard = gtk.clipboard_get()
 
                self._find_result = [] # empty find result list
                self._findIndex = 0 # default to find result number zero
 
                self._find_result = [] # empty find result list
                self._findIndex = 0 # default to find result number zero
@@ -333,6 +334,17 @@ class Gonvert(object):
                windowDatPath = "/".join((constants._data_path_, "window.dat"))
                pickle.dump(window_settings, open(windowDatPath, 'w'))
 
                windowDatPath = "/".join((constants._data_path_, "window.dat"))
                pickle.dump(window_settings, open(windowDatPath, 'w'))
 
+       def _refresh_columns(self):
+               self._unitsView.remove_column(self._unitNameColumn)
+               self._unitsView.remove_column(self._unitIntegerColumn)
+               self._unitsView.remove_column(self._unitFractionalColumn)
+               self._unitsView.remove_column(self._unitSymbolColumn)
+
+               self._unitsView.append_column(self._unitNameColumn)
+               self._unitsView.append_column(self._unitIntegerColumn)
+               self._unitsView.append_column(self._unitFractionalColumn)
+               self._unitsView.append_column(self._unitSymbolColumn)
+
        def _clear_find(self):
                # switch to "new find" state
                self._find_result = []
        def _clear_find(self):
                # switch to "new find" state
                self._find_result = []
@@ -461,8 +473,9 @@ class Gonvert(object):
                self._sortedUnitModel.sort_column_changed()
 
                if FORCE_HILDON_LIKE:
                self._sortedUnitModel.sort_column_changed()
 
                if FORCE_HILDON_LIKE:
-                       charWidth = int(nameLength * 0.75)
-                       charWidth = min(charWidth, 20)
+                       maxCatCharWidth = int(nameLength * 0.75)
+                       maxCharWidth = int(len("nibble | hexit | quadbit") * 0.75)
+                       charWidth = min(maxCatCharWidth, maxCharWidth)
                        self._unitsNameRenderer.set_property("width-chars", charWidth)
 
                self._select_default_unit()
                        self._unitsNameRenderer.set_property("width-chars", charWidth)
 
                self._select_default_unit()
@@ -545,6 +558,11 @@ class Gonvert(object):
                                self._find_previous()
                        elif event.keyval == gtk.keysyms.n and event.get_state() & gtk.gdk.CONTROL_MASK:
                                self._find_next()
                                self._find_previous()
                        elif event.keyval == gtk.keysyms.n and event.get_state() & gtk.gdk.CONTROL_MASK:
                                self._find_next()
+                       elif event.keyval == ord("l") and event.get_state() & gtk.gdk.CONTROL_MASK:
+                               with open(constants._user_logpath_, "r") as f:
+                                       logLines = f.xreadlines()
+                                       log = "".join(logLines)
+                                       self._clipboard.set_text(str(log))
                except Exception, e:
                        _moduleLogger.exception("_on_key_press")
 
                except Exception, e:
                        _moduleLogger.exception("_on_key_press")
 
@@ -710,6 +728,7 @@ class Gonvert(object):
                                self._previousUnitValue.set_text(str(func.from_base(base, arg, )))
 
                        self._sortedUnitModel.sort_column_changed()
                                self._previousUnitValue.set_text(str(func.from_base(base, arg, )))
 
                        self._sortedUnitModel.sort_column_changed()
+                       self._refresh_columns()
                except Exception:
                        _moduleLogger.exception("_on_unit_value_changed")
 
                except Exception:
                        _moduleLogger.exception("_on_unit_value_changed")
 
@@ -742,6 +761,7 @@ class Gonvert(object):
                        self._unitValue.set_text(str(func.from_base(base, arg, )))
 
                        self._sortedUnitModel.sort_column_changed()
                        self._unitValue.set_text(str(func.from_base(base, arg, )))
 
                        self._sortedUnitModel.sort_column_changed()
+                       self._refresh_columns()
                except Exception:
                        _moduleLogger.exception("_on_previous_unit_value_changed")
 
                except Exception:
                        _moduleLogger.exception("_on_previous_unit_value_changed")