From 4735c5339bea3e7bd3ae6c450318f1812811b2fa Mon Sep 17 00:00:00 2001 From: Matt Shin Date: Tue, 13 Mar 2018 15:44:00 +0000 Subject: [PATCH] Fix gui insert nested family --- lib/cylc/gui/updater_graph.py | 7 +++++- lib/cylc/gui/view_graph.py | 43 ++++++++++++++--------------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/lib/cylc/gui/updater_graph.py b/lib/cylc/gui/updater_graph.py index 438cfd652ed..cb84ca66907 100644 --- a/lib/cylc/gui/updater_graph.py +++ b/lib/cylc/gui/updater_graph.py @@ -59,6 +59,10 @@ def compare_dict_of_dict(one, two): class GraphUpdater(threading.Thread): + """Thread for updating "cylc gui" graph view.""" + + PREFIX_BASE = 'base:' + def __init__(self, cfg, updater, theme, info_bar, xdot): super(GraphUpdater, self).__init__() @@ -406,7 +410,8 @@ def update_gui(self): node.attr['color'] = '#888888' node.attr['fillcolor'] = 'white' node.attr['fontcolor'] = '#888888' - node.attr['URL'] = 'base:%s' % node.attr['URL'] + if not node.attr['URL'].startswith(self.PREFIX_BASE): + node.attr['URL'] = self.PREFIX_BASE + node.attr['URL'] for id_ in self.state_summary: try: diff --git a/lib/cylc/gui/view_graph.py b/lib/cylc/gui/view_graph.py index fd09e06ad2a..d49303ff192 100644 --- a/lib/cylc/gui/view_graph.py +++ b/lib/cylc/gui/view_graph.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import re import gtk import gobject @@ -77,19 +76,6 @@ def toggle_graph_disconnect(self, w, update_button): def graph_update(self, w): self.t.action_required = True - def on_url_clicked(self, widget, url, event): - if event.button != 3: - return False - - m = re.match('base:(.*)', url) - if m: - # base graph node - task_id = m.groups()[0] - self.right_click_menu(event, task_id, type_='base graph task') - return - - self.right_click_menu(event, url, type_='live task') - def on_motion_notify(self, widget, event): """Add a new tooltip when the cursor moves in the graph.""" url = self.xdot.widget.get_url(event.x, event.y) @@ -103,21 +89,26 @@ def on_motion_notify(self, widget, event): if url is None: self.xdot.widget.set_tooltip_text(None) return False - url = unicode(url.url) - m = re.match('base:(.*)', url) - if m: - task_id = m.groups()[0] - self.xdot.widget.set_tooltip_text(self.t.get_summary(task_id)) - return False - - # URL is task ID - self.xdot.widget.set_tooltip_text(self.t.get_summary(url)) + task_id = unicode(url.url) + if task_id.startswith(self.t.PREFIX_BASE): + # base graph node + task_id = task_id[len(self.t.PREFIX_BASE):] + self.xdot.widget.set_tooltip_text(self.t.get_summary(task_id)) return False def stop(self): self.t.quit = True - def right_click_menu(self, event, task_id, type_='live task'): + def on_url_clicked(self, _, task_id, event): + """Callback on clicking the right hand mouse button.""" + if event.button != 3: + return False + + is_base = task_id.startswith(self.t.PREFIX_BASE) + if is_base: + # base graph node + task_id = task_id[len(self.t.PREFIX_BASE):] + name, point_string = TaskID.split(task_id) menu = gtk.Menu() @@ -158,7 +149,7 @@ def right_click_menu(self, event, task_id, type_='live task'): name not in self.t.leaves) ungroup_rec_item.connect('activate', self.grouping, name, False, True) - if type_ != 'live task': + if is_base: insert_item = gtk.ImageMenuItem('Insert ...') img = gtk.image_new_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_MENU) @@ -181,7 +172,7 @@ def right_click_menu(self, event, task_id, type_='live task'): menu.append(ungroup_item) menu.append(ungroup_rec_item) - if type_ == 'live task': + if not is_base: is_fam = (name in self.t.descendants) if is_fam: if task_id not in self.t.fam_state_summary: