From d9eba446f2d6d99a71e7edfb4537c4ca2f7e450c Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Tue, 14 May 2013 15:44:47 +0200 Subject: lib.py: tune the code + enabling item will enable its ancestors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- lib.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'lib.py') diff --git a/lib.py b/lib.py index b4fd12a..56f6fbf 100644 --- a/lib.py +++ b/lib.py @@ -312,28 +312,34 @@ def xdot_graph(*args, **kwargs): label = widget.get_label() bl = self._kwargs.setdefault('blacklist', []) change = False - if widget.active and globals()[label] in bl: - bl.remove(globals()[label]) + cls = globals()[label] + if widget.active and cls in bl: + bl.remove(cls) + bs = bases(cls) + bs.remove(cls) + for item in filter(lambda x: isinstance(x, gtk.CheckMenuItem) + and globals()[x.get_label()] in bs, + widget.get_parent().get_children()): + if not item.get_active(): + item.set_active(True) change = True - elif not widget.active and label not in bl: - bl.append(globals()[label]) + elif not widget.active and cls not in bl: + bl.append(cls) change = True if change: self.set_dotcode( gen_graph(*self._args, **self._kwargs).to_string()) def on_clean_all(self, widget): - for item in widget.get_parent().get_children(): - if not isinstance(item, gtk.CheckMenuItem): - continue + for item in filter(lambda x: isinstance(x, gtk.CheckMenuItem), + widget.get_parent().get_children()): item.set_active(False) item.set_active(True) item.activate() def on_set_all(self, widget): - for item in widget.get_parent().get_children(): - if not isinstance(item, gtk.CheckMenuItem): - continue + for item in filter(lambda x: isinstance(x, gtk.CheckMenuItem), + widget.get_parent().get_children()): item.set_active(True) item.set_active(False) item.activate() -- cgit