printers: Use a shared PpCups object
This commit is contained in:
parent
f8204635ce
commit
68042c95c1
1 changed files with 11 additions and 19 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue