4 http://www.grigoriev.ru/svgmath/ (MathML->SVG in Python)
5 http://helm.cs.unibo.it/mml-widget/ (MathML widget in C++)
7 @bug Columns auto-expand with large items but when they are gone, the columns don't auto-shrink
19 class GtkCalcHistory(history.AbstractHistory):
27 def __init__(self, view):
28 super(GtkCalcHistory, self).__init__()
29 self.__prettyRenderer = operation.render_number()
30 self._historyView = view
32 # stock-id, display, value
33 self.__historyStore = gtk.ListStore(
34 gobject.TYPE_STRING, # stock id for pixbuf
35 gobject.TYPE_STRING, # view of data
36 gobject.TYPE_STRING, # view of result
40 self._historyView.set_model(self.__historyStore)
42 # create the TreeViewColumns to display the data
43 self.__closeColumn = gtk.TreeViewColumn('')
44 self._historyView.append_column(self.__closeColumn)
46 self.__historyColumn = gtk.TreeViewColumn('History')
47 self.__historyColumn.set_sort_column_id(0)
48 self.__historyColumn.set_expand(True)
49 self._historyView.append_column(self.__historyColumn)
51 self.__resultColumn = gtk.TreeViewColumn('')
52 self.__resultColumn.set_sort_column_id(0)
53 self._historyView.append_column(self.__resultColumn)
55 # create a CellRenderers to render the data
56 self.__closeCell = gtk.CellRendererPixbuf()
57 self.__closeColumn.pack_start(self.__closeCell, False)
58 self.__closeColumn.set_attributes(self.__closeCell, stock_id=0)
60 self.__expressionCell = gtk.CellRendererText()
61 self.__historyColumn.pack_start(self.__expressionCell, True)
62 self.__historyColumn.set_attributes(self.__expressionCell, text=1)
64 self.__valueCell = gtk.CellRendererText()
65 self.__resultColumn.pack_end(self.__valueCell, False)
66 self.__resultColumn.set_attributes(self.__valueCell, text=2)
68 self._historyView.set_reorderable(True)
69 self._historyView.connect("row-activated", self._on_close_activated)
72 simpleNode = node.simplify()
73 self.__historyStore.prepend([
75 operation.render_operation(self.__prettyRenderer, node),
76 operation.render_operation(self.__prettyRenderer, simpleNode),
82 if len(self.__historyStore) == 0:
83 raise IndexError("Not enough items in the history for the operation")
85 row = self.__historyStore[0]
86 data = row[self.DATA_IDX]
87 del self.__historyStore[0]
92 if len(self.__historyStore) == 0:
93 raise IndexError("Not enough items in the history for the operation")
94 row = self.__historyStore[0]
95 data = row[self.DATA_IDX]
99 self.__historyStore.clear()
102 return len(self.__historyStore)
105 for row in iter(self.__historyStore):
106 data = row[self.DATA_IDX]
109 def _on_close_activated(self, treeView, path, viewColumn):
110 if viewColumn is self.__closeColumn:
111 del self.__historyStore[path[0]]
112 elif viewColumn is self.__resultColumn:
113 row = self.__historyStore[path[0]]
114 data = row[self.RESULT_IDX]
116 elif viewColumn is self.__historyColumn:
117 row = self.__historyStore[path[0]]
118 data = row[self.DATA_IDX]