X-Git-Url: http://git.maemo.org/git/?p=gonvert;a=blobdiff_plain;f=src%2Fgonvert_glade.py;h=53267173fe221d79b448d945f6ab74245d358fe0;hp=077ffce78005adefb4d0de3f4dea93019a1bf1f7;hb=26a0319cee778b4458d5ff3a29547263b5259abc;hpb=4fb620a441c6975fc7f765f29033ef75480d70db diff --git a/src/gonvert_glade.py b/src/gonvert_glade.py index 077ffce..5326717 100755 --- a/src/gonvert_glade.py +++ b/src/gonvert_glade.py @@ -1,13 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF8 -*- -""" -@tood Add a unit description dialog for when hildonized - -@todo Add support for custom units - -@todo Add support for compound units -""" +from __future__ import with_statement import os import math @@ -94,6 +88,7 @@ class Gonvert(object): 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 @@ -148,9 +143,10 @@ class Gonvert(object): self._findButton = widgets.get_widget('findButton') self._unitsNameRenderer = gtk.CellRendererText() - self._unitsNameRenderer.set_property("ellipsize", pango.ELLIPSIZE_END) self._unitsNameRenderer.set_property("scale", 0.75) - self._unitsNameRenderer.set_property("width-chars", 5) + if FORCE_HILDON_LIKE: + self._unitsNameRenderer.set_property("ellipsize", pango.ELLIPSIZE_END) + self._unitsNameRenderer.set_property("width-chars", 5) self._unitNameColumn = gtk.TreeViewColumn(_('Name'), self._unitsNameRenderer) self._unitNameColumn.set_property('resizable', True) self._unitNameColumn.add_attribute(self._unitsNameRenderer, 'text', self.UNITS_NAME_IDX) @@ -340,6 +336,17 @@ class Gonvert(object): 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 = [] @@ -466,7 +473,12 @@ class Gonvert(object): self._unitModel.append(row) nameLength = max(nameLength, len(key)) self._sortedUnitModel.sort_column_changed() - self._unitsNameRenderer.set_property("width-chars", int(nameLength * 0.75)) + + if FORCE_HILDON_LIKE: + 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() @@ -548,6 +560,11 @@ 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 == 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") @@ -713,6 +730,7 @@ class Gonvert(object): 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") @@ -745,6 +763,7 @@ class Gonvert(object): 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") @@ -755,7 +774,7 @@ class Gonvert(object): dlg.set_copyright("Copyright 2009 - GPL") dlg.set_comments("") dlg.set_website("http://unihedron.com/projects/gonvert/gonvert.php") - dlg.set_authors(["Anthony Tekatch ", "Ed Page "]) + dlg.set_authors(["Anthony Tekatch ", "Ed Page (Blame him for the most recent bugs)"]) dlg.run() dlg.destroy()