[gnome-control-center/signal-connect-object: 4/16] sharing: Connect signals with g_signal_connect_object in swapped form
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/signal-connect-object: 4/16] sharing: Connect signals with g_signal_connect_object in swapped form
- Date: Fri, 22 Nov 2019 02:55:11 +0000 (UTC)
commit 591808ce9cc331eb1cf2d9f55839c1a838951210
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Nov 22 11:09:20 2019 +1300
sharing: Connect signals with g_signal_connect_object in swapped form
panels/sharing/cc-sharing-networks.c | 25 +++----
panels/sharing/cc-sharing-panel.c | 131 +++++++++++++++++------------------
2 files changed, 74 insertions(+), 82 deletions(-)
---
diff --git a/panels/sharing/cc-sharing-networks.c b/panels/sharing/cc-sharing-networks.c
index c23a8119b..39ebf7678 100644
--- a/panels/sharing/cc-sharing-networks.c
+++ b/panels/sharing/cc-sharing-networks.c
@@ -134,8 +134,8 @@ cc_sharing_update_networks (CcSharingNetworks *self)
}
static void
-cc_sharing_networks_remove_network (GtkWidget *button,
- CcSharingNetworks *self)
+cc_sharing_networks_remove_network (CcSharingNetworks *self,
+ GtkWidget *button)
{
GtkWidget *row;
g_autoptr(GError) error = NULL;
@@ -159,11 +159,10 @@ cc_sharing_networks_remove_network (GtkWidget *button,
}
static gboolean
-cc_sharing_networks_enable_network (GtkSwitch *widget,
+cc_sharing_networks_enable_network (CcSharingNetworks *self,
gboolean state,
- gpointer user_data)
+ GtkSwitch *widget)
{
- CcSharingNetworks *self = user_data;
g_autoptr(GError) error = NULL;
gboolean ret;
@@ -242,8 +241,8 @@ cc_sharing_networks_new_row (const char *uuid,
gtk_widget_set_margin_end (w, 12);
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (w), "clicked",
- G_CALLBACK (cc_sharing_networks_remove_network), self);
+ g_signal_connect_object (G_OBJECT (w), "clicked",
+ G_CALLBACK (cc_sharing_networks_remove_network), self, G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (w), "row", row);
g_object_set_data_full (G_OBJECT (row), "uuid", g_strdup (uuid), g_free);
@@ -284,8 +283,8 @@ cc_sharing_networks_new_current_row (CcSharingNetworks *self)
gtk_widget_set_margin_end (w, 12);
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (w), "state-set",
- G_CALLBACK (cc_sharing_networks_enable_network), self);
+ g_signal_connect_object (G_OBJECT (w), "state-set",
+ G_CALLBACK (cc_sharing_networks_enable_network), self, G_CONNECT_SWAPPED);
self->current_switch = w;
g_object_set_data (G_OBJECT (w), "row", row);
@@ -401,9 +400,7 @@ cc_sharing_update_networks_box (CcSharingNetworks *self)
}
static void
-current_network_changed (GObject *object,
- GParamSpec *pspec,
- CcSharingNetworks *self)
+current_network_changed (CcSharingNetworks *self)
{
cc_sharing_update_networks (self);
cc_sharing_update_networks_box (self);
@@ -434,8 +431,8 @@ cc_sharing_networks_constructed (GObject *object)
cc_sharing_update_networks (self);
cc_sharing_update_networks_box (self);
- g_signal_connect (self->proxy, "notify::current-network",
- G_CALLBACK (current_network_changed), self);
+ g_signal_connect_object (self->proxy, "notify::current-network",
+ G_CALLBACK (current_network_changed), self, G_CONNECT_SWAPPED);
}
static void
diff --git a/panels/sharing/cc-sharing-panel.c b/panels/sharing/cc-sharing-panel.c
index 808f5afa8..c5af32d5e 100644
--- a/panels/sharing/cc-sharing-panel.c
+++ b/panels/sharing/cc-sharing-panel.c
@@ -112,13 +112,11 @@ CC_PANEL_REGISTER (CcSharingPanel, cc_sharing_panel)
#define OFF_IF_VISIBLE(x, y) { if (gtk_widget_is_visible(x) && (y) != NULL && gtk_widget_is_sensitive(y))
gtk_switch_set_active (GTK_SWITCH(y), FALSE); }
static void
-cc_sharing_panel_master_switch_notify (GtkSwitch *gtkswitch,
- GParamSpec *pspec,
- CcSharingPanel *self)
+cc_sharing_panel_master_switch_notify (CcSharingPanel *self)
{
gboolean active;
- active = gtk_switch_get_active (gtkswitch);
+ active = gtk_switch_get_active (GTK_SWITCH (self->master_switch));
if (!active)
{
@@ -278,9 +276,8 @@ cc_sharing_panel_run_dialog (CcSharingPanel *self,
}
static void
-cc_sharing_panel_main_list_box_row_activated (GtkListBox *listbox,
- GtkListBoxRow *row,
- CcSharingPanel *self)
+cc_sharing_panel_main_list_box_row_activated (CcSharingPanel *self,
+ GtkListBoxRow *row)
{
GtkWidget *dialog;
@@ -295,7 +292,7 @@ cc_sharing_panel_main_list_box_row_activated (GtkListBox *listbox,
else
return;
- gtk_list_box_select_row (listbox, NULL);
+ gtk_list_box_select_row (GTK_LIST_BOX (self->main_list_box), NULL);
cc_sharing_panel_run_dialog (self, dialog);
}
@@ -410,9 +407,8 @@ cc_sharing_panel_bind_switch_to_widgets (GtkWidget *gtkswitch,
}
static void
-cc_sharing_panel_add_folder (GtkListBox *box,
- GtkListBoxRow *row,
- CcSharingPanel *self)
+cc_sharing_panel_add_folder (CcSharingPanel *self,
+ GtkListBoxRow *row)
{
GtkWidget *dialog;
g_autofree gchar *folder = NULL;
@@ -423,7 +419,7 @@ cc_sharing_panel_add_folder (GtkListBox *box,
return;
dialog = gtk_file_chooser_dialog_new (_("Choose a Folder"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (box))),
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET
(self->shared_folders_listbox))),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Open"), GTK_RESPONSE_ACCEPT,
@@ -473,8 +469,8 @@ bail:
}
static void
-cc_sharing_panel_remove_folder (GtkButton *button,
- CcSharingPanel *self)
+cc_sharing_panel_remove_folder (CcSharingPanel *self,
+ GtkButton *button)
{
GtkWidget *row;
@@ -484,9 +480,8 @@ cc_sharing_panel_remove_folder (GtkButton *button,
}
static void
-cc_sharing_panel_media_sharing_dialog_response (GtkDialog *dialog,
- gint reponse_id,
- CcSharingPanel *self)
+cc_sharing_panel_media_sharing_dialog_response (CcSharingPanel *self,
+ gint reponse_id)
{
g_autoptr(GPtrArray) folders = NULL;
GtkWidget *box;
@@ -600,8 +595,8 @@ cc_sharing_panel_new_media_sharing_row (const char *uri_or_path,
gtk_widget_set_margin_end (w, 12);
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (w), "clicked",
- G_CALLBACK (cc_sharing_panel_remove_folder), self);
+ g_signal_connect_object (G_OBJECT (w), "clicked",
+ G_CALLBACK (cc_sharing_panel_remove_folder), self, G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (w), "row", row);
g_object_set_data_full (G_OBJECT (row), "path", g_steal_pointer (&path), g_free);
@@ -649,9 +644,9 @@ cc_sharing_panel_setup_media_sharing_dialog (CcSharingPanel *self)
return;
}
- g_signal_connect (self->media_sharing_dialog, "response",
- G_CALLBACK (cc_sharing_panel_media_sharing_dialog_response),
- self);
+ g_signal_connect_object (self->media_sharing_dialog, "response",
+ G_CALLBACK (cc_sharing_panel_media_sharing_dialog_response),
+ self, G_CONNECT_SWAPPED);
cc_media_sharing_get_preferences (&folders);
@@ -675,8 +670,8 @@ cc_sharing_panel_setup_media_sharing_dialog (CcSharingPanel *self)
cc_list_box_adjust_scrolling (GTK_LIST_BOX (self->shared_folders_listbox));
- g_signal_connect (G_OBJECT (self->shared_folders_listbox), "row-activated",
- G_CALLBACK (cc_sharing_panel_add_folder), self);
+ g_signal_connect_object (self->shared_folders_listbox, "row-activated",
+ G_CALLBACK (cc_sharing_panel_add_folder), self, G_CONNECT_SWAPPED);
networks = cc_sharing_networks_new (self->sharing_proxy, "rygel");
gtk_grid_attach (GTK_GRID (self->shared_folders_grid), networks, 0, 4, 2, 1);
@@ -932,11 +927,9 @@ cc_sharing_panel_setup_personal_file_sharing_dialog (CcSharingPanel *self)
}
static void
-remote_login_switch_activate (GtkSwitch *remote_login_switch,
- GParamSpec *pspec,
- CcSharingPanel *self)
+remote_login_switch_activate (CcSharingPanel *self)
{
- cc_remote_login_set_enabled (self->remote_login_cancellable, remote_login_switch);
+ cc_remote_login_set_enabled (self->remote_login_cancellable, GTK_SWITCH (self->remote_login_switch));
}
static void
@@ -947,8 +940,8 @@ cc_sharing_panel_setup_remote_login_dialog (CcSharingPanel *self)
cc_sharing_panel_setup_label_with_hostname (self, self->remote_login_label);
- g_signal_connect (self->remote_login_switch, "notify::active",
- G_CALLBACK (remote_login_switch_activate), self);
+ g_signal_connect_object (self->remote_login_switch, "notify::active",
+ G_CALLBACK (remote_login_switch_activate), self, G_CONNECT_SWAPPED);
gtk_widget_set_sensitive (self->remote_login_switch, FALSE);
cc_remote_login_get_enabled (self->remote_login_cancellable,
@@ -975,14 +968,14 @@ cc_sharing_panel_check_schema_available (CcSharingPanel *self,
}
static void
-screen_sharing_show_cb (GtkWidget *widget, CcSharingPanel *self)
+screen_sharing_show_cb (CcSharingPanel *self)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->show_password_checkbutton),
FALSE);
}
static void
-screen_sharing_hide_cb (GtkWidget *widget, CcSharingPanel *self)
+screen_sharing_hide_cb (CcSharingPanel *self)
{
GtkToggleButton *ac_radio;
GtkEntry *pw_entry;
@@ -998,33 +991,32 @@ screen_sharing_hide_cb (GtkWidget *widget, CcSharingPanel *self)
#define MAX_PASSWORD_SIZE 8
static void
-screen_sharing_password_insert_text_cb (GtkEditable *editable,
- gchar *new_text,
- gint new_text_length,
- gpointer position,
- gpointer user_data)
+screen_sharing_password_insert_text_cb (CcSharingPanel *self,
+ gchar *new_text,
+ gint new_text_length,
+ gpointer position)
{
int l, available_size;
- l = gtk_entry_buffer_get_bytes (gtk_entry_get_buffer (GTK_ENTRY (editable)));
+ l = gtk_entry_buffer_get_bytes (gtk_entry_get_buffer (GTK_ENTRY (self->remote_control_password_entry)));
if (l + new_text_length <= MAX_PASSWORD_SIZE)
return;
- g_signal_stop_emission_by_name (editable, "insert-text");
- gtk_widget_error_bell (GTK_WIDGET (editable));
+ g_signal_stop_emission_by_name (self->remote_control_password_entry, "insert-text");
+ gtk_widget_error_bell (GTK_WIDGET (self->remote_control_password_entry));
available_size = g_utf8_strlen (new_text, MAX_PASSWORD_SIZE - l);
if (available_size == 0)
return;
- g_signal_handlers_block_by_func (editable,
+ g_signal_handlers_block_by_func (self->remote_control_password_entry,
(gpointer) screen_sharing_password_insert_text_cb,
- user_data);
- gtk_editable_insert_text (editable, new_text, available_size, position);
- g_signal_handlers_unblock_by_func (editable,
+ self);
+ gtk_editable_insert_text (GTK_EDITABLE (self->remote_control_password_entry), new_text, available_size,
position);
+ g_signal_handlers_unblock_by_func (self->remote_control_password_entry,
(gpointer) screen_sharing_password_insert_text_cb,
- user_data);
+ self);
}
#undef MAX_PASSWORD_SIZE
@@ -1066,15 +1058,15 @@ cc_sharing_panel_setup_screen_sharing_dialog_vino (CcSharingPanel *self)
G_BINDING_SYNC_CREATE);
/* make sure the password entry is hidden by default */
- g_signal_connect (self->screen_sharing_dialog, "show",
- G_CALLBACK (screen_sharing_show_cb), self);
+ g_signal_connect_object (self->screen_sharing_dialog, "show",
+ G_CALLBACK (screen_sharing_show_cb), self, G_CONNECT_SWAPPED);
- g_signal_connect (self->screen_sharing_dialog, "hide",
- G_CALLBACK (screen_sharing_hide_cb), self);
+ g_signal_connect_object (self->screen_sharing_dialog, "hide",
+ G_CALLBACK (screen_sharing_hide_cb), self, G_CONNECT_SWAPPED);
/* accept at most 8 bytes in password entry */
- g_signal_connect (self->remote_control_password_entry, "insert-text",
- G_CALLBACK (screen_sharing_password_insert_text_cb), self);
+ g_signal_connect_object (self->remote_control_password_entry, "insert-text",
+ G_CALLBACK (screen_sharing_password_insert_text_cb), self, G_CONNECT_SWAPPED);
networks = cc_sharing_networks_new (self->sharing_proxy, "vino-server");
box = self->remote_control_box;
@@ -1106,21 +1098,24 @@ cc_sharing_panel_setup_screen_sharing_dialog_gnome_remote_desktop (CcSharingPane
G_BINDING_SYNC_CREATE);
/* make sure the password entry is hidden by default */
- g_signal_connect (self->screen_sharing_dialog,
- "show",
- G_CALLBACK (screen_sharing_show_cb),
- self);
-
- g_signal_connect (self->screen_sharing_dialog,
- "hide",
- G_CALLBACK (screen_sharing_hide_cb),
- self);
+ g_signal_connect_object (self->screen_sharing_dialog,
+ "show",
+ G_CALLBACK (screen_sharing_show_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (self->screen_sharing_dialog,
+ "hide",
+ G_CALLBACK (screen_sharing_hide_cb),
+ self,
+ G_CONNECT_SWAPPED);
/* accept at most 8 bytes in password entry */
- g_signal_connect (self->remote_control_password_entry,
- "insert-text",
- G_CALLBACK (screen_sharing_password_insert_text_cb),
- self);
+ g_signal_connect_object (self->remote_control_password_entry,
+ "insert-text",
+ G_CALLBACK (screen_sharing_password_insert_text_cb),
+ self,
+ G_CONNECT_SWAPPED);
/* Bind settings to widgets */
vnc_settings = g_settings_new (GNOME_REMOTE_DESKTOP_VNC_SCHEMA_ID);
@@ -1256,8 +1251,8 @@ cc_sharing_panel_init (CcSharingPanel *self)
gtk_widget_init_template (GTK_WIDGET (self));
- g_signal_connect (self->main_list_box, "row-activated",
- G_CALLBACK (cc_sharing_panel_main_list_box_row_activated), self);
+ g_signal_connect_object (self->main_list_box, "row-activated",
+ G_CALLBACK (cc_sharing_panel_main_list_box_row_activated), self,
G_CONNECT_SWAPPED);
self->hostname_cancellable = g_cancellable_new ();
@@ -1291,8 +1286,8 @@ cc_sharing_panel_init (CcSharingPanel *self)
/* start the panel in the disabled state */
gtk_switch_set_active (GTK_SWITCH (self->master_switch), FALSE);
gtk_widget_set_sensitive (self->main_list_box, FALSE);
- g_signal_connect (self->master_switch, "notify::active",
- G_CALLBACK (cc_sharing_panel_master_switch_notify), self);
+ g_signal_connect_object (self->master_switch, "notify::active",
+ G_CALLBACK (cc_sharing_panel_master_switch_notify), self, G_CONNECT_SWAPPED);
self->sharing_proxy_cancellable = g_cancellable_new ();
gsd_sharing_proxy_new_for_bus (G_BUS_TYPE_SESSION,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]