]>
git.sthu.org Git - pygdb.git/blob - WatchesFrame.py
15 class WatchesFrame (StatusFrame
.StatusFrame
):
18 def __init__(self
, debugger
):
20 StatusFrame
.StatusFrame
.__init
__(self
, debugger
)
21 self
.set_label("Watches")
23 debugger
.gotActiveCallback
+= [self
.updateValues
]
25 vbox
= gtk
.VBox(False, 5)
29 vbox
.pack_start(hbox
, False, False)
31 self
.addBtn
= gtk
.Button(stock
=gtk
.STOCK_ADD
)
32 self
.delBtn
= gtk
.Button(stock
=gtk
.STOCK_REMOVE
)
36 sw
= gtk
.ScrolledWindow()
37 sw
.set_shadow_type(gtk
.SHADOW_ETCHED_IN
)
38 sw
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_AUTOMATIC
)
41 self
.model
= self
.__createModel
()
42 self
.tv
= gtk
.TreeView(self
.model
)
43 self
.tv
.set_rules_hint(True)
44 self
.tv
.get_selection().set_mode(gtk
.SELECTION_MULTIPLE
)
46 self
.__addColumns
(self
.tv
)
49 self
.addBtn
.connect("clicked", self
.addBtnClicked
)
50 self
.delBtn
.connect("clicked", self
.delBtnClicked
)
54 def __createModel(self
):
56 model
= gtk
.ListStore(gobject
.TYPE_STRING
, gobject
.TYPE_STRING
, \
62 def __addColumns(self
, tv
):
64 model
= tv
.get_model()
66 renderer
= gtk
.CellRendererText()
67 renderer
.connect("edited", self
.onExprEdited
, model
)
68 renderer
.set_data("column", 0)
69 col
= gtk
.TreeViewColumn("Expr", renderer
, text
=0, editable
=2)
70 col
.set_resizable(True)
74 renderer
= gtk
.CellRendererText()
75 renderer
.set_data("column", 1)
76 col
= gtk
.TreeViewColumn("Result", renderer
, text
=1)
77 col
.set_resizable(True)
81 def onExprEdited(self
, cell
, pathStr
, expr
, model
):
82 iter = model
.get_iter_from_string(pathStr
)
83 path
= model
.get_path(iter)[0]
84 col
= cell
.get_data("column")
86 model
.set(iter, 0, expr
)
88 if self
.debugger
.isActive():
89 res
= self
.debugger
.getExpression(expr
)
90 model
.set(iter, 1, res
)
93 def applyConfiguration(self
, conf
):
94 for w
in conf
.watches
:
95 iter = self
.model
.append()
96 self
.model
.set(iter, 0, w
["expr"], 1, "<unkown>", 2, True)
97 self
.updateValues(None, None)
100 def fillConfiguration(self
, conf
):
102 iter = self
.model
.get_iter_first()
104 expr
, = self
.model
.get(iter, 0)
105 conf
.parseWatch(expr
)
106 iter = self
.model
.iter_next(iter)
109 def addBtnClicked(self
, btn
):
110 iter = self
.model
.append()
111 self
.model
.set(iter, 0, "0", 1, "0", 2, True)
113 def delBtnClicked(self
, btn
):
114 selection
= self
.tv
.get_selection()
115 model
, paths
= selection
.get_selected_rows()
117 for path
in reversed(paths
):
118 iter = model
.get_iter(path
)
121 def updateValues(self
, status
, param
):
122 iter = self
.model
.get_iter_first()
124 expr
, = self
.model
.get(iter, 0)
125 res
= self
.debugger
.getExpression(expr
)
126 self
.model
.set(iter, 1, res
)
128 iter = self
.model
.iter_next(iter)