diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-09-25 23:46:49 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-09-25 23:46:49 +0200 |
commit | 5f7ac45e4dfe4849338f4a8c39652266689e3eea (patch) | |
tree | ea3891a17ca29543a68abf1a7f6a58f7a715939b /lib.py | |
parent | d4c95ff1132fd67a9c00aaddc01ca5ba0964f7e0 (diff) | |
download | cluster-overview-5f7ac45e4dfe4849338f4a8c39652266689e3eea.tar.gz cluster-overview-5f7ac45e4dfe4849338f4a8c39652266689e3eea.tar.xz cluster-overview-5f7ac45e4dfe4849338f4a8c39652266689e3eea.zip |
Expose tracked info upon entity click via tooltip + stdout text
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'lib.py')
-rw-r--r-- | lib.py | 42 |
1 files changed, 41 insertions, 1 deletions
@@ -66,6 +66,7 @@ class LibMeta(type): for akey, avalue in getattr(cls, 'defaults', {}).iteritems(): kwargs.setdefault(akey, avalue) + kwargs['URL'] = "class://" + self.__class__.__name__ old_init(self, *args, **kwargs) super(cls, self).__init__(*args, **kwargs) @@ -133,6 +134,7 @@ def gen_graph(graph, blacklist=(), **kwargs): def xdot_graph(*args, **kwargs): import gtk import gtk.gdk + import pango try: path[:] = [expanduser('~/wrkspc/goss-medium/jrfonseca.xdot')] + path[:] import xdot @@ -140,6 +142,44 @@ def xdot_graph(*args, **kwargs): print 'missing xdot; use "pip install xdot" or equivalent' raise + class LibDotWidget(xdot.DotWidget): + """Overriden so as to serve our info tooltip purpose""" + def __init__(self, *args, **kwargs): + super(LibDotWidget, self).__init__(*args, **kwargs) + self.connect('leave-notify-event', + lambda self, *args: self.set_tooltip_markup(None)) + + def on_click(self, element, event): + if element is None or not element.url: + return False + # create the resulting markup + print element.url + cls = REGISTRY[element.url.split('class://', 1)[1]] + markup = "" + if hasattr(cls, 'summary'): + markup += "<b>" + cls.summary + "</b>\n\n" + if hasattr(cls, 'web'): + markup += "<u>" + cls.web + "</u>\n\n" + if hasattr(cls, 'repo'): + markup += "repository:\n" + for name, value in cls.repo.iteritems(): + markup += "* " + name + ": <u>" + value + "</u>\n" + markup += '\n' + if hasattr(cls, 'man'): + markup += "man:\n" + for item in cls.man: + markup += "* <i>" + item + "</i>\n" + markup += '\n' + if hasattr(cls, 'ids'): + markup += "identifiers:\n" + for name, value in cls.ids.iteritems(): + markup += "* " + name + ": <i>" + value + "</i>\n" + markup += '\n' + markup = markup.rstrip('\n') + print pango.parse_markup(markup)[1].join(2 * ['\n' + 3*'=' + '\n']) + self.set_tooltip_markup(markup) + return False + class LibDotWindow(xdot.DotWindow): # heavily inspired from http://zetcode.com/gui/pygtk/menus/ def on_toggle_item(self, widget): @@ -186,7 +226,7 @@ def xdot_graph(*args, **kwargs): self._args = args self._kwargs = kwargs self._can_change = True - super(LibDotWindow, self).__init__() + super(LibDotWindow, self).__init__(LibDotWidget()) dotcode = gen_graph(*args, **kwargs).to_string() title = dotcode[dotcode.find('digraph', 0, 512) + len('digraph') : |