From b029ee3dd1a5a785737e73ac6fc024a58d855104 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Mon, 9 Jun 2008 20:44:15 +0200 Subject: [PATCH] remembering window sizes --- Configuration.py | 37 ++++++++++++++++++++++++++++++++++++- MainControlWindow.py | 4 ++-- StatusWindow.py | 24 ++++++++++++++++++++---- WatchesFrame.py | 1 + 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/Configuration.py b/Configuration.py index 7dcd290..a8b4abf 100755 --- a/Configuration.py +++ b/Configuration.py @@ -15,6 +15,7 @@ class Configuration: def __init__(self): self.breakpoints = [] self.watches = [] + self.ints = [] def load(self, filename): @@ -32,6 +33,8 @@ class Configuration: self.parseBreak(tail) elif cmd == "watch": self.parseWatch(tail) + elif cmd == "int": + self.parseInt(tail) else: cnt -= 1 print "Unkown command", cmd @@ -39,6 +42,7 @@ class Configuration: except IOError: return None + def store(self, filename): f = file(filename, "w") @@ -49,6 +53,10 @@ class Configuration: for w in self.watches: self.__writeWatch(f, w) + for s in self.ints: + self.__writeInt(f, s) + + def parseBreak(self, tail): @@ -71,6 +79,17 @@ class Configuration: self.addBreak(file, lineno, cond) + def parseInt(self, tail): + tail.strip() + rx = re.compile("^[\w_\-]+\s+\d+$") + + if not rx.search(tail): + print "Wrong size format:", tail + return + + [name,val] = string.split(tail) + val = int(val) + self.addInt(name, val) def parseWatch(self, tail): self.addWatch(tail) @@ -82,6 +101,9 @@ class Configuration: else: f.write("break %(file)s:%(lineno)d\n" % b) + def __writeInt(self, f, s): + f.write("int %(name)s %(val)d\n" % s) + def __writeWatch(self, f, w): f.write("watch %(expr)s\n" % w) @@ -89,11 +111,24 @@ class Configuration: def addBreak(self, file, lineno, cond=None): self.breakpoints += [ {"file" : file, "lineno" : lineno, "cond" : cond} ] + def addInt(self, name, val): + self.ints += [{"name": name, "val": val}] + def addWatch(self, expr): self.watches += [ {"expr" : expr.strip() } ] + + def findInt(self, name): + for i in self.ints: + if i["name"] == name: + return i["val"] + return None + + def __str__(self): - return "breakpoints=" + str(self.breakpoints) + ", watches=" + str(self.watches) + return "breakpoints=" + str(self.breakpoints) + \ + ", watches=" + str(self.watches) + \ + ", ints=" + str(self.ints) diff --git a/MainControlWindow.py b/MainControlWindow.py index 13d32ee..d8235c0 100644 --- a/MainControlWindow.py +++ b/MainControlWindow.py @@ -39,8 +39,8 @@ class MainControlWindow (gtk.Window): self.add(vbox) #Button box - hbtnbox = gtk.HButtonBox() - hbtnbox.set_layout(gtk.BUTTONBOX_START) + hbtnbox = gtk.HBox(False, spacing=5) + #hbtnbox.set_layout(gtk.BUTTONBOX_START) vbox.pack_start(hbtnbox) self.runBtn = gtk.Button("Run") diff --git a/StatusWindow.py b/StatusWindow.py index 121c0b8..4a08b54 100644 --- a/StatusWindow.py +++ b/StatusWindow.py @@ -29,15 +29,15 @@ class StatusWindow (gtk.Window): self.status = gtk.Label("Not Running") vbox.pack_start(self.status, False, False) - vpaned = gtk.VPaned() - vbox.add(vpaned) + self.paned1 = gtk.VPaned() + vbox.add(self.paned1) #Adding the frames self.frames = [] self.frames += [WatchesFrame.WatchesFrame(debugger)] self.frames += [BreakpointsFrame.BreakpointsFrame(debugger)] - vpaned.add1(self.frames[0]) - vpaned.add2(self.frames[1]) + self.paned1.add1(self.frames[0]) + self.paned1.add2(self.frames[1]) #Register callback function for new positions #and update the values @@ -48,6 +48,17 @@ class StatusWindow (gtk.Window): def applyConfiguration(self, conf): + w = conf.findInt("statuswnd-width") + h = conf.findInt("statuswnd-height") + paned1 = conf.findInt("statuswnd-paned1") + + print w, h, paned1 + if w!=None and h!=None: + self.resize(w,h) + if paned1!=None: + self.paned1.set_position(paned1) + + while not self.debugger.isActive(): gtk.main_iteration() @@ -56,6 +67,11 @@ class StatusWindow (gtk.Window): def fillConfiguration(self, conf): + + conf.addInt("statuswnd-width", self.get_size()[0]) + conf.addInt("statuswnd-height", self.get_size()[1]) + conf.addInt("statuswnd-paned1", self.paned1.get_position()) + for f in self.frames: f.fillConfiguration(conf) diff --git a/WatchesFrame.py b/WatchesFrame.py index 675e47c..10a4695 100644 --- a/WatchesFrame.py +++ b/WatchesFrame.py @@ -96,6 +96,7 @@ class WatchesFrame (StatusFrame.StatusFrame): def fillConfiguration(self, conf): + iter = self.model.get_iter_first() while iter != None: expr, = self.model.get(iter, 0) -- 2.39.5