From: Stefan Huber Date: Mon, 23 Jun 2008 16:49:01 +0000 (+0200) Subject: Added controller class: X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=81efa6ae3c403a5b6d0580f77b6349534186e857;p=pygdb.git Added controller class: - Add/Del watches - Add/Del breakpoints - Corresponding code in frame classes --- diff --git a/BreakpointsFrame.py b/BreakpointsFrame.py index 8450699..201ca2f 100644 --- a/BreakpointsFrame.py +++ b/BreakpointsFrame.py @@ -63,8 +63,8 @@ class BreakpointsFrame (StatusFrame.StatusFrame): def __createModel(self): - #Breakpoint number, position and a boolean flag indicating whether BP has been set - #at debugger yet + #Breakpoint number, position and a boolean flag indicating + #whether BP has been set at debugger yet model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) return model @@ -112,6 +112,26 @@ class BreakpointsFrame (StatusFrame.StatusFrame): dialog.run() dialog.destroy() + return no + + + def delBreakpoints(self, file, lineno): + + def addIters(model, path, iter, iters): + expr = model.get_value(iter,1) + expr = string.split(expr, " if ")[0].strip() + if expr == "%s:%d"%(file,lineno): + iters += [iter] + + iters = [] + self.model.foreach(addIters, iters) + + #Need reversed here since rows are moved + #when removing rows + for i in reversed(iters): + self.model.remove(i) + + def applyConfiguration(self, conf): for b in conf.breakpoints: @@ -193,6 +213,9 @@ class BreakpointsFrame (StatusFrame.StatusFrame): def delBtnClicked(self, btn): + self.delBreakpoints("main.cpp", 26) + return + if not self.debugger.isActive(): return diff --git a/Controller.py b/Controller.py new file mode 100644 index 0000000..3f1d25e --- /dev/null +++ b/Controller.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +#shuber, 2008-06-24 + +__author__ = "shuber" + + + +class Controller: + + def __init__(self, debugger, statuswnd): + self.debugger = debugger + self.watchframe = statuswnd.frames[1] + self.bpframe = statuswnd.frames[2] + + def addWatch(self, expr): + self.watchframe.addWatch(expr) + + def delWatches(self, expr): + self.watchframe.delWatches(expr) + + def addBreakpoint(self, file, lineno, cond=None): + return self.bpframe.addBreakpoint(file, lineno, cond) + + def delBreakpoints(self, file, lineno): + self.bpframe.delBreakpoints(file, lineno) diff --git a/WatchesFrame.py b/WatchesFrame.py index 0ee6623..08271f4 100644 --- a/WatchesFrame.py +++ b/WatchesFrame.py @@ -6,9 +6,7 @@ __author__ = "shuber" import gobject import gtk -import vte -import DbgTerminal import StatusFrame @@ -106,11 +104,37 @@ class WatchesFrame (StatusFrame.StatusFrame): iter = self.model.iter_next(iter) - def addBtnClicked(self, btn): + def addWatch(self, expr): + if self.debugger.isActive(): + res = self.debugger.getExpression(expr) + else: + res = expr + iter = self.model.append() - self.model.set(iter, 0, "0", 1, "0", 2, True) + self.model.set(iter, 0, expr, 1, res, 2, True) + + + def delWatches(self, expr): + + def addIters(model, path, iter, iters): + if model.get_value(iter, 0)==expr: + iters += [iter] + + iters = [] + self.model.foreach(addIters, iters) + + #Need reversed here since rows are moved + #when removing rows + for i in reversed(iters): + self.model.remove(i) + + + def addBtnClicked(self, btn): + self.addWatch("0") + def delBtnClicked(self, btn): + selection = self.tv.get_selection() model, paths = selection.get_selected_rows()