X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=BreakpointsFrame.py;h=0d3bcf2cf8f5204a04d601242cf9ba5db7692610;hb=74af4d713d7a7456beabc86693e2cc53819e7935;hp=3093fbbe18c047c2e44361dfa75a8d4c560732df;hpb=f2698c930f26434a100e0b4c1e4f39291b55b4f9;p=pygdb.git diff --git a/BreakpointsFrame.py b/BreakpointsFrame.py index 3093fbb..0d3bcf2 100644 --- a/BreakpointsFrame.py +++ b/BreakpointsFrame.py @@ -49,6 +49,7 @@ class BreakpointsFrame (StatusFrame.StatusFrame): self.tv = gtk.TreeView(self.model) self.tv.set_rules_hint(True) self.tv.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + self.tv.get_selection().connect("changed", self.selChanged) self.__addColumns(self.tv) sw.add(self.tv) @@ -85,40 +86,15 @@ class BreakpointsFrame (StatusFrame.StatusFrame): tv.append_column(col) + def selChanged(self, sel): + model, paths = sel.get_selected_rows() - def addBtnClicked(self, btn): - - if not self.debugger.isActive(): - return - - - bpspec = self.bpEntry.get_text() - bpspec = bpspec.strip() - rx = re.compile("^[\w\._\-]+:\d+(\s+if\s+\S+.*)?$") - - #Check if format is correct - if not rx.search(bpspec): - dialog = gtk.MessageDialog(None, \ - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ - gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, \ - "Invalid format!") - dialog.run() - dialog.destroy() - return - - - ifsplit = string.split(bpspec, "if") - - if len(ifsplit)>1: - cond = ifsplit[1].strip() - else: - cond = None - - pos = ifsplit[0].strip() - [file,lineno] = string.split(pos, ":") + if len(paths) > 0: + path = paths[0] + iter = model.get_iter(path) + bpspec, = model.get(iter, 1) + self.bpEntry.set_text(bpspec) - self.addBreakpoint(file, lineno, cond) - def addBreakpoint(self, file, lineno, cond=None): @@ -139,6 +115,7 @@ class BreakpointsFrame (StatusFrame.StatusFrame): def applyConfiguration(self, conf): for b in conf.breakpoints: self.addBreakpoint(b["file"], b["lineno"], b["cond"]) + self.updateValues(None) def fillConfiguration(self, conf): iter = self.model.get_iter_first() @@ -150,13 +127,60 @@ class BreakpointsFrame (StatusFrame.StatusFrame): def addBreakpointToList(self, no, file, lineno, cond=None): - iter = self.model.append() - self.model.set(iter, 0, no) if cond==None: - self.model.set(iter, 1, "%s:%s" % (str(file), str(lineno))) + expr = "%s:%s" % (str(file), str(lineno)) else: - self.model.set(iter, 1, "%s:%s if %s" % (str(file), str(lineno), str(cond))) + expr = "%s:%s if %s" % (str(file), str(lineno), str(cond)) + + iter = self.model.get_iter_first() + while iter != None: + newiter = self.model.iter_next(iter) + #Found a expression which is the same --> remove the breakpoint + if (expr,) == self.model.get(iter,1): + self.debugger.delBreakpoint(no) + return + iter = newiter + + #Add the entry to the breakpoint list + iter = self.model.append() + self.model.set(iter, 0, no) + self.model.set(iter, 1, expr) + + + def addBtnClicked(self, btn): + + if not self.debugger.isActive(): + return + + + bpspec = self.bpEntry.get_text() + bpspec = bpspec.strip() + rx = re.compile("^[\w/\._\-]+:\d+(\s+if\s+\S+.*)?$") + + #Check if format is correct + if not rx.search(bpspec): + dialog = gtk.MessageDialog(None, \ + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ + gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, \ + "Invalid format!") + dialog.run() + dialog.destroy() + return + + + ifsplit = string.split(bpspec, "if") + + if len(ifsplit)>1: + cond = ifsplit[1].strip() + else: + cond = None + + pos = ifsplit[0].strip() + [file,lineno] = string.split(pos, ":") + + self.addBreakpoint(file, lineno, cond) + @@ -168,7 +192,7 @@ class BreakpointsFrame (StatusFrame.StatusFrame): selection = self.tv.get_selection() model, paths = selection.get_selected_rows() - for path in paths: + for path in reversed(paths): iter = model.get_iter(path) bpno, = self.model.get(iter, 0) self.debugger.delBreakpoint(bpno)