[gnome-control-center/signal-connect-object: 5/16] sharing: Move GTK code that was innappropriately in a helper function
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/signal-connect-object: 5/16] sharing: Move GTK code that was innappropriately in a helper function
- Date: Fri, 22 Nov 2019 02:55:16 +0000 (UTC)
commit 9e86b82f3be6f05b804ab4adba33ca65e4b6d2ba
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Nov 22 11:18:30 2019 +1300
sharing: Move GTK code that was innappropriately in a helper function
panels/sharing/cc-gnome-remote-desktop.c | 28 ++--------------------------
panels/sharing/cc-gnome-remote-desktop.h | 6 ++----
panels/sharing/cc-sharing-panel.c | 23 +++++++++++++++++++----
3 files changed, 23 insertions(+), 34 deletions(-)
---
diff --git a/panels/sharing/cc-gnome-remote-desktop.c b/panels/sharing/cc-gnome-remote-desktop.c
index 8420fddca..7f4822495 100644
--- a/panels/sharing/cc-gnome-remote-desktop.c
+++ b/panels/sharing/cc-gnome-remote-desktop.c
@@ -123,7 +123,6 @@ on_password_stored (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
- GtkEntry *entry = GTK_ENTRY (user_data);
GError *error = NULL;
if (!secret_password_store_finish (result, &error))
@@ -131,41 +130,18 @@ on_password_stored (GObject *source,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
g_warning ("Failed to store VNC password: %s", error->message);
- g_object_set_data (G_OBJECT (entry),
- "vnc-password-cancellable", NULL);
}
g_error_free (error);
}
- else
- {
- g_object_set_data (G_OBJECT (entry),
- "vnc-password-cancellable", NULL);
- }
}
void
-cc_grd_on_vnc_password_entry_notify_text (GtkEntry *entry,
- GParamSpec *pspec,
- gpointer user_data)
+cc_grd_store_vnc_password (const gchar *password, GCancellable *cancellable)
{
- GCancellable *cancellable;
- const char *password;
-
- cancellable = g_object_get_data (G_OBJECT (entry), "vnc-password-cancellable");
- if (cancellable)
- g_cancellable_cancel (cancellable);
-
- cancellable = g_cancellable_new ();
- g_object_set_data_full (G_OBJECT (entry),
- "vnc-password-cancellable",
- cancellable, g_object_unref);
-
- password = gtk_entry_get_text (entry);
-
secret_password_store (CC_GRD_VNC_PASSWORD_SCHEMA,
SECRET_COLLECTION_DEFAULT,
"GNOME Remote Desktop VNC password",
password,
- cancellable, on_password_stored, entry,
+ cancellable, on_password_stored, NULL,
NULL);
}
diff --git a/panels/sharing/cc-gnome-remote-desktop.h b/panels/sharing/cc-gnome-remote-desktop.h
index 2a4819986..f8ac2a9c2 100644
--- a/panels/sharing/cc-gnome-remote-desktop.h
+++ b/panels/sharing/cc-gnome-remote-desktop.h
@@ -20,7 +20,6 @@
#ifndef CC_GNOME_REMOTE_DESKTOP_H
#define CC_GNOME_REMOTE_DESKTOP_H
-#include <gtk/gtk.h>
#include <libsecret/secret.h>
const SecretSchema * cc_grd_vnc_password_get_schema (void);
@@ -42,8 +41,7 @@ GVariant * cc_grd_set_is_auth_method_password (const GValue *value,
const GVariantType *type,
gpointer user_data);
-void cc_grd_on_vnc_password_entry_notify_text (GtkEntry *entry,
- GParamSpec *pspec,
- gpointer user_data);
+void cc_grd_store_vnc_password (const gchar *password,
+ GCancellable *cancellable);
#endif /* CC_GNOME_REMOTE_DESKTOP_H */
diff --git a/panels/sharing/cc-sharing-panel.c b/panels/sharing/cc-sharing-panel.c
index c5af32d5e..2521b4a1c 100644
--- a/panels/sharing/cc-sharing-panel.c
+++ b/panels/sharing/cc-sharing-panel.c
@@ -103,6 +103,7 @@ struct _CcSharingPanel
GCancellable *remote_login_cancellable;
GCancellable *hostname_cancellable;
+ GCancellable *vnc_password_cancellable;
guint remote_desktop_name_watch;
};
@@ -193,6 +194,9 @@ cc_sharing_panel_dispose (GObject *object)
g_clear_object (&self->sharing_proxy_cancellable);
g_clear_object (&self->sharing_proxy);
+ g_cancellable_cancel (self->vnc_password_cancellable);
+ g_clear_object (&self->vnc_password_cancellable);
+
G_OBJECT_CLASS (cc_sharing_panel_parent_class)->dispose (object);
}
@@ -1081,6 +1085,16 @@ cc_sharing_panel_setup_screen_sharing_dialog_vino (CcSharingPanel *self)
self->screen_sharing_status_label);
}
+static void
+on_vnc_password_entry_notify_text (CcSharingPanel *self)
+{
+ g_cancellable_cancel (self->vnc_password_cancellable);
+ g_clear_object (&self->vnc_password_cancellable);
+
+ self->vnc_password_cancellable = g_cancellable_new ();
+ cc_grd_store_vnc_password (gtk_entry_get_text (GTK_ENTRY (self->remote_control_password_entry)),
self->vnc_password_cancellable);
+}
+
static void
cc_sharing_panel_setup_screen_sharing_dialog_gnome_remote_desktop (CcSharingPanel *self)
{
@@ -1146,10 +1160,11 @@ cc_sharing_panel_setup_screen_sharing_dialog_gnome_remote_desktop (CcSharingPane
NULL,
NULL);
- g_signal_connect (self->remote_control_password_entry,
- "notify::text",
- G_CALLBACK (cc_grd_on_vnc_password_entry_notify_text),
- self);
+ g_signal_connect_object (self->remote_control_password_entry,
+ "notify::text",
+ G_CALLBACK (on_vnc_password_entry_notify_text),
+ self,
+ G_CONNECT_SWAPPED);
networks = cc_sharing_networks_new (self->sharing_proxy, "gnome-remote-desktop");
gtk_box_pack_end (GTK_BOX (self->remote_control_box), networks, TRUE, TRUE, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]