Пример #1
0
 def on_action_new_activate(self, action):
     """Define a new host"""
     dialog = UIHost(parent=self.ui.win_main, hosts=self.model_hosts)
     response = dialog.show(default_name='',
                            default_description='',
                            title=_('Add a new host'),
                            treeiter=None)
     if response == Gtk.ResponseType.OK:
         destinations = dialog.model_destinations.dump()
         associations = dialog.model_associations.dump()
         host = HostInfo(dialog.name, dialog.description)
         # Set the associations
         for values in associations:
             (destination_name, description, service_name,
              service_arguments) = associations[values]
             destination = destinations[destination_name]
             arguments = json.loads(service_arguments)
             host.add_association(description=description,
                                  destination_name=destination_name,
                                  service_name=service_name,
                                  arguments=arguments)
         self.add_host(host=host,
                       destinations=destinations,
                       update_settings=True)
         # Automatically select the newly added host
         self.ui.tvw_connections.set_cursor(
             path=self.model_hosts.get_path_by_name(dialog.name),
             column=None,
             start_editing=False)
     dialog.destroy()