[libnma] run-vpn: check & update the connection on each change
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnma] run-vpn: check & update the connection on each change
- Date: Tue, 18 Jan 2022 17:52:33 +0000 (UTC)
commit 5568db9d61e9687080a4ec252b80b86f795bbbc0
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Fri Jan 14 12:17:36 2022 +0100
run-vpn: check & update the connection on each change
This makes the tool slightly more useful.
https://gitlab.gnome.org/GNOME/libnma/-/merge_requests/18
src/tests/run-vpn.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/tests/run-vpn.c b/src/tests/run-vpn.c
index 00dc9dd7..7a1ecd60 100644
--- a/src/tests/run-vpn.c
+++ b/src/tests/run-vpn.c
@@ -17,7 +17,23 @@ static gboolean
window_deleted (GMainLoop *main_loop)
{
g_main_loop_quit (main_loop);
- return TRUE;
+ return FALSE;
+}
+
+static void
+changed_cb (NMVpnEditor *editor, gpointer user_data)
+{
+ gs_unref_object NMConnection *connection = NULL;
+ gs_free_error GError *error = NULL;
+
+ g_printerr ("=== CHANGED ===\n");
+
+ connection = nm_simple_connection_new ();
+ if (!nm_vpn_editor_update_connection (editor, connection, &error)) {
+ g_printerr ("Error: %s\n", error->message);
+ } else {
+ nm_connection_dump (connection);
+ }
}
int
@@ -59,6 +75,7 @@ main (int argc, char *argv[])
g_printerr ("Error: %s\n", error->message);
return EXIT_FAILURE;
}
+ g_signal_connect (G_OBJECT (editor), "changed", G_CALLBACK (changed_cb), NULL);
main_loop = g_main_loop_new (NULL, FALSE);
window = gtk_window_new ();
@@ -76,13 +93,5 @@ main (int argc, char *argv[])
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
- if (!nm_vpn_editor_update_connection (editor, connection, &error)) {
- g_printerr ("Error: %s\n", error->message);
- return EXIT_FAILURE;
- }
- nm_connection_dump (connection);
-
- gtk_window_destroy (GTK_WINDOW (window));
-
return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]