Пример #1
0
static gboolean
idle_create_connection (gpointer user_data)
{
	CreateConnectionInfo *info = user_data;

	if (info->create) {
		if (!info->ctype)
			nm_connection_list_add (info->list);
		else {
			nm_connection_list_create (info->list, info->ctype,
			                           info->detail, NULL);
		}
	} else {
		/* import */
		nm_connection_list_create (info->list, info->ctype,
		                           info->detail, info->connection);
	}

	g_object_unref (info->list);
	g_free (info->detail);
	nm_g_object_unref (info->connection);
	g_slice_free (CreateConnectionInfo, info);
	return FALSE;
}
Пример #2
0
static gboolean
handle_arguments (NMConnectionList *list,
                  const char *type,
                  gboolean create,
                  gboolean show,
                  const char *edit_uuid,
                  gboolean quit_after)
{
	gboolean show_list = TRUE;
	GType ctype;

	/* Grab type to create or show */
	ctype = nm_connection_lookup_setting_type (type ? type : NM_SETTING_WIRED_SETTING_NAME);
	if (ctype == 0) {
		g_warning ("Unknown connection type '%s'", type);
		return TRUE;
	}

	if (show) {
		/* Just show the given connection type page */
		nm_connection_list_set_type (list, ctype);
	} else if (create) {
		if (!type) {
			g_warning ("'create' requested but no connection type given.");
			return TRUE;
		}
		nm_connection_list_create (list, ctype);

		show_list = FALSE;
	} else if (edit_uuid) {
		/* Show the edit dialog for the given UUID */
		nm_connection_list_edit (list, edit_uuid);
		show_list = FALSE;
	}

	/* If only editing a single connection, exit when done with that connection */
	if (show_list == FALSE && quit_after == TRUE)
		g_signal_connect_swapped (list, "editing-done", G_CALLBACK (g_main_loop_quit), loop);

	return show_list;
}