static void
connections_read (NMRemoteSettings *settings, EditData *data)
{
	NMConnection *connection;
	static gulong signal_id = 0;

	connection = get_connection (settings, data->uuid);
	if (connection) {
		edit_connection (data->self, connection);
		g_object_unref (connection);
	} else if (data->wait) {
		data->wait = FALSE;
		signal_id = g_signal_connect (settings, "connections-read",
		                              G_CALLBACK (connections_read), data);
		return;
	} else {
		nm_connection_editor_error (NULL,
		                            _("Error editing connection"),
		                            _("Did not find a connection with UUID '%s'"), data->uuid);
	}

	if (signal_id != 0) {
		g_signal_handler_disconnect (settings, signal_id);
		signal_id = 0;
	}

	g_free (data);
}
static void
do_edit (NMConnectionList *list)
{
	edit_connection (list, NM_CONNECTION (get_active_connection (list->connection_list)));
}
예제 #3
0
/**
 * main callback for control panel plugins
 */
osso_return_t execute(osso_context_t *osso, gpointer data,
					  gboolean user_activated)
{
	gint response;

	create_list_dialog (data);

	if (!user_activated)
	{
		/* load state */
	}

	do
	{
		gchar *selected;
		response = gtk_dialog_run (GTK_DIALOG (ListDialog.dialog));
		switch (response)
		{
			case RESPONSE_NEW:
			{
				edit_connection (data, NULL);
				break;
			}
			case RESPONSE_EDIT:
			{
				StrongswanConnection *conn;
				selected = get_selected ();
				conn = strongswan_connections_get_connection (ListDialog.conns,
															  selected);
				if (conn)
				{
					edit_connection (data, conn);
				}
				else
				{
					hildon_banner_show_information (NULL, NULL,
												"Select a connection first");
				}
				g_free (selected);
				break;
			}
			case RESPONSE_DELETE:
			{
				GtkWidget *confirm;
				gint retval;
				gchar *msg;
				selected = get_selected ();
				if (!selected)
				{
					hildon_banner_show_information (NULL, NULL,
												"Select a connection first");
					break;
				}
				msg = g_strdup_printf ("Delete connection?\n%s", selected);
				confirm = hildon_note_new_confirmation (data, msg);
				retval = gtk_dialog_run (GTK_DIALOG (confirm));
				if (retval == GTK_RESPONSE_OK)
				{
					strongswan_connections_remove_connection (ListDialog.conns,
															  selected);
				}
				gtk_widget_destroy (confirm);
				g_free (msg);
				g_free (selected);
				break;
			}
			default:
				break;
		}
	}
	while (response > 0);

	gtk_widget_destroy (ListDialog.dialog);
	g_object_unref (ListDialog.conns);
	return OSSO_OK;
}