4 http://www.grigoriev.ru/svgmath/ (MathML->SVG in Python)
5 http://helm.cs.unibo.it/mml-widget/ (MathML widget in C++)
18 class GtkCalcHistory(history.AbstractHistory):
26 def __init__(self, view):
27 super(GtkCalcHistory, self).__init__()
28 self.__prettyRenderer = operation.render_number()
29 self._historyView = view
31 # stock-id, display, value
32 self.__historyStore = gtk.ListStore(
33 gobject.TYPE_STRING, # stock id for pixbuf
34 gobject.TYPE_STRING, # view of data
35 gobject.TYPE_STRING, # view of result
39 self._historyView.set_model(self.__historyStore)
41 # create the TreeViewColumns to display the data
42 self.__closeColumn = gtk.TreeViewColumn('')
43 self._historyView.append_column(self.__closeColumn)
45 self.__historyColumn = gtk.TreeViewColumn('History')
46 self.__historyColumn.set_sort_column_id(0)
47 self.__historyColumn.set_expand(True)
48 self._historyView.append_column(self.__historyColumn)
50 self.__resultColumn = gtk.TreeViewColumn('')
51 self.__resultColumn.set_sort_column_id(0)
52 self._historyView.append_column(self.__resultColumn)
54 # create a CellRenderers to render the data
55 self.__closeCell = gtk.CellRendererPixbuf()
56 self.__closeColumn.pack_start(self.__closeCell, False)
57 self.__closeColumn.set_attributes(self.__closeCell, stock_id=0)
59 self.__expressionCell = gtk.CellRendererText()
60 self.__expressionCell.set_property("ellipsize", pango.ELLIPSIZE_MIDDLE)
61 self.__historyColumn.pack_start(self.__expressionCell, True)
62 self.__historyColumn.set_attributes(self.__expressionCell, text=1)
64 self.__valueCell = gtk.CellRendererText()
65 self.__valueCell.set_property("ellipsize", pango.ELLIPSIZE_NONE)
66 self.__resultColumn.pack_end(self.__valueCell, False)
67 self.__resultColumn.set_attributes(self.__valueCell, text=2)
69 self._historyView.set_reorderable(True)
70 self._historyView.connect("row-activated", self._on_close_activated)
73 simpleNode = node.simplify()
74 self.__historyStore.prepend([
76 operation.render_operation(self.__prettyRenderer, node),
77 operation.render_operation(self.__prettyRenderer, simpleNode),
83 if len(self.__historyStore) == 0:
84 raise IndexError("Not enough items in the history for the operation")
86 row = self.__historyStore[0]
87 data = row[self.DATA_IDX]
88 del self.__historyStore[0]
93 if len(self.__historyStore) == 0:
94 raise IndexError("Not enough items in the history for the operation")
95 row = self.__historyStore[0]
96 data = row[self.DATA_IDX]
100 self.__historyStore.clear()
103 return len(self.__historyStore)
106 for row in iter(self.__historyStore):
107 data = row[self.DATA_IDX]
110 def _on_close_activated(self, treeView, path, viewColumn):
111 if viewColumn is self.__closeColumn:
112 del self.__historyStore[path[0]]
113 elif viewColumn is self.__resultColumn:
114 row = self.__historyStore[path[0]]
115 data = row[self.RESULT_IDX]
117 elif viewColumn is self.__historyColumn:
118 row = self.__historyStore[path[0]]
119 data = row[self.DATA_IDX]