def __init__(self, parent, services): """Prepare the services detail dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('service_detail.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_edit_service.set_transient_for(parent) # Restore the saved size and position settings.positions.restore_window_position( self.ui.dialog_edit_service, SECTION_WINDOW_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels widget.set_label(text(widget.get_label())) # Initialize labels for widget in self.ui.get_objects_by_type(Gtk.Label): widget.set_label(text(widget.get_label())) widget.set_tooltip_text(widget.get_label().replace('_', '')) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) self.model = services self.selected_iter = None self.name = '' self.description = '' # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent): """Prepare the devices dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('devices.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_devices.set_transient_for(parent) # Restore the saved size and position settings.positions.restore_window_position(self.ui.dialog_devices, SECTION_WINDOW_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels widget.set_label(text(widget.get_label())) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) # Initialize column headers for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn): widget.set_title(text(widget.get_title())) # Load the devices self.model = ModelDevices(self.ui.store_devices) self.selected_iter = None # Sort the data in the models self.model.model.set_sort_column_id( self.ui.column_name.get_sort_column_id(), Gtk.SortType.ASCENDING) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent, groups): """Prepare the group detail dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('group_detail.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_edit_group.set_transient_for(parent) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels widget.set_label(text(widget.get_label())) # Initialize labels for widget in self.ui.get_objects_by_type(Gtk.Label): widget.set_label(text(widget.get_label())) widget.set_tooltip_text(widget.get_label().replace('_', '')) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) self.model = groups self.name = '' # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent, hosts): """Prepare the host dialog""" self.hosts = hosts # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('host.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_host.set_transient_for(parent) # Restore the saved size and position settings.positions.restore_window_position( self.ui.dialog_host, SECTION_WINDOW_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels if widget.get_label(): widget.set_label(text(widget.get_label())) else: widget.set_label(text(widget.get_short_label())) # Initialize labels for widget in self.ui.get_objects_by_type(Gtk.Label): widget.set_label(text(widget.get_label())) widget.set_tooltip_text(widget.get_label().replace('_', '')) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) # Initialize column headers for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn): widget.set_title(text(widget.get_title())) self.selected_iter = None self.model_devices = ModelDevices(self.ui.store_devices) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent, hosts): """Prepare the host dialog""" self.hosts = hosts # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('host.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_host.set_transient_for(parent) # Restore the saved size and position settings.positions.restore_window_position(self.ui.dialog_host, SECTION_WINDOW_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels if widget.get_label(): widget.set_label(text(widget.get_label())) else: widget.set_label(text(widget.get_short_label())) # Initialize labels for widget in self.ui.get_objects_by_type(Gtk.Label): widget.set_label(text(widget.get_label())) widget.set_tooltip_text(widget.get_label().replace('_', '')) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) # Initialize column headers for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn): widget.set_title(text(widget.get_title())) self.selected_iter = None self.model_devices = ModelDevices(self.ui.store_devices) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent): """Prepare the devices dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('devices.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_devices.set_transient_for(parent) # Restore the saved size and position settings.positions.restore_window_position( self.ui.dialog_devices, SECTION_WINDOW_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels widget.set_label(text(widget.get_label())) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) # Initialize column headers for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn): widget.set_title(text(widget.get_title())) # Load the devices self.model = ModelDevices(self.ui.store_devices) self.selected_iter = None # Sort the data in the models self.model.model.set_sort_column_id( self.ui.column_name.get_sort_column_id(), Gtk.SortType.ASCENDING) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def startup(self, application): """Configure the application during the startup""" self.ui = UIMain(self) # Add the about action to the app menu action = Gio.SimpleAction(name="settings_folder") action.connect("activate", self.on_app_settings_folder_activate) self.add_action(action) # Add the about action to the app menu action = Gio.SimpleAction(name="about") action.connect("activate", self.on_app_about_activate) self.add_action(action) # Add the quit action to the app menu action = Gio.SimpleAction(name="quit") action.connect("activate", self.on_app_quit_activate) self.add_action(action) # Add the app menu builder_appmenu = GtkBuilderLoader(get_ui_file('appmenu.ui')) self.set_app_menu(builder_appmenu.app_menu)
def __init__(self, parent, host): """Prepare the snmp values dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('snmp_values.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.window_snmp.set_transient_for(parent) # Restore the saved size and position settings.positions.restore_window_position( self.ui.window_snmp, SECTION_WINDOW_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels if widget.get_label(): widget.set_label(text(widget.get_label())) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) # Initialize column headers for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn): widget.set_title(text(widget.get_title())) # Initialize services self.model = SNMPValues(self.ui.store_values) self.services = {} for service in model_devices.devices[host.device].services: oid = model_services.services[service].numeric_oid self.services[service] = oid value = SNMPValueInfo(name=service, value='', timestamp=0) self.model.add_data(value) # Sort the data in the models self.model.model.set_sort_column_id( self.ui.column_name.get_sort_column_id(), Gtk.SortType.ASCENDING) self.host = host self.ui.window_snmp.set_title(_('SNMP values for %s') % host.name) self.semaphore = None self.completed_threads = 0 # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent, host): """Prepare the snmp values dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('snmp_values.glade')) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.window_snmp.set_transient_for(parent) # Restore the saved size and position settings.positions.restore_window_position(self.ui.window_snmp, SECTION_WINDOW_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels if widget.get_label(): widget.set_label(text(widget.get_label())) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.Button): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) # Initialize column headers for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn): widget.set_title(text(widget.get_title())) # Initialize services self.model = SNMPValues(self.ui.store_values) self.services = {} for service in model_devices.devices[host.device].services: oid = model_services.services[service].numeric_oid self.services[service] = oid value = SNMPValueInfo(name=service, value='', timestamp=0) self.model.add_data(value) # Sort the data in the models self.model.model.set_sort_column_id( self.ui.column_name.get_sort_column_id(), Gtk.SortType.ASCENDING) self.host = host self.ui.window_snmp.set_title(_('SNMP values for %s') % host.name) self.semaphore = None self.completed_threads = 0 # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent): """Prepare the about dialog""" # Retrieve the translators list translators = [] for line in readlines(FILE_TRANSLATORS, False): if ':' in line: line = line.split(':', 1)[1] line = line.replace('(at)', '@').strip() if line not in translators: translators.append(line) # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('about.glade')) # Set various properties self.ui.dialog_about.set_program_name(APP_NAME) self.ui.dialog_about.set_version('Version %s' % APP_VERSION) self.ui.dialog_about.set_comments(APP_DESCRIPTION) self.ui.dialog_about.set_website(APP_URL) self.ui.dialog_about.set_copyright(APP_COPYRIGHT) # Prepare lists for authors and contributors authors = ['%s <%s>' % (APP_AUTHOR, APP_AUTHOR_EMAIL)] contributors = [] for line in readlines(FILE_CONTRIBUTORS, False): contributors.append(line) if len(contributors) > 0: contributors.insert(0, _('Contributors:')) authors.extend(contributors) self.ui.dialog_about.set_authors(authors) self.ui.dialog_about.set_license( '\n'.join(readlines(FILE_LICENSE, True))) self.ui.dialog_about.set_translator_credits('\n'.join(translators)) # Retrieve the external resources links # only for GTK+ 3.6.0 and higher if not Gtk.check_version(3, 6, 0): for line in readlines(FILE_RESOURCES, False): resource_type, resource_url = line.split(':', 1) self.ui.dialog_about.add_credit_section( resource_type, (resource_url,)) icon_logo = Pixbuf.new_from_file(FILE_ICON) self.ui.dialog_about.set_logo(icon_logo) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_about.set_transient_for(parent)
def __init__(self, parent): """Prepare the about dialog""" # Retrieve the translators list translators = [] for line in readlines(FILE_TRANSLATORS, False): if ':' in line: line = line.split(':', 1)[1] line = line.replace('(at)', '@').strip() if line not in translators: translators.append(line) # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('about.glade')) # Set various properties self.ui.dialog_about.set_program_name(APP_NAME) self.ui.dialog_about.set_version('Version %s' % APP_VERSION) self.ui.dialog_about.set_comments(APP_DESCRIPTION) self.ui.dialog_about.set_website(APP_URL) self.ui.dialog_about.set_copyright(APP_COPYRIGHT) # Prepare lists for authors and contributors authors = ['%s <%s>' % (APP_AUTHOR, APP_AUTHOR_EMAIL)] contributors = [] for line in readlines(FILE_CONTRIBUTORS, False): contributors.append(line) if len(contributors) > 0: contributors.insert(0, _('Contributors:')) authors.extend(contributors) self.ui.dialog_about.set_authors(authors) self.ui.dialog_about.set_license('\n'.join( readlines(FILE_LICENSE, True))) self.ui.dialog_about.set_translator_credits('\n'.join(translators)) # Retrieve the external resources links # only for GTK+ 3.6.0 and higher if not Gtk.check_version(3, 6, 0): for line in readlines(FILE_RESOURCES, False): resource_type, resource_url = line.split(':', 1) self.ui.dialog_about.add_credit_section( resource_type, (resource_url, )) icon_logo = Pixbuf.new_from_file(FILE_ICON) self.ui.dialog_about.set_logo(icon_logo) if not preferences.get(preferences.DETACHED_WINDOWS): self.ui.dialog_about.set_transient_for(parent)
def loadUI(self): """Load the interface UI""" self.ui = GtkBuilderLoader(get_ui_file('main.glade')) self.ui.win_main.set_application(self.application) self.ui.win_main.set_title(APP_NAME) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels widget.set_label(text(widget.get_label())) # Initialize tooltips for widget in self.ui.get_objects_by_type(Gtk.ToolButton): action = widget.get_related_action() if action: widget.set_tooltip_text(action.get_label().replace('_', '')) # Initialize column headers for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn): widget.set_title(text(widget.get_title())) # Set list items row height icon_size = preferences.ICON_SIZE self.ui.cell_name.props.height = preferences.get(icon_size) self.ui.cell_group_name.props.height = preferences.get(icon_size) # Set groups visibility self.ui.scroll_groups.set_visible( preferences.get(preferences.GROUPS_SHOW)) # Add a Gtk.Headerbar, only for GTK+ 3.10.0 and higher if (not Gtk.check_version(3, 10, 0) and not preferences.get(preferences.HEADERBARS_DISABLE)): self.load_ui_headerbar() if preferences.get(preferences.HEADERBARS_REMOVE_TOOLBAR): # This is only for development, it should always be True # Remove the redundant toolbar self.ui.toolbar_main.destroy() # Flatten the Gtk.ScrolledWindows self.ui.scroll_groups.set_shadow_type(Gtk.ShadowType.NONE) self.ui.scroll_connections.set_shadow_type(Gtk.ShadowType.NONE) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)