4 http://www.grigoriev.ru/svgmath/ (MathML->SVG in Python)
5 http://helm.cs.unibo.it/mml-widget/ (MathML widget in C++)
17 class GtkCalcHistory(history.AbstractHistory):
25 def __init__(self, view):
26 super(GtkCalcHistory, self).__init__()
27 self.__prettyRenderer = operation.render_number()
28 self._historyView = view
30 # stock-id, display, value
31 self.__historyStore = gtk.ListStore(
32 gobject.TYPE_STRING, # stock id for pixbuf
33 gobject.TYPE_STRING, # view of data
34 gobject.TYPE_STRING, # view of result
38 self._historyView.set_model(self.__historyStore)
40 # create the TreeViewColumns to display the data
41 self.__closeColumn = gtk.TreeViewColumn('')
42 self._historyView.append_column(self.__closeColumn)
44 self.__historyColumn = gtk.TreeViewColumn('History')
45 self.__historyColumn.set_sort_column_id(0)
46 self.__historyColumn.set_expand(True)
47 self._historyView.append_column(self.__historyColumn)
49 self.__resultColumn = gtk.TreeViewColumn('')
50 self.__resultColumn.set_sort_column_id(0)
51 self._historyView.append_column(self.__resultColumn)
53 # create a CellRenderers to render the data
54 self.__closeCell = gtk.CellRendererPixbuf()
55 self.__closeColumn.pack_start(self.__closeCell, False)
56 self.__closeColumn.set_attributes(self.__closeCell, stock_id=0)
58 self.__expressionCell = gtk.CellRendererText()
59 self.__historyColumn.pack_start(self.__expressionCell, True)
60 self.__historyColumn.set_attributes(self.__expressionCell, text=1)
62 self.__valueCell = gtk.CellRendererText()
63 self.__resultColumn.pack_end(self.__valueCell, False)
64 self.__resultColumn.set_attributes(self.__valueCell, text=2)
66 self._historyView.set_reorderable(True)
67 self._historyView.connect("row-activated", self._on_close_activated)
70 simpleNode = node.simplify()
71 self.__historyStore.prepend([
73 operation.render_operation(self.__prettyRenderer, node),
74 operation.render_operation(self.__prettyRenderer, simpleNode),
80 if len(self.__historyStore) == 0:
81 raise IndexError("Not enough items in the history for the operation")
83 row = self.__historyStore[0]
84 data = row[self.DATA_IDX]
85 del self.__historyStore[0]
90 if len(self.__historyStore) == 0:
91 raise IndexError("Not enough items in the history for the operation")
92 row = self.__historyStore[0]
93 data = row[self.DATA_IDX]
97 self.__historyStore.clear()
100 return len(self.__historyStore)
103 for row in iter(self.__historyStore):
104 data = row[self.DATA_IDX]
107 def _on_close_activated(self, treeView, path, viewColumn):
108 if viewColumn is self.__closeColumn:
109 del self.__historyStore[path[0]]
110 elif viewColumn is self.__resultColumn:
111 row = self.__historyStore[path[0]]
112 data = row[self.RESULT_IDX]
114 elif viewColumn is self.__historyColumn:
115 row = self.__historyStore[path[0]]
116 data = row[self.DATA_IDX]