def __init__(self, suite, suiterc, template_vars, orientation="TB", should_hide=False, start_point_string=None, stop_point_string=None, interactive=True): self.suite = suite self.suiterc = None self.template_vars = template_vars self.orientation = orientation self.should_hide = should_hide self.start_point_string = start_point_string self.stop_point_string = stop_point_string self.interactive = interactive self.outfile = None self.disable_output_image = False self.file = suiterc self.filter_recs = [] util.setup_icons() gtk.Window.__init__(self) self.graph = xdot.Graph() self.set_icon(util.get_icon()) self.set_default_size(512, 512) self.vbox = gtk.VBox() self.add(self.vbox) self.widget = xdot.DotWidget()
def __init__(self, hosts=None, owner=None, poll_interval=None, is_compact=False): # We can't use gobject.threads_init() for panel applets. warnings.filterwarnings('ignore', 'use the new', Warning) setup_icons() if not hosts: try: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) except KeyError: hosts = ["localhost"] self.is_compact = is_compact self.hosts = hosts if owner is None: owner = user self.owner = owner dot_hbox = gtk.HBox() dot_hbox.show() dot_eb = gtk.EventBox() dot_eb.show() dot_eb.add(dot_hbox) image = gtk.image_new_from_stock("gcylc", gtk.ICON_SIZE_MENU) image.show() image_eb = gtk.EventBox() image_eb.show() image_eb.connect("button-press-event", self._on_button_press_event) image_eb.add(image) self.top_hbox = gtk.HBox() self.top_hbox.pack_start(image_eb, expand=False, fill=False) self.top_hbox.pack_start(dot_eb, expand=False, fill=False, padding=2) self.top_hbox.show() self.updater = ScanPanelAppletUpdater(hosts, dot_hbox, image, self.is_compact, owner=owner, poll_interval=poll_interval) self.top_hbox.connect("destroy", self.stop)
def __init__(self, hosts=None, poll_interval=None, is_compact=False): # We can't use gobject.threads_init() for panel applets. warnings.filterwarnings('ignore', 'use the new', Warning) setup_icons() if not hosts: try: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) except KeyError: hosts = ["localhost"] self.is_compact = is_compact self.hosts = hosts dot_hbox = gtk.HBox() dot_hbox.show() dot_eb = gtk.EventBox() dot_eb.show() dot_eb.add(dot_hbox) image = gtk.image_new_from_stock("gcylc", gtk.ICON_SIZE_MENU) image.show() image_eb = gtk.EventBox() image_eb.show() image_eb.connect("button-press-event", self._on_button_press_event) image_eb.add(image) self.top_hbox = gtk.HBox() self.top_hbox.pack_start(image_eb, expand=False, fill=False) self.top_hbox.pack_start(dot_eb, expand=False, fill=False, padding=2) self.top_hbox.show() self.updater = ScanPanelAppletUpdater(hosts, dot_hbox, image, self.is_compact, poll_interval=poll_interval) self.top_hbox.connect("destroy", self.stop) if gsfg.get(["activate on startup"]): self.updater.start()
def __init__(self, is_compact=False): # We can't use gobject.threads_init() for panel applets. warnings.filterwarnings('ignore', 'use the new', Warning) setup_icons() self.is_compact = is_compact dot_hbox = gtk.HBox() dot_hbox.show() dot_eb = gtk.EventBox() dot_eb.show() dot_eb.add(dot_hbox) image = gtk.image_new_from_stock("gcylc", gtk.ICON_SIZE_MENU) image.show() image_eb = gtk.EventBox() image_eb.show() image_eb.connect("button-press-event", self._on_button_press_event) image_eb.add(image) self.top_hbox = gtk.HBox() self.top_hbox.pack_start(image_eb, expand=False, fill=False) self.top_hbox.pack_start(dot_eb, expand=False, fill=False, padding=2) self.top_hbox.show() self.updater = ScanPanelAppletUpdater(dot_hbox, image, self.is_compact) self.top_hbox.connect("destroy", self.stop) if gsfg.get(["activate on startup"]): self.updater.start()
def __init__(self, is_compact=False): # We can't use gobject.threads_init() for panel applets. warnings.filterwarnings('ignore', 'use the new', Warning) setup_icons() self.is_compact = is_compact dot_hbox = gtk.HBox() dot_hbox.show() dot_eb = gtk.EventBox() dot_eb.show() dot_eb.add(dot_hbox) image = gtk.image_new_from_stock("gcylc", gtk.ICON_SIZE_MENU) image.show() image_eb = gtk.EventBox() image_eb.show() image_eb.connect("button-press-event", self._on_button_press_event) image_eb.add(image) self.top_hbox = gtk.HBox() self.top_hbox.pack_start(image_eb, expand=False, fill=False) self.top_hbox.pack_start(dot_eb, expand=False, fill=False, padding=2) self.top_hbox.show() self.updater = ScanPanelAppletUpdater(dot_hbox, image, self.is_compact) self.top_hbox.connect("destroy", self.stop) if GScanConfig.get_inst().get(["activate on startup"]): self.updater.start()
def __init__(self, suite, suiterc, template_vars, orientation="TB", should_hide=False): self.outfile = None self.disable_output_image = False self.suite = suite self.file = suiterc self.suiterc = None self.orientation = orientation self.template_vars = template_vars self.start_point_string = None self.stop_point_string = None self.filter_recs = [] util.setup_icons() gtk.Window.__init__(self) self.graph = xdot.Graph() window = self window.set_title('Cylc Suite Runtime Inheritance Graph Viewer') window.set_default_size(512, 512) window.set_icon(util.get_icon()) vbox = gtk.VBox() window.add(vbox) self.widget = xdot.DotWidget() # Create a UIManager instance uimanager = self.uimanager = gtk.UIManager() # Add the accelerator group to the toplevel window accelgroup = uimanager.get_accel_group() window.add_accel_group(accelgroup) # Create an ActionGroup actiongroup = gtk.ActionGroup('Actions') self.actiongroup = actiongroup actiongroup.add_actions(( ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In', self.widget.on_zoom_in), ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out', self.widget.on_zoom_out), ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit', self.widget.on_zoom_fit), ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100', self.widget.on_zoom_100), ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh', self.on_refresh), ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action), )) actiongroup.add_toggle_actions(( ('LeftToRight', 'transpose', 'Transpose', None, 'Transpose the graph', self.on_left_to_right), )) # Add the actiongroup to the uimanager uimanager.insert_action_group(actiongroup, 0) # Add a UI descrption uimanager.add_ui_from_string(self.ui) left_to_right_toolitem = uimanager.get_widget( '/ToolBar/LeftToRight') left_to_right_toolitem.set_active(self.orientation == "LR") # Create a Toolbar toolbar = uimanager.get_widget('/ToolBar') vbox.pack_start(toolbar, False) vbox.pack_start(self.widget) self.set_focus(self.widget) if not should_hide: self.show_all() self.load_config()
def __init__(self, suite, suiterc, template_vars, orientation="TB", should_hide=False): self.outfile = None self.disable_output_image = False self.suite = suite self.file = suiterc self.suiterc = None self.orientation = orientation self.template_vars = template_vars self.start_point_string = None self.stop_point_string = None self.filter_recs = [] util.setup_icons() gtk.Window.__init__(self) self.graph = xdot.Graph() window = self window.set_title('Cylc Suite Runtime Inheritance Graph Viewer') window.set_default_size(512, 512) window.set_icon(util.get_icon()) vbox = gtk.VBox() window.add(vbox) self.widget = xdot.DotWidget() # Create a UIManager instance uimanager = self.uimanager = gtk.UIManager() # Add the accelerator group to the toplevel window accelgroup = uimanager.get_accel_group() window.add_accel_group(accelgroup) # Create an ActionGroup actiongroup = gtk.ActionGroup('Actions') self.actiongroup = actiongroup actiongroup.add_actions(( ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In', self.widget.on_zoom_in), ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out', self.widget.on_zoom_out), ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit', self.widget.on_zoom_fit), ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100', self.widget.on_zoom_100), ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh', self.on_refresh), ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action), )) actiongroup.add_toggle_actions( (('LeftToRight', 'transpose', 'Transpose', None, 'Transpose the graph', self.on_left_to_right), )) # Add the actiongroup to the uimanager uimanager.insert_action_group(actiongroup, 0) # Add a UI descrption uimanager.add_ui_from_string(self.ui) left_to_right_toolitem = uimanager.get_widget('/ToolBar/LeftToRight') left_to_right_toolitem.set_active(self.orientation == "LR") # Create a Toolbar toolbar = uimanager.get_widget('/ToolBar') vbox.pack_start(toolbar, False) vbox.pack_start(self.widget) self.set_focus(self.widget) if not should_hide: self.show_all() self.load_config()
def __init__(self, suite, suiterc, start_point_string, stop_point_string, template_vars, orientation="TB", subgraphs_on=False, ignore_suicide=True, should_hide=False): self.outfile = None self.disable_output_image = False self.suite = suite self.file = suiterc self.suiterc = None self.orientation = orientation self.subgraphs_on = subgraphs_on self.template_vars = template_vars self.ignore_suicide = ignore_suicide self.start_point_string = start_point_string self.stop_point_string = stop_point_string self.filter_recs = [] util.setup_icons() gtk.Window.__init__(self) self.graph = xdot.Graph() window = self window.set_title('Cylc Suite Dependency Graph Viewer') window.set_default_size(512, 512) window.set_icon(util.get_icon()) vbox = gtk.VBox() window.add(vbox) self.widget = xdot.DotWidget() # Create a UIManager instance uimanager = self.uimanager = gtk.UIManager() # Add the accelerator group to the toplevel window accelgroup = uimanager.get_accel_group() window.add_accel_group(accelgroup) # Create an ActionGroup actiongroup = gtk.ActionGroup('Actions') self.actiongroup = actiongroup # create new stock icons for group and ungroup actions imagedir = os.environ['CYLC_DIR'] + '/images/icons' factory = gtk.IconFactory() for i in ['group', 'ungroup']: pixbuf = gtk.gdk.pixbuf_new_from_file(imagedir + '/' + i + '.png') iconset = gtk.IconSet(pixbuf) factory.add(i, iconset) factory.add_default() actiongroup.add_actions(( ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In', self.widget.on_zoom_in), ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out', self.widget.on_zoom_out), ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit', self.widget.on_zoom_fit), ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100', self.widget.on_zoom_100), ('Group', 'group', 'Group', None, 'Group All Families', self.group_all), ('UnGroup', 'ungroup', 'Ungroup', None, 'Ungroup All Families', self.ungroup_all), ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh', self.on_refresh), ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action), )) actiongroup.add_toggle_actions( (('LeftToRight', 'transpose', 'Transpose', None, 'Transpose the graph', self.on_left_to_right), )) actiongroup.add_toggle_actions( (('Subgraphs', gtk.STOCK_LEAVE_FULLSCREEN, 'Cycle Point Subgraphs', None, 'Organise by cycle point', self.on_subgraphs), )) actiongroup.add_toggle_actions( (('IgnoreSuicide', gtk.STOCK_CANCEL, 'Ignore Suicide Triggers', None, 'Ignore Suicide Triggers', self.on_igsui), )) # Add the actiongroup to the uimanager uimanager.insert_action_group(actiongroup, 0) # Add a UI descrption uimanager.add_ui_from_string(self.ui) left_to_right_toolitem = uimanager.get_widget('/ToolBar/LeftToRight') left_to_right_toolitem.set_active(self.orientation == "LR") subgraphs_toolitem = uimanager.get_widget('/ToolBar/Subgraphs') subgraphs_toolitem.set_active(self.subgraphs_on) igsui_toolitem = uimanager.get_widget('/ToolBar/IgnoreSuicide') igsui_toolitem.set_active(self.ignore_suicide) # Create a Toolbar toolbar = uimanager.get_widget('/ToolBar') vbox.pack_start(toolbar, False) vbox.pack_start(self.widget) eb = gtk.EventBox() eb.add(gtk.Label("right-click on nodes to control family grouping")) eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#8be')) vbox.pack_start(eb, False) self.set_focus(self.widget) if not should_hide: self.show_all() self.load_config()
def __init__( self, hosts=None, patterns_name=None, patterns_owner=None, comms_timeout=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gscan") setup_icons() if not hosts: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) self.hosts = hosts self.window = gtk.Window() title = "cylc gscan" for opt, items, skip in [ ("-n", patterns_name, None), ("-o", patterns_owner, USER)]: if items: for pattern in items: if pattern != skip: title += " %s %s" % (opt, pattern) self.window.set_title(title) self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.warnings = {} self.theme_name = gcfg.get(['use theme']) self.theme = gcfg.get(['themes', self.theme_name]) self.dots = DotMaker(self.theme) suite_treemodel = gtk.TreeStore( str, # group str, # host str, # owner str, # suite bool, # is_stopped str, # title int, # update_time str, # states str, # states_text str) # warning_text self._prev_tooltip_location_id = None self.suite_treeview = gtk.TreeView(suite_treemodel) # Visibility of columns vis_cols = gsfg.get(["columns"]) # Doesn't make any sense without suite name column if gsfg.COL_SUITE not in vis_cols: vis_cols.append(gsfg.COL_SUITE.lower()) # In multiple host environment, add host column by default if hosts: vis_cols.append(gsfg.COL_HOST.lower()) # In multiple owner environment, add owner column by default if patterns_owner != [USER]: vis_cols.append(gsfg.COL_OWNER.lower()) # Construct the group, host, owner, suite, title, update time column. for col_title, col_id, col_cell_text_setter in [ (gsfg.COL_GROUP, self.GROUP_COLUMN, self._set_cell_text_group), (gsfg.COL_HOST, self.HOST_COLUMN, self._set_cell_text_host), (gsfg.COL_OWNER, self.OWNER_COLUMN, self._set_cell_text_owner), (gsfg.COL_SUITE, self.SUITE_COLUMN, self._set_cell_text_name), (gsfg.COL_TITLE, self.TITLE_COLUMN, self._set_cell_text_title), (gsfg.COL_UPDATED, self.UPDATE_TIME_COLUMN, self._set_cell_text_time), ]: column = gtk.TreeViewColumn(col_title) cell_text = gtk.CellRendererText() column.pack_start(cell_text, expand=False) column.set_cell_data_func(cell_text, col_cell_text_setter) column.set_sort_column_id(col_id) column.set_visible(col_title.lower() in vis_cols) column.set_resizable(True) self.suite_treeview.append_column(column) # Construct the status column. status_column = gtk.TreeViewColumn(gsfg.COL_STATUS) status_column.set_sort_column_id(self.STATUS_COLUMN) status_column.set_visible(gsfg.COL_STATUS.lower() in vis_cols) status_column.set_resizable(True) cell_text_cycle = gtk.CellRendererText() status_column.pack_start(cell_text_cycle, expand=False) status_column.set_cell_data_func( cell_text_cycle, self._set_cell_text_cycle, self.CYCLE_COLUMN) self.suite_treeview.append_column(status_column) # Warning icon. warn_icon = gtk.CellRendererPixbuf() image = gtk.Image() pixbuf = image.render_icon( gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_LARGE_TOOLBAR) self.warn_icon_colour = pixbuf.scale_simple( # colour warn icon pixbuf self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_grey = pixbuf.scale_simple( self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_colour.saturate_and_pixelate( self.warn_icon_grey, 0, False) # b&w warn icon pixbuf status_column.pack_start(warn_icon, expand=False) status_column.set_cell_data_func(warn_icon, self._set_error_icon_state) self.warn_icon_blank = gtk.gdk.Pixbuf( # Transparent pixbuff. gtk.gdk.COLORSPACE_RGB, True, 8, self.ICON_SIZE, self.ICON_SIZE ).fill(0x00000000) # Task status icons. for i in range(len(TASK_STATUSES_ORDERED)): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func( cell_pixbuf_state, self._set_cell_pixbuf_state, i) self.suite_treeview.show() if hasattr(self.suite_treeview, "set_has_tooltip"): self.suite_treeview.set_has_tooltip(True) try: self.suite_treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.suite_treeview.connect("button-press-event", self._on_button_press_event) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.suite_treeview) scrolled_window.show() self.vbox.pack_start(scrolled_window, expand=True, fill=True) patterns = {"name": None, "owner": None} for label, items in [ ("owner", patterns_owner), ("name", patterns_name)]: if items: patterns[label] = r"\A(?:" + r")|(?:".join(items) + r")\Z" try: patterns[label] = re.compile(patterns[label]) except re.error: raise ValueError("Invalid %s pattern: %s" % (label, items)) self.updater = ScanAppUpdater( self.window, self.hosts, suite_treemodel, self.suite_treeview, comms_timeout=comms_timeout, poll_interval=poll_interval, group_column_id=self.GROUP_COLUMN, name_pattern=patterns["name"], owner_pattern=patterns["owner"]) self.updater.start() self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) self.window.set_default_size(300, 150) self.suite_treeview.grab_focus() self.window.show() self.warning_icon_shown = []
def __init__(self, hosts=None, owner=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gsummary") setup_icons() if not hosts: try: hosts = sitecfg.get( ["suite host scanning","hosts"] ) except KeyError: hosts = ["localhost"] self.hosts = hosts if owner is None: owner = user self.owner = owner self.window = gtk.Window() self.window.set_title("cylc gsummary") self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.theme_name = gcfg.get( ['use theme'] ) self.theme = gcfg.get( ['themes', self.theme_name] ) self.dots = DotMaker(self.theme) suite_treemodel = gtk.TreeStore(*([str, str, bool, str, int] + [str] * 20)) self._prev_tooltip_location_id = None self.suite_treeview = gtk.TreeView(suite_treemodel) # Construct the host column. host_name_column = gtk.TreeViewColumn("Host") cell_text_host = gtk.CellRendererText() host_name_column.pack_start(cell_text_host, expand=False) host_name_column.set_cell_data_func( cell_text_host, self._set_cell_text_host) host_name_column.set_sort_column_id(0) host_name_column.set_visible(False) # Construct the suite name column. suite_name_column = gtk.TreeViewColumn("Suite") cell_text_name = gtk.CellRendererText() suite_name_column.pack_start(cell_text_name, expand=False) suite_name_column.set_cell_data_func( cell_text_name, self._set_cell_text_name) suite_name_column.set_sort_column_id(1) # Construct the suite title column. suite_title_column = gtk.TreeViewColumn("Title") cell_text_title = gtk.CellRendererText() suite_title_column.pack_start(cell_text_title, expand=False) suite_title_column.set_cell_data_func( cell_text_title, self._set_cell_text_title) suite_title_column.set_sort_column_id(3) suite_title_column.set_visible(False) # Construct the update time column. time_column = gtk.TreeViewColumn("Updated") cell_text_time = gtk.CellRendererText() time_column.pack_start(cell_text_time, expand=False) time_column.set_cell_data_func( cell_text_time, self._set_cell_text_time) time_column.set_sort_column_id(4) time_column.set_visible(False) # Construct the status column. status_column = gtk.TreeViewColumn("Status") status_column.set_sort_column_id(5) for i in range(5, 25): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func( cell_pixbuf_state, self._set_cell_pixbuf_state, i) self.suite_treeview.append_column(host_name_column) self.suite_treeview.append_column(suite_name_column) self.suite_treeview.append_column(suite_title_column) self.suite_treeview.append_column(time_column) self.suite_treeview.append_column(status_column) self.suite_treeview.show() if hasattr(self.suite_treeview, "set_has_tooltip"): self.suite_treeview.set_has_tooltip(True) try: self.suite_treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.suite_treeview.connect("button-press-event", self._on_button_press_event) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.suite_treeview) scrolled_window.show() self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.updater = SummaryAppUpdater(self.hosts, suite_treemodel, owner=self.owner, poll_interval=poll_interval) self.updater.start() self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) self.window.set_default_size(200, 100) self.suite_treeview.grab_focus() self.window.show()
def __init__(self, hosts=None, owner=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gscan") setup_icons() if not hosts: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) self.hosts = hosts if owner is None: owner = user self.owner = owner self.window = gtk.Window() self.window.set_title("cylc gscan") self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.theme_name = gcfg.get(['use theme']) self.theme = gcfg.get(['themes', self.theme_name]) self.dots = DotMaker(self.theme) suite_treemodel = gtk.TreeStore(str, str, bool, str, int, str, str) self._prev_tooltip_location_id = None self.suite_treeview = gtk.TreeView(suite_treemodel) # Construct the host column. host_name_column = gtk.TreeViewColumn("Host") cell_text_host = gtk.CellRendererText() host_name_column.pack_start(cell_text_host, expand=False) host_name_column.set_cell_data_func(cell_text_host, self._set_cell_text_host) host_name_column.set_sort_column_id(0) host_name_column.set_visible(False) host_name_column.set_resizable(True) # Construct the suite name column. suite_name_column = gtk.TreeViewColumn("Suite") cell_text_name = gtk.CellRendererText() suite_name_column.pack_start(cell_text_name, expand=False) suite_name_column.set_cell_data_func(cell_text_name, self._set_cell_text_name) suite_name_column.set_sort_column_id(1) suite_name_column.set_resizable(True) # Construct the suite title column. suite_title_column = gtk.TreeViewColumn("Title") cell_text_title = gtk.CellRendererText() suite_title_column.pack_start(cell_text_title, expand=False) suite_title_column.set_cell_data_func(cell_text_title, self._set_cell_text_title) suite_title_column.set_sort_column_id(3) suite_title_column.set_visible(False) suite_title_column.set_resizable(True) # Construct the update time column. time_column = gtk.TreeViewColumn("Updated") cell_text_time = gtk.CellRendererText() time_column.pack_start(cell_text_time, expand=False) time_column.set_cell_data_func(cell_text_time, self._set_cell_text_time) time_column.set_sort_column_id(4) time_column.set_visible(False) time_column.set_resizable(True) self.suite_treeview.append_column(host_name_column) self.suite_treeview.append_column(suite_name_column) self.suite_treeview.append_column(suite_title_column) self.suite_treeview.append_column(time_column) # Construct the status column. status_column = gtk.TreeViewColumn("Status") status_column.set_sort_column_id(5) status_column.set_resizable(True) status_column_info = 6 cycle_column_info = 5 cell_text_cycle = gtk.CellRendererText() status_column.pack_start(cell_text_cycle, expand=False) status_column.set_cell_data_func(cell_text_cycle, self._set_cell_text_cycle, cycle_column_info) self.suite_treeview.append_column(status_column) distinct_states = len(task_state.legal) for i in range(distinct_states): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func(cell_pixbuf_state, self._set_cell_pixbuf_state, (status_column_info, i)) self.suite_treeview.show() if hasattr(self.suite_treeview, "set_has_tooltip"): self.suite_treeview.set_has_tooltip(True) try: self.suite_treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.suite_treeview.connect("button-press-event", self._on_button_press_event) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.suite_treeview) scrolled_window.show() self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.updater = ScanAppUpdater(self.hosts, suite_treemodel, self.suite_treeview, owner=self.owner, poll_interval=poll_interval) self.updater.start() self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) self.window.set_default_size(300, 150) self.suite_treeview.grab_focus() self.window.show()
def __init__(self, hosts=None, owner=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gscan") setup_icons() if not hosts: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) self.hosts = hosts if owner is None: owner = USER self.owner = owner self.window = gtk.Window() self.window.set_title("cylc gscan") self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.theme_name = gcfg.get(["use theme"]) self.theme = gcfg.get(["themes", self.theme_name]) self.dots = DotMaker(self.theme) suite_treemodel = gtk.TreeStore(str, str, bool, str, int, str, str) self._prev_tooltip_location_id = None self.suite_treeview = gtk.TreeView(suite_treemodel) # Construct the host column. host_name_column = gtk.TreeViewColumn("Host") cell_text_host = gtk.CellRendererText() host_name_column.pack_start(cell_text_host, expand=False) host_name_column.set_cell_data_func(cell_text_host, self._set_cell_text_host) host_name_column.set_sort_column_id(0) host_name_column.set_visible("host" in gsfg.get(["columns"])) host_name_column.set_resizable(True) # Construct the suite name column. suite_name_column = gtk.TreeViewColumn("Suite") cell_text_name = gtk.CellRendererText() suite_name_column.pack_start(cell_text_name, expand=False) suite_name_column.set_cell_data_func(cell_text_name, self._set_cell_text_name) suite_name_column.set_sort_column_id(1) suite_name_column.set_visible("suite" in gsfg.get(["columns"])) suite_name_column.set_resizable(True) # Construct the suite title column. suite_title_column = gtk.TreeViewColumn("Title") cell_text_title = gtk.CellRendererText() suite_title_column.pack_start(cell_text_title, expand=False) suite_title_column.set_cell_data_func(cell_text_title, self._set_cell_text_title) suite_title_column.set_sort_column_id(3) suite_title_column.set_visible("title" in gsfg.get(["columns"])) suite_title_column.set_resizable(True) # Construct the update time column. time_column = gtk.TreeViewColumn("Updated") cell_text_time = gtk.CellRendererText() time_column.pack_start(cell_text_time, expand=False) time_column.set_cell_data_func(cell_text_time, self._set_cell_text_time) time_column.set_sort_column_id(4) time_column.set_visible("updated" in gsfg.get(["columns"])) time_column.set_resizable(True) self.suite_treeview.append_column(host_name_column) self.suite_treeview.append_column(suite_name_column) self.suite_treeview.append_column(suite_title_column) self.suite_treeview.append_column(time_column) # Construct the status column. status_column = gtk.TreeViewColumn("Status") status_column.set_sort_column_id(5) status_column.set_visible("status" in gsfg.get(["columns"])) status_column.set_resizable(True) status_column_info = 6 cycle_column_info = 5 cell_text_cycle = gtk.CellRendererText() status_column.pack_start(cell_text_cycle, expand=False) status_column.set_cell_data_func(cell_text_cycle, self._set_cell_text_cycle, cycle_column_info) self.suite_treeview.append_column(status_column) for i in range(len(TASK_STATUSES_ORDERED)): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func(cell_pixbuf_state, self._set_cell_pixbuf_state, (status_column_info, i)) self.suite_treeview.show() if hasattr(self.suite_treeview, "set_has_tooltip"): self.suite_treeview.set_has_tooltip(True) try: self.suite_treeview.connect("query-tooltip", self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.suite_treeview.connect("button-press-event", self._on_button_press_event) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.suite_treeview) scrolled_window.show() self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.updater = ScanAppUpdater( self.hosts, suite_treemodel, self.suite_treeview, owner=self.owner, poll_interval=poll_interval ) self.updater.start() self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) self.window.set_default_size(300, 150) self.suite_treeview.grab_focus() self.window.show()
def __init__(self, hosts=None, owner=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gsummary") setup_icons() if not hosts: gcfg = get_global_cfg() try: hosts = gcfg.cfg["suite host scanning"]["hosts"] except KeyError: hosts = ["localhost"] self.hosts = hosts if owner is None: owner = user self.owner = owner self.window = gtk.Window() self.window.set_title("cylc gsummary") self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.usercfg = config().cfg self.theme_name = self.usercfg['use theme'] self.theme = self.usercfg['themes'][self.theme_name] self.dots = DotMaker(self.theme) suite_treemodel = gtk.TreeStore(*([str, str, bool, str, int] + [str] * 20)) self._prev_tooltip_location_id = None self.suite_treeview = gtk.TreeView(suite_treemodel) # Construct the host column. host_name_column = gtk.TreeViewColumn("Host") cell_text_host = gtk.CellRendererText() host_name_column.pack_start(cell_text_host, expand=False) host_name_column.set_cell_data_func(cell_text_host, self._set_cell_text_host) host_name_column.set_sort_column_id(0) host_name_column.set_visible(False) # Construct the suite name column. suite_name_column = gtk.TreeViewColumn("Suite") cell_text_name = gtk.CellRendererText() suite_name_column.pack_start(cell_text_name, expand=False) suite_name_column.set_cell_data_func(cell_text_name, self._set_cell_text_name) suite_name_column.set_sort_column_id(1) # Construct the suite title column. suite_title_column = gtk.TreeViewColumn("Title") cell_text_title = gtk.CellRendererText() suite_title_column.pack_start(cell_text_title, expand=False) suite_title_column.set_cell_data_func(cell_text_title, self._set_cell_text_title) suite_title_column.set_sort_column_id(3) suite_title_column.set_visible(False) # Construct the update time column. time_column = gtk.TreeViewColumn("Updated") cell_text_time = gtk.CellRendererText() time_column.pack_start(cell_text_time, expand=False) time_column.set_cell_data_func(cell_text_time, self._set_cell_text_time) time_column.set_sort_column_id(4) time_column.set_visible(False) # Construct the status column. status_column = gtk.TreeViewColumn("Status") status_column.set_sort_column_id(5) for i in range(5, 25): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func(cell_pixbuf_state, self._set_cell_pixbuf_state, i) self.suite_treeview.append_column(host_name_column) self.suite_treeview.append_column(suite_name_column) self.suite_treeview.append_column(suite_title_column) self.suite_treeview.append_column(time_column) self.suite_treeview.append_column(status_column) self.suite_treeview.show() if hasattr(self.suite_treeview, "set_has_tooltip"): self.suite_treeview.set_has_tooltip(True) try: self.suite_treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.suite_treeview.connect("button-press-event", self._on_button_press_event) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.suite_treeview) scrolled_window.show() self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.updater = SummaryAppUpdater(self.hosts, suite_treemodel, owner=self.owner, poll_interval=poll_interval) self.updater.start() self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) self.window.set_default_size(200, 100) self.suite_treeview.grab_focus() self.window.show()
def __init__(self, hosts=None, owner=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gscan") setup_icons() if not hosts: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) self.hosts = hosts if owner is None: owner = USER self.owner = owner self.window = gtk.Window() self.window.set_title("cylc gscan") self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.warnings = {} self.theme_name = gcfg.get(['use theme']) self.theme = gcfg.get(['themes', self.theme_name]) self.dots = DotMaker(self.theme) suite_treemodel = gtk.TreeStore( str, str, bool, str, int, str, str, str) self._prev_tooltip_location_id = None self.suite_treeview = gtk.TreeView(suite_treemodel) # Construct the host column. host_name_column = gtk.TreeViewColumn("Host") cell_text_host = gtk.CellRendererText() host_name_column.pack_start(cell_text_host, expand=False) host_name_column.set_cell_data_func( cell_text_host, self._set_cell_text_host) host_name_column.set_sort_column_id(0) host_name_column.set_visible("host" in gsfg.get(["columns"])) host_name_column.set_resizable(True) # Construct the suite name column. suite_name_column = gtk.TreeViewColumn("Suite") cell_text_name = gtk.CellRendererText() suite_name_column.pack_start(cell_text_name, expand=False) suite_name_column.set_cell_data_func( cell_text_name, self._set_cell_text_name) suite_name_column.set_sort_column_id(1) suite_name_column.set_visible("suite" in gsfg.get(["columns"])) suite_name_column.set_resizable(True) # Construct the suite title column. suite_title_column = gtk.TreeViewColumn("Title") cell_text_title = gtk.CellRendererText() suite_title_column.pack_start(cell_text_title, expand=False) suite_title_column.set_cell_data_func( cell_text_title, self._set_cell_text_title) suite_title_column.set_sort_column_id(3) suite_title_column.set_visible("title" in gsfg.get( ["columns"])) suite_title_column.set_resizable(True) # Construct the update time column. time_column = gtk.TreeViewColumn("Updated") cell_text_time = gtk.CellRendererText() time_column.pack_start(cell_text_time, expand=False) time_column.set_cell_data_func( cell_text_time, self._set_cell_text_time) time_column.set_sort_column_id(4) time_column.set_visible("updated" in gsfg.get(["columns"])) time_column.set_resizable(True) self.suite_treeview.append_column(host_name_column) self.suite_treeview.append_column(suite_name_column) self.suite_treeview.append_column(suite_title_column) self.suite_treeview.append_column(time_column) # Construct the status column. status_column = gtk.TreeViewColumn("Status") status_column.set_sort_column_id(5) status_column.set_visible("status" in gsfg.get(["columns"])) status_column.set_resizable(True) cell_text_cycle = gtk.CellRendererText() status_column.pack_start(cell_text_cycle, expand=False) status_column.set_cell_data_func( cell_text_cycle, self._set_cell_text_cycle, self.CYCLE_COLUMN) self.suite_treeview.append_column(status_column) # Warning icon. warn_icon = gtk.CellRendererPixbuf() image = gtk.Image() pixbuf = image.render_icon( gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_LARGE_TOOLBAR) self.warn_icon_colour = pixbuf.scale_simple( # colour warn icon pixbuf self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_grey = pixbuf.scale_simple( self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_colour.saturate_and_pixelate( self.warn_icon_grey, 0, False) # b&w warn icon pixbuf status_column.pack_start(warn_icon, expand=False) status_column.set_cell_data_func(warn_icon, self._set_error_icon_state) self.warn_icon_blank = gtk.gdk.Pixbuf( # Transparent pixbuff. gtk.gdk.COLORSPACE_RGB, True, 8, self.ICON_SIZE, self.ICON_SIZE ).fill(0x00000000) # Task status icons. for i in range(len(TASK_STATUSES_ORDERED)): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func( cell_pixbuf_state, self._set_cell_pixbuf_state, i) self.suite_treeview.show() if hasattr(self.suite_treeview, "set_has_tooltip"): self.suite_treeview.set_has_tooltip(True) try: self.suite_treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.suite_treeview.connect("button-press-event", self._on_button_press_event) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.suite_treeview) scrolled_window.show() self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.updater = ScanAppUpdater( self.hosts, suite_treemodel, self.suite_treeview, owner=self.owner, poll_interval=poll_interval ) self.updater.start() self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) self.window.set_default_size(300, 150) self.suite_treeview.grab_focus() self.window.show() self.warning_icon_shown = []
def __init__(self, suite, suiterc, start_point_string, stop_point_string, template_vars, orientation="TB", subgraphs_on=False, ignore_suicide=True, should_hide=False): self.outfile = None self.disable_output_image = False self.suite = suite self.file = suiterc self.suiterc = None self.orientation = orientation self.subgraphs_on = subgraphs_on self.template_vars = template_vars self.ignore_suicide = ignore_suicide self.start_point_string = start_point_string self.stop_point_string = stop_point_string self.filter_recs = [] util.setup_icons() gtk.Window.__init__(self) self.graph = xdot.Graph() window = self window.set_title('Cylc Suite Dependency Graph Viewer') window.set_default_size(512, 512) window.set_icon(util.get_icon()) vbox = gtk.VBox() window.add(vbox) self.widget = xdot.DotWidget() # Create a UIManager instance uimanager = self.uimanager = gtk.UIManager() # Add the accelerator group to the toplevel window accelgroup = uimanager.get_accel_group() window.add_accel_group(accelgroup) # Create an ActionGroup actiongroup = gtk.ActionGroup('Actions') self.actiongroup = actiongroup # create new stock icons for group and ungroup actions imagedir = os.environ['CYLC_DIR'] + '/images/icons' factory = gtk.IconFactory() for i in ['group', 'ungroup']: pixbuf = gtk.gdk.pixbuf_new_from_file(imagedir + '/' + i + '.png') iconset = gtk.IconSet(pixbuf) factory.add(i, iconset) factory.add_default() actiongroup.add_actions(( ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In', self.widget.on_zoom_in), ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out', self.widget.on_zoom_out), ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit', self.widget.on_zoom_fit), ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100', self.widget.on_zoom_100), ('Group', 'group', 'Group', None, 'Group All Families', self.group_all), ('UnGroup', 'ungroup', 'Ungroup', None, 'Ungroup All Families', self.ungroup_all), ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh', self.on_refresh), ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action), )) actiongroup.add_toggle_actions(( ('LeftToRight', 'transpose', 'Transpose', None, 'Transpose the graph', self.on_left_to_right), )) actiongroup.add_toggle_actions(( ('Subgraphs', gtk.STOCK_LEAVE_FULLSCREEN, 'Cycle Point Subgraphs', None, 'Organise by cycle point', self.on_subgraphs), )) actiongroup.add_toggle_actions(( ('IgnoreSuicide', gtk.STOCK_CANCEL, 'Ignore Suicide Triggers', None, 'Ignore Suicide Triggers', self.on_igsui), )) # Add the actiongroup to the uimanager uimanager.insert_action_group(actiongroup, 0) # Add a UI descrption uimanager.add_ui_from_string(self.ui) left_to_right_toolitem = uimanager.get_widget('/ToolBar/LeftToRight') left_to_right_toolitem.set_active(self.orientation == "LR") subgraphs_toolitem = uimanager.get_widget( '/ToolBar/Subgraphs') subgraphs_toolitem.set_active(self.subgraphs_on) igsui_toolitem = uimanager.get_widget( '/ToolBar/IgnoreSuicide') igsui_toolitem.set_active(self.ignore_suicide) # Create a Toolbar toolbar = uimanager.get_widget('/ToolBar') vbox.pack_start(toolbar, False) vbox.pack_start(self.widget) eb = gtk.EventBox() eb.add(gtk.Label("right-click on nodes to control family grouping")) eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#8be')) vbox.pack_start(eb, False) self.set_focus(self.widget) if not should_hide: self.show_all() self.load_config()
def __init__(self, hosts=None, patterns_name=None, patterns_owner=None, comms_timeout=None, interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gscan") setup_icons() self.window = gtk.Window() title = "cylc gscan" for opt, items in [("-n", patterns_name), ("-o", patterns_owner)]: if items: for pattern in items: if pattern is not None: title += " %s %s" % (opt, pattern) self.window.set_title(title) self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.warnings = {} self.theme_name = GcylcConfig.get_inst().get(['use theme']) self.theme = GcylcConfig.get_inst().get(['themes', self.theme_name]) suite_treemodel = gtk.TreeStore( str, # group str, # host str, # owner str, # suite str, # version bool, # is_stopped str, # title int, # update_time str, # states str, # states_text str) # warning_text self._prev_tooltip_location_id = None self.treeview = gtk.TreeView(suite_treemodel) # Visibility of columns gsfg = GScanConfig.get_inst() vis_cols = gsfg.get(["columns"]) hide_main_menu_bar = gsfg.get(["hide main menubar"]) # Doesn't make any sense without suite name column if gsfg.COL_SUITE not in vis_cols: vis_cols.append(gsfg.COL_SUITE.lower()) # Construct the group, host, owner, suite, title, update time column. for col_title, col_id, col_cell_text_setter in [ (gsfg.COL_GROUP, self.GROUP_COLUMN, self._set_cell_text_group), (gsfg.COL_HOST, self.HOST_COLUMN, self._set_cell_text_host), (gsfg.COL_OWNER, self.OWNER_COLUMN, self._set_cell_text_owner), (gsfg.COL_SUITE, self.SUITE_COLUMN, self._set_cell_text_name), (gsfg.COL_VERSION, self.VERSION_COLUMN, self._set_cell_text_version), (gsfg.COL_TITLE, self.TITLE_COLUMN, self._set_cell_text_title), (gsfg.COL_UPDATED, self.UPDATE_TIME_COLUMN, self._set_cell_text_time), ]: column = gtk.TreeViewColumn(col_title) cell_text = gtk.CellRendererText() column.pack_start(cell_text, expand=False) column.set_cell_data_func(cell_text, col_cell_text_setter) column.set_sort_column_id(col_id) column.set_visible(col_title.lower() in vis_cols) column.set_resizable(True) self.treeview.append_column(column) # Construct the status column. status_column = gtk.TreeViewColumn(gsfg.COL_STATUS) status_column.set_sort_column_id(self.STATUS_COLUMN) status_column.set_visible(gsfg.COL_STATUS.lower() in vis_cols) status_column.set_resizable(True) cell_text_cycle = gtk.CellRendererText() status_column.pack_start(cell_text_cycle, expand=False) status_column.set_cell_data_func(cell_text_cycle, self._set_cell_text_cycle, self.CYCLE_COLUMN) self.treeview.append_column(status_column) # Warning icon. warn_icon = gtk.CellRendererPixbuf() image = gtk.Image() pixbuf = image.render_icon(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_LARGE_TOOLBAR) self.warn_icon_colour = pixbuf.scale_simple( # colour warn icon pixbuf self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_grey = pixbuf.scale_simple(self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_colour.saturate_and_pixelate( self.warn_icon_grey, 0, False) # b&w warn icon pixbuf status_column.pack_start(warn_icon, expand=False) status_column.set_cell_data_func(warn_icon, self._set_error_icon_state) self.warn_icon_blank = gtk.gdk.Pixbuf( # Transparent pixbuff. gtk.gdk.COLORSPACE_RGB, True, 8, self.ICON_SIZE, self.ICON_SIZE).fill(0x00000000) # Task status icons. for i in range(len(TASK_STATUSES_ORDERED)): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func(cell_pixbuf_state, self._set_cell_pixbuf_state, i) self.treeview.show() if hasattr(self.treeview, "set_has_tooltip"): self.treeview.set_has_tooltip(True) try: self.treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.treeview.connect("button-press-event", self._on_button_press_event) cre_owner, cre_name = re_compile_filters(patterns_owner, patterns_name) self.updater = ScanAppUpdater(self.window, hosts, suite_treemodel, self.treeview, comms_timeout, interval, self.GROUP_COLUMN, cre_owner, cre_name) self.updater.start() self.dot_size = GcylcConfig.get_inst().get(['dot icon size']) self.dots = None self._set_dots() self.menu_bar = None self.create_menubar() accelgroup = gtk.AccelGroup() self.window.add_accel_group(accelgroup) key, modifier = gtk.accelerator_parse('<Alt>m') accelgroup.connect_group(key, modifier, gtk.ACCEL_VISIBLE, self._toggle_hide_menu_bar) self.tool_bar = None self.create_tool_bar() self.menu_hbox = gtk.HBox() self.menu_hbox.pack_start(self.menu_bar, expand=True, fill=True) self.menu_hbox.pack_start(self.tool_bar, expand=True, fill=True) self.menu_hbox.show_all() if hide_main_menu_bar: self.menu_hbox.hide_all() scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.treeview) scrolled_window.show() self.vbox.pack_start(self.menu_hbox, expand=False) self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) wsize = gsfg.get(['window size']) self.window.set_default_size(*wsize) self.treeview.grab_focus() self.window.show() self.theme_legend_window = None self.warning_icon_shown = []
def __init__( self, hosts=None, patterns_name=None, patterns_owner=None, comms_timeout=None, poll_interval=None): gobject.threads_init() set_exception_hook_dialog("cylc gscan") setup_icons() if not hosts: hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"]) self.hosts = hosts self.window = gtk.Window() title = "cylc gscan" for opt, items, skip in [ ("-n", patterns_name, None), ("-o", patterns_owner, USER)]: if items: for pattern in items: if pattern != skip: title += " %s %s" % (opt, pattern) self.window.set_title(title) self.window.set_icon(get_icon()) self.vbox = gtk.VBox() self.vbox.show() self.warnings = {} self.theme_name = gcfg.get(['use theme']) self.theme = gcfg.get(['themes', self.theme_name]) suite_treemodel = gtk.TreeStore( str, # group str, # host str, # owner str, # suite bool, # is_stopped str, # title int, # update_time str, # states str, # states_text str) # warning_text self._prev_tooltip_location_id = None self.treeview = gtk.TreeView(suite_treemodel) # Visibility of columns vis_cols = gsfg.get(["columns"]) # Doesn't make any sense without suite name column if gsfg.COL_SUITE not in vis_cols: vis_cols.append(gsfg.COL_SUITE.lower()) # In multiple host environment, add host column by default if hosts: vis_cols.append(gsfg.COL_HOST.lower()) # In multiple owner environment, add owner column by default if patterns_owner != [USER]: vis_cols.append(gsfg.COL_OWNER.lower()) # Construct the group, host, owner, suite, title, update time column. for col_title, col_id, col_cell_text_setter in [ (gsfg.COL_GROUP, self.GROUP_COLUMN, self._set_cell_text_group), (gsfg.COL_HOST, self.HOST_COLUMN, self._set_cell_text_host), (gsfg.COL_OWNER, self.OWNER_COLUMN, self._set_cell_text_owner), (gsfg.COL_SUITE, self.SUITE_COLUMN, self._set_cell_text_name), (gsfg.COL_TITLE, self.TITLE_COLUMN, self._set_cell_text_title), (gsfg.COL_UPDATED, self.UPDATE_TIME_COLUMN, self._set_cell_text_time), ]: column = gtk.TreeViewColumn(col_title) cell_text = gtk.CellRendererText() column.pack_start(cell_text, expand=False) column.set_cell_data_func(cell_text, col_cell_text_setter) column.set_sort_column_id(col_id) column.set_visible(col_title.lower() in vis_cols) column.set_resizable(True) self.treeview.append_column(column) # Construct the status column. status_column = gtk.TreeViewColumn(gsfg.COL_STATUS) status_column.set_sort_column_id(self.STATUS_COLUMN) status_column.set_visible(gsfg.COL_STATUS.lower() in vis_cols) status_column.set_resizable(True) cell_text_cycle = gtk.CellRendererText() status_column.pack_start(cell_text_cycle, expand=False) status_column.set_cell_data_func( cell_text_cycle, self._set_cell_text_cycle, self.CYCLE_COLUMN) self.treeview.append_column(status_column) # Warning icon. warn_icon = gtk.CellRendererPixbuf() image = gtk.Image() pixbuf = image.render_icon( gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_LARGE_TOOLBAR) self.warn_icon_colour = pixbuf.scale_simple( # colour warn icon pixbuf self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_grey = pixbuf.scale_simple( self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER) self.warn_icon_colour.saturate_and_pixelate( self.warn_icon_grey, 0, False) # b&w warn icon pixbuf status_column.pack_start(warn_icon, expand=False) status_column.set_cell_data_func(warn_icon, self._set_error_icon_state) self.warn_icon_blank = gtk.gdk.Pixbuf( # Transparent pixbuff. gtk.gdk.COLORSPACE_RGB, True, 8, self.ICON_SIZE, self.ICON_SIZE ).fill(0x00000000) # Task status icons. for i in range(len(TASK_STATUSES_ORDERED)): cell_pixbuf_state = gtk.CellRendererPixbuf() status_column.pack_start(cell_pixbuf_state, expand=False) status_column.set_cell_data_func( cell_pixbuf_state, self._set_cell_pixbuf_state, i) self.treeview.show() if hasattr(self.treeview, "set_has_tooltip"): self.treeview.set_has_tooltip(True) try: self.treeview.connect('query-tooltip', self._on_query_tooltip) except TypeError: # Lower PyGTK version. pass self.treeview.connect("button-press-event", self._on_button_press_event) patterns = {"name": None, "owner": None} for label, items in [ ("owner", patterns_owner), ("name", patterns_name)]: if items: patterns[label] = r"\A(?:" + r")|(?:".join(items) + r")\Z" try: patterns[label] = re.compile(patterns[label]) except re.error: raise ValueError("Invalid %s pattern: %s" % (label, items)) self.updater = ScanAppUpdater( self.window, self.hosts, suite_treemodel, self.treeview, comms_timeout=comms_timeout, poll_interval=poll_interval, group_column_id=self.GROUP_COLUMN, name_pattern=patterns["name"], owner_pattern=patterns["owner"]) self.updater.start() self.dot_size = gcfg.get(['dot icon size']) self._set_dots() self.create_menubar() accelgroup = gtk.AccelGroup() self.window.add_accel_group(accelgroup) key, modifier = gtk.accelerator_parse('<Alt>m') accelgroup.connect_group( key, modifier, gtk.ACCEL_VISIBLE, self._toggle_hide_menu_bar) self.create_tool_bar() self.menu_hbox = gtk.HBox() self.menu_hbox.pack_start(self.menu_bar, expand=True, fill=True) self.menu_hbox.pack_start(self.tool_bar, expand=True, fill=True) self.menu_hbox.show_all() self.menu_hbox.hide_all() scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.treeview) scrolled_window.show() self.vbox.pack_start(self.menu_hbox, expand=False) self.vbox.pack_start(scrolled_window, expand=True, fill=True) self.window.add(self.vbox) self.window.connect("destroy", self._on_destroy_event) wsize = gsfg.get(['window size']) self.window.set_default_size(*wsize) self.treeview.grab_focus() self.window.show() self.theme_legend_window = None self.warning_icon_shown = []