From 36fe125220877b22150ce223dd51399bad021a29 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Mon, 24 Dec 2007 23:36:11 +0000 Subject: [PATCH] added uistate to Python Gadget svn: r9578 --- src/DataViews/_MyGrampsView.py | 10 ++++++---- src/plugins/DefaultGadgets.py | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/DataViews/_MyGrampsView.py b/src/DataViews/_MyGrampsView.py index 913152336..642a18e1e 100644 --- a/src/DataViews/_MyGrampsView.py +++ b/src/DataViews/_MyGrampsView.py @@ -55,10 +55,10 @@ def get_gadget_opts(name, opts): return my_data return {} -def make_requested_gadget(viewpage, name, opts, dbstate): +def make_requested_gadget(viewpage, name, opts, dbstate, uistate): for data in AVAILABLE_GADGETS: if data.get("name", None) == name: - gui = GuiGadget(viewpage, dbstate, **opts) + gui = GuiGadget(viewpage, dbstate, uistate, **opts) if opts.get("content", None): opts["content"](gui) return gui @@ -161,9 +161,10 @@ class GuiGadget: TARGET_TYPE_FRAME = 80 LOCAL_DRAG_TYPE = 'GADGET' LOCAL_DRAG_TARGET = (LOCAL_DRAG_TYPE, 0, TARGET_TYPE_FRAME) - def __init__(self, viewpage, dbstate, title, **kwargs): + def __init__(self, viewpage, dbstate, uistate, title, **kwargs): self.viewpage = viewpage self.dbstate = dbstate + self.uistate = uistate self.title = title ########## Set defaults self.expand = kwargs.get("expand", False) @@ -304,7 +305,8 @@ class MyGrampsView(PageView.PageView): cnt += 1 all_opts["title"] = unique if all_opts["title"] not in self.gadget_map: - g = make_requested_gadget(self, name, all_opts, self.dbstate) + g = make_requested_gadget(self, name, all_opts, + self.dbstate, self.uistate) if g: self.gadget_map[all_opts["title"]] = g self.frame_map[str(g.mainframe)] = g diff --git a/src/plugins/DefaultGadgets.py b/src/plugins/DefaultGadgets.py index 62a58145a..d77865dc4 100644 --- a/src/plugins/DefaultGadgets.py +++ b/src/plugins/DefaultGadgets.py @@ -293,6 +293,7 @@ class ShellGadget(Gadget): class PythonGadget(Gadget): def init(self): self.env = {"dbstate": self.gui.dbstate, + "uistate": self.gui.uistate, "self": self, } # GUI setup: @@ -316,8 +317,9 @@ class PythonGadget(Gadget): if line.startswith("> "): self.append_text("\n") line = line[2:] - # update dbstate, in case in changed: + # update states, in case of change: self.env["dbstate"] = self.gui.dbstate + self.env["uistate"] = self.gui.uistate _retval = None if "_retval" in self.env: del self.env["_retval"]