Skip to content

Commit

Permalink
Updated status column tooltip text.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Jun 29, 2016
1 parent 6e85022 commit 53b6caa
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions lib/cylc/gui/gscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,22 @@ def _on_query_tooltip(self, widget, x, y, kbd_ctx, tooltip):
tooltip.set_text(None)
return False

# Generate text for the number of tasks in each state
state_texts = []
status_column_info = 6
state_text = model.get_value(iter_, status_column_info)
if state_text is None:
tooltip.set_text(None)
return False
info = re.findall(r'\D+\d+', state_text)
for status_number in info:
status, number = status_number.rsplit(" ", 1)
state_texts.append(number + " " + status.strip())
tooltip_prefix = (
"<span foreground=\"#777777\">Tasks: " + ", ".join(state_texts) +
"</span>"
)

# If hovering over a status indicator set tooltip to show most recent
# tasks.
dot_offset, dot_width = tuple(column.cell_get_position(
Expand All @@ -661,25 +677,14 @@ def _on_query_tooltip(self, widget, x, y, kbd_ctx, tooltip):
point_string = model.get(iter_, 5)[0]
tasks = self.updater.get_last_n_tasks(
suite, host, state, point_string)
tooltip.set_markup('<b>{state}</b>\n{tasks}'.format(
state=state,
tasks='\n'.join(tasks))
)
tooltip.set_markup(
tooltip_prefix + ('\n<b>Recent {state} tasks</b>'
'\n{tasks}').format(state=state,
tasks='\n'.join(tasks)))
return True

# Set the tooltip to a generic status for this suite.
state_texts = []
status_column_info = 6
state_text = model.get_value(iter_, status_column_info)
if state_text is None:
tooltip.set_text(None)
return False
info = re.findall(r'\D+\d+', state_text)
for status_number in info:
status, number = status_number.rsplit(" ", 1)
state_texts.append(number + " " + status.strip())
text = "Tasks: " + ", ".join(state_texts)
tooltip.set_text(text)
tooltip.set_markup(tooltip_prefix)
return True

def _on_toggle_column_visible(self, menu_item):
Expand Down Expand Up @@ -997,7 +1002,8 @@ def get_last_n_tasks(self, suite, host, task_state, point_string):
if temp:
tasks.remove(temp[0])
if not point_string:
suffix.append('<i>And %s more</i>' % (temp[0][1],))
suffix.append(('<span foreground="#777777">'
'<i>And %s more</i></span>') % (temp[0][1],))

# Filter by point string if provided.
if point_string:
Expand All @@ -1007,6 +1013,9 @@ def get_last_n_tasks(self, suite, host, task_state, point_string):
else:
ret = [task[1] + '.' + task[2] for task in tasks]

if not ret:
return ['<span foreground="#777777"><i>None</i></span>']

return ret + suffix

def update(self):
Expand Down

0 comments on commit 53b6caa

Please sign in to comment.