[gnome-control-center/signal-connect-object: 15/16] printers: 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: 15/16] printers: Connect signals with g_signal_connect_object in swapped form
- Date: Fri, 22 Nov 2019 02:56:07 +0000 (UTC)
commit 8d49f3856a20175fdadafbd2fe3459fed5f2e27e
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Nov 22 15:28:24 2019 +1300
printers: Connect signals with g_signal_connect_object in swapped form
panels/printers/cc-printers-panel.c | 130 +++++++++++++-----------------
panels/printers/pp-ipp-option-widget.c | 24 +++---
panels/printers/pp-jobs-dialog.c | 39 ++++-----
panels/printers/pp-new-printer-dialog.c | 116 ++++++++++----------------
panels/printers/pp-ppd-option-widget.c | 17 ++--
panels/printers/pp-ppd-selection-dialog.c | 64 +++++++--------
panels/printers/pp-printer-entry.c | 19 +++--
7 files changed, 172 insertions(+), 237 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 9fc0c7980..955266b3c 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -651,11 +651,8 @@ cancel_notification_timeout (CcPrintersPanel *self)
}
static void
-on_printer_deletion_undone (GtkButton *button,
- gpointer user_data)
+on_printer_deletion_undone (CcPrintersPanel *self)
{
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
-
gtk_revealer_set_reveal_child (self->notification, FALSE);
g_clear_pointer (&self->deleted_printer_name, g_free);
@@ -695,13 +692,12 @@ on_remove_printer_timeout (gpointer user_data)
}
static void
-on_printer_deleted (PpPrinterEntry *printer_entry,
- gpointer user_data)
+on_printer_deleted (CcPrintersPanel *self,
+ PpPrinterEntry *printer_entry)
{
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- GtkLabel *label;
- g_autofree gchar *notification_message = NULL;
- g_autofree gchar *printer_name = NULL;
+ GtkLabel *label;
+ g_autofree gchar *notification_message = NULL;
+ g_autofree gchar *printer_name = NULL;
gtk_widget_hide (GTK_WIDGET (printer_entry));
@@ -726,12 +722,10 @@ on_printer_deleted (PpPrinterEntry *printer_entry,
}
static void
-on_printer_renamed (PpPrinterEntry *printer_entry,
- gchar *new_name,
- gpointer user_data)
+on_printer_renamed (CcPrintersPanel *self,
+ gchar *new_name,
+ PpPrinterEntry *printer_entry)
{
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
-
g_object_get (printer_entry,
"printer-name",
&self->old_printer_name,
@@ -740,10 +734,9 @@ on_printer_renamed (PpPrinterEntry *printer_entry,
}
static void
-on_printer_changed (PpPrinterEntry *printer_entry,
- gpointer user_data)
+on_printer_changed (CcPrintersPanel *self)
{
- actualize_printers_list (user_data);
+ actualize_printers_list (self);
}
static void
@@ -763,18 +756,21 @@ add_printer_entry (CcPrintersPanel *self,
gtk_size_group_add_widget (self->size_group, GTK_WIDGET (l->data));
g_slist_free (widgets);
- g_signal_connect (printer_entry,
- "printer-changed",
- G_CALLBACK (on_printer_changed),
- self);
- g_signal_connect (printer_entry,
- "printer-delete",
- G_CALLBACK (on_printer_deleted),
- self);
- g_signal_connect (printer_entry,
- "printer-renamed",
- G_CALLBACK (on_printer_renamed),
- self);
+ g_signal_connect_object (printer_entry,
+ "printer-changed",
+ G_CALLBACK (on_printer_changed),
+ self,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (printer_entry,
+ "printer-delete",
+ G_CALLBACK (on_printer_deleted),
+ self,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (printer_entry,
+ "printer-renamed",
+ G_CALLBACK (on_printer_renamed),
+ self,
+ G_CONNECT_SWAPPED);
gtk_list_box_insert (GTK_LIST_BOX (content), GTK_WIDGET (printer_entry), -1);
gtk_widget_show_all (content);
@@ -892,15 +888,12 @@ actualize_printers_list (CcPrintersPanel *self)
}
static void
-new_printer_dialog_pre_response_cb (PpNewPrinterDialog *dialog,
- const gchar *device_name,
- const gchar *device_location,
- const gchar *device_make_and_model,
- gboolean is_network_device,
- gpointer user_data)
+new_printer_dialog_pre_response_cb (CcPrintersPanel *self,
+ const gchar *device_name,
+ const gchar *device_location,
+ const gchar *device_make_and_model,
+ gboolean is_network_device)
{
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
-
self->new_printer_name = g_strdup (device_name);
self->new_printer_location = g_strdup (device_location);
self->new_printer_make_and_model = g_strdup (device_make_and_model);
@@ -910,11 +903,9 @@ new_printer_dialog_pre_response_cb (PpNewPrinterDialog *dialog,
}
static void
-new_printer_dialog_response_cb (PpNewPrinterDialog *dialog,
- gint response_id,
- gpointer user_data)
+new_printer_dialog_response_cb (CcPrintersPanel *self,
+ gint response_id)
{
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
GtkScrolledWindow *scrolled_window;
GtkAllocation allocation;
GtkAdjustment *adjustment;
@@ -963,26 +954,26 @@ new_printer_dialog_response_cb (PpNewPrinterDialog *dialog,
}
static void
-printer_add_cb (GtkToolButton *toolbutton,
- gpointer user_data)
+printer_add_cb (CcPrintersPanel *self)
{
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- GtkWidget *toplevel;
+ GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
self->pp_new_printer_dialog = PP_NEW_PRINTER_DIALOG (
pp_new_printer_dialog_new (GTK_WINDOW (toplevel),
self->all_ppds_list));
- g_signal_connect (self->pp_new_printer_dialog,
- "pre-response",
- G_CALLBACK (new_printer_dialog_pre_response_cb),
- self);
+ g_signal_connect_object (self->pp_new_printer_dialog,
+ "pre-response",
+ G_CALLBACK (new_printer_dialog_pre_response_cb),
+ self,
+ G_CONNECT_SWAPPED);
- g_signal_connect (self->pp_new_printer_dialog,
- "response",
- G_CALLBACK (new_printer_dialog_response_cb),
- self);
+ g_signal_connect_object (self->pp_new_printer_dialog,
+ "response",
+ G_CALLBACK (new_printer_dialog_response_cb),
+ self,
+ G_CONNECT_SWAPPED);
}
static void
@@ -1032,21 +1023,16 @@ update_sensitivity (gpointer user_data)
}
static void
-on_permission_changed (GPermission *permission,
- GParamSpec *pspec,
- gpointer data)
+on_permission_changed (CcPrintersPanel *self)
{
- actualize_printers_list (data);
- update_sensitivity (data);
+ actualize_printers_list (self);
+ update_sensitivity (self);
}
static void
-on_lockdown_settings_changed (GSettings *settings,
- const char *key,
- gpointer user_data)
+on_lockdown_settings_changed (CcPrintersPanel *self,
+ const char *key)
{
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
-
if (g_str_equal (key, "disable-print-setup") == FALSE)
return;
@@ -1056,7 +1042,7 @@ on_lockdown_settings_changed (GSettings *settings,
!g_settings_get_boolean (self->lockdown_settings, "disable-print-setup"));
#endif
- on_permission_changed (self->permission, NULL, user_data);
+ on_permission_changed (self);
}
static void
@@ -1252,11 +1238,11 @@ cc_printers_panel_init (CcPrintersPanel *self)
widget = (GtkWidget*)
gtk_builder_get_object (self->builder, "notification-undo-button");
- g_signal_connect (widget, "clicked", G_CALLBACK (on_printer_deletion_undone), self);
+ g_signal_connect_object (widget, "clicked", G_CALLBACK (on_printer_deletion_undone), self,
G_CONNECT_SWAPPED);
widget = (GtkWidget*)
gtk_builder_get_object (self->builder, "notification-dismiss-button");
- g_signal_connect (widget, "clicked", G_CALLBACK (on_notification_dismissed), self);
+ g_signal_connect_object (widget, "clicked", G_CALLBACK (on_notification_dismissed), self,
G_CONNECT_SWAPPED);
/* add the top level widget */
top_widget = (GtkWidget*)
@@ -1265,11 +1251,11 @@ cc_printers_panel_init (CcPrintersPanel *self)
/* connect signals */
widget = (GtkWidget*)
gtk_builder_get_object (self->builder, "printer-add-button");
- g_signal_connect (widget, "clicked", G_CALLBACK (printer_add_cb), self);
+ g_signal_connect_object (widget, "clicked", G_CALLBACK (printer_add_cb), self, G_CONNECT_SWAPPED);
widget = (GtkWidget*)
gtk_builder_get_object (self->builder, "printer-add-button2");
- g_signal_connect (widget, "clicked", G_CALLBACK (printer_add_cb), self);
+ g_signal_connect_object (widget, "clicked", G_CALLBACK (printer_add_cb), self, G_CONNECT_SWAPPED);
widget = (GtkWidget*)
gtk_builder_get_object (self->builder, "content");
@@ -1288,7 +1274,7 @@ cc_printers_panel_init (CcPrintersPanel *self)
"changed",
G_CALLBACK (on_lockdown_settings_changed),
self,
- G_CONNECT_AFTER);
+ G_CONNECT_SWAPPED | G_CONNECT_AFTER);
/* Add unlock button */
self->permission = (GPermission *)polkit_permission_new_sync (
@@ -1299,8 +1285,8 @@ cc_printers_panel_init (CcPrintersPanel *self)
"notify",
G_CALLBACK (on_permission_changed),
self,
- G_CONNECT_AFTER);
- on_permission_changed (self->permission, NULL, self);
+ G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+ on_permission_changed (self);
}
else
g_warning ("Your system does not have the cups-pk-helper's policy \
diff --git a/panels/printers/pp-ipp-option-widget.c b/panels/printers/pp-ipp-option-widget.c
index 430325ac3..9ca8ba2fd 100644
--- a/panels/printers/pp-ipp-option-widget.c
+++ b/panels/printers/pp-ipp-option-widget.c
@@ -283,15 +283,13 @@ printer_add_option_async_cb (gboolean success,
}
static void
-switch_changed_cb (GtkWidget *switch_button,
- GParamSpec *pspec,
- PpIPPOptionWidget *self)
+switch_changed_cb (PpIPPOptionWidget *self)
{
gchar **values;
values = g_new0 (gchar *, 2);
- if (gtk_switch_get_active (GTK_SWITCH (switch_button)))
+ if (gtk_switch_get_active (GTK_SWITCH (self->switch_button)))
values[0] = g_strdup ("True");
else
values[0] = g_strdup ("False");
@@ -315,13 +313,12 @@ switch_changed_cb (GtkWidget *switch_button,
}
static void
-combo_changed_cb (GtkWidget *combo,
- PpIPPOptionWidget *self)
+combo_changed_cb (PpIPPOptionWidget *self)
{
gchar **values;
values = g_new0 (gchar *, 2);
- values[0] = combo_box_get (combo);
+ values[0] = combo_box_get (self->combo);
if (self->cancellable)
{
@@ -342,13 +339,12 @@ combo_changed_cb (GtkWidget *combo,
}
static void
-spin_button_changed_cb (GtkWidget *spin_button,
- PpIPPOptionWidget *self)
+spin_button_changed_cb (PpIPPOptionWidget *self)
{
gchar **values;
values = g_new0 (gchar *, 2);
- values[0] = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin_button)));
+ values[0] = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (self->spin_button)));
if (self->cancellable)
{
@@ -404,7 +400,7 @@ construct_widget (PpIPPOptionWidget *self)
self->switch_button = gtk_switch_new ();
gtk_box_pack_start (GTK_BOX (self), self->switch_button, FALSE, FALSE, 0);
- g_signal_connect (self->switch_button, "notify::active", G_CALLBACK (switch_changed_cb),
self);
+ g_signal_connect_object (self->switch_button, "notify::active", G_CALLBACK
(switch_changed_cb), self, G_CONNECT_SWAPPED);
break;
case IPP_ATTRIBUTE_TYPE_INTEGER:
@@ -422,7 +418,7 @@ construct_widget (PpIPPOptionWidget *self)
}
gtk_box_pack_start (GTK_BOX (self), self->combo, FALSE, FALSE, 0);
- g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
+ g_signal_connect_object (self->combo, "changed", G_CALLBACK (combo_changed_cb), self,
G_CONNECT_SWAPPED);
break;
case IPP_ATTRIBUTE_TYPE_STRING:
@@ -435,7 +431,7 @@ construct_widget (PpIPPOptionWidget *self)
self->option_supported->attribute_values[i].string_value);
gtk_box_pack_start (GTK_BOX (self), self->combo, FALSE, FALSE, 0);
- g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
+ g_signal_connect_object (self->combo, "changed", G_CALLBACK (combo_changed_cb), self,
G_CONNECT_SWAPPED);
break;
case IPP_ATTRIBUTE_TYPE_RANGE:
@@ -445,7 +441,7 @@ construct_widget (PpIPPOptionWidget *self)
1);
gtk_box_pack_start (GTK_BOX (self), self->spin_button, FALSE, FALSE, 0);
- g_signal_connect (self->spin_button, "value-changed", G_CALLBACK (spin_button_changed_cb),
self);
+ g_signal_connect_object (self->spin_button, "value-changed", G_CALLBACK
(spin_button_changed_cb), self, G_CONNECT_SWAPPED);
break;
default:
diff --git a/panels/printers/pp-jobs-dialog.c b/panels/printers/pp-jobs-dialog.c
index 4aa0452e5..6f2ba5308 100644
--- a/panels/printers/pp-jobs-dialog.c
+++ b/panels/printers/pp-jobs-dialog.c
@@ -129,8 +129,7 @@ auth_popup_filled (PpJobsDialog *self)
}
static void
-auth_entries_changed (GtkEntry *entry,
- PpJobsDialog *self)
+auth_entries_changed (PpJobsDialog *self)
{
GtkWidget *widget;
@@ -139,8 +138,7 @@ auth_entries_changed (GtkEntry *entry,
}
static void
-auth_entries_activated (GtkEntry *entry,
- PpJobsDialog *self)
+auth_entries_activated (PpJobsDialog *self)
{
GtkWidget *widget;
@@ -437,12 +435,9 @@ update_jobs_list (PpJobsDialog *self)
}
static void
-jobs_dialog_response_cb (GtkDialog *dialog,
- gint response_id,
- gpointer user_data)
+jobs_dialog_response_cb (PpJobsDialog *self,
+ gint response_id)
{
- PpJobsDialog *self = (PpJobsDialog*) user_data;
-
pp_jobs_dialog_hide (self);
self->user_callback (GTK_DIALOG (self->dialog),
@@ -451,10 +446,8 @@ jobs_dialog_response_cb (GtkDialog *dialog,
}
static void
-on_clear_all_button_clicked (GtkButton *button,
- gpointer user_data)
+on_clear_all_button_clicked (PpJobsDialog *self)
{
- PpJobsDialog *self = user_data;
guint num_items;
guint i;
@@ -493,10 +486,8 @@ pp_job_authenticate_cb (GObject *source_object,
}
static void
-authenticate_button_clicked (GtkWidget *button,
- gpointer user_data)
+authenticate_button_clicked (PpJobsDialog *self)
{
- PpJobsDialog *self = user_data;
GtkWidget *widget;
PpJob *job;
gchar **auth_info_required = NULL;
@@ -588,26 +579,26 @@ pp_jobs_dialog_new (GtkWindow *parent,
/* connect signals */
g_signal_connect (self->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
- g_signal_connect (self->dialog, "response", G_CALLBACK (jobs_dialog_response_cb), self);
+ g_signal_connect_object (self->dialog, "response", G_CALLBACK (jobs_dialog_response_cb), self,
G_CONNECT_SWAPPED);
g_signal_connect (self->dialog, "key-press-event", G_CALLBACK (key_press_event_cb), NULL);
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "jobs-clear-all-button"));
- g_signal_connect (widget, "clicked", G_CALLBACK (on_clear_all_button_clicked), self);
+ g_signal_connect_object (widget, "clicked", G_CALLBACK (on_clear_all_button_clicked), self,
G_CONNECT_SWAPPED);
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "authenticate-button"));
- g_signal_connect (widget, "clicked", G_CALLBACK (authenticate_button_clicked), self);
+ g_signal_connect_object (widget, "clicked", G_CALLBACK (authenticate_button_clicked), self,
G_CONNECT_SWAPPED);
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "domain-entry"));
- g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), self);
- g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), self);
+ g_signal_connect_object (widget, "changed", G_CALLBACK (auth_entries_changed), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (widget, "activate", G_CALLBACK (auth_entries_activated), self, G_CONNECT_SWAPPED);
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "username-entry"));
- g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), self);
- g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), self);
+ g_signal_connect_object (widget, "changed", G_CALLBACK (auth_entries_changed), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (widget, "activate", G_CALLBACK (auth_entries_activated), self, G_CONNECT_SWAPPED);
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "password-entry"));
- g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), self);
- g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), self);
+ g_signal_connect_object (widget, "changed", G_CALLBACK (auth_entries_changed), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (widget, "activate", G_CALLBACK (auth_entries_activated), self, G_CONNECT_SWAPPED);
/* Translators: This is the printer name for which we are showing the active jobs */
title = g_strdup_printf (C_("Printer jobs dialog title", "%s — Active Jobs"), printer_name);
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 81a4cc1f6..3ddc85d10 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -65,13 +65,10 @@ static void replace_device (PpNewPrinterDialog *self,
PpPrintDevice *old_device,
PpPrintDevice *new_device);
static void populate_devices_list (PpNewPrinterDialog *self);
-static void search_entry_activated_cb (GtkEntry *entry,
- gpointer user_data);
-static void search_entry_changed_cb (GtkSearchEntry *entry,
- gpointer user_data);
-static void new_printer_dialog_response_cb (GtkDialog *_dialog,
- gint response_id,
- gpointer user_data);
+static void search_entry_activated_cb (PpNewPrinterDialog *self);
+static void search_entry_changed_cb (PpNewPrinterDialog *self);
+static void new_printer_dialog_response_cb (PpNewPrinterDialog *self,
+ gint response_id);
static void update_dialog_state (PpNewPrinterDialog *self);
static void add_devices_to_list (PpNewPrinterDialog *self,
GList *devices);
@@ -254,7 +251,6 @@ get_authenticated_samba_devices_cb (GObject *source_object,
PpNewPrinterDialog *self = PP_NEW_PRINTER_DIALOG (data->dialog);
PpDevicesList *result;
PpPrintDevice *device;
- GtkWidget *widget;
gboolean cancelled = FALSE;
PpSamba *samba = (PpSamba *) source_object;
g_autoptr(GError) error = NULL;
@@ -289,9 +285,8 @@ get_authenticated_samba_devices_cb (GObject *source_object,
device = (PpPrintDevice *) result->devices->data;
if (device != NULL)
{
- widget = WID ("search-entry");
- gtk_entry_set_text (GTK_ENTRY (widget), pp_print_device_get_device_location (device));
- search_entry_activated_cb (GTK_ENTRY (widget), self);
+ gtk_entry_set_text (GTK_ENTRY (WID ("search-entry")), pp_print_device_get_device_location
(device));
+ search_entry_activated_cb (self);
}
}
}
@@ -339,10 +334,8 @@ get_entry_text (const gchar *object_name,
}
static void
-on_authenticate (GtkWidget *button,
- gpointer user_data)
+on_authenticate (PpNewPrinterDialog *self)
{
- PpNewPrinterDialog *self = user_data;
gchar *hostname = NULL;
gchar *username = NULL;
gchar *password = NULL;
@@ -368,10 +361,8 @@ on_authenticate (GtkWidget *button,
}
static void
-on_authentication_required (PpHost *host,
- gpointer user_data)
+on_authentication_required (PpNewPrinterDialog *self)
{
- PpNewPrinterDialog *self = user_data;
g_autofree gchar *hostname = NULL;
g_autofree gchar *title = NULL;
g_autofree gchar *text = NULL;
@@ -379,7 +370,7 @@ on_authentication_required (PpHost *host,
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (WID ("headerbar")), NULL);
gtk_header_bar_set_title (GTK_HEADER_BAR (WID ("headerbar")), _("Unlock Print Server"));
- g_object_get (G_OBJECT (host), "hostname", &hostname, NULL);
+ g_object_get (self->samba_host, "hostname", &hostname, NULL);
/* Translators: Samba server needs authentication of the user to show list of its printers. */
title = g_strdup_printf (_("Unlock %s."), hostname);
gtk_label_set_text (GTK_LABEL (WID ("authentication-title")), title);
@@ -390,14 +381,12 @@ on_authentication_required (PpHost *host,
go_to_page (self, AUTHENTICATION_PAGE);
- g_signal_connect (WID ("authenticate-button"), "clicked", G_CALLBACK (on_authenticate), self);
+ g_signal_connect_object (WID ("authenticate-button"), "clicked", G_CALLBACK (on_authenticate), self,
G_CONNECT_SWAPPED);
}
static void
-auth_entries_changed (GtkEditable *editable,
- gpointer user_data)
+auth_entries_changed (PpNewPrinterDialog *self)
{
- PpNewPrinterDialog *self = user_data;
gboolean can_authenticate = FALSE;
gchar *username = NULL;
gchar *password = NULL;
@@ -415,11 +404,8 @@ auth_entries_changed (GtkEditable *editable,
}
static void
-on_go_back_button_clicked (GtkButton *button,
- gpointer user_data)
+on_go_back_button_clicked (PpNewPrinterDialog *self)
{
- PpNewPrinterDialog *self = user_data;
-
pp_samba_set_auth_info (self->samba_host, NULL, NULL);
g_clear_object (&self->samba_host);
@@ -431,16 +417,14 @@ on_go_back_button_clicked (GtkButton *button,
}
static void
-authenticate_samba_server (GtkButton *button,
- gpointer user_data)
+authenticate_samba_server (PpNewPrinterDialog *self)
{
- PpNewPrinterDialog *self = user_data;
GtkTreeModel *model;
GtkTreeIter iter;
AuthSMBData *data;
gchar *server_name = NULL;
- gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
+ gtk_widget_set_sensitive (WID ("unlock-button"), FALSE);
gtk_widget_set_sensitive (WID ("authenticate-button"), FALSE);
gtk_widget_grab_focus (WID ("username-entry"));
@@ -458,7 +442,7 @@ authenticate_samba_server (GtkButton *button,
g_signal_connect_object (self->samba_host,
"authentication-required",
G_CALLBACK (on_authentication_required),
- self, 0);
+ self, G_CONNECT_SWAPPED);
self->samba_authenticated_searching = TRUE;
update_dialog_state (self);
@@ -477,12 +461,9 @@ authenticate_samba_server (GtkButton *button,
}
static gboolean
-stack_key_press_cb (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
+stack_key_press_cb (PpNewPrinterDialog *self,
+ GdkEvent *event)
{
- PpNewPrinterDialog *self = user_data;
-
gtk_widget_grab_focus (WID ("search-entry"));
gtk_main_do_event (event);
@@ -525,21 +506,20 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *self)
self->filter = GTK_TREE_MODEL_FILTER (gtk_builder_get_object (self->builder, "devices-model-filter"));
/* Connect signals */
- g_signal_connect (self->dialog, "response", G_CALLBACK (new_printer_dialog_response_cb), self);
+ g_signal_connect_object (self->dialog, "response", G_CALLBACK (new_printer_dialog_response_cb), self,
G_CONNECT_SWAPPED);
widget = WID ("search-entry");
- g_signal_connect (widget, "activate", G_CALLBACK (search_entry_activated_cb), self);
- g_signal_connect (widget, "search-changed", G_CALLBACK (search_entry_changed_cb), self);
+ g_signal_connect_object (widget, "activate", G_CALLBACK (search_entry_activated_cb), self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (widget, "search-changed", G_CALLBACK (search_entry_changed_cb), self,
G_CONNECT_SWAPPED);
- widget = WID ("unlock-button");
- g_signal_connect (widget, "clicked", G_CALLBACK (authenticate_samba_server), self);
+ g_signal_connect_object (WID ("unlock-button"), "clicked", G_CALLBACK (authenticate_samba_server), self,
G_CONNECT_SWAPPED);
- g_signal_connect (WID ("stack"), "key-press-event", G_CALLBACK (stack_key_press_cb), self);
+ g_signal_connect_object (WID ("stack"), "key-press-event", G_CALLBACK (stack_key_press_cb), self,
G_CONNECT_SWAPPED);
/* Authentication form widgets */
- g_signal_connect (WID ("username-entry"), "changed", G_CALLBACK (auth_entries_changed), self);
- g_signal_connect (WID ("password-entry"), "changed", G_CALLBACK (auth_entries_changed), self);
- g_signal_connect (WID ("go-back-button"), "clicked", G_CALLBACK (on_go_back_button_clicked), self);
+ g_signal_connect_object (WID ("username-entry"), "changed", G_CALLBACK (auth_entries_changed), self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (WID ("password-entry"), "changed", G_CALLBACK (auth_entries_changed), self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (WID ("go-back-button"), "clicked", G_CALLBACK (on_go_back_button_clicked), self,
G_CONNECT_SWAPPED);
/* Set junctions */
widget = WID ("scrolledwindow1");
@@ -593,10 +573,8 @@ pp_new_printer_dialog_finalize (GObject *object)
}
static void
-device_selection_changed_cb (GtkTreeSelection *selection,
- gpointer user_data)
+device_selection_changed_cb (PpNewPrinterDialog *self)
{
- PpNewPrinterDialog *self = user_data;
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *widget;
@@ -1665,20 +1643,18 @@ search_address (const gchar *text,
}
static void
-search_entry_activated_cb (GtkEntry *entry,
- gpointer user_data)
+search_entry_activated_cb (PpNewPrinterDialog *self)
{
- search_address (gtk_entry_get_text (entry),
- PP_NEW_PRINTER_DIALOG (user_data),
+ search_address (gtk_entry_get_text (GTK_ENTRY (WID ("search-entry"))),
+ self,
FALSE);
}
static void
-search_entry_changed_cb (GtkSearchEntry *entry,
- gpointer user_data)
+search_entry_changed_cb (PpNewPrinterDialog *self)
{
- search_address (gtk_entry_get_text (GTK_ENTRY (entry)),
- PP_NEW_PRINTER_DIALOG (user_data),
+ search_address (gtk_entry_get_text (GTK_ENTRY (WID ("search-entry"))),
+ self,
TRUE);
}
@@ -1853,15 +1829,10 @@ cups_get_dests_cb (GObject *source_object,
}
static void
-row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- gpointer user_data)
+row_activated_cb (PpNewPrinterDialog *self)
{
- PpNewPrinterDialog *self = user_data;
GtkTreeModel *model;
GtkTreeIter iter;
- GtkWidget *widget;
gboolean authentication_needed;
gboolean selected;
@@ -1875,8 +1846,7 @@ row_activated_cb (GtkTreeView *tree_view,
if (authentication_needed)
{
- widget = WID ("unlock-button");
- authenticate_samba_server (GTK_BUTTON (widget), self);
+ authenticate_samba_server (self);
}
else
{
@@ -1940,11 +1910,11 @@ populate_devices_list (PpNewPrinterDialog *self)
PpCups *cups;
GIcon *icon, *emblem_icon;
- g_signal_connect (gtk_tree_view_get_selection (self->treeview),
- "changed", G_CALLBACK (device_selection_changed_cb), self);
+ g_signal_connect_object (gtk_tree_view_get_selection (self->treeview),
+ "changed", G_CALLBACK (device_selection_changed_cb), self, G_CONNECT_SWAPPED);
- g_signal_connect (self->treeview,
- "row-activated", G_CALLBACK (row_activated_cb), self);
+ g_signal_connect_object (self->treeview,
+ "row-activated", G_CALLBACK (row_activated_cb), self, G_CONNECT_SWAPPED);
self->local_printer_icon = g_themed_icon_new ("printer");
self->remote_printer_icon = g_themed_icon_new ("printer-network");
@@ -2110,17 +2080,15 @@ ppd_selection_cb (GtkDialog *_dialog,
}
static void
-new_printer_dialog_response_cb (GtkDialog *dialog,
- gint response_id,
- gpointer user_data)
+new_printer_dialog_response_cb (PpNewPrinterDialog *self,
+ gint response_id)
{
- PpNewPrinterDialog *self = user_data;
PpPrintDevice *device = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
gint acquisition_method;
- gtk_widget_hide (GTK_WIDGET (dialog));
+ gtk_widget_hide (GTK_WIDGET (self->dialog));
if (response_id == GTK_RESPONSE_OK)
{
@@ -2161,7 +2129,7 @@ new_printer_dialog_response_cb (GtkDialog *dialog,
pp_print_device_get_device_make_and_model (device),
pp_print_device_is_network_device (device));
- window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET
(gtk_window_get_transient_for (GTK_WINDOW (dialog)))));
+ window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET
(gtk_window_get_transient_for (GTK_WINDOW (self->dialog)))));
new_printer = pp_new_printer_new ();
g_object_set (new_printer,
diff --git a/panels/printers/pp-ppd-option-widget.c b/panels/printers/pp-ppd-option-widget.c
index 11c54fcec..db409d078 100644
--- a/panels/printers/pp-ppd-option-widget.c
+++ b/panels/printers/pp-ppd-option-widget.c
@@ -342,15 +342,13 @@ printer_add_option_async_cb (gboolean success,
}
static void
-switch_changed_cb (GtkWidget *switch_button,
- GParamSpec *pspec,
- PpPPDOptionWidget *self)
+switch_changed_cb (PpPPDOptionWidget *self)
{
gchar **values;
values = g_new0 (gchar *, 2);
- if (gtk_switch_get_active (GTK_SWITCH (switch_button)))
+ if (gtk_switch_get_active (GTK_SWITCH (self->switch_button)))
values[0] = g_strdup ("True");
else
values[0] = g_strdup ("False");
@@ -374,13 +372,12 @@ switch_changed_cb (GtkWidget *switch_button,
}
static void
-combo_changed_cb (GtkWidget *combo,
- PpPPDOptionWidget *self)
+combo_changed_cb (PpPPDOptionWidget *self)
{
gchar **values;
values = g_new0 (gchar *, 2);
- values[0] = combo_box_get (combo);
+ values[0] = combo_box_get (self->combo);
if (self->cancellable)
{
@@ -412,7 +409,7 @@ construct_widget (PpPPDOptionWidget *self)
{
case PPD_UI_BOOLEAN:
self->switch_button = gtk_switch_new ();
- g_signal_connect (self->switch_button, "notify::active", G_CALLBACK (switch_changed_cb), self);
+ g_signal_connect_object (self->switch_button, "notify::active", G_CALLBACK
(switch_changed_cb), self, G_CONNECT_SWAPPED);
gtk_box_pack_start (GTK_BOX (self), self->switch_button, FALSE, FALSE, 0);
break;
@@ -427,7 +424,7 @@ construct_widget (PpPPDOptionWidget *self)
}
gtk_box_pack_start (GTK_BOX (self), self->combo, FALSE, FALSE, 0);
- g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
+ g_signal_connect_object (self->combo, "changed", G_CALLBACK (combo_changed_cb), self,
G_CONNECT_SWAPPED);
break;
case PPD_UI_PICKMANY:
@@ -441,7 +438,7 @@ construct_widget (PpPPDOptionWidget *self)
}
gtk_box_pack_start (GTK_BOX (self), self->combo, TRUE, TRUE, 0);
- g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
+ g_signal_connect_object (self->combo, "changed", G_CALLBACK (combo_changed_cb), self,
G_CONNECT_SWAPPED);
break;
default:
diff --git a/panels/printers/pp-ppd-selection-dialog.c b/panels/printers/pp-ppd-selection-dialog.c
index 9be6c4dfc..7c0f5927c 100644
--- a/panels/printers/pp-ppd-selection-dialog.c
+++ b/panels/printers/pp-ppd-selection-dialog.c
@@ -67,18 +67,18 @@ struct _PpPPDSelectionDialog {
};
static void
-manufacturer_selection_changed_cb (GtkTreeSelection *selection,
- gpointer user_data)
+manufacturer_selection_changed_cb (PpPPDSelectionDialog *self)
{
- PpPPDSelectionDialog *self = user_data;
- GtkListStore *store;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeView *models_treeview;
- gchar *manufacturer_name = NULL;
- gint i, index;
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ GtkTreeView *treeview;
+ GtkListStore *store;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeView *models_treeview;
+ gchar *manufacturer_name = NULL;
+ gint i, index;
+
+ treeview = GTK_TREE_VIEW (gtk_builder_get_object (self->builder, "ppd-selection-manufacturers-treeview"));
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (treeview), &model, &iter))
{
gtk_tree_model_get (model, &iter,
PPD_MANUFACTURERS_NAMES_COLUMN, &manufacturer_name,
@@ -124,16 +124,16 @@ manufacturer_selection_changed_cb (GtkTreeSelection *selection,
}
static void
-model_selection_changed_cb (GtkTreeSelection *selection,
- gpointer user_data)
+model_selection_changed_cb (PpPPDSelectionDialog *self)
{
- PpPPDSelectionDialog *self = user_data;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *widget;
- gchar *model_name = NULL;
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ GtkTreeView *treeview;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkWidget *widget;
+ gchar *model_name = NULL;
+
+ treeview = GTK_TREE_VIEW (gtk_builder_get_object (self->builder, "ppd-selection-models-treeview"));
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (treeview), &model, &iter))
{
gtk_tree_model_get (model, &iter,
PPD_NAMES_COLUMN, &model_name,
@@ -258,11 +258,11 @@ populate_dialog (PpPPDSelectionDialog *self)
gtk_tree_view_append_column (models_treeview, column);
- g_signal_connect (gtk_tree_view_get_selection (models_treeview),
- "changed", G_CALLBACK (model_selection_changed_cb), self);
+ g_signal_connect_object (gtk_tree_view_get_selection (models_treeview),
+ "changed", G_CALLBACK (model_selection_changed_cb), self, G_CONNECT_SWAPPED);
- g_signal_connect (gtk_tree_view_get_selection (manufacturers_treeview),
- "changed", G_CALLBACK (manufacturer_selection_changed_cb), self);
+ g_signal_connect_object (gtk_tree_view_get_selection (manufacturers_treeview),
+ "changed", G_CALLBACK (manufacturer_selection_changed_cb), self,
G_CONNECT_SWAPPED);
gtk_widget_show_all (self->dialog);
@@ -284,15 +284,13 @@ populate_dialog (PpPPDSelectionDialog *self)
}
static void
-ppd_selection_dialog_response_cb (GtkDialog *dialog,
- gint response_id,
- gpointer user_data)
+ppd_selection_dialog_response_cb (PpPPDSelectionDialog *self,
+ gint response_id)
{
- PpPPDSelectionDialog *self = user_data;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeView *models_treeview;
- GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeView *models_treeview;
+ GtkTreeIter iter;
pp_ppd_selection_dialog_hide (self);
@@ -361,7 +359,7 @@ pp_ppd_selection_dialog_new (GtkWindow *parent,
/* connect signals */
g_signal_connect (self->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
- g_signal_connect (self->dialog, "response", G_CALLBACK (ppd_selection_dialog_response_cb), self);
+ g_signal_connect_object (self->dialog, "response", G_CALLBACK (ppd_selection_dialog_response_cb), self,
G_CONNECT_SWAPPED);
gtk_window_set_transient_for (GTK_WINDOW (self->dialog), GTK_WINDOW (parent));
diff --git a/panels/printers/pp-printer-entry.c b/panels/printers/pp-printer-entry.c
index 51ed7664e..7d02cc179 100644
--- a/panels/printers/pp-printer-entry.c
+++ b/panels/printers/pp-printer-entry.c
@@ -275,9 +275,8 @@ tone_down_color (GdkRGBA *color,
}
static gboolean
-supply_levels_draw_cb (GtkWidget *widget,
- cairo_t *cr,
- PpPrinterEntry *self)
+supply_levels_draw_cb (PpPrinterEntry *self,
+ cairo_t *cr)
{
GtkStyleContext *context;
gboolean is_empty = TRUE;
@@ -286,10 +285,10 @@ supply_levels_draw_cb (GtkWidget *widget,
gint height;
int i;
- context = gtk_widget_get_style_context (widget);
+ context = gtk_widget_get_style_context (GTK_WIDGET (self->supply_drawing_area));
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
+ width = gtk_widget_get_allocated_width (GTK_WIDGET (self->supply_drawing_area));
+ height = gtk_widget_get_allocated_height (GTK_WIDGET (self->supply_drawing_area));
gtk_render_background (context, cr, 0, 0, width, height);
@@ -388,12 +387,12 @@ supply_levels_draw_cb (GtkWidget *widget,
if (tooltip_text)
{
- gtk_widget_set_tooltip_text (widget, tooltip_text);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self->supply_drawing_area), tooltip_text);
}
else
{
- gtk_widget_set_tooltip_text (widget, NULL);
- gtk_widget_set_has_tooltip (widget, FALSE);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self->supply_drawing_area), NULL);
+ gtk_widget_set_has_tooltip (GTK_WIDGET (self->supply_drawing_area), FALSE);
}
}
@@ -958,7 +957,7 @@ pp_printer_entry_new (cups_dest_t printer,
gtk_label_set_text (self->printer_location_address_label, location);
}
- g_signal_connect (self->supply_drawing_area, "draw", G_CALLBACK (supply_levels_draw_cb), self);
+ g_signal_connect_object (self->supply_drawing_area, "draw", G_CALLBACK (supply_levels_draw_cb), self,
G_CONNECT_SWAPPED);
ink_supply_is_empty = supply_level_is_empty (self);
gtk_widget_set_visible (GTK_WIDGET (self->printer_inklevel_label), !ink_supply_is_empty);
gtk_widget_set_visible (GTK_WIDGET (self->supply_frame), !ink_supply_is_empty);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]