static void added_cb (GObject *client, GAsyncResult *result, gpointer user_data) { GMainLoop *loop = user_data; NMRemoteConnection *remote; GError *error; /* NM responded to our request; either handle the resulting error or * print out the object path of the connection we just added. */ remote = nm_client_add_connection_finish (NM_CLIENT (client), result, &error); if (error) { g_print ("Error adding connection: %s", error->message); g_error_free (error); } else { g_print ("Added: %s\n", nm_connection_get_path (NM_CONNECTION (remote))); g_object_unref (remote); } /* Tell the mainloop we're done and we can quit now */ g_main_loop_quit (loop); }
static void add_cb (GObject *s, GAsyncResult *result, gpointer user_data) { gboolean *done = user_data; GError *error = NULL; remote = nm_client_add_connection_finish (client, result, &error); g_assert_no_error (error); *done = TRUE; g_object_add_weak_pointer (G_OBJECT (remote), (void **) &remote); /* nm_client_add_connection_finish() adds a ref to @remote, but we * want the weak pointer to be cleared as soon as @client drops its own ref. * So drop ours. */ g_object_unref (remote); }
static void added_connection_cb (GObject *client, GAsyncResult *result, gpointer user_data) { NMConnectionEditor *self = user_data; NMRemoteConnection *connection; GError *error = NULL; nm_connection_editor_set_busy (self, FALSE); connection = nm_client_add_connection_finish (NM_CLIENT (client), result, &error); if (error) { nm_connection_editor_error (self->parent_window, _("Connection add failed"), "%s", error->message); /* Leave the editor open */ return; } g_clear_object (&connection); g_clear_error (&error); g_signal_emit (self, editor_signals[EDITOR_DONE], 0, GTK_RESPONSE_OK); }