]> git.sthu.org Git - pygdb.git/commitdiff
Added controller class: controller
authorStefan Huber <shuber2@gmail.com>
Mon, 23 Jun 2008 16:49:01 +0000 (18:49 +0200)
committerStefan Huber <shuber2@gmail.com>
Mon, 23 Jun 2008 16:49:01 +0000 (18:49 +0200)
  - Add/Del watches
  - Add/Del breakpoints
  - Corresponding code in frame classes

BreakpointsFrame.py
Controller.py [new file with mode: 0644]
WatchesFrame.py

index 8450699eb4c5e970cd73837bf4ffba2ec177f436..201ca2f12abecff73eb13680967e967ec3c4556d 100644 (file)
@@ -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 (file)
index 0000000..3f1d25e
--- /dev/null
@@ -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)
index 0ee6623645fa9bd285dc1f3192d7adac0e18de75..08271f4d7d7180df66661cf7a2d69301e74301c3 100644 (file)
@@ -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()