示例#1
0
 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
         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('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     # Load the destinations
     self.model_destinations = ModelDestinations(self.ui.store_destinations)
     self.model_associations = ModelAssociations(self.ui.store_associations)
     self.selected_iter = None
     # Sort the data in the models
     self.model_destinations.model.set_sort_column_id(
         self.ui.column_destinations_name.get_sort_column_id(),
         Gtk.SortType.ASCENDING)
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)