diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2020-06-27 10:51:23 +1200 |
---|---|---|
committer | Robert Ancell <robert.ancell@gmail.com> | 2020-09-22 21:23:05 +0000 |
commit | 68042c95c11b96825ba754db0c2331f5efe8a69b (patch) | |
tree | 4de875a4b6e67e63a86d99f5fa4b15c575b8f0aa | |
parent | f8204635ce42f4d6eb0aa578cf435e466a075e03 (diff) | |
download | gnome-control-center-68042c95c11b96825ba754db0c2331f5efe8a69b.tar.gz |
printers: Use a shared PpCups object
-rw-r--r-- | panels/printers/cc-printers-panel.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c index b793931f3..49ca0d1ba 100644 --- a/panels/printers/cc-printers-panel.c +++ b/panels/printers/cc-printers-panel.c @@ -70,6 +70,8 @@ struct _CcPrintersPanel GtkBuilder *builder; + PpCups *cups; + cups_dest_t *dests; int num_dests; @@ -297,6 +299,7 @@ cc_printers_panel_dispose (GObject *object) NULL); } + g_clear_object (&self->cups); g_clear_object (&self->pp_new_printer_dialog); g_clear_pointer (&self->new_printer_name, g_free); g_clear_pointer (&self->renamed_printer_name, g_free); @@ -494,10 +497,8 @@ static gboolean renew_subscription (gpointer data) { CcPrintersPanel *self = (CcPrintersPanel*) data; - g_autoptr(PpCups) cups = NULL; - cups = pp_cups_new (); - pp_cups_renew_subscription_async (cups, + pp_cups_renew_subscription_async (self->cups, self->subscription_id, subscription_events, SUBSCRIPTION_DURATION, @@ -560,10 +561,8 @@ static void attach_to_cups_notifier (gpointer data) { CcPrintersPanel *self = (CcPrintersPanel*) data; - g_autoptr(PpCups) cups = NULL; - cups = pp_cups_new (); - pp_cups_renew_subscription_async (cups, + pp_cups_renew_subscription_async (self->cups, self->subscription_id, subscription_events, SUBSCRIPTION_DURATION, @@ -584,7 +583,6 @@ static void detach_from_cups_notifier (gpointer data) { CcPrintersPanel *self = (CcPrintersPanel*) data; - g_autoptr(PpCups) cups = NULL; if (self->dbus_subscription_id != 0) { g_dbus_connection_signal_unsubscribe (self->cups_bus_connection, @@ -592,8 +590,7 @@ detach_from_cups_notifier (gpointer data) self->dbus_subscription_id = 0; } - cups = pp_cups_new (); - pp_cups_cancel_subscription_async (cups, + pp_cups_cancel_subscription_async (self->cups, self->subscription_id, subscription_cancel_cb, NULL); @@ -911,10 +908,7 @@ actualize_printers_list_cb (GObject *source_object, static void actualize_printers_list (CcPrintersPanel *self) { - g_autoptr(PpCups) cups = NULL; - - cups = pp_cups_new (); - pp_cups_get_dests_async (cups, + pp_cups_get_dests_async (self->cups, cc_panel_get_cancellable (CC_PANEL (self)), actualize_printers_list_cb, self); @@ -1068,10 +1062,8 @@ static gboolean cups_status_check (gpointer user_data) { CcPrintersPanel *self = (CcPrintersPanel*) user_data; - g_autoptr(PpCups) cups = NULL; - cups = pp_cups_new (); - pp_cups_connection_test_async (cups, NULL, cups_status_check_cb, self); + pp_cups_connection_test_async (self->cups, NULL, cups_status_check_cb, self); return self->cups_status_check_id != 0; } @@ -1219,7 +1211,6 @@ cc_printers_panel_init (CcPrintersPanel *self) { GtkWidget *top_widget; GtkWidget *widget; - g_autoptr(PpCups) cups = NULL; g_autoptr(GError) error = NULL; gchar *objects[] = { "overlay", "permission-infobar", "top-right-buttons", "printer-add-button", "search-button", NULL }; guint builder_result; @@ -1230,6 +1221,8 @@ cc_printers_panel_init (CcPrintersPanel *self) self->builder = gtk_builder_new (); self->reference = g_object_new (G_TYPE_OBJECT, NULL); + self->cups = pp_cups_new (); + self->printer_entries = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, @@ -1330,8 +1323,7 @@ Please check your installation"); get_all_ppds_async_cb, self); - cups = pp_cups_new (); - pp_cups_connection_test_async (cups, cc_panel_get_cancellable (CC_PANEL (self)), connection_test_cb, self); + pp_cups_connection_test_async (self->cups, cc_panel_get_cancellable (CC_PANEL (self)), connection_test_cb, self); gtk_container_add (GTK_CONTAINER (self), top_widget); gtk_widget_show_all (GTK_WIDGET (self)); } |