4 http://www.grigoriev.ru/svgmath/ (MathML->SVG in Python)
5 http://helm.cs.unibo.it/mml-widget/ (MathML widget in C++)
21 _moduleLogger = logging.getLogger("gtkhistory")
24 class GtkCalcHistory(history.AbstractHistory):
32 def __init__(self, view):
33 super(GtkCalcHistory, self).__init__()
34 self.__prettyRenderer = operation.render_number()
35 self._historyView = view
37 # stock-id, display, value
38 self.__historyStore = gtk.ListStore(
39 gobject.TYPE_STRING, # stock id for pixbuf
40 gobject.TYPE_STRING, # view of data
41 gobject.TYPE_STRING, # view of result
45 self._historyView.set_model(self.__historyStore)
47 # create the TreeViewColumns to display the data
48 self.__closeColumn = gtk.TreeViewColumn('')
49 self._historyView.append_column(self.__closeColumn)
51 self.__historyColumn = gtk.TreeViewColumn('History')
52 self.__historyColumn.set_sort_column_id(0)
53 self.__historyColumn.set_expand(True)
54 self._historyView.append_column(self.__historyColumn)
56 self.__resultColumn = gtk.TreeViewColumn('')
57 self.__resultColumn.set_sort_column_id(0)
58 self._historyView.append_column(self.__resultColumn)
60 # create a CellRenderers to render the data
61 self.__closeCell = gtk.CellRendererPixbuf()
62 hildonize.set_pix_cell_thumb_selectable(self.__closeCell)
63 self.__closeColumn.pack_start(self.__closeCell, False)
64 self.__closeColumn.set_attributes(self.__closeCell, stock_id=0)
66 self.__expressionCell = gtk.CellRendererText()
67 self.__expressionCell.set_property("ellipsize", pango.ELLIPSIZE_MIDDLE)
68 self.__historyColumn.pack_start(self.__expressionCell, True)
69 self.__historyColumn.set_attributes(self.__expressionCell, text=1)
71 self.__valueCell = gtk.CellRendererText()
72 self.__valueCell.set_property("ellipsize", pango.ELLIPSIZE_NONE)
73 self.__resultColumn.pack_end(self.__valueCell, False)
74 self.__resultColumn.set_attributes(self.__valueCell, text=2)
76 self._historyView.set_reorderable(True)
77 self._historyView.get_selection().set_mode(gtk.SELECTION_SINGLE)
78 self._historyView.connect("row-activated", self._on_close_activated)
81 simpleNode = node.simplify()
82 self.__historyStore.append([
84 operation.render_operation(self.__prettyRenderer, node),
85 operation.render_operation(self.__prettyRenderer, simpleNode),
89 selection = self._historyView.get_selection()
90 selectionPath = (len(self.__historyStore)-1, )
91 selection.select_path(selectionPath)
92 self._historyView.scroll_to_cell(selectionPath)
95 if len(self.__historyStore) == 0:
96 raise IndexError("Not enough items in the history for the operation")
98 row = self.__historyStore[-1]
99 data = row[self.DATA_IDX]
100 del self.__historyStore[-1]
105 if len(self.__historyStore) == 0:
106 raise IndexError("Not enough items in the history for the operation")
107 row = self.__historyStore[-1]
108 data = row[self.DATA_IDX]
112 self.__historyStore.clear()
115 return len(self.__historyStore)
118 for row in iter(self.__historyStore):
119 data = row[self.DATA_IDX]
122 @gtk_toolbox.log_exception(_moduleLogger)
123 def _on_close_activated(self, treeView, path, viewColumn):
124 if viewColumn is self.__closeColumn:
125 del self.__historyStore[path[0]]
126 elif viewColumn is self.__resultColumn:
127 row = self.__historyStore[path[0]]
128 data = row[self.RESULT_IDX]
130 elif viewColumn is self.__historyColumn:
131 row = self.__historyStore[path[0]]
132 data = row[self.DATA_IDX]