[gnome-control-center/signal-connect-object: 13/16] user-accounts: 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: 13/16] user-accounts: Connect signals with g_signal_connect_object in swapped form
- Date: Fri, 22 Nov 2019 02:55:56 +0000 (UTC)
commit 64cfc809d23946ff54e8a6e72c2f4c6ac08e036d
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Nov 22 13:10:38 2019 +1300
user-accounts: Connect signals with g_signal_connect_object in swapped form
panels/user-accounts/cc-add-user-dialog.c | 28 +++++-------
panels/user-accounts/cc-avatar-chooser.c | 73 ++++++++++++++-----------------
panels/user-accounts/cc-carousel.c | 12 +++--
panels/user-accounts/cc-realm-manager.c | 15 +++----
panels/user-accounts/cc-user-panel.c | 33 +++++++-------
panels/user-accounts/user-utils.c | 10 ++---
6 files changed, 75 insertions(+), 96 deletions(-)
---
diff --git a/panels/user-accounts/cc-add-user-dialog.c b/panels/user-accounts/cc-add-user-dialog.c
index 07c1edfdb..2c89e97ba 100644
--- a/panels/user-accounts/cc-add-user-dialog.c
+++ b/panels/user-accounts/cc-add-user-dialog.c
@@ -167,9 +167,9 @@ finish_action (CcAddUserDialog *self)
}
static void
-user_loaded_cb (ActUser *user,
+user_loaded_cb (CcAddUserDialog *self,
GParamSpec *pspec,
- CcAddUserDialog *self)
+ ActUser *user)
{
const gchar *password;
@@ -210,9 +210,9 @@ create_user_done (ActUserManager *manager,
/* Check if the returned object is fully loaded before returning it */
if (act_user_is_loaded (user))
- user_loaded_cb (user, NULL, self);
+ user_loaded_cb (self, NULL, user);
else
- g_signal_connect (user, "notify::is-loaded", G_CALLBACK (user_loaded_cb), self);
+ g_signal_connect_object (user, "notify::is-loaded", G_CALLBACK (user_loaded_cb),
self, G_CONNECT_SWAPPED);
}
}
@@ -863,11 +863,9 @@ enterprise_add_realm (CcAddUserDialog *self,
}
static void
-on_manager_realm_added (CcRealmManager *manager,
- CcRealmObject *realm,
- gpointer user_data)
+on_manager_realm_added (CcAddUserDialog *self,
+ CcRealmObject *realm)
{
- CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
enterprise_add_realm (self, realm);
}
@@ -988,12 +986,10 @@ enterprise_permit_user_login (CcAddUserDialog *self)
}
static void
-on_join_response (GtkDialog *dialog,
+on_join_response (CcAddUserDialog *self,
gint response,
- gpointer user_data)
+ GtkDialog *dialog)
{
- CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
-
gtk_widget_hide (GTK_WIDGET (dialog));
if (response != GTK_RESPONSE_OK) {
finish_action (self);
@@ -1123,8 +1119,8 @@ join_init (CcAddUserDialog *self)
self->join_name = GTK_ENTRY (gtk_builder_get_object (builder, "join-name"));
self->join_password = GTK_ENTRY (gtk_builder_get_object (builder, "join-password"));
- g_signal_connect (self->join_dialog, "response",
- G_CALLBACK (on_join_response), self);
+ g_signal_connect_object (self->join_dialog, "response",
+ G_CALLBACK (on_join_response), self, G_CONNECT_SWAPPED);
g_object_unref (builder);
}
@@ -1387,8 +1383,8 @@ on_realm_manager_created (GObject *source,
for (l = realms; l != NULL; l = g_list_next (l))
enterprise_add_realm (self, l->data);
g_list_free (realms);
- g_signal_connect (self->realm_manager, "realm-added",
- G_CALLBACK (on_manager_realm_added), self);
+ g_signal_connect_object (self->realm_manager, "realm-added",
+ G_CALLBACK (on_manager_realm_added), self, G_CONNECT_SWAPPED);
/* When no realms try to discover a sensible default, triggers realm-added signal */
cc_realm_manager_discover (self->realm_manager, "", self->cancellable,
diff --git a/panels/user-accounts/cc-avatar-chooser.c b/panels/user-accounts/cc-avatar-chooser.c
index 221e2d8c9..60c4010e3 100644
--- a/panels/user-accounts/cc-avatar-chooser.c
+++ b/panels/user-accounts/cc-avatar-chooser.c
@@ -69,9 +69,9 @@ struct _CcAvatarChooser {
G_DEFINE_TYPE (CcAvatarChooser, cc_avatar_chooser, GTK_TYPE_POPOVER)
static void
-crop_dialog_response (GtkWidget *dialog,
+crop_dialog_response (CcAvatarChooser *self,
gint response_id,
- CcAvatarChooser *self)
+ GtkWidget *dialog)
{
GdkPixbuf *pb, *pb2;
@@ -113,8 +113,8 @@ cc_avatar_chooser_crop (CcAvatarChooser *self,
gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (crop_dialog_response), self);
+ g_signal_connect_object (G_OBJECT (dialog), "response",
+ G_CALLBACK (crop_dialog_response), self, G_CONNECT_SWAPPED);
/* Content */
self->crop_area = cc_crop_area_new ();
@@ -132,9 +132,9 @@ cc_avatar_chooser_crop (CcAvatarChooser *self,
}
static void
-file_chooser_response (GtkDialog *chooser,
+file_chooser_response (CcAvatarChooser *self,
gint response,
- CcAvatarChooser *self)
+ GtkDialog *chooser)
{
gchar *filename;
GError *error;
@@ -260,8 +260,8 @@ cc_avatar_chooser_select_file (CcAvatarChooser *self)
gtk_file_filter_add_pixbuf_formats (filter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter);
- g_signal_connect (chooser, "response",
- G_CALLBACK (file_chooser_response), self);
+ g_signal_connect_object (chooser, "response",
+ G_CALLBACK (file_chooser_response), self, G_CONNECT_SWAPPED);
gtk_window_present (GTK_WINDOW (chooser));
}
@@ -275,9 +275,9 @@ destroy_chooser (GtkWidget *chooser)
}
static void
-webcam_response_cb (GtkDialog *dialog,
+webcam_response_cb (CcAvatarChooser *self,
int response,
- CcAvatarChooser *self)
+ GtkDialog *dialog)
{
if (response == GTK_RESPONSE_ACCEPT) {
GdkPixbuf *pb, *pb2;
@@ -306,8 +306,8 @@ webcam_icon_selected (CcAvatarChooser *self)
gtk_window_set_transient_for (GTK_WINDOW (window),
GTK_WINDOW (gtk_widget_get_toplevel (self->popup_button)));
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
- g_signal_connect (G_OBJECT (window), "response",
- G_CALLBACK (webcam_response_cb), self);
+ g_signal_connect_object (G_OBJECT (window), "response",
+ G_CALLBACK (webcam_response_cb), self, G_CONNECT_SWAPPED);
gtk_widget_show (window);
}
@@ -321,18 +321,14 @@ update_photo_menu_status (CcAvatarChooser *self)
}
static void
-device_added (CheeseCameraDeviceMonitor *monitor,
- CheeseCameraDevice *device,
- CcAvatarChooser *self)
+device_added (CcAvatarChooser *self)
{
self->num_cameras++;
update_photo_menu_status (self);
}
static void
-device_removed (CheeseCameraDeviceMonitor *monitor,
- const char *id,
- CcAvatarChooser *self)
+device_removed (CcAvatarChooser *self)
{
self->num_cameras--;
update_photo_menu_status (self);
@@ -341,9 +337,8 @@ device_removed (CheeseCameraDeviceMonitor *monitor,
#endif /* HAVE_CHEESE */
static void
-face_widget_activated (GtkFlowBox *flowbox,
- GtkFlowBoxChild *child,
- CcAvatarChooser *self)
+face_widget_activated (CcAvatarChooser *self,
+ GtkFlowBoxChild *child)
{
const gchar *filename;
GtkWidget *image;
@@ -389,8 +384,8 @@ create_face_widget (gpointer item,
static void
setup_cheese_camera_device_monitor (CcAvatarChooser *self)
{
- g_signal_connect (G_OBJECT (self->monitor), "added", G_CALLBACK (device_added), self);
- g_signal_connect (G_OBJECT (self->monitor), "removed", G_CALLBACK (device_removed), self);
+ g_signal_connect_object (G_OBJECT (self->monitor), "added", G_CALLBACK (device_added), self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (G_OBJECT (self->monitor), "removed", G_CALLBACK (device_removed), self,
G_CONNECT_SWAPPED);
cheese_camera_device_monitor_coldplug (self->monitor);
}
@@ -430,8 +425,8 @@ setup_photo_popup (CcAvatarChooser *self)
self,
NULL);
- g_signal_connect (self->flowbox, "child-activated",
- G_CALLBACK (face_widget_activated), self);
+ g_signal_connect_object (self->flowbox, "child-activated",
+ G_CALLBACK (face_widget_activated), self, G_CONNECT_SWAPPED);
dirs = g_get_system_data_dirs ();
for (i = 0; dirs[i] != NULL; i++) {
@@ -497,24 +492,22 @@ setup_photo_popup (CcAvatarChooser *self)
}
static void
-popup_icon_menu (GtkToggleButton *button,
- CcAvatarChooser *self)
+popup_icon_menu (CcAvatarChooser *self)
{
gtk_popover_popup (GTK_POPOVER (self));
}
static gboolean
-on_popup_button_button_pressed (GtkToggleButton *button,
- GdkEventButton *event,
- CcAvatarChooser *self)
+on_popup_button_button_pressed (CcAvatarChooser *self,
+ GdkEventButton *event)
{
if (event->button == 1) {
if (!gtk_widget_get_visible (GTK_WIDGET (self))) {
- popup_icon_menu (button, self);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ popup_icon_menu (self);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->popup_button), TRUE);
} else {
gtk_popover_popdown (GTK_POPOVER (self));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->popup_button), FALSE);
}
return TRUE;
@@ -537,10 +530,10 @@ cc_avatar_chooser_new (GtkWidget *button)
/* Set up the popup */
self->popup_button = button;
setup_photo_popup (self);
- g_signal_connect (button, "toggled",
- G_CALLBACK (popup_icon_menu), self);
- g_signal_connect (button, "button-press-event",
- G_CALLBACK (on_popup_button_button_pressed), self);
+ g_signal_connect_object (button, "toggled",
+ G_CALLBACK (popup_icon_menu), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (button, "button-press-event",
+ G_CALLBACK (on_popup_button_button_pressed), self, G_CONNECT_SWAPPED);
return self;
}
@@ -588,9 +581,7 @@ cc_avatar_chooser_class_init (CcAvatarChooserClass *klass)
}
static void
-user_flowbox_activated (GtkFlowBox *flowbox,
- GtkFlowBoxChild *child,
- CcAvatarChooser *self)
+user_flowbox_activated (CcAvatarChooser *self)
{
set_default_avatar (self->user);
@@ -620,6 +611,6 @@ cc_avatar_chooser_set_user (CcAvatarChooser *self,
gtk_image_set_pixel_size (GTK_IMAGE (image), AVATAR_CHOOSER_PIXEL_SIZE);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (self->user_flowbox), image);
- g_signal_connect (self->user_flowbox, "child-activated", G_CALLBACK (user_flowbox_activated), self);
+ g_signal_connect_object (self->user_flowbox, "child-activated", G_CALLBACK (user_flowbox_activated),
self, G_CONNECT_SWAPPED);
}
diff --git a/panels/user-accounts/cc-carousel.c b/panels/user-accounts/cc-carousel.c
index 94f2e4979..c9dddb43d 100644
--- a/panels/user-accounts/cc-carousel.c
+++ b/panels/user-accounts/cc-carousel.c
@@ -186,12 +186,10 @@ cc_carousel_find_item (CcCarousel *self,
}
static void
-on_item_toggled (CcCarouselItem *item,
+on_item_toggled (CcCarousel *self,
GdkEvent *event,
- gpointer user_data)
+ CcCarouselItem *item)
{
- CcCarousel *self = CC_CAROUSEL (user_data);
-
cc_carousel_select_item (self, item);
}
@@ -297,7 +295,7 @@ cc_carousel_add (GtkContainer *container,
CC_CAROUSEL_ITEM (widget)->page = get_last_page_number (self);
if (self->selected_item != NULL)
gtk_radio_button_join_group (GTK_RADIO_BUTTON (widget), GTK_RADIO_BUTTON
(self->selected_item));
- g_signal_connect (widget, "button-press-event", G_CALLBACK (on_item_toggled), self);
+ g_signal_connect_object (widget, "button-press-event", G_CALLBACK (on_item_toggled), self,
G_CONNECT_SWAPPED);
last_box_is_full = ((g_list_length (self->children) - 1) % ITEMS_PER_PAGE == 0);
if (last_box_is_full) {
@@ -401,8 +399,8 @@ cc_carousel_init (CcCarousel *self)
g_object_unref (provider);
- g_signal_connect_swapped (self->stack, "size-allocate", G_CALLBACK (on_size_allocate), self);
- g_signal_connect_swapped (self->stack, "notify::transition-running", G_CALLBACK
(on_transition_running), self);
+ g_signal_connect_object (self->stack, "size-allocate", G_CALLBACK (on_size_allocate), self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->stack, "notify::transition-running", G_CALLBACK
(on_transition_running), self, G_CONNECT_SWAPPED);
}
guint
diff --git a/panels/user-accounts/cc-realm-manager.c b/panels/user-accounts/cc-realm-manager.c
index dd61c1312..9b8077e49 100644
--- a/panels/user-accounts/cc-realm-manager.c
+++ b/panels/user-accounts/cc-realm-manager.c
@@ -81,7 +81,7 @@ is_realm_with_kerberos_and_membership (gpointer object)
}
static void
-on_interface_added (GDBusObjectManager *manager,
+on_interface_added (CcRealmManager *self,
GDBusObject *object,
GDBusInterface *interface)
{
@@ -89,28 +89,27 @@ on_interface_added (GDBusObjectManager *manager,
}
static void
-on_object_added (GDBusObjectManager *manager,
- GDBusObject *object,
- gpointer user_data)
+on_object_added (CcRealmManager *self,
+ GDBusObject *object)
{
GList *interfaces, *l;
interfaces = g_dbus_object_get_interfaces (object);
for (l = interfaces; l != NULL; l = g_list_next (l))
- on_interface_added (manager, object, l->data);
+ on_interface_added (self, object, l->data);
g_list_free_full (interfaces, g_object_unref);
if (is_realm_with_kerberos_and_membership (object)) {
g_debug ("Saw realm: %s", g_dbus_object_get_object_path (object));
- g_signal_emit (user_data, signals[REALM_ADDED], 0, object);
+ g_signal_emit (self, signals[REALM_ADDED], 0, object);
}
}
static void
cc_realm_manager_init (CcRealmManager *self)
{
- g_signal_connect (self, "object-added", G_CALLBACK (on_object_added), self);
- g_signal_connect (self, "interface-added", G_CALLBACK (on_interface_added), self);
+ g_signal_connect (self, "object-added", G_CALLBACK (on_object_added), NULL);
+ g_signal_connect (self, "interface-added", G_CALLBACK (on_interface_added), NULL);
}
static void
diff --git a/panels/user-accounts/cc-user-panel.c b/panels/user-accounts/cc-user-panel.c
index 5a0bab308..90b8b90c3 100644
--- a/panels/user-accounts/cc-user-panel.c
+++ b/panels/user-accounts/cc-user-panel.c
@@ -393,9 +393,9 @@ delete_user_done (ActUserManager *manager,
}
static void
-delete_user_response (GtkWidget *dialog,
+delete_user_response (CcUserPanel *self,
gint response_id,
- CcUserPanel *self)
+ GtkWidget *dialog)
{
ActUser *user;
gboolean remove_files;
@@ -562,11 +562,10 @@ enterprise_user_uncached (GObject *source,
}
static void
-delete_enterprise_user_response (GtkWidget *dialog,
- gint response_id,
- gpointer user_data)
+delete_enterprise_user_response (CcUserPanel *self,
+ gint response_id,
+ GtkWidget *dialog)
{
- CcUserPanel *self = CC_USER_PANEL (user_data);
AsyncDeleteData *data;
ActUser *user;
@@ -643,8 +642,8 @@ delete_user (CcUserPanel *self)
gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");
- g_signal_connect (dialog, "response",
- G_CALLBACK (delete_user_response), self);
+ g_signal_connect_object (dialog, "response",
+ G_CALLBACK (delete_user_response), self, G_CONNECT_SWAPPED);
}
else {
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
@@ -661,8 +660,8 @@ delete_user (CcUserPanel *self)
gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");
- g_signal_connect (dialog, "response",
- G_CALLBACK (delete_enterprise_user_response), self);
+ g_signal_connect_object (dialog, "response",
+ G_CALLBACK (delete_enterprise_user_response), self,
G_CONNECT_SWAPPED);
}
g_signal_connect (dialog, "close",
@@ -975,9 +974,9 @@ show_restart_notification (CcUserPanel *self, const gchar *locale)
}
static void
-language_response (GtkDialog *dialog,
+language_response (CcUserPanel *self,
gint response_id,
- CcUserPanel *self)
+ GtkDialog *dialog)
{
ActUser *user;
const gchar *lang, *account_language;
@@ -1022,8 +1021,8 @@ change_language (CcUserPanel *self)
gtk_window_set_transient_for (GTK_WINDOW (self->language_chooser),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))));
- g_signal_connect (self->language_chooser, "response",
- G_CALLBACK (language_response), self);
+ g_signal_connect_object (self->language_chooser, "response",
+ G_CALLBACK (language_response), self, G_CONNECT_SWAPPED);
g_signal_connect (self->language_chooser, "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
@@ -1098,9 +1097,9 @@ users_loaded (CcUserPanel *self)
_("Failed to contact the accounts service"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("Please make sure that the AccountService is
installed and enabled."));
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
gtk_widget_show (dialog);
gtk_widget_set_sensitive (GTK_WIDGET (self->accounts_box), FALSE);
diff --git a/panels/user-accounts/user-utils.c b/panels/user-accounts/user-utils.c
index ce1815cc3..c1d61a117 100644
--- a/panels/user-accounts/user-utils.c
+++ b/panels/user-accounts/user-utils.c
@@ -163,8 +163,7 @@ query_unlock_tooltip (GtkWidget *widget,
gint x,
gint y,
gboolean keyboard_tooltip,
- GtkTooltip *tooltip,
- gpointer user_data)
+ GtkTooltip *tooltip)
{
GtkWidget *label;
PangoLayout *layout;
@@ -268,10 +267,7 @@ query_tooltip (GtkWidget *widget,
}
static void
-icon_released (GtkEntry *entry,
- GtkEntryIconPosition pos,
- GdkEvent *event,
- gpointer user_data)
+icon_released (GtkEntry *entry)
{
GtkSettings *settings;
gint timeout;
@@ -298,7 +294,7 @@ set_entry_validation_error (GtkEntry *entry,
GTK_ENTRY_ICON_SECONDARY,
TRUE);
g_signal_connect (entry, "icon-release",
- G_CALLBACK (icon_released), FALSE);
+ G_CALLBACK (icon_released), NULL);
g_signal_connect (entry, "query-tooltip",
G_CALLBACK (query_tooltip), NULL);
g_object_set (entry, "has-tooltip", TRUE, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]