[gnome-control-center] printers: Replace GObject boilerplace with G_DECLARE_TYPE
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Replace GObject boilerplace with G_DECLARE_TYPE
- Date: Tue, 29 Jan 2019 22:39:35 +0000 (UTC)
commit 4042cb5d332dbe001d0d9e2335f2471e7c8054e4
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Jun 15 14:13:15 2018 +1200
printers: Replace GObject boilerplace with G_DECLARE_TYPE
panels/printers/cc-printers-panel.c | 539 +++++++++++++------------------
panels/printers/cc-printers-panel.h | 41 +--
panels/printers/pp-cups.c | 5 +
panels/printers/pp-cups.h | 23 +-
panels/printers/pp-details-dialog.c | 2 +-
panels/printers/pp-details-dialog.h | 7 +-
panels/printers/pp-host.c | 48 ++-
panels/printers/pp-host.h | 30 +-
panels/printers/pp-ipp-option-widget.c | 279 ++++++++--------
panels/printers/pp-ipp-option-widget.h | 31 +-
panels/printers/pp-job.c | 54 ++--
panels/printers/pp-job.h | 5 -
panels/printers/pp-maintenance-command.c | 65 ++--
panels/printers/pp-maintenance-command.h | 25 +-
panels/printers/pp-new-printer-dialog.c | 520 +++++++++++++----------------
panels/printers/pp-new-printer-dialog.h | 33 +-
panels/printers/pp-new-printer.c | 217 ++++++-------
panels/printers/pp-new-printer.h | 24 +-
panels/printers/pp-ppd-option-widget.c | 243 +++++++-------
panels/printers/pp-ppd-option-widget.h | 28 +-
panels/printers/pp-print-device.c | 145 ++++-----
panels/printers/pp-print-device.h | 8 -
panels/printers/pp-printer-entry.c | 6 +-
panels/printers/pp-printer-entry.h | 7 +-
panels/printers/pp-printer.c | 27 +-
panels/printers/pp-printer.h | 1 -
panels/printers/pp-samba.c | 67 ++--
panels/printers/pp-samba.h | 25 +-
28 files changed, 1006 insertions(+), 1499 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index a2566a022..faa833910 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -44,11 +44,6 @@
#include "cc-util.h"
-CC_PANEL_REGISTER (CcPrintersPanel, cc_printers_panel)
-
-#define PRINTERS_PANEL_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_PRINTERS_PANEL, CcPrintersPanelPrivate))
-
#define RENEW_INTERVAL 500
#define SUBSCRIPTION_DURATION 600
@@ -68,8 +63,10 @@ CC_PANEL_REGISTER (CcPrintersPanel, cc_printers_panel)
#define ippGetString(attr, element, language) attr->values[element].string.text
#endif
-struct _CcPrintersPanelPrivate
+struct _CcPrintersPanel
{
+ CcPanel parent_instance;
+
GtkBuilder *builder;
cups_dest_t *dests;
@@ -117,6 +114,8 @@ struct _CcPrintersPanelPrivate
gpointer dummy;
};
+CC_PANEL_REGISTER (CcPrintersPanel, cc_printers_panel)
+
#define PAGE_LOCK "_lock"
#define PAGE_ADDPRINTER "_addprinter"
@@ -140,7 +139,6 @@ static void
execute_action (CcPrintersPanel *self,
GVariant *action)
{
- CcPrintersPanelPrivate *priv = self->priv;
PpPrinterEntry *printer_entry;
const gchar *action_name;
const gchar *printer_name;
@@ -160,7 +158,7 @@ execute_action (CcPrintersPanel *self,
g_variant_get_child (action, 1, "v", &variant);
printer_name = g_variant_get_string (variant, NULL);
- printer_entry = PP_PRINTER_ENTRY (g_hash_table_lookup (priv->printer_entries, printer_name));
+ printer_entry = PP_PRINTER_ENTRY (g_hash_table_lookup (self->printer_entries, printer_name));
if (printer_entry != NULL)
pp_printer_entry_authenticate_jobs (printer_entry);
else
@@ -174,7 +172,7 @@ execute_action (CcPrintersPanel *self,
g_variant_get_child (action, 1, "v", &variant);
printer_name = g_variant_get_string (variant, NULL);
- printer_entry = PP_PRINTER_ENTRY (g_hash_table_lookup (priv->printer_entries, printer_name));
+ printer_entry = PP_PRINTER_ENTRY (g_hash_table_lookup (self->printer_entries, printer_name));
if (printer_entry != NULL)
pp_printer_entry_show_jobs_dialog (printer_entry);
else
@@ -207,7 +205,6 @@ cc_printers_panel_set_property (GObject *object,
GParamSpec *pspec)
{
CcPrintersPanel *self = CC_PRINTERS_PANEL (object);
- CcPrintersPanelPrivate *priv = self->priv;
GVariant *parameters;
switch (property_id)
@@ -216,15 +213,15 @@ cc_printers_panel_set_property (GObject *object,
parameters = g_value_get_variant (value);
if (parameters != NULL && g_variant_n_children (parameters) > 0)
{
- if (priv->entries_filled)
+ if (self->entries_filled)
{
execute_action (CC_PRINTERS_PANEL (object), parameters);
}
else
{
- if (priv->action != NULL)
- g_variant_unref (priv->action);
- priv->action = g_variant_ref (parameters);
+ if (self->action != NULL)
+ g_variant_unref (self->action);
+ self->action = g_variant_ref (parameters);
}
}
break;
@@ -238,25 +235,24 @@ static void
cc_printers_panel_constructed (GObject *object)
{
CcPrintersPanel *self = CC_PRINTERS_PANEL (object);
- CcPrintersPanelPrivate *priv = self->priv;
GtkWidget *widget;
CcShell *shell;
G_OBJECT_CLASS (cc_printers_panel_parent_class)->constructed (object);
shell = cc_panel_get_shell (CC_PANEL (self));
- cc_shell_embed_widget_in_header (shell, priv->headerbar_buttons);
+ cc_shell_embed_widget_in_header (shell, self->headerbar_buttons);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "lock-button");
- gtk_lock_button_set_permission (GTK_LOCK_BUTTON (widget), priv->permission);
+ gtk_builder_get_object (self->builder, "lock-button");
+ gtk_lock_button_set_permission (GTK_LOCK_BUTTON (widget), self->permission);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "search-button");
+ gtk_builder_get_object (self->builder, "search-button");
cc_shell_embed_widget_in_header (shell, widget);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "search-bar");
+ gtk_builder_get_object (self->builder, "search-bar");
g_signal_connect_object (shell,
"key-press-event",
G_CALLBACK (gtk_search_bar_handle_event),
@@ -281,80 +277,80 @@ printer_removed_cb (GObject *source_object,
static void
cc_printers_panel_dispose (GObject *object)
{
- CcPrintersPanelPrivate *priv = CC_PRINTERS_PANEL (object)->priv;
+ CcPrintersPanel *self = CC_PRINTERS_PANEL (object);
- if (priv->pp_new_printer_dialog)
- g_clear_object (&priv->pp_new_printer_dialog);
+ if (self->pp_new_printer_dialog)
+ g_clear_object (&self->pp_new_printer_dialog);
free_dests (CC_PRINTERS_PANEL (object));
- g_clear_pointer (&priv->new_printer_name, g_free);
- g_clear_pointer (&priv->new_printer_location, g_free);
- g_clear_pointer (&priv->new_printer_make_and_model, g_free);
+ g_clear_pointer (&self->new_printer_name, g_free);
+ g_clear_pointer (&self->new_printer_location, g_free);
+ g_clear_pointer (&self->new_printer_make_and_model, g_free);
- g_clear_pointer (&priv->renamed_printer_name, g_free);
- g_clear_pointer (&priv->old_printer_name, g_free);
+ g_clear_pointer (&self->renamed_printer_name, g_free);
+ g_clear_pointer (&self->old_printer_name, g_free);
- if (priv->builder)
+ if (self->builder)
{
- g_object_unref (priv->builder);
- priv->builder = NULL;
+ g_object_unref (self->builder);
+ self->builder = NULL;
}
- if (priv->lockdown_settings)
+ if (self->lockdown_settings)
{
- g_object_unref (priv->lockdown_settings);
- priv->lockdown_settings = NULL;
+ g_object_unref (self->lockdown_settings);
+ self->lockdown_settings = NULL;
}
- if (priv->permission)
+ if (self->permission)
{
- g_object_unref (priv->permission);
- priv->permission = NULL;
+ g_object_unref (self->permission);
+ self->permission = NULL;
}
- g_cancellable_cancel (priv->subscription_renew_cancellable);
- g_clear_object (&priv->subscription_renew_cancellable);
+ g_cancellable_cancel (self->subscription_renew_cancellable);
+ g_clear_object (&self->subscription_renew_cancellable);
- g_cancellable_cancel (priv->actualize_printers_list_cancellable);
- g_clear_object (&priv->actualize_printers_list_cancellable);
+ g_cancellable_cancel (self->actualize_printers_list_cancellable);
+ g_clear_object (&self->actualize_printers_list_cancellable);
detach_from_cups_notifier (CC_PRINTERS_PANEL (object));
- g_cancellable_cancel (priv->cups_status_check_cancellable);
- g_clear_object (&priv->cups_status_check_cancellable);
+ g_cancellable_cancel (self->cups_status_check_cancellable);
+ g_clear_object (&self->cups_status_check_cancellable);
- if (priv->cups_status_check_id > 0)
+ if (self->cups_status_check_id > 0)
{
- g_source_remove (priv->cups_status_check_id);
- priv->cups_status_check_id = 0;
+ g_source_remove (self->cups_status_check_id);
+ self->cups_status_check_id = 0;
}
- if (priv->remove_printer_timeout_id > 0)
+ if (self->remove_printer_timeout_id > 0)
{
- g_source_remove (priv->remove_printer_timeout_id);
- priv->remove_printer_timeout_id = 0;
+ g_source_remove (self->remove_printer_timeout_id);
+ self->remove_printer_timeout_id = 0;
}
- if (priv->all_ppds_list)
+ if (self->all_ppds_list)
{
- ppd_list_free (priv->all_ppds_list);
- priv->all_ppds_list = NULL;
+ ppd_list_free (self->all_ppds_list);
+ self->all_ppds_list = NULL;
}
- if (priv->get_all_ppds_cancellable)
+ if (self->get_all_ppds_cancellable)
{
- g_cancellable_cancel (priv->get_all_ppds_cancellable);
- g_object_unref (priv->get_all_ppds_cancellable);
- priv->get_all_ppds_cancellable = NULL;
+ g_cancellable_cancel (self->get_all_ppds_cancellable);
+ g_object_unref (self->get_all_ppds_cancellable);
+ self->get_all_ppds_cancellable = NULL;
}
- if (priv->deleted_printer_name != NULL)
+ if (self->deleted_printer_name != NULL)
{
PpPrinter *printer;
- printer = pp_printer_new (priv->deleted_printer_name);
- g_clear_pointer (&priv->deleted_printer_name, g_free);
+ printer = pp_printer_new (self->deleted_printer_name);
+ g_clear_pointer (&self->deleted_printer_name, g_free);
pp_printer_delete_async (printer,
NULL,
@@ -362,10 +358,10 @@ cc_printers_panel_dispose (GObject *object)
NULL);
}
- if (priv->action != NULL)
- g_variant_unref (priv->action);
+ if (self->action != NULL)
+ g_variant_unref (self->action);
- g_clear_pointer (&priv->printer_entries, g_hash_table_destroy);
+ g_clear_pointer (&self->printer_entries, g_hash_table_destroy);
G_OBJECT_CLASS (cc_printers_panel_parent_class)->dispose (object);
}
@@ -388,8 +384,6 @@ cc_printers_panel_class_init (CcPrintersPanelClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CcPrintersPanelPrivate));
-
object_class->get_property = cc_printers_panel_get_property;
object_class->set_property = cc_printers_panel_set_property;
object_class->constructed = cc_printers_panel_constructed;
@@ -407,7 +401,6 @@ on_get_job_attributes_cb (GObject *source_object,
gpointer user_data)
{
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- CcPrintersPanelPrivate *priv;
const gchar *job_originating_user_name;
const gchar *job_printer_uri;
GVariant *attributes;
@@ -415,8 +408,6 @@ on_get_job_attributes_cb (GObject *source_object,
GVariant *printer_uri;
g_autoptr(GError) error = NULL;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
attributes = pp_job_get_attributes_finish (PP_JOB (source_object), res, &error);
g_object_unref (source_object);
@@ -432,13 +423,13 @@ on_get_job_attributes_cb (GObject *source_object,
if (job_originating_user_name != NULL && job_printer_uri != NULL &&
g_strcmp0 (job_originating_user_name, cupsUser ()) == 0 &&
g_strrstr (job_printer_uri, "/") != 0 &&
- priv->dests != NULL)
+ self->dests != NULL)
{
PpPrinterEntry *printer_entry;
gchar *printer_name;
printer_name = g_strrstr (job_printer_uri, "/") + 1;
- printer_entry = PP_PRINTER_ENTRY (g_hash_table_lookup (priv->printer_entries,
printer_name));
+ printer_entry = PP_PRINTER_ENTRY (g_hash_table_lookup (self->printer_entries,
printer_name));
pp_printer_entry_update_jobs_count (printer_entry);
}
@@ -547,7 +538,6 @@ renew_subscription_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
PpCups *cups = PP_CUPS (source_object);
gint subscription_id;
@@ -556,28 +546,21 @@ renew_subscription_cb (GObject *source_object,
g_object_unref (source_object);
if (subscription_id > 0)
- {
- priv = self->priv;
-
- priv->subscription_id = subscription_id;
- }
+ self->subscription_id = subscription_id;
}
static gboolean
renew_subscription (gpointer data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) data;
PpCups *cups;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
cups = pp_cups_new ();
pp_cups_renew_subscription_async (cups,
- priv->subscription_id,
+ self->subscription_id,
subscription_events,
SUBSCRIPTION_DURATION,
- priv->subscription_renew_cancellable,
+ self->subscription_renew_cancellable,
renew_subscription_cb,
data);
@@ -589,7 +572,6 @@ attach_to_cups_notifier_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
PpCups *cups = PP_CUPS (source_object);
g_autoptr(GError) error = NULL;
@@ -600,14 +582,12 @@ attach_to_cups_notifier_cb (GObject *source_object,
if (subscription_id > 0)
{
- priv = self->priv;
+ self->subscription_id = subscription_id;
- priv->subscription_id = subscription_id;
-
- priv->subscription_renewal_id =
+ self->subscription_renewal_id =
g_timeout_add_seconds (RENEW_INTERVAL, renew_subscription, self);
- priv->cups_proxy = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SYSTEM,
+ self->cups_proxy = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
CUPS_DBUS_NAME,
CUPS_DBUS_PATH,
@@ -615,16 +595,16 @@ attach_to_cups_notifier_cb (GObject *source_object,
NULL,
&error);
- if (!priv->cups_proxy)
+ if (!self->cups_proxy)
{
g_warning ("%s", error->message);
return;
}
- priv->cups_bus_connection = g_dbus_proxy_get_connection (priv->cups_proxy);
+ self->cups_bus_connection = g_dbus_proxy_get_connection (self->cups_proxy);
- priv->dbus_subscription_id =
- g_dbus_connection_signal_subscribe (priv->cups_bus_connection,
+ self->dbus_subscription_id =
+ g_dbus_connection_signal_subscribe (self->cups_bus_connection,
NULL,
CUPS_DBUS_INTERFACE,
NULL,
@@ -640,18 +620,15 @@ attach_to_cups_notifier_cb (GObject *source_object,
static void
attach_to_cups_notifier (gpointer data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) data;
PpCups *cups;
- priv = self->priv;
-
cups = pp_cups_new ();
pp_cups_renew_subscription_async (cups,
- priv->subscription_id,
+ self->subscription_id,
subscription_events,
SUBSCRIPTION_DURATION,
- priv->subscription_renew_cancellable,
+ self->subscription_renew_cancellable,
attach_to_cups_notifier_cb,
data);
}
@@ -670,79 +647,65 @@ subscription_cancel_cb (GObject *source_object,
static void
detach_from_cups_notifier (gpointer data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) data;
PpCups *cups;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- if (priv->dbus_subscription_id != 0) {
- g_dbus_connection_signal_unsubscribe (priv->cups_bus_connection,
- priv->dbus_subscription_id);
- priv->dbus_subscription_id = 0;
+ if (self->dbus_subscription_id != 0) {
+ g_dbus_connection_signal_unsubscribe (self->cups_bus_connection,
+ self->dbus_subscription_id);
+ self->dbus_subscription_id = 0;
}
cups = pp_cups_new ();
pp_cups_cancel_subscription_async (cups,
- priv->subscription_id,
+ self->subscription_id,
subscription_cancel_cb,
NULL);
- priv->subscription_id = 0;
+ self->subscription_id = 0;
- if (priv->subscription_renewal_id != 0) {
- g_source_remove (priv->subscription_renewal_id);
- priv->subscription_renewal_id = 0;
+ if (self->subscription_renewal_id != 0) {
+ g_source_remove (self->subscription_renewal_id);
+ self->subscription_renewal_id = 0;
}
- if (priv->cups_proxy != NULL) {
- g_object_unref (priv->cups_proxy);
- priv->cups_proxy = NULL;
+ if (self->cups_proxy != NULL) {
+ g_object_unref (self->cups_proxy);
+ self->cups_proxy = NULL;
}
}
static void
free_dests (CcPrintersPanel *self)
{
- CcPrintersPanelPrivate *priv;
-
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- if (priv->num_dests > 0)
+ if (self->num_dests > 0)
{
- cupsFreeDests (priv->num_dests, priv->dests);
+ cupsFreeDests (self->num_dests, self->dests);
}
- priv->dests = NULL;
- priv->num_dests = 0;
+ self->dests = NULL;
+ self->num_dests = 0;
}
static void
cancel_notification_timeout (CcPrintersPanel *self)
{
- CcPrintersPanelPrivate *priv;
-
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- if (priv->remove_printer_timeout_id == 0)
+ if (self->remove_printer_timeout_id == 0)
return;
- g_source_remove (priv->remove_printer_timeout_id);
+ g_source_remove (self->remove_printer_timeout_id);
- priv->remove_printer_timeout_id = 0;
+ self->remove_printer_timeout_id = 0;
}
static void
on_printer_deletion_undone (GtkButton *button,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- gtk_revealer_set_reveal_child (priv->notification, FALSE);
+ gtk_revealer_set_reveal_child (self->notification, FALSE);
- g_clear_pointer (&priv->deleted_printer_name, g_free);
+ g_clear_pointer (&self->deleted_printer_name, g_free);
actualize_printers_list (self);
cancel_notification_timeout (self);
@@ -752,25 +715,22 @@ static void
on_notification_dismissed (GtkButton *button,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- if (priv->deleted_printer_name != NULL)
+ if (self->deleted_printer_name != NULL)
{
PpPrinter *printer;
- printer = pp_printer_new (priv->deleted_printer_name);
+ printer = pp_printer_new (self->deleted_printer_name);
pp_printer_delete_async (printer,
NULL,
printer_removed_cb,
NULL);
- g_clear_pointer (&priv->deleted_printer_name, g_free);
+ g_clear_pointer (&self->deleted_printer_name, g_free);
}
- gtk_revealer_set_reveal_child (priv->notification, FALSE);
+ gtk_revealer_set_reveal_child (self->notification, FALSE);
}
static gboolean
@@ -785,7 +745,6 @@ static void
on_printer_deleted (PpPrinterEntry *printer_entry,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
GtkLabel *label;
gchar *notification_message;
@@ -793,8 +752,6 @@ on_printer_deleted (PpPrinterEntry *printer_entry,
gtk_widget_hide (GTK_WIDGET (printer_entry));
- priv = PRINTERS_PANEL_PRIVATE (self);
-
on_notification_dismissed (NULL, self);
g_object_get (printer_entry,
@@ -805,17 +762,17 @@ on_printer_deleted (PpPrinterEntry *printer_entry,
notification_message = g_strdup_printf (_("Printer ā%sā has been deleted"),
printer_name);
label = (GtkLabel*)
- gtk_builder_get_object (priv->builder, "notification-label");
+ gtk_builder_get_object (self->builder, "notification-label");
gtk_label_set_label (label, notification_message);
g_free (notification_message);
- priv->deleted_printer_name = g_strdup (printer_name);
+ self->deleted_printer_name = g_strdup (printer_name);
g_free (printer_name);
- gtk_revealer_set_reveal_child (priv->notification, TRUE);
+ gtk_revealer_set_reveal_child (self->notification, TRUE);
- priv->remove_printer_timeout_id = g_timeout_add_seconds (10, on_remove_printer_timeout, self);
+ self->remove_printer_timeout_id = g_timeout_add_seconds (10, on_remove_printer_timeout, self);
}
static void
@@ -824,15 +781,12 @@ on_printer_renamed (PpPrinterEntry *printer_entry,
gpointer user_data)
{
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- CcPrintersPanelPrivate *priv;
-
- priv = PRINTERS_PANEL_PRIVATE (self);
g_object_get (printer_entry,
"printer-name",
- &priv->old_printer_name,
+ &self->old_printer_name,
NULL);
- priv->renamed_printer_name = g_strdup (new_name);
+ self->renamed_printer_name = g_strdup (new_name);
}
static void
@@ -846,20 +800,17 @@ static void
add_printer_entry (CcPrintersPanel *self,
cups_dest_t printer)
{
- CcPrintersPanelPrivate *priv;
PpPrinterEntry *printer_entry;
GtkWidget *content;
GSList *widgets, *l;
- priv = PRINTERS_PANEL_PRIVATE (self);
+ content = (GtkWidget*) gtk_builder_get_object (self->builder, "content");
- content = (GtkWidget*) gtk_builder_get_object (priv->builder, "content");
-
- printer_entry = pp_printer_entry_new (printer, priv->is_authorized);
+ printer_entry = pp_printer_entry_new (printer, self->is_authorized);
widgets = pp_printer_entry_get_size_group_widgets (printer_entry);
for (l = widgets; l != NULL; l = l->next)
- gtk_size_group_add_widget (priv->size_group, GTK_WIDGET (l->data));
+ gtk_size_group_add_widget (self->size_group, GTK_WIDGET (l->data));
g_slist_free (widgets);
g_signal_connect (printer_entry,
@@ -878,7 +829,7 @@ add_printer_entry (CcPrintersPanel *self,
gtk_list_box_insert (GTK_LIST_BOX (content), GTK_WIDGET (printer_entry), -1);
gtk_widget_show_all (content);
- g_hash_table_insert (priv->printer_entries, g_strdup (printer.name), printer_entry);
+ g_hash_table_insert (self->printer_entries, g_strdup (printer.name), printer_entry);
}
static void
@@ -886,18 +837,15 @@ set_current_page (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel *) user_data;
GtkWidget *widget;
PpCups *cups = PP_CUPS (source_object);
gboolean success;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
success = pp_cups_connection_test_finish (cups, result, NULL);
g_object_unref (source_object);
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "main-vbox");
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "main-vbox");
if (success)
gtk_stack_set_visible_child_name (GTK_STACK (widget), "empty-state");
else
@@ -911,7 +859,6 @@ actualize_printers_list_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
GtkWidget *widget;
PpCups *cups = PP_CUPS (source_object);
@@ -933,50 +880,48 @@ actualize_printers_list_cb (GObject *source_object,
return;
}
- priv = PRINTERS_PANEL_PRIVATE (self);
-
free_dests (self);
- priv->dests = cups_dests->dests;
- priv->num_dests = cups_dests->num_of_dests;
+ self->dests = cups_dests->dests;
+ self->num_dests = cups_dests->num_of_dests;
g_free (cups_dests);
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "main-vbox");
- if (priv->num_dests == 0 && !priv->new_printer_name)
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "main-vbox");
+ if (self->num_dests == 0 && !self->new_printer_name)
pp_cups_connection_test_async (g_object_ref (cups), NULL, set_current_page, self);
else
gtk_stack_set_visible_child_name (GTK_STACK (widget), "printers-list");
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "content");
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "content");
gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_destroy, NULL);
- for (i = 0; i < priv->num_dests; i++)
+ for (i = 0; i < self->num_dests; i++)
{
- new_printer_available = g_strcmp0 (priv->dests[i].name, priv->renamed_printer_name) == 0;
+ new_printer_available = g_strcmp0 (self->dests[i].name, self->renamed_printer_name) == 0;
if (new_printer_available)
break;
}
- for (i = 0; i < priv->num_dests; i++)
+ for (i = 0; i < self->num_dests; i++)
{
- if (g_strcmp0 (priv->dests[i].name, priv->deleted_printer_name) == 0)
+ if (g_strcmp0 (self->dests[i].name, self->deleted_printer_name) == 0)
continue;
- if (new_printer_available && g_strcmp0 (priv->dests[i].name, priv->old_printer_name) == 0)
+ if (new_printer_available && g_strcmp0 (self->dests[i].name, self->old_printer_name) == 0)
continue;
- add_printer_entry (self, priv->dests[i]);
+ add_printer_entry (self, self->dests[i]);
}
- if (!priv->entries_filled)
+ if (!self->entries_filled)
{
- if (priv->action != NULL)
+ if (self->action != NULL)
{
- execute_action (self, priv->action);
- g_variant_unref (priv->action);
- priv->action = NULL;
+ execute_action (self, self->action);
+ g_variant_unref (self->action);
+ self->action = NULL;
}
- priv->entries_filled = TRUE;
+ self->entries_filled = TRUE;
}
update_sensitivity (user_data);
@@ -987,14 +932,11 @@ actualize_printers_list_cb (GObject *source_object,
static void
actualize_printers_list (CcPrintersPanel *self)
{
- CcPrintersPanelPrivate *priv;
PpCups *cups;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
cups = pp_cups_new ();
pp_cups_get_dests_async (cups,
- priv->actualize_printers_list_cancellable,
+ self->actualize_printers_list_cancellable,
actualize_printers_list_cb,
self);
}
@@ -1007,15 +949,12 @@ new_printer_dialog_pre_response_cb (PpNewPrinterDialog *dialog,
gboolean is_network_device,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- priv->new_printer_name = g_strdup (device_name);
- priv->new_printer_location = g_strdup (device_location);
- priv->new_printer_make_and_model = g_strdup (device_make_and_model);
- priv->new_printer_on_network = is_network_device;
+ 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);
+ self->new_printer_on_network = is_network_device;
actualize_printers_list (self);
}
@@ -1025,20 +964,17 @@ new_printer_dialog_response_cb (PpNewPrinterDialog *dialog,
gint response_id,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
GtkScrolledWindow *scrolled_window;
GtkAllocation allocation;
GtkAdjustment *adjustment;
GtkWidget *printer_entry;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- if (priv->pp_new_printer_dialog)
- g_clear_object (&priv->pp_new_printer_dialog);
+ if (self->pp_new_printer_dialog)
+ g_clear_object (&self->pp_new_printer_dialog);
- g_clear_pointer (&priv->new_printer_location, g_free);
- g_clear_pointer (&priv->new_printer_make_and_model, g_free);
+ g_clear_pointer (&self->new_printer_location, g_free);
+ g_clear_pointer (&self->new_printer_make_and_model, g_free);
if (response_id == GTK_RESPONSE_REJECT)
{
@@ -1059,18 +995,18 @@ new_printer_dialog_response_cb (PpNewPrinterDialog *dialog,
actualize_printers_list (self);
- if (priv->new_printer_name == NULL)
+ if (self->new_printer_name == NULL)
return;
/* Scroll the view to show the newly added printer-entry. */
- scrolled_window = GTK_SCROLLED_WINDOW (gtk_builder_get_object (priv->builder,
+ scrolled_window = GTK_SCROLLED_WINDOW (gtk_builder_get_object (self->builder,
"scrolled-window"));
adjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
- printer_entry = GTK_WIDGET (g_hash_table_lookup (priv->printer_entries,
- priv->new_printer_name));
+ printer_entry = GTK_WIDGET (g_hash_table_lookup (self->printer_entries,
+ self->new_printer_name));
gtk_widget_get_allocation (printer_entry, &allocation);
- g_clear_pointer (&priv->new_printer_name, g_free);
+ g_clear_pointer (&self->new_printer_name, g_free);
gtk_adjustment_set_value (adjustment,
allocation.y - gtk_widget_get_margin_top (printer_entry));
@@ -1080,23 +1016,20 @@ static void
printer_add_cb (GtkToolButton *toolbutton,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
GtkWidget *toplevel;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
- priv->pp_new_printer_dialog = PP_NEW_PRINTER_DIALOG (
+ self->pp_new_printer_dialog = PP_NEW_PRINTER_DIALOG (
pp_new_printer_dialog_new (GTK_WINDOW (toplevel),
- priv->all_ppds_list));
+ self->all_ppds_list));
- g_signal_connect (priv->pp_new_printer_dialog,
+ g_signal_connect (self->pp_new_printer_dialog,
"pre-response",
G_CALLBACK (new_printer_dialog_pre_response_cb),
self);
- g_signal_connect (priv->pp_new_printer_dialog,
+ g_signal_connect (self->pp_new_printer_dialog,
"response",
G_CALLBACK (new_printer_dialog_response_cb),
self);
@@ -1105,25 +1038,22 @@ printer_add_cb (GtkToolButton *toolbutton,
static void
update_sensitivity (gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
const char *cups_server = NULL;
GtkWidget *widget;
gboolean local_server = TRUE;
gboolean no_cups = FALSE;
- priv = PRINTERS_PANEL_PRIVATE (self);
+ self->is_authorized =
+ self->permission &&
+ g_permission_get_allowed (G_PERMISSION (self->permission)) &&
+ self->lockdown_settings &&
+ !g_settings_get_boolean (self->lockdown_settings, "disable-print-setup");
- priv->is_authorized =
- priv->permission &&
- g_permission_get_allowed (G_PERMISSION (priv->permission)) &&
- priv->lockdown_settings &&
- !g_settings_get_boolean (priv->lockdown_settings, "disable-print-setup");
+ gtk_stack_set_visible_child_name (GTK_STACK (self->headerbar_buttons),
+ self->is_authorized ? PAGE_ADDPRINTER : PAGE_LOCK);
- gtk_stack_set_visible_child_name (GTK_STACK (priv->headerbar_buttons),
- priv->is_authorized ? PAGE_ADDPRINTER : PAGE_LOCK);
-
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "main-vbox");
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "main-vbox");
if (g_strcmp0 (gtk_stack_get_visible_child_name (GTK_STACK (widget)), "no-cups-page") == 0)
no_cups = TRUE;
@@ -1135,20 +1065,20 @@ update_sensitivity (gpointer user_data)
cups_server[0] != '/')
local_server = FALSE;
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "headerbar-buttons");
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "headerbar-buttons");
gtk_widget_set_visible (widget, !no_cups);
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "search-button");
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "search-button");
gtk_widget_set_visible (widget, !no_cups);
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "search-bar");
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "search-bar");
gtk_widget_set_visible (widget, !no_cups);
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "printer-add-button");
- gtk_widget_set_sensitive (widget, local_server && priv->is_authorized && !no_cups &&
!priv->new_printer_name);
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "printer-add-button");
+ gtk_widget_set_sensitive (widget, local_server && self->is_authorized && !no_cups &&
!self->new_printer_name);
- widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "printer-add-button2");
- gtk_widget_set_sensitive (widget, local_server && priv->is_authorized && !no_cups &&
!priv->new_printer_name);
+ widget = (GtkWidget*) gtk_builder_get_object (self->builder, "printer-add-button2");
+ gtk_widget_set_sensitive (widget, local_server && self->is_authorized && !no_cups &&
!self->new_printer_name);
}
static void
@@ -1165,21 +1095,18 @@ on_lockdown_settings_changed (GSettings *settings,
const char *key,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
if (g_str_equal (key, "disable-print-setup") == FALSE)
return;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
#if 0
/* FIXME */
- gtk_widget_set_sensitive (priv->lock_button,
- !g_settings_get_boolean (priv->lockdown_settings, "disable-print-setup"));
+ gtk_widget_set_sensitive (self->lock_button,
+ !g_settings_get_boolean (self->lockdown_settings, "disable-print-setup"));
#endif
- on_permission_changed (priv->permission, NULL, user_data);
+ on_permission_changed (self->permission, NULL, user_data);
}
static void
@@ -1187,21 +1114,18 @@ cups_status_check_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
gboolean success;
PpCups *cups = PP_CUPS (source_object);
- priv = self->priv;
-
success = pp_cups_connection_test_finish (cups, result, NULL);
if (success)
{
actualize_printers_list (self);
attach_to_cups_notifier (self);
- g_source_remove (priv->cups_status_check_id);
- priv->cups_status_check_id = 0;
+ g_source_remove (self->cups_status_check_id);
+ self->cups_status_check_id = 0;
}
g_object_unref (cups);
@@ -1210,16 +1134,13 @@ cups_status_check_cb (GObject *source_object,
static gboolean
cups_status_check (gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
PpCups *cups;
- priv = self->priv;
-
cups = pp_cups_new ();
pp_cups_connection_test_async (cups, NULL, cups_status_check_cb, self);
- return priv->cups_status_check_id != 0;
+ return self->cups_status_check_id != 0;
}
static void
@@ -1227,7 +1148,6 @@ connection_test_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self;
gboolean success;
PpCups *cups = PP_CUPS (source_object);
@@ -1247,11 +1167,10 @@ connection_test_cb (GObject *source_object,
}
self = CC_PRINTERS_PANEL (user_data);
- priv = self->priv;
if (!success)
{
- priv->cups_status_check_id =
+ self->cups_status_check_id =
g_timeout_add_seconds (CUPS_STATUS_CHECK_INTERVAL, cups_status_check, self);
}
}
@@ -1260,30 +1179,26 @@ static void
get_all_ppds_async_cb (PPDList *ppds,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- priv = self->priv = PRINTERS_PANEL_PRIVATE (self);
+ self->all_ppds_list = ppds;
- priv->all_ppds_list = ppds;
+ if (self->pp_ppd_selection_dialog)
+ pp_ppd_selection_dialog_set_ppd_list (self->pp_ppd_selection_dialog,
+ self->all_ppds_list);
- if (priv->pp_ppd_selection_dialog)
- pp_ppd_selection_dialog_set_ppd_list (priv->pp_ppd_selection_dialog,
- priv->all_ppds_list);
+ if (self->pp_new_printer_dialog)
+ pp_new_printer_dialog_set_ppd_list (self->pp_new_printer_dialog,
+ self->all_ppds_list);
- if (priv->pp_new_printer_dialog)
- pp_new_printer_dialog_set_ppd_list (priv->pp_new_printer_dialog,
- priv->all_ppds_list);
-
- g_object_unref (priv->get_all_ppds_cancellable);
- priv->get_all_ppds_cancellable = NULL;
+ g_object_unref (self->get_all_ppds_cancellable);
+ self->get_all_ppds_cancellable = NULL;
}
static gboolean
filter_function (GtkListBoxRow *row,
gpointer user_data)
{
- CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
GtkWidget *search_entry;
gboolean retval;
@@ -1293,10 +1208,8 @@ filter_function (GtkListBoxRow *row,
gchar *printer_name;
gchar *printer_location;
- priv = PRINTERS_PANEL_PRIVATE (self);
-
search_entry = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "search-entry");
+ gtk_builder_get_object (self->builder, "search-entry");
if (gtk_entry_get_text_length (GTK_ENTRY (search_entry)) == 0)
return TRUE;
@@ -1329,7 +1242,6 @@ filter_function (GtkListBoxRow *row,
static void
cc_printers_panel_init (CcPrintersPanel *self)
{
- CcPrintersPanelPrivate *priv;
GtkWidget *top_widget;
GtkWidget *widget;
PpCups *cups;
@@ -1337,49 +1249,48 @@ cc_printers_panel_init (CcPrintersPanel *self)
gchar *objects[] = { "overlay", "headerbar-buttons", "search-button", NULL };
guint builder_result;
- priv = self->priv = PRINTERS_PANEL_PRIVATE (self);
g_resources_register (cc_printers_get_resource ());
/* initialize main data structure */
- priv->builder = gtk_builder_new ();
- priv->dests = NULL;
- priv->num_dests = 0;
+ self->builder = gtk_builder_new ();
+ self->dests = NULL;
+ self->num_dests = 0;
- priv->pp_new_printer_dialog = NULL;
+ self->pp_new_printer_dialog = NULL;
- priv->subscription_id = 0;
- priv->cups_status_check_id = 0;
- priv->subscription_renewal_id = 0;
- priv->cups_proxy = NULL;
- priv->cups_bus_connection = NULL;
- priv->dbus_subscription_id = 0;
- priv->remove_printer_timeout_id = 0;
+ self->subscription_id = 0;
+ self->cups_status_check_id = 0;
+ self->subscription_renewal_id = 0;
+ self->cups_proxy = NULL;
+ self->cups_bus_connection = NULL;
+ self->dbus_subscription_id = 0;
+ self->remove_printer_timeout_id = 0;
- priv->new_printer_name = NULL;
- priv->new_printer_location = NULL;
- priv->new_printer_make_and_model = NULL;
- priv->new_printer_on_network = FALSE;
+ self->new_printer_name = NULL;
+ self->new_printer_location = NULL;
+ self->new_printer_make_and_model = NULL;
+ self->new_printer_on_network = FALSE;
- priv->renamed_printer_name = NULL;
- priv->old_printer_name = NULL;
- priv->deleted_printer_name = NULL;
+ self->renamed_printer_name = NULL;
+ self->old_printer_name = NULL;
+ self->deleted_printer_name = NULL;
- priv->permission = NULL;
- priv->lockdown_settings = NULL;
+ self->permission = NULL;
+ self->lockdown_settings = NULL;
- priv->all_ppds_list = NULL;
+ self->all_ppds_list = NULL;
- priv->printer_entries = g_hash_table_new_full (g_str_hash,
+ self->printer_entries = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
NULL);
- priv->entries_filled = FALSE;
- priv->action = NULL;
+ self->entries_filled = FALSE;
+ self->action = NULL;
- priv->actualize_printers_list_cancellable = g_cancellable_new ();
- priv->cups_status_check_cancellable = g_cancellable_new ();
+ self->actualize_printers_list_cancellable = g_cancellable_new ();
+ self->cups_status_check_cancellable = g_cancellable_new ();
- builder_result = gtk_builder_add_objects_from_resource (priv->builder,
+ builder_result = gtk_builder_add_objects_from_resource (self->builder,
"/org/gnome/control-center/printers/printers.ui",
objects, &error);
@@ -1391,83 +1302,83 @@ cc_printers_panel_init (CcPrintersPanel *self)
}
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "headerbar-buttons");
- priv->headerbar_buttons = widget;
+ gtk_builder_get_object (self->builder, "headerbar-buttons");
+ self->headerbar_buttons = widget;
- priv->notification = (GtkRevealer*)
- gtk_builder_get_object (priv->builder, "notification");
+ self->notification = (GtkRevealer*)
+ gtk_builder_get_object (self->builder, "notification");
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "notification-undo-button");
+ gtk_builder_get_object (self->builder, "notification-undo-button");
g_signal_connect (widget, "clicked", G_CALLBACK (on_printer_deletion_undone), self);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "notification-dismiss-button");
+ gtk_builder_get_object (self->builder, "notification-dismiss-button");
g_signal_connect (widget, "clicked", G_CALLBACK (on_notification_dismissed), self);
/* add the top level widget */
top_widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "overlay");
+ gtk_builder_get_object (self->builder, "overlay");
/* connect signals */
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "printer-add-button");
+ gtk_builder_get_object (self->builder, "printer-add-button");
g_signal_connect (widget, "clicked", G_CALLBACK (printer_add_cb), self);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "printer-add-button2");
+ gtk_builder_get_object (self->builder, "printer-add-button2");
g_signal_connect (widget, "clicked", G_CALLBACK (printer_add_cb), self);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "content");
+ gtk_builder_get_object (self->builder, "content");
gtk_list_box_set_filter_func (GTK_LIST_BOX (widget),
filter_function,
self,
NULL);
- g_signal_connect_swapped (gtk_builder_get_object (priv->builder, "search-entry"),
+ g_signal_connect_swapped (gtk_builder_get_object (self->builder, "search-entry"),
"search-changed",
G_CALLBACK (gtk_list_box_invalidate_filter),
widget);
- priv->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
- if (priv->lockdown_settings)
- g_signal_connect_object (priv->lockdown_settings,
+ self->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
+ if (self->lockdown_settings)
+ g_signal_connect_object (self->lockdown_settings,
"changed",
G_CALLBACK (on_lockdown_settings_changed),
self,
G_CONNECT_AFTER);
/* Add unlock button */
- priv->permission = (GPermission *)polkit_permission_new_sync (
+ self->permission = (GPermission *)polkit_permission_new_sync (
"org.opensuse.cupspkhelper.mechanism.all-edit", NULL, NULL, NULL);
- if (priv->permission != NULL)
+ if (self->permission != NULL)
{
- g_signal_connect_object (priv->permission,
+ g_signal_connect_object (self->permission,
"notify",
G_CALLBACK (on_permission_changed),
self,
G_CONNECT_AFTER);
- on_permission_changed (priv->permission, NULL, self);
+ on_permission_changed (self->permission, NULL, self);
}
else
g_warning ("Your system does not have the cups-pk-helper's policy \
\"org.opensuse.cupspkhelper.mechanism.all-edit\" installed. \
Please check your installation");
- priv->subscription_renew_cancellable = g_cancellable_new ();
+ self->subscription_renew_cancellable = g_cancellable_new ();
- priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ self->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
actualize_printers_list (self);
attach_to_cups_notifier (self);
- priv->get_all_ppds_cancellable = g_cancellable_new ();
- get_all_ppds_async (priv->get_all_ppds_cancellable,
+ self->get_all_ppds_cancellable = g_cancellable_new ();
+ get_all_ppds_async (self->get_all_ppds_cancellable,
get_all_ppds_async_cb,
self);
cups = pp_cups_new ();
- pp_cups_connection_test_async (cups, priv->cups_status_check_cancellable, connection_test_cb, self);
+ pp_cups_connection_test_async (cups, self->cups_status_check_cancellable, connection_test_cb, self);
gtk_container_add (GTK_CONTAINER (self), top_widget);
gtk_widget_show_all (GTK_WIDGET (self));
}
diff --git a/panels/printers/cc-printers-panel.h b/panels/printers/cc-printers-panel.h
index 31beca83e..ed5abb29f 100644
--- a/panels/printers/cc-printers-panel.h
+++ b/panels/printers/cc-printers-panel.h
@@ -24,45 +24,8 @@
G_BEGIN_DECLS
-#define CC_TYPE_PRINTERS_PANEL cc_printers_panel_get_type()
-
-#define CC_PRINTERS_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- CC_TYPE_PRINTERS_PANEL, CcPrintersPanel))
-
-#define CC_PRINTERS_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- CC_TYPE_PRINTERS_PANEL, CcPrintersPanelClass))
-
-#define CC_IS_PRINTERS_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- CC_TYPE_PRINTERS_PANEL))
-
-#define CC_IS_PRINTERS_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- CC_TYPE_PRINTERS_PANEL))
-
-#define CC_PRINTERS_PANEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- CC_TYPE_PRINTERS_PANEL, CcPrintersPanelClass))
-
-typedef struct _CcPrintersPanel CcPrintersPanel;
-typedef struct _CcPrintersPanelClass CcPrintersPanelClass;
-typedef struct _CcPrintersPanelPrivate CcPrintersPanelPrivate;
-
-struct _CcPrintersPanel
-{
- CcPanel parent;
-
- CcPrintersPanelPrivate *priv;
-};
-
-struct _CcPrintersPanelClass
-{
- CcPanelClass parent_class;
-};
-
-GType cc_printers_panel_get_type (void) G_GNUC_CONST;
+#define CC_TYPE_PRINTERS_PANEL (cc_printers_panel_get_type ())
+G_DECLARE_FINAL_TYPE (CcPrintersPanel, cc_printers_panel, CC, PRINTERS_PANEL, CcPanel)
G_END_DECLS
diff --git a/panels/printers/pp-cups.c b/panels/printers/pp-cups.c
index 2a716d9e4..162bf81c3 100644
--- a/panels/printers/pp-cups.c
+++ b/panels/printers/pp-cups.c
@@ -29,6 +29,11 @@
#define ippGetStatusCode(ipp) ipp->request.status.status_code
#endif
+struct _PpCups
+{
+ GObject parent_instance;
+};
+
G_DEFINE_TYPE (PpCups, pp_cups, G_TYPE_OBJECT);
static void
diff --git a/panels/printers/pp-cups.h b/panels/printers/pp-cups.h
index c446febb9..e30203436 100644
--- a/panels/printers/pp-cups.h
+++ b/panels/printers/pp-cups.h
@@ -27,33 +27,14 @@
G_BEGIN_DECLS
-#define PP_TYPE_CUPS (pp_cups_get_type ())
-#define PP_CUPS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PP_TYPE_CUPS, PpCups))
-#define PP_CUPS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PP_TYPE_CUPS, PpCupsClass))
-#define PP_IS_CUPS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PP_TYPE_CUPS))
-#define PP_IS_CUPS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PP_TYPE_CUPS))
-#define PP_CUPS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PP_TYPE_CUPS, PpCupsClass))
+#define PP_TYPE_CUPS (pp_cups_get_type ())
+G_DECLARE_FINAL_TYPE (PpCups, pp_cups, PP, CUPS, GObject)
typedef struct{
cups_dest_t *dests;
gint num_of_dests;
} PpCupsDests;
-typedef struct _PpCups PpCups;
-typedef struct _PpCupsClass PpCupsClass;
-
-struct _PpCups
-{
- GObject parent_instance;
-};
-
-struct _PpCupsClass
-{
- GObjectClass parent_class;
-};
-
-GType pp_cups_get_type (void) G_GNUC_CONST;
-
PpCups *pp_cups_new (void);
void pp_cups_get_dests_async (PpCups *cups,
diff --git a/panels/printers/pp-details-dialog.c b/panels/printers/pp-details-dialog.c
index bd15110c1..f29cb3ef7 100644
--- a/panels/printers/pp-details-dialog.c
+++ b/panels/printers/pp-details-dialog.c
@@ -403,7 +403,7 @@ pp_details_dialog_class_init (PpDetailsDialogClass *klass)
signals[PRINTER_RENAMED] = g_signal_new ("printer-renamed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PpDetailsDialogClass, printer_renamed),
+ 0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_STRING);
diff --git a/panels/printers/pp-details-dialog.h b/panels/printers/pp-details-dialog.h
index 266ce5afe..499f9dbbb 100644
--- a/panels/printers/pp-details-dialog.h
+++ b/panels/printers/pp-details-dialog.h
@@ -27,12 +27,7 @@
G_BEGIN_DECLS
#define PP_DETAILS_DIALOG_TYPE (pp_details_dialog_get_type ())
-#define PP_DETAILS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PP_DETAILS_DIALOG_TYPE, PpDetailsDialog))
-
-typedef struct _PpDetailsDialog PpDetailsDialog;
-typedef struct _PpDetailsDialogClass PpDetailsDialogClass;
-
-GType pp_details_dialog_get_type (void);
+G_DECLARE_FINAL_TYPE (PpDetailsDialog, pp_details_dialog, PP, DETAILS_DIALOG, GtkDialog)
PpDetailsDialog *pp_details_dialog_new (GtkWindow *parent,
gchar *printer_name,
diff --git a/panels/printers/pp-host.c b/panels/printers/pp-host.c
index 101aa0feb..a5d2ca197 100644
--- a/panels/printers/pp-host.c
+++ b/panels/printers/pp-host.c
@@ -24,11 +24,11 @@
#define BUFFER_LENGTH 1024
-struct _PpHostPrivate
+typedef struct
{
- gchar *hostname;
- gint port;
-};
+ gchar *hostname;
+ gint port;
+} PpHostPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (PpHost, pp_host, G_TYPE_OBJECT);
@@ -48,9 +48,8 @@ static guint signals[LAST_SIGNAL] = { 0 };
static void
pp_host_finalize (GObject *object)
{
- PpHostPrivate *priv;
-
- priv = PP_HOST (object)->priv;
+ PpHost *self = PP_HOST (object);
+ PpHostPrivate *priv = pp_host_get_instance_private (self);
g_clear_pointer (&priv->hostname, g_free);
@@ -63,17 +62,16 @@ pp_host_get_property (GObject *object,
GValue *value,
GParamSpec *param_spec)
{
- PpHost *self;
-
- self = PP_HOST (object);
+ PpHost *self = PP_HOST (object);
+ PpHostPrivate *priv = pp_host_get_instance_private (self);
switch (prop_id)
{
case PROP_HOSTNAME:
- g_value_set_string (value, self->priv->hostname);
+ g_value_set_string (value, priv->hostname);
break;
case PROP_PORT:
- g_value_set_int (value, self->priv->port);
+ g_value_set_int (value, priv->port);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -90,15 +88,16 @@ pp_host_set_property (GObject *object,
GParamSpec *param_spec)
{
PpHost *self = PP_HOST (object);
+ PpHostPrivate *priv = pp_host_get_instance_private (self);
switch (prop_id)
{
case PROP_HOSTNAME:
- g_free (self->priv->hostname);
- self->priv->hostname = g_value_dup_string (value);
+ g_free (priv->hostname);
+ priv->hostname = g_value_dup_string (value);
break;
case PROP_PORT:
- self->priv->port = g_value_get_int (value);
+ priv->port = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -135,7 +134,7 @@ pp_host_class_init (PpHostClass *klass)
g_signal_new ("authentication-required",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PpHostClass, authentication_required),
+ 0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
}
@@ -143,10 +142,8 @@ pp_host_class_init (PpHostClass *klass)
static void
pp_host_init (PpHost *host)
{
- host->priv = G_TYPE_INSTANCE_GET_PRIVATE (host,
- PP_TYPE_HOST,
- PpHostPrivate);
- host->priv->port = PP_HOST_UNSET_PORT;
+ PpHostPrivate *priv = pp_host_get_instance_private (host);
+ priv->port = PP_HOST_UNSET_PORT;
}
PpHost *
@@ -248,7 +245,7 @@ _pp_host_get_snmp_devices_thread (GTask *task,
GCancellable *cancellable)
{
PpHost *host = (PpHost *) source_object;
- PpHostPrivate *priv = host->priv;
+ PpHostPrivate *priv = pp_host_get_instance_private (host);
PpDevicesList *devices;
PpPrintDevice *device;
gboolean is_network_device;
@@ -342,7 +339,7 @@ _pp_host_get_remote_cups_devices_thread (GTask *task,
{
cups_dest_t *dests = NULL;
PpHost *host = (PpHost *) source_object;
- PpHostPrivate *priv = host->priv;
+ PpHostPrivate *priv = pp_host_get_instance_private (host);
PpDevicesList *devices;
PpPrintDevice *device;
const char *device_location;
@@ -450,6 +447,7 @@ jetdirect_connection_test_cb (GObject *source_object,
g_autoptr(GTask) task = G_TASK (user_data);
data = g_task_get_task_data (task);
+ priv = pp_host_get_instance_private (data->host);
devices = g_new0 (PpDevicesList, 1);
@@ -463,8 +461,6 @@ jetdirect_connection_test_cb (GObject *source_object,
g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
- priv = data->host->priv;
-
device_uri = g_strdup_printf ("socket://%s:%d",
priv->hostname,
data->port);
@@ -494,7 +490,7 @@ pp_host_get_jetdirect_devices_async (PpHost *host,
GAsyncReadyCallback callback,
gpointer user_data)
{
- PpHostPrivate *priv = host->priv;
+ PpHostPrivate *priv = pp_host_get_instance_private (host);
JetDirectData *data;
g_autoptr(GTask) task = NULL;
g_autofree gchar *address = NULL;
@@ -621,7 +617,7 @@ _pp_host_get_lpd_devices_thread (GTask *task,
g_autoptr(GSocketConnection) connection = NULL;
PpPrintDevice *device;
PpHost *host = (PpHost *) source_object;
- PpHostPrivate *priv = host->priv;
+ PpHostPrivate *priv = pp_host_get_instance_private (host);
PpDevicesList *devices;
g_autoptr(GSocketClient) client = NULL;
g_autoptr(GError) error = NULL;
diff --git a/panels/printers/pp-host.h b/panels/printers/pp-host.h
index 9cdbfdda4..cc1410328 100644
--- a/panels/printers/pp-host.h
+++ b/panels/printers/pp-host.h
@@ -27,36 +27,18 @@
G_BEGIN_DECLS
-#define PP_TYPE_HOST (pp_host_get_type ())
-#define PP_HOST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PP_TYPE_HOST, PpHost))
-#define PP_HOST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PP_TYPE_HOST, PpHostClass))
-#define PP_IS_HOST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PP_TYPE_HOST))
-#define PP_IS_HOST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PP_TYPE_HOST))
-#define PP_HOST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PP_TYPE_HOST, PpHostClass))
-
-#define PP_HOST_UNSET_PORT -1
-#define PP_HOST_DEFAULT_IPP_PORT 631
-#define PP_HOST_DEFAULT_JETDIRECT_PORT 9100
-#define PP_HOST_DEFAULT_LPD_PORT 515
-
-typedef struct _PpHost PpHost;
-typedef struct _PpHostClass PpHostClass;
-typedef struct _PpHostPrivate PpHostPrivate;
-
-struct _PpHost
-{
- GObject parent_instance;
- PpHostPrivate *priv;
-};
+#define PP_TYPE_HOST (pp_host_get_type ())
+G_DECLARE_DERIVABLE_TYPE (PpHost, pp_host, PP, HOST, GObject)
struct _PpHostClass
{
GObjectClass parent_class;
-
- void (*authentication_required) (PpHost *host);
};
-GType pp_host_get_type (void) G_GNUC_CONST;
+#define PP_HOST_UNSET_PORT -1
+#define PP_HOST_DEFAULT_IPP_PORT 631
+#define PP_HOST_DEFAULT_JETDIRECT_PORT 9100
+#define PP_HOST_DEFAULT_LPD_PORT 515
PpHost *pp_host_new (const gchar *hostname);
diff --git a/panels/printers/pp-ipp-option-widget.c b/panels/printers/pp-ipp-option-widget.c
index 37e835a85..f9c7f0bc6 100644
--- a/panels/printers/pp-ipp-option-widget.c
+++ b/panels/printers/pp-ipp-option-widget.c
@@ -28,17 +28,16 @@
#include "pp-ipp-option-widget.h"
#include "pp-utils.h"
-#define PP_IPP_OPTION_WIDGET_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), PP_TYPE_IPP_OPTION_WIDGET, PpIPPOptionWidgetPrivate))
-
static void pp_ipp_option_widget_finalize (GObject *object);
static gboolean construct_widget (PpIPPOptionWidget *widget);
static void update_widget (PpIPPOptionWidget *widget);
static void update_widget_real (PpIPPOptionWidget *widget);
-struct PpIPPOptionWidgetPrivate
+struct _PpIPPOptionWidget
{
+ GtkBox parent_instance;
+
GtkWidget *switch_button;
GtkWidget *spin_button;
GtkWidget *combo;
@@ -102,76 +101,67 @@ pp_ipp_option_widget_class_init (PpIPPOptionWidgetClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->finalize = pp_ipp_option_widget_finalize;
-
- g_type_class_add_private (class, sizeof (PpIPPOptionWidgetPrivate));
}
static void
pp_ipp_option_widget_init (PpIPPOptionWidget *widget)
{
- PpIPPOptionWidgetPrivate *priv;
-
gtk_orientable_set_orientation (GTK_ORIENTABLE (widget),
GTK_ORIENTATION_HORIZONTAL);
- priv = widget->priv = PP_IPP_OPTION_WIDGET_GET_PRIVATE (widget);
- priv->switch_button = NULL;
- priv->spin_button = NULL;
- priv->combo = NULL;
- priv->box = NULL;
+ widget->switch_button = NULL;
+ widget->spin_button = NULL;
+ widget->combo = NULL;
+ widget->box = NULL;
- priv->printer_name = NULL;
- priv->option_name = NULL;
+ widget->printer_name = NULL;
+ widget->option_name = NULL;
- priv->option_supported = NULL;
- priv->option_default = NULL;
+ widget->option_supported = NULL;
+ widget->option_default = NULL;
- priv->ipp_attribute = NULL;
+ widget->ipp_attribute = NULL;
}
static void
pp_ipp_option_widget_finalize (GObject *object)
{
PpIPPOptionWidget *widget = PP_IPP_OPTION_WIDGET (object);
- PpIPPOptionWidgetPrivate *priv = widget->priv;
- if (priv)
+ if (widget->option_name)
{
- if (priv->option_name)
- {
- g_free (priv->option_name);
- priv->option_name = NULL;
- }
-
- if (priv->printer_name)
- {
- g_free (priv->printer_name);
- priv->printer_name = NULL;
- }
+ g_free (widget->option_name);
+ widget->option_name = NULL;
+ }
- if (priv->option_supported)
- {
- ipp_attribute_free (priv->option_supported);
- priv->option_supported = NULL;
- }
+ if (widget->printer_name)
+ {
+ g_free (widget->printer_name);
+ widget->printer_name = NULL;
+ }
- if (priv->option_default)
- {
- ipp_attribute_free (priv->option_default);
- priv->option_default = NULL;
- }
+ if (widget->option_supported)
+ {
+ ipp_attribute_free (widget->option_supported);
+ widget->option_supported = NULL;
+ }
- if (priv->ipp_attribute)
- {
- g_hash_table_unref (priv->ipp_attribute);
- priv->ipp_attribute = NULL;
- }
+ if (widget->option_default)
+ {
+ ipp_attribute_free (widget->option_default);
+ widget->option_default = NULL;
+ }
- if (priv->cancellable)
- {
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
- }
+ if (widget->ipp_attribute)
+ {
+ g_hash_table_unref (widget->ipp_attribute);
+ widget->ipp_attribute = NULL;
+ }
+
+ if (widget->cancellable)
+ {
+ g_cancellable_cancel (widget->cancellable);
+ g_object_unref (widget->cancellable);
}
G_OBJECT_CLASS (pp_ipp_option_widget_parent_class)->finalize (object);
@@ -183,19 +173,16 @@ pp_ipp_option_widget_new (IPPAttribute *attr_supported,
const gchar *option_name,
const gchar *printer)
{
- PpIPPOptionWidgetPrivate *priv;
PpIPPOptionWidget *widget = NULL;
if (attr_supported && option_name && printer)
{
widget = g_object_new (PP_TYPE_IPP_OPTION_WIDGET, NULL);
- priv = PP_IPP_OPTION_WIDGET_GET_PRIVATE (widget);
-
- priv->printer_name = g_strdup (printer);
- priv->option_name = g_strdup (option_name);
- priv->option_supported = ipp_attribute_copy (attr_supported);
- priv->option_default = ipp_attribute_copy (attr_default);
+ widget->printer_name = g_strdup (printer);
+ widget->option_name = g_strdup (option_name);
+ widget->option_supported = ipp_attribute_copy (attr_supported);
+ widget->option_default = ipp_attribute_copy (attr_default);
if (construct_widget (widget))
{
@@ -318,10 +305,9 @@ printer_add_option_async_cb (gboolean success,
gpointer user_data)
{
PpIPPOptionWidget *widget = (PpIPPOptionWidget *) user_data;
- PpIPPOptionWidgetPrivate *priv = widget->priv;
update_widget (user_data);
- g_clear_object (&priv->cancellable);
+ g_clear_object (&widget->cancellable);
}
static void
@@ -329,7 +315,6 @@ switch_changed_cb (GtkWidget *switch_button,
GParamSpec *pspec,
PpIPPOptionWidget *widget)
{
- PpIPPOptionWidgetPrivate *priv = widget->priv;
gchar **values;
values = g_new0 (gchar *, 2);
@@ -339,18 +324,18 @@ switch_changed_cb (GtkWidget *switch_button,
else
values[0] = g_strdup ("False");
- if (priv->cancellable)
+ if (widget->cancellable)
{
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
+ g_cancellable_cancel (widget->cancellable);
+ g_object_unref (widget->cancellable);
}
- priv->cancellable = g_cancellable_new ();
- printer_add_option_async (priv->printer_name,
- priv->option_name,
+ widget->cancellable = g_cancellable_new ();
+ printer_add_option_async (widget->printer_name,
+ widget->option_name,
values,
TRUE,
- priv->cancellable,
+ widget->cancellable,
printer_add_option_async_cb,
widget);
@@ -361,24 +346,23 @@ static void
combo_changed_cb (GtkWidget *combo,
PpIPPOptionWidget *widget)
{
- PpIPPOptionWidgetPrivate *priv = widget->priv;
gchar **values;
values = g_new0 (gchar *, 2);
values[0] = combo_box_get (combo);
- if (priv->cancellable)
+ if (widget->cancellable)
{
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
+ g_cancellable_cancel (widget->cancellable);
+ g_object_unref (widget->cancellable);
}
- priv->cancellable = g_cancellable_new ();
- printer_add_option_async (priv->printer_name,
- priv->option_name,
+ widget->cancellable = g_cancellable_new ();
+ printer_add_option_async (widget->printer_name,
+ widget->option_name,
values,
TRUE,
- priv->cancellable,
+ widget->cancellable,
printer_add_option_async_cb,
widget);
@@ -389,24 +373,23 @@ static void
spin_button_changed_cb (GtkWidget *spin_button,
PpIPPOptionWidget *widget)
{
- PpIPPOptionWidgetPrivate *priv = widget->priv;
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)));
- if (priv->cancellable)
+ if (widget->cancellable)
{
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
+ g_cancellable_cancel (widget->cancellable);
+ g_object_unref (widget->cancellable);
}
- priv->cancellable = g_cancellable_new ();
- printer_add_option_async (priv->printer_name,
- priv->option_name,
+ widget->cancellable = g_cancellable_new ();
+ printer_add_option_async (widget->printer_name,
+ widget->option_name,
values,
TRUE,
- priv->cancellable,
+ widget->cancellable,
printer_add_option_async_cb,
widget);
@@ -416,82 +399,81 @@ spin_button_changed_cb (GtkWidget *spin_button,
static gboolean
construct_widget (PpIPPOptionWidget *widget)
{
- PpIPPOptionWidgetPrivate *priv = widget->priv;
gboolean trivial_option = FALSE;
gboolean result = FALSE;
gchar *value;
gint i;
- if (priv->option_supported)
+ if (widget->option_supported)
{
- switch (priv->option_supported->attribute_type)
+ switch (widget->option_supported->attribute_type)
{
case IPP_ATTRIBUTE_TYPE_INTEGER:
- if (priv->option_supported->num_of_values <= 1)
+ if (widget->option_supported->num_of_values <= 1)
trivial_option = TRUE;
break;
case IPP_ATTRIBUTE_TYPE_STRING:
- if (priv->option_supported->num_of_values <= 1)
+ if (widget->option_supported->num_of_values <= 1)
trivial_option = TRUE;
break;
case IPP_ATTRIBUTE_TYPE_RANGE:
- if (priv->option_supported->attribute_values[0].lower_range ==
- priv->option_supported->attribute_values[0].upper_range)
+ if (widget->option_supported->attribute_values[0].lower_range ==
+ widget->option_supported->attribute_values[0].upper_range)
trivial_option = TRUE;
break;
}
if (!trivial_option)
{
- switch (priv->option_supported->attribute_type)
+ switch (widget->option_supported->attribute_type)
{
case IPP_ATTRIBUTE_TYPE_BOOLEAN:
- priv->switch_button = gtk_switch_new ();
+ widget->switch_button = gtk_switch_new ();
- gtk_box_pack_start (GTK_BOX (widget), priv->switch_button, FALSE, FALSE, 0);
- g_signal_connect (priv->switch_button, "notify::active", G_CALLBACK (switch_changed_cb),
widget);
+ gtk_box_pack_start (GTK_BOX (widget), widget->switch_button, FALSE, FALSE, 0);
+ g_signal_connect (widget->switch_button, "notify::active", G_CALLBACK (switch_changed_cb),
widget);
break;
case IPP_ATTRIBUTE_TYPE_INTEGER:
- priv->combo = combo_box_new ();
+ widget->combo = combo_box_new ();
- for (i = 0; i < priv->option_supported->num_of_values; i++)
+ for (i = 0; i < widget->option_supported->num_of_values; i++)
{
- value = g_strdup_printf ("%d",
priv->option_supported->attribute_values[i].integer_value);
- combo_box_append (priv->combo,
- ipp_choice_translate (priv->option_name,
+ value = g_strdup_printf ("%d",
widget->option_supported->attribute_values[i].integer_value);
+ combo_box_append (widget->combo,
+ ipp_choice_translate (widget->option_name,
value),
value);
g_free (value);
}
- gtk_box_pack_start (GTK_BOX (widget), priv->combo, FALSE, FALSE, 0);
- g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
+ gtk_box_pack_start (GTK_BOX (widget), widget->combo, FALSE, FALSE, 0);
+ g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
break;
case IPP_ATTRIBUTE_TYPE_STRING:
- priv->combo = combo_box_new ();
+ widget->combo = combo_box_new ();
- for (i = 0; i < priv->option_supported->num_of_values; i++)
- combo_box_append (priv->combo,
- ipp_choice_translate (priv->option_name,
-
priv->option_supported->attribute_values[i].string_value),
- priv->option_supported->attribute_values[i].string_value);
+ for (i = 0; i < widget->option_supported->num_of_values; i++)
+ combo_box_append (widget->combo,
+ ipp_choice_translate (widget->option_name,
+
widget->option_supported->attribute_values[i].string_value),
+ widget->option_supported->attribute_values[i].string_value);
- gtk_box_pack_start (GTK_BOX (widget), priv->combo, FALSE, FALSE, 0);
- g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
+ gtk_box_pack_start (GTK_BOX (widget), widget->combo, FALSE, FALSE, 0);
+ g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
break;
case IPP_ATTRIBUTE_TYPE_RANGE:
- priv->spin_button = gtk_spin_button_new_with_range (
- priv->option_supported->attribute_values[0].lower_range,
- priv->option_supported->attribute_values[0].upper_range,
+ widget->spin_button = gtk_spin_button_new_with_range (
+ widget->option_supported->attribute_values[0].lower_range,
+ widget->option_supported->attribute_values[0].upper_range,
1);
- gtk_box_pack_start (GTK_BOX (widget), priv->spin_button, FALSE, FALSE, 0);
- g_signal_connect (priv->spin_button, "value-changed", G_CALLBACK (spin_button_changed_cb),
widget);
+ gtk_box_pack_start (GTK_BOX (widget), widget->spin_button, FALSE, FALSE, 0);
+ g_signal_connect (widget->spin_button, "value-changed", G_CALLBACK
(spin_button_changed_cb), widget);
break;
default:
@@ -508,95 +490,94 @@ construct_widget (PpIPPOptionWidget *widget)
static void
update_widget_real (PpIPPOptionWidget *widget)
{
- PpIPPOptionWidgetPrivate *priv = widget->priv;
IPPAttribute *attr = NULL;
gchar *value;
gchar *attr_name;
- if (priv->option_default)
+ if (widget->option_default)
{
- attr = ipp_attribute_copy (priv->option_default);
+ attr = ipp_attribute_copy (widget->option_default);
- ipp_attribute_free (priv->option_default);
- priv->option_default = NULL;
+ ipp_attribute_free (widget->option_default);
+ widget->option_default = NULL;
}
- else if (priv->ipp_attribute)
+ else if (widget->ipp_attribute)
{
- attr_name = g_strdup_printf ("%s-default", priv->option_name);
- attr = ipp_attribute_copy (g_hash_table_lookup (priv->ipp_attribute, attr_name));
+ attr_name = g_strdup_printf ("%s-default", widget->option_name);
+ attr = ipp_attribute_copy (g_hash_table_lookup (widget->ipp_attribute, attr_name));
g_free (attr_name);
- g_hash_table_unref (priv->ipp_attribute);
- priv->ipp_attribute = NULL;
+ g_hash_table_unref (widget->ipp_attribute);
+ widget->ipp_attribute = NULL;
}
- switch (priv->option_supported->attribute_type)
+ switch (widget->option_supported->attribute_type)
{
case IPP_ATTRIBUTE_TYPE_BOOLEAN:
- g_signal_handlers_block_by_func (priv->switch_button, switch_changed_cb, widget);
+ g_signal_handlers_block_by_func (widget->switch_button, switch_changed_cb, widget);
if (attr && attr->num_of_values > 0 &&
attr->attribute_type == IPP_ATTRIBUTE_TYPE_BOOLEAN)
{
- gtk_switch_set_active (GTK_SWITCH (priv->switch_button),
+ gtk_switch_set_active (GTK_SWITCH (widget->switch_button),
attr->attribute_values[0].boolean_value);
}
- g_signal_handlers_unblock_by_func (priv->switch_button, switch_changed_cb, widget);
+ g_signal_handlers_unblock_by_func (widget->switch_button, switch_changed_cb, widget);
break;
case IPP_ATTRIBUTE_TYPE_INTEGER:
- g_signal_handlers_block_by_func (priv->combo, combo_changed_cb, widget);
+ g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
if (attr && attr->num_of_values > 0 &&
attr->attribute_type == IPP_ATTRIBUTE_TYPE_INTEGER)
{
value = g_strdup_printf ("%d", attr->attribute_values[0].integer_value);
- combo_box_set (priv->combo, value);
+ combo_box_set (widget->combo, value);
g_free (value);
}
else
{
- value = g_strdup_printf ("%d", priv->option_supported->attribute_values[0].integer_value);
- combo_box_set (priv->combo, value);
+ value = g_strdup_printf ("%d", widget->option_supported->attribute_values[0].integer_value);
+ combo_box_set (widget->combo, value);
g_free (value);
}
- g_signal_handlers_unblock_by_func (priv->combo, combo_changed_cb, widget);
+ g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
break;
case IPP_ATTRIBUTE_TYPE_STRING:
- g_signal_handlers_block_by_func (priv->combo, combo_changed_cb, widget);
+ g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
if (attr && attr->num_of_values > 0 &&
attr->attribute_type == IPP_ATTRIBUTE_TYPE_STRING)
{
- combo_box_set (priv->combo, attr->attribute_values[0].string_value);
+ combo_box_set (widget->combo, attr->attribute_values[0].string_value);
}
else
{
- combo_box_set (priv->combo, priv->option_supported->attribute_values[0].string_value);
+ combo_box_set (widget->combo, widget->option_supported->attribute_values[0].string_value);
}
- g_signal_handlers_unblock_by_func (priv->combo, combo_changed_cb, widget);
+ g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
break;
case IPP_ATTRIBUTE_TYPE_RANGE:
- g_signal_handlers_block_by_func (priv->spin_button, spin_button_changed_cb, widget);
+ g_signal_handlers_block_by_func (widget->spin_button, spin_button_changed_cb, widget);
if (attr && attr->num_of_values > 0 &&
attr->attribute_type == IPP_ATTRIBUTE_TYPE_INTEGER)
{
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spin_button),
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget->spin_button),
attr->attribute_values[0].integer_value);
}
else
{
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spin_button),
- priv->option_supported->attribute_values[0].lower_range);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget->spin_button),
+ widget->option_supported->attribute_values[0].lower_range);
}
- g_signal_handlers_unblock_by_func (priv->spin_button, spin_button_changed_cb, widget);
+ g_signal_handlers_unblock_by_func (widget->spin_button, spin_button_changed_cb, widget);
break;
default:
@@ -611,12 +592,11 @@ get_ipp_attributes_cb (GHashTable *table,
gpointer user_data)
{
PpIPPOptionWidget *widget = (PpIPPOptionWidget *) user_data;
- PpIPPOptionWidgetPrivate *priv = widget->priv;
- if (priv->ipp_attribute)
- g_hash_table_unref (priv->ipp_attribute);
+ if (widget->ipp_attribute)
+ g_hash_table_unref (widget->ipp_attribute);
- priv->ipp_attribute = table;
+ widget->ipp_attribute = table;
update_widget_real (widget);
}
@@ -624,13 +604,12 @@ get_ipp_attributes_cb (GHashTable *table,
static void
update_widget (PpIPPOptionWidget *widget)
{
- PpIPPOptionWidgetPrivate *priv = widget->priv;
gchar **attributes_names;
attributes_names = g_new0 (gchar *, 2);
- attributes_names[0] = g_strdup_printf ("%s-default", priv->option_name);
+ attributes_names[0] = g_strdup_printf ("%s-default", widget->option_name);
- get_ipp_attributes_async (priv->printer_name,
+ get_ipp_attributes_async (widget->printer_name,
attributes_names,
get_ipp_attributes_cb,
widget);
diff --git a/panels/printers/pp-ipp-option-widget.h b/panels/printers/pp-ipp-option-widget.h
index f5dc2cac6..aa2ffbcb8 100644
--- a/panels/printers/pp-ipp-option-widget.h
+++ b/panels/printers/pp-ipp-option-widget.h
@@ -29,35 +29,8 @@
G_BEGIN_DECLS
-#define PP_TYPE_IPP_OPTION_WIDGET (pp_ipp_option_widget_get_type ())
-#define PP_IPP_OPTION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
PP_TYPE_IPP_OPTION_WIDGET, PpIPPOptionWidget))
-#define PP_IPP_OPTION_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
PP_TYPE_IPP_OPTION_WIDGET, PpIPPOptionWidgetClass))
-#define PP_IS_IPP_OPTION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
PP_TYPE_IPP_OPTION_WIDGET))
-#define PP_IS_IPP_OPTION_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
PP_TYPE_IPP_OPTION_WIDGET))
-#define PP_IPP_OPTION_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
PP_TYPE_IPP_OPTION_WIDGET, PpIPPOptionWidgetClass))
-
-typedef struct _PpIPPOptionWidget PpIPPOptionWidget;
-typedef struct _PpIPPOptionWidgetClass PpIPPOptionWidgetClass;
-typedef struct PpIPPOptionWidgetPrivate PpIPPOptionWidgetPrivate;
-
-struct _PpIPPOptionWidget
-{
- GtkHBox parent_instance;
-
- PpIPPOptionWidgetPrivate *priv;
-};
-
-struct _PpIPPOptionWidgetClass
-{
- GtkHBoxClass parent_class;
-
- void (*changed) (PpIPPOptionWidget *widget);
-};
-
-typedef void (*IPPOptionCallback) (GtkWidget *widget,
- gpointer user_data);
-
-GType pp_ipp_option_widget_get_type (void) G_GNUC_CONST;
+#define PP_TYPE_IPP_OPTION_WIDGET (pp_ipp_option_widget_get_type ())
+G_DECLARE_FINAL_TYPE (PpIPPOptionWidget, pp_ipp_option_widget, PP, IPP_OPTION_WIDGET, GtkBox)
GtkWidget *pp_ipp_option_widget_new (IPPAttribute *attr_supported,
IPPAttribute *attr_default,
diff --git a/panels/printers/pp-job.c b/panels/printers/pp-job.c
index 4bfa8154d..b80320d54 100644
--- a/panels/printers/pp-job.c
+++ b/panels/printers/pp-job.c
@@ -43,17 +43,17 @@ ippGetRange (ipp_attribute_t *attr,
}
#endif
-typedef struct
+struct _PpJob
{
- GObject parent;
+ GObject parent_instance;
gint id;
gchar *title;
gint state;
gchar **auth_info_required;
-} PpJobPrivate;
+};
-G_DEFINE_TYPE_WITH_PRIVATE (PpJob, pp_job, G_TYPE_OBJECT)
+G_DEFINE_TYPE (PpJob, pp_job, G_TYPE_OBJECT)
enum
{
@@ -180,23 +180,21 @@ pp_job_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- PpJobPrivate *priv;
-
- priv = pp_job_get_instance_private (PP_JOB (object));
+ PpJob *self = PP_JOB (object);
switch (property_id)
{
case PROP_ID:
- g_value_set_int (value, priv->id);
+ g_value_set_int (value, self->id);
break;
case PROP_TITLE:
- g_value_set_string (value, priv->title);
+ g_value_set_string (value, self->title);
break;
case PROP_STATE:
- g_value_set_int (value, priv->state);
+ g_value_set_int (value, self->state);
break;
case PROP_AUTH_INFO_REQUIRED:
- g_value_set_pointer (value, g_strdupv (priv->auth_info_required));
+ g_value_set_pointer (value, g_strdupv (self->auth_info_required));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -210,24 +208,22 @@ pp_job_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- PpJobPrivate *priv;
-
- priv = pp_job_get_instance_private (PP_JOB (object));
+ PpJob *self = PP_JOB (object);
switch (property_id)
{
case PROP_ID:
- priv->id = g_value_get_int (value);
+ self->id = g_value_get_int (value);
break;
case PROP_TITLE:
- g_free (priv->title);
- priv->title = g_value_dup_string (value);
+ g_free (self->title);
+ self->title = g_value_dup_string (value);
break;
case PROP_STATE:
- priv->state = g_value_get_int (value);
+ self->state = g_value_get_int (value);
break;
case PROP_AUTH_INFO_REQUIRED:
- priv->auth_info_required = g_strdupv (g_value_get_pointer (value));
+ self->auth_info_required = g_strdupv (g_value_get_pointer (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -238,12 +234,10 @@ pp_job_set_property (GObject *object,
static void
pp_job_finalize (GObject *object)
{
- PpJobPrivate *priv;
+ PpJob *self = PP_JOB (object);
- priv = pp_job_get_instance_private (PP_JOB (object));
-
- g_free (priv->title);
- g_strfreev (priv->auth_info_required);
+ g_free (self->title);
+ g_strfreev (self->auth_info_required);
G_OBJECT_CLASS (pp_job_parent_class)->finalize (object);
}
@@ -290,19 +284,17 @@ _pp_job_get_attributes_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
+ PpJob *self = PP_JOB (source_object);
ipp_attribute_t *attr = NULL;
GVariantBuilder builder;
GVariant *attributes = NULL;
gchar **attributes_names = task_data;
- PpJobPrivate *priv;
ipp_t *request;
ipp_t *response = NULL;
gchar *job_uri;
gint i, j, length = 0, n_attrs = 0;
- priv = pp_job_get_instance_private (source_object);
-
- job_uri = g_strdup_printf ("ipp://localhost/jobs/%d", priv->id);
+ job_uri = g_strdup_printf ("ipp://localhost/jobs/%d", self->id);
if (attributes_names != NULL)
{
@@ -431,7 +423,7 @@ _pp_job_authenticate_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- PpJobPrivate *priv;
+ PpJob *job = PP_JOB (source_object);
gboolean result = FALSE;
gchar **auth_info = task_data;
ipp_t *request;
@@ -439,11 +431,9 @@ _pp_job_authenticate_thread (GTask *task,
gchar *job_uri;
gint length;
- priv = pp_job_get_instance_private (source_object);
-
if (auth_info != NULL)
{
- job_uri = g_strdup_printf ("ipp://localhost/jobs/%d", priv->id);
+ job_uri = g_strdup_printf ("ipp://localhost/jobs/%d", job->id);
length = g_strv_length (auth_info);
diff --git a/panels/printers/pp-job.h b/panels/printers/pp-job.h
index d0af2b5be..29fffddbd 100644
--- a/panels/printers/pp-job.h
+++ b/panels/printers/pp-job.h
@@ -31,11 +31,6 @@ G_BEGIN_DECLS
#define PP_TYPE_JOB (pp_job_get_type ())
G_DECLARE_FINAL_TYPE (PpJob, pp_job, PP, JOB, GObject)
-struct _PpJob
-{
- GObject parent_instance;
-};
-
void pp_job_set_hold_until_async (PpJob *job,
const gchar *job_hold_until);
diff --git a/panels/printers/pp-maintenance-command.c b/panels/printers/pp-maintenance-command.c
index e7073146b..60dea4d80 100644
--- a/panels/printers/pp-maintenance-command.c
+++ b/panels/printers/pp-maintenance-command.c
@@ -35,8 +35,10 @@
#define ippGetString(attr, element, language) attr->values[element].string.text
#endif
-struct _PpMaintenanceCommandPrivate
+struct _PpMaintenanceCommand
{
+ GObject parent_instance;
+
gchar *printer_name;
gchar *command;
gchar *parameters;
@@ -56,14 +58,12 @@ enum {
static void
pp_maintenance_command_finalize (GObject *object)
{
- PpMaintenanceCommandPrivate *priv;
-
- priv = PP_MAINTENANCE_COMMAND (object)->priv;
+ PpMaintenanceCommand *self = PP_MAINTENANCE_COMMAND (object);
- g_clear_pointer (&priv->printer_name, g_free);
- g_clear_pointer (&priv->command, g_free);
- g_clear_pointer (&priv->parameters, g_free);
- g_clear_pointer (&priv->title, g_free);
+ g_clear_pointer (&self->printer_name, g_free);
+ g_clear_pointer (&self->command, g_free);
+ g_clear_pointer (&self->parameters, g_free);
+ g_clear_pointer (&self->title, g_free);
G_OBJECT_CLASS (pp_maintenance_command_parent_class)->finalize (object);
}
@@ -74,23 +74,21 @@ pp_maintenance_command_get_property (GObject *object,
GValue *value,
GParamSpec *param_spec)
{
- PpMaintenanceCommand *self;
-
- self = PP_MAINTENANCE_COMMAND (object);
+ PpMaintenanceCommand *self = PP_MAINTENANCE_COMMAND (object);
switch (prop_id)
{
case PROP_PRINTER_NAME:
- g_value_set_string (value, self->priv->printer_name);
+ g_value_set_string (value, self->printer_name);
break;
case PROP_COMMAND:
- g_value_set_string (value, self->priv->command);
+ g_value_set_string (value, self->command);
break;
case PROP_PARAMETERS:
- g_value_set_string (value, self->priv->parameters);
+ g_value_set_string (value, self->parameters);
break;
case PROP_TITLE:
- g_value_set_string (value, self->priv->title);
+ g_value_set_string (value, self->title);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -111,20 +109,20 @@ pp_maintenance_command_set_property (GObject *object,
switch (prop_id)
{
case PROP_PRINTER_NAME:
- g_free (self->priv->printer_name);
- self->priv->printer_name = g_value_dup_string (value);
+ g_free (self->printer_name);
+ self->printer_name = g_value_dup_string (value);
break;
case PROP_COMMAND:
- g_free (self->priv->command);
- self->priv->command = g_value_dup_string (value);
+ g_free (self->command);
+ self->command = g_value_dup_string (value);
break;
case PROP_PARAMETERS:
- g_free (self->priv->parameters);
- self->priv->parameters = g_value_dup_string (value);
+ g_free (self->parameters);
+ self->parameters = g_value_dup_string (value);
break;
case PROP_TITLE:
- g_free (self->priv->title);
- self->priv->title = g_value_dup_string (value);
+ g_free (self->title);
+ self->title = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -139,8 +137,6 @@ pp_maintenance_command_class_init (PpMaintenanceCommandClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (PpMaintenanceCommandPrivate));
-
gobject_class->set_property = pp_maintenance_command_set_property;
gobject_class->get_property = pp_maintenance_command_get_property;
gobject_class->finalize = pp_maintenance_command_finalize;
@@ -177,9 +173,6 @@ pp_maintenance_command_class_init (PpMaintenanceCommandClass *klass)
static void
pp_maintenance_command_init (PpMaintenanceCommand *command)
{
- command->priv = G_TYPE_INSTANCE_GET_PRIVATE (command,
- PP_TYPE_MAINTENANCE_COMMAND,
- PpMaintenanceCommandPrivate);
}
PpMaintenanceCommand *
@@ -206,11 +199,10 @@ _pp_maintenance_command_execute_thread (GTask *task,
GCancellable *cancellable)
{
PpMaintenanceCommand *command = PP_MAINTENANCE_COMMAND (source_object);
- PpMaintenanceCommandPrivate *priv = command->priv;
gboolean success = FALSE;
GError *error = NULL;
- if (_pp_maintenance_command_is_supported (priv->printer_name, priv->command))
+ if (_pp_maintenance_command_is_supported (command->printer_name, command->command))
{
ipp_t *request;
ipp_t *response = NULL;
@@ -219,14 +211,14 @@ _pp_maintenance_command_execute_thread (GTask *task,
int fd = -1;
printer_uri = g_strdup_printf ("ipp://localhost/printers/%s",
- priv->printer_name);
+ command->printer_name);
request = ippNewRequest (IPP_PRINT_JOB);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, printer_uri);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "job-name", NULL, priv->title);
+ "job-name", NULL, command->title);
ippAddString (request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
"document-format", NULL, "application/vnd.cups-command");
@@ -238,9 +230,9 @@ _pp_maintenance_command_execute_thread (GTask *task,
file = fdopen (fd, "w");
fprintf (file, "#CUPS-COMMAND\n");
- fprintf (file, "%s", priv->command);
- if (priv->parameters)
- fprintf (file, " %s", priv->parameters);
+ fprintf (file, "%s", command->command);
+ if (command->parameters)
+ fprintf (file, " %s", command->parameters);
fprintf (file, "\n");
fclose (file);
@@ -377,10 +369,9 @@ _pp_maintenance_command_is_supported_thread (GTask *task,
GCancellable *cancellable)
{
PpMaintenanceCommand *command = PP_MAINTENANCE_COMMAND (source_object);
- PpMaintenanceCommandPrivate *priv = command->priv;
gboolean success = FALSE;
- success = _pp_maintenance_command_is_supported (priv->printer_name, priv->command);
+ success = _pp_maintenance_command_is_supported (command->printer_name, command->command);
g_task_return_boolean (task, success);
}
diff --git a/panels/printers/pp-maintenance-command.h b/panels/printers/pp-maintenance-command.h
index 5069a0120..5ba0a08d2 100644
--- a/panels/printers/pp-maintenance-command.h
+++ b/panels/printers/pp-maintenance-command.h
@@ -26,29 +26,8 @@
G_BEGIN_DECLS
-#define PP_TYPE_MAINTENANCE_COMMAND (pp_maintenance_command_get_type ())
-#define PP_MAINTENANCE_COMMAND(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PP_TYPE_MAINTENANCE_COMMAND,
PpMaintenanceCommand))
-#define PP_MAINTENANCE_COMMAND_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PP_TYPE_MAINTENANCE_COMMAND,
PpMaintenanceCommandClass))
-#define PP_IS_MAINTENANCE_COMMAND(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PP_TYPE_MAINTENANCE_COMMAND))
-#define PP_IS_MAINTENANCE_COMMAND_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PP_TYPE_MAINTENANCE_COMMAND))
-#define PP_MAINTENANCE_COMMAND_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PP_TYPE_MAINTENANCE_COMMAND,
PpMaintenanceCommandClass))
-
-typedef struct _PpMaintenanceCommand PpMaintenanceCommand;
-typedef struct _PpMaintenanceCommandClass PpMaintenanceCommandClass;
-typedef struct _PpMaintenanceCommandPrivate PpMaintenanceCommandPrivate;
-
-struct _PpMaintenanceCommand
-{
- GObject parent_instance;
- PpMaintenanceCommandPrivate *priv;
-};
-
-struct _PpMaintenanceCommandClass
-{
- GObjectClass parent_class;
-};
-
-GType pp_maintenance_command_get_type (void) G_GNUC_CONST;
+#define PP_TYPE_MAINTENANCE_COMMAND (pp_maintenance_command_get_type ())
+G_DECLARE_FINAL_TYPE (PpMaintenanceCommand, pp_maintenance_command, PP, MAINTENANCE_COMMAND, GObject)
PpMaintenanceCommand *pp_maintenance_command_new (const gchar *printer_name,
const gchar *command,
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 3bf4a7368..d76f62f7d 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -53,7 +53,7 @@
*/
#define HOST_SEARCH_DELAY (500 - 150)
-#define WID(s) GTK_WIDGET (gtk_builder_get_object (priv->builder, s))
+#define WID(s) GTK_WIDGET (gtk_builder_get_object (dialog->builder, s))
#define AUTHENTICATION_PAGE "authentication-page"
#define ADDPRINTER_PAGE "addprinter-page"
@@ -90,8 +90,10 @@ enum
DEVICE_N_COLUMNS
};
-struct _PpNewPrinterDialogPrivate
+struct _PpNewPrinterDialog
{
+ GObject parent_instance;
+
GtkBuilder *builder;
GList *local_cups_devices;
@@ -134,7 +136,7 @@ struct _PpNewPrinterDialogPrivate
guint host_search_timeout_id;
};
-#define PP_NEW_PRINTER_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
PP_TYPE_NEW_PRINTER_DIALOG, PpNewPrinterDialogPrivate))
+G_DEFINE_TYPE (PpNewPrinterDialog, pp_new_printer_dialog, G_TYPE_OBJECT)
static void pp_new_printer_dialog_finalize (GObject *object);
@@ -146,8 +148,6 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (PpNewPrinterDialog, pp_new_printer_dialog, G_TYPE_OBJECT)
-
static void
pp_new_printer_dialog_class_init (PpNewPrinterDialogClass *klass)
{
@@ -156,8 +156,6 @@ pp_new_printer_dialog_class_init (PpNewPrinterDialogClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = pp_new_printer_dialog_finalize;
- g_type_class_add_private (object_class, sizeof (PpNewPrinterDialogPrivate));
-
/**
* PpNewPrinterDialog::pre-response:
* @device: the device that is being added
@@ -168,7 +166,7 @@ pp_new_printer_dialog_class_init (PpNewPrinterDialogClass *klass)
g_signal_new ("pre-response",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PpNewPrinterDialogClass, pre_response),
+ 0,
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
@@ -183,7 +181,7 @@ pp_new_printer_dialog_class_init (PpNewPrinterDialogClass *klass)
g_signal_new ("response",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PpNewPrinterDialogClass, response),
+ 0,
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 1, G_TYPE_INT);
@@ -194,18 +192,16 @@ PpNewPrinterDialog *
pp_new_printer_dialog_new (GtkWindow *parent,
PPDList *ppd_list)
{
- PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog;
dialog = g_object_new (PP_TYPE_NEW_PRINTER_DIALOG, NULL);
- priv = dialog->priv;
- priv->list = ppd_list_copy (ppd_list);
- priv->parent = parent;
+ dialog->list = ppd_list_copy (ppd_list);
+ dialog->parent = parent;
- gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), GTK_WINDOW (parent));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (parent));
- gtk_widget_show_all (priv->dialog);
+ gtk_widget_show_all (dialog->dialog);
return PP_NEW_PRINTER_DIALOG (dialog);
}
@@ -214,12 +210,10 @@ void
pp_new_printer_dialog_set_ppd_list (PpNewPrinterDialog *dialog,
PPDList *list)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
-
- priv->list = ppd_list_copy (list);
+ dialog->list = ppd_list_copy (list);
- if (priv->ppd_selection_dialog)
- pp_ppd_selection_dialog_set_ppd_list (priv->ppd_selection_dialog, priv->list);
+ if (dialog->ppd_selection_dialog)
+ pp_ppd_selection_dialog_set_ppd_list (dialog->ppd_selection_dialog, dialog->list);
}
static void
@@ -256,7 +250,6 @@ get_authenticated_samba_devices_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog;
PpDevicesList *result;
PpPrintDevice *device;
@@ -277,9 +270,8 @@ get_authenticated_samba_devices_cb (GObject *source_object,
if (result != NULL)
{
dialog = PP_NEW_PRINTER_DIALOG (data->dialog);
- priv = dialog->priv;
- priv->samba_authenticated_searching = FALSE;
+ dialog->samba_authenticated_searching = FALSE;
for (iter = result->devices; iter; iter = iter->next)
{
@@ -317,11 +309,10 @@ get_authenticated_samba_devices_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
dialog = PP_NEW_PRINTER_DIALOG (data->dialog);
- priv = dialog->priv;
g_warning ("%s", error->message);
- priv->samba_authenticated_searching = FALSE;
+ dialog->samba_authenticated_searching = FALSE;
update_dialog_state (dialog);
}
}
@@ -334,7 +325,6 @@ static void
go_to_page (PpNewPrinterDialog *dialog,
const gchar *page)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkStack *stack;
stack = GTK_STACK (WID ("dialog-stack"));
@@ -351,8 +341,6 @@ static gchar *
get_entry_text (const gchar *object_name,
PpNewPrinterDialog *dialog)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
-
return g_strdup (gtk_entry_get_text (GTK_ENTRY (WID (object_name))));
}
@@ -361,7 +349,6 @@ on_authenticate (GtkWidget *button,
gpointer user_data)
{
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
- PpNewPrinterDialogPrivate *priv = dialog->priv;
gchar *hostname = NULL;
gchar *username = NULL;
gchar *password = NULL;
@@ -377,12 +364,12 @@ on_authenticate (GtkWidget *button,
return;
}
- pp_samba_set_auth_info (PP_SAMBA (priv->samba_host), username, password);
+ pp_samba_set_auth_info (PP_SAMBA (dialog->samba_host), username, password);
gtk_header_bar_set_title (GTK_HEADER_BAR (WID ("headerbar")), _("Add Printer"));
go_to_page (dialog, ADDPRINTER_PAGE);
- g_object_get (PP_HOST (priv->samba_host), "hostname", &hostname, NULL);
+ g_object_get (PP_HOST (dialog->samba_host), "hostname", &hostname, NULL);
remove_device_from_list (dialog, hostname);
}
@@ -390,12 +377,9 @@ static void
on_authentication_required (PpHost *host,
gpointer user_data)
{
- PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
gchar *text, *hostname;
- priv = dialog->priv;
-
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (WID ("headerbar")), NULL);
gtk_header_bar_set_title (GTK_HEADER_BAR (WID ("headerbar")), _("Unlock Print Server"));
@@ -420,14 +404,11 @@ static void
auth_entries_changed (GtkEditable *editable,
gpointer user_data)
{
- PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
gboolean can_authenticate = FALSE;
gchar *username = NULL;
gchar *password = NULL;
- priv = dialog->priv;
-
username = get_entry_text ("username-entry", dialog);
password = get_entry_text ("password-entry", dialog);
@@ -445,16 +426,15 @@ on_go_back_button_clicked (GtkButton *button,
gpointer user_data)
{
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
- PpNewPrinterDialogPrivate *priv = dialog->priv;
- pp_samba_set_auth_info (priv->samba_host, NULL, NULL);
- g_clear_object (&priv->samba_host);
+ pp_samba_set_auth_info (dialog->samba_host, NULL, NULL);
+ g_clear_object (&dialog->samba_host);
go_to_page (dialog, ADDPRINTER_PAGE);
gtk_header_bar_set_title (GTK_HEADER_BAR (WID ("headerbar")), _("Add Printer"));
gtk_widget_set_sensitive (WID ("new-printer-add-button"), FALSE);
- gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (priv->treeview));
+ gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (dialog->treeview));
}
static void
@@ -462,7 +442,6 @@ authenticate_samba_server (GtkButton *button,
gpointer user_data)
{
PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
- PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkTreeModel *model;
GtkTreeIter iter;
AuthSMBData *data;
@@ -472,7 +451,7 @@ authenticate_samba_server (GtkButton *button,
gtk_widget_set_sensitive (WID ("authenticate-button"), FALSE);
gtk_widget_grab_focus (WID ("username-entry"));
- if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (priv->treeview), &model, &iter))
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (dialog->treeview), &model, &iter))
{
gtk_tree_model_get (model, &iter,
DEVICE_NAME_COLUMN, &server_name,
@@ -480,24 +459,24 @@ authenticate_samba_server (GtkButton *button,
if (server_name != NULL)
{
- g_clear_object (&priv->samba_host);
+ g_clear_object (&dialog->samba_host);
- priv->samba_host = pp_samba_new (server_name);
- g_signal_connect_object (priv->samba_host,
+ dialog->samba_host = pp_samba_new (server_name);
+ g_signal_connect_object (dialog->samba_host,
"authentication-required",
G_CALLBACK (on_authentication_required),
dialog, 0);
- priv->samba_authenticated_searching = TRUE;
+ dialog->samba_authenticated_searching = TRUE;
update_dialog_state (dialog);
data = g_new (AuthSMBData, 1);
data->server_name = server_name;
data->dialog = dialog;
- pp_samba_get_devices_async (priv->samba_host,
+ pp_samba_get_devices_async (dialog->samba_host,
TRUE,
- priv->cancellable,
+ dialog->cancellable,
get_authenticated_samba_devices_cb,
data);
}
@@ -510,7 +489,6 @@ stack_key_press_cb (GtkWidget *widget,
gpointer user_data)
{
PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
- PpNewPrinterDialogPrivate *priv = dialog->priv;
gtk_widget_grab_focus (WID ("search-entry"));
gtk_main_do_event (event);
@@ -521,7 +499,6 @@ stack_key_press_cb (GtkWidget *widget,
static void
pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
{
- PpNewPrinterDialogPrivate *priv;
GtkStyleContext *context;
GtkWidget *widget;
g_autoptr(GError) error = NULL;
@@ -531,12 +508,9 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
NULL };
guint builder_result;
- priv = PP_NEW_PRINTER_DIALOG_GET_PRIVATE (dialog);
- dialog->priv = priv;
+ dialog->builder = gtk_builder_new ();
- priv->builder = gtk_builder_new ();
-
- builder_result = gtk_builder_add_objects_from_resource (priv->builder,
+ builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
"/org/gnome/control-center/printers/new-printer-dialog.ui",
objects, &error);
@@ -546,19 +520,19 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
}
/* GCancellable for cancelling of async operations */
- priv->cancellable = g_cancellable_new ();
+ dialog->cancellable = g_cancellable_new ();
/* Construct dialog */
- priv->dialog = WID ("dialog");
+ dialog->dialog = WID ("dialog");
- priv->treeview = GTK_TREE_VIEW (WID ("devices-treeview"));
+ dialog->treeview = GTK_TREE_VIEW (WID ("devices-treeview"));
- priv->store = GTK_LIST_STORE (gtk_builder_get_object (priv->builder, "devices-liststore"));
+ dialog->store = GTK_LIST_STORE (gtk_builder_get_object (dialog->builder, "devices-liststore"));
- priv->filter = GTK_TREE_MODEL_FILTER (gtk_builder_get_object (priv->builder, "devices-model-filter"));
+ dialog->filter = GTK_TREE_MODEL_FILTER (gtk_builder_get_object (dialog->builder, "devices-model-filter"));
/* Connect signals */
- g_signal_connect (priv->dialog, "response", G_CALLBACK (new_printer_dialog_response_cb), dialog);
+ g_signal_connect (dialog->dialog, "response", G_CALLBACK (new_printer_dialog_response_cb), dialog);
widget = WID ("search-entry");
g_signal_connect (widget, "activate", G_CALLBACK (search_entry_activated_cb), dialog);
@@ -591,49 +565,48 @@ static void
pp_new_printer_dialog_finalize (GObject *object)
{
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (object);
- PpNewPrinterDialogPrivate *priv = dialog->priv;
- priv->text_renderer = NULL;
- priv->icon_renderer = NULL;
+ dialog->text_renderer = NULL;
+ dialog->icon_renderer = NULL;
- if (priv->host_search_timeout_id != 0)
+ if (dialog->host_search_timeout_id != 0)
{
- g_source_remove (priv->host_search_timeout_id);
- priv->host_search_timeout_id = 0;
+ g_source_remove (dialog->host_search_timeout_id);
+ dialog->host_search_timeout_id = 0;
}
- if (priv->remote_host_cancellable)
+ if (dialog->remote_host_cancellable)
{
- g_cancellable_cancel (priv->remote_host_cancellable);
- g_clear_object (&priv->remote_host_cancellable);
+ g_cancellable_cancel (dialog->remote_host_cancellable);
+ g_clear_object (&dialog->remote_host_cancellable);
}
- if (priv->cancellable)
+ if (dialog->cancellable)
{
- g_cancellable_cancel (priv->cancellable);
- g_clear_object (&priv->cancellable);
+ g_cancellable_cancel (dialog->cancellable);
+ g_clear_object (&dialog->cancellable);
}
- g_clear_pointer (&priv->dialog, gtk_widget_destroy);
+ g_clear_pointer (&dialog->dialog, gtk_widget_destroy);
- g_clear_pointer (&priv->list, ppd_list_free);
+ g_clear_pointer (&dialog->list, ppd_list_free);
- if (priv->builder)
- g_clear_object (&priv->builder);
+ if (dialog->builder)
+ g_clear_object (&dialog->builder);
- g_list_free_full (priv->local_cups_devices, (GDestroyNotify) g_object_unref);
- priv->local_cups_devices = NULL;
+ g_list_free_full (dialog->local_cups_devices, (GDestroyNotify) g_object_unref);
+ dialog->local_cups_devices = NULL;
- if (priv->num_of_dests > 0)
+ if (dialog->num_of_dests > 0)
{
- cupsFreeDests (priv->num_of_dests, priv->dests);
- priv->num_of_dests = 0;
- priv->dests = NULL;
+ cupsFreeDests (dialog->num_of_dests, dialog->dests);
+ dialog->num_of_dests = 0;
+ dialog->dests = NULL;
}
- g_clear_object (&priv->local_printer_icon);
- g_clear_object (&priv->remote_printer_icon);
- g_clear_object (&priv->authenticated_server_icon);
+ g_clear_object (&dialog->local_printer_icon);
+ g_clear_object (&dialog->remote_printer_icon);
+ g_clear_object (&dialog->authenticated_server_icon);
G_OBJECT_CLASS (pp_new_printer_dialog_parent_class)->finalize (object);
}
@@ -643,7 +616,6 @@ device_selection_changed_cb (GtkTreeSelection *selection,
gpointer user_data)
{
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
- PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *widget;
@@ -651,7 +623,7 @@ device_selection_changed_cb (GtkTreeSelection *selection,
gboolean authentication_needed;
gboolean selected;
- selected = gtk_tree_selection_get_selected (gtk_tree_view_get_selection (priv->treeview),
+ selected = gtk_tree_selection_get_selected (gtk_tree_view_get_selection (dialog->treeview),
&model,
&iter);
@@ -680,28 +652,27 @@ static void
remove_device_from_list (PpNewPrinterDialog *dialog,
const gchar *device_name)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
PpPrintDevice *device;
GtkTreeIter iter;
gboolean cont;
- cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter);
while (cont)
{
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
DEVICE_COLUMN, &device,
-1);
if (g_strcmp0 (pp_print_device_get_device_name (device), device_name) == 0)
{
- gtk_list_store_remove (priv->store, &iter);
+ gtk_list_store_remove (dialog->store, &iter);
g_object_unref (device);
break;
}
g_object_unref (device);
- cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter);
}
update_dialog_state (dialog);
@@ -731,7 +702,6 @@ static void
add_device_to_list (PpNewPrinterDialog *dialog,
PpPrintDevice *device)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
PpPrintDevice *store_device;
GList *original_names_list = NULL;
gchar *canonicalized_name = NULL;
@@ -762,16 +732,16 @@ add_device_to_list (PpNewPrinterDialog *dialog,
"device-original-name", pp_print_device_get_device_name (device),
NULL);
- gtk_tree_model_foreach (GTK_TREE_MODEL (priv->store),
+ gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->store),
prepend_original_name,
&original_names_list);
original_names_list = g_list_reverse (original_names_list);
canonicalized_name = canonicalize_device_name (original_names_list,
- priv->local_cups_devices,
- priv->dests,
- priv->num_of_dests,
+ dialog->local_cups_devices,
+ dialog->dests,
+ dialog->num_of_dests,
device);
g_list_free_full (original_names_list, g_free);
@@ -784,7 +754,7 @@ add_device_to_list (PpNewPrinterDialog *dialog,
g_free (canonicalized_name);
if (pp_print_device_get_acquisition_method (device) == ACQUISITION_METHOD_DEFAULT_CUPS_SERVER)
- priv->local_cups_devices = g_list_append (priv->local_cups_devices, g_object_ref (device));
+ dialog->local_cups_devices = g_list_append (dialog->local_cups_devices, g_object_ref (device));
else
set_device (dialog, device, NULL);
}
@@ -868,20 +838,19 @@ device_in_liststore (gchar *device_uri,
static void
update_dialog_state (PpNewPrinterDialog *dialog)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkTreeIter iter;
GtkWidget *header;
GtkWidget *stack;
gboolean searching;
- searching = priv->cups_searching ||
- priv->remote_cups_host != NULL ||
- priv->snmp_host != NULL ||
- priv->socket_host != NULL ||
- priv->lpd_host != NULL ||
- priv->samba_host != NULL ||
- priv->samba_authenticated_searching ||
- priv->samba_searching;
+ searching = dialog->cups_searching ||
+ dialog->remote_cups_host != NULL ||
+ dialog->snmp_host != NULL ||
+ dialog->socket_host != NULL ||
+ dialog->lpd_host != NULL ||
+ dialog->samba_host != NULL ||
+ dialog->samba_authenticated_searching ||
+ dialog->samba_searching;
header = WID ("headerbar");
stack = WID ("stack");
@@ -895,7 +864,7 @@ update_dialog_state (PpNewPrinterDialog *dialog)
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), NULL);
}
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter))
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter))
gtk_stack_set_visible_child_name (GTK_STACK (stack), "standard-page");
else
gtk_stack_set_visible_child_name (GTK_STACK (stack), searching ? "loading-page" : "no-printers-page");
@@ -906,7 +875,6 @@ group_physical_devices_cb (gchar ***device_uris,
gpointer user_data)
{
PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
- PpNewPrinterDialogPrivate *priv = dialog->priv;
PpPrintDevice *device, *better_device;
GList *iter;
gint i, j;
@@ -921,7 +889,7 @@ group_physical_devices_cb (gchar ***device_uris,
device = NULL;
for (j = 0; device_uris[i][j] != NULL; j++)
{
- device = device_in_liststore (device_uris[i][j], priv->store);
+ device = device_in_liststore (device_uris[i][j], dialog->store);
if (device != NULL)
break;
}
@@ -932,7 +900,7 @@ group_physical_devices_cb (gchar ***device_uris,
/* Is there better device in the sublist? */
if (j != 0)
{
- better_device = device_in_list (device_uris[i][0], priv->local_cups_devices);
+ better_device = device_in_list (device_uris[i][0], dialog->local_cups_devices);
replace_device (dialog, device, better_device);
g_object_unref (better_device);
}
@@ -941,7 +909,7 @@ group_physical_devices_cb (gchar ***device_uris,
}
else
{
- device = device_in_list (device_uris[i][0], priv->local_cups_devices);
+ device = device_in_list (device_uris[i][0], dialog->local_cups_devices);
if (device != NULL)
{
set_device (dialog, device, NULL);
@@ -958,10 +926,10 @@ group_physical_devices_cb (gchar ***device_uris,
}
else
{
- for (iter = priv->local_cups_devices; iter != NULL; iter = iter->next)
+ for (iter = dialog->local_cups_devices; iter != NULL; iter = iter->next)
set_device (dialog, (PpPrintDevice *) iter->data, NULL);
- g_list_free_full (priv->local_cups_devices, g_object_unref);
- priv->local_cups_devices = NULL;
+ g_list_free_full (dialog->local_cups_devices, g_object_unref);
+ dialog->local_cups_devices = NULL;
}
update_dialog_state (dialog);
@@ -1048,7 +1016,6 @@ get_cups_devices_cb (GList *devices,
gpointer user_data)
{
PpNewPrinterDialog *dialog;
- PpNewPrinterDialogPrivate *priv;
GDBusConnection *bus;
GVariantBuilder device_list;
GVariantBuilder device_hash;
@@ -1066,27 +1033,26 @@ get_cups_devices_cb (GList *devices,
if (!cancelled)
{
dialog = (PpNewPrinterDialog *) user_data;
- priv = dialog->priv;
if (finished)
{
- priv->cups_searching = FALSE;
+ dialog->cups_searching = FALSE;
}
if (devices)
{
add_devices_to_list (dialog, devices);
- length = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->store), NULL) + g_list_length
(priv->local_cups_devices);
+ length = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (dialog->store), NULL) + g_list_length
(dialog->local_cups_devices);
if (length > 0)
{
all_devices = g_new0 (PpPrintDevice *, length);
i = 0;
- cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter);
while (cont)
{
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
DEVICE_COLUMN, &device,
-1);
@@ -1100,10 +1066,10 @@ get_cups_devices_cb (GList *devices,
g_object_unref (device);
- cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter);
}
- for (liter = priv->local_cups_devices; liter != NULL; liter = liter->next)
+ for (liter = dialog->local_cups_devices; liter != NULL; liter = liter->next)
{
pp_device = (PpPrintDevice *) liter->data;
if (pp_device != NULL)
@@ -1167,7 +1133,7 @@ get_cups_devices_cb (GList *devices,
G_VARIANT_TYPE ("(aas)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
- priv->cancellable,
+ dialog->cancellable,
group_physical_devices_dbus_cb,
dialog);
}
@@ -1201,7 +1167,6 @@ get_snmp_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *dialog;
- PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
PpDevicesList *result;
@@ -1212,10 +1177,9 @@ get_snmp_devices_cb (GObject *source_object,
if (result)
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
- if ((gpointer) source_object == (gpointer) priv->snmp_host)
- priv->snmp_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->snmp_host)
+ dialog->snmp_host = NULL;
add_devices_to_list (dialog, result->devices);
@@ -1228,12 +1192,11 @@ get_snmp_devices_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) priv->snmp_host)
- priv->snmp_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->snmp_host)
+ dialog->snmp_host = NULL;
update_dialog_state (dialog);
}
@@ -1246,7 +1209,6 @@ get_remote_cups_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *dialog;
- PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
PpDevicesList *result;
@@ -1257,10 +1219,9 @@ get_remote_cups_devices_cb (GObject *source_object,
if (result)
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
- if ((gpointer) source_object == (gpointer) priv->remote_cups_host)
- priv->remote_cups_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->remote_cups_host)
+ dialog->remote_cups_host = NULL;
add_devices_to_list (dialog, result->devices);
@@ -1273,12 +1234,11 @@ get_remote_cups_devices_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) priv->remote_cups_host)
- priv->remote_cups_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->remote_cups_host)
+ dialog->remote_cups_host = NULL;
update_dialog_state (dialog);
}
@@ -1290,7 +1250,6 @@ get_samba_host_devices_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog;
PpDevicesList *result;
PpSamba *samba = (PpSamba *) source_object;
@@ -1302,10 +1261,9 @@ get_samba_host_devices_cb (GObject *source_object,
if (result)
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
- if ((gpointer) source_object == (gpointer) priv->samba_host)
- priv->samba_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->samba_host)
+ dialog->samba_host = NULL;
add_devices_to_list (dialog, result->devices);
@@ -1318,12 +1276,11 @@ get_samba_host_devices_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) priv->samba_host)
- priv->samba_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->samba_host)
+ dialog->samba_host = NULL;
update_dialog_state (dialog);
}
@@ -1335,7 +1292,6 @@ get_samba_devices_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog;
PpDevicesList *result;
PpSamba *samba = (PpSamba *) source_object;
@@ -1347,9 +1303,8 @@ get_samba_devices_cb (GObject *source_object,
if (result)
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
- priv->samba_searching = FALSE;
+ dialog->samba_searching = FALSE;
add_devices_to_list (dialog, result->devices);
@@ -1362,11 +1317,10 @@ get_samba_devices_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
g_warning ("%s", error->message);
- priv->samba_searching = FALSE;
+ dialog->samba_searching = FALSE;
update_dialog_state (dialog);
}
@@ -1379,7 +1333,6 @@ get_jetdirect_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *dialog;
- PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
PpDevicesList *result;
@@ -1390,10 +1343,9 @@ get_jetdirect_devices_cb (GObject *source_object,
if (result != NULL)
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
- if ((gpointer) source_object == (gpointer) priv->socket_host)
- priv->socket_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->socket_host)
+ dialog->socket_host = NULL;
add_devices_to_list (dialog, result->devices);
@@ -1406,12 +1358,11 @@ get_jetdirect_devices_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) priv->socket_host)
- priv->socket_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->socket_host)
+ dialog->socket_host = NULL;
update_dialog_state (dialog);
}
@@ -1424,7 +1375,6 @@ get_lpd_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *dialog;
- PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
PpDevicesList *result;
@@ -1435,10 +1385,9 @@ get_lpd_devices_cb (GObject *source_object,
if (result != NULL)
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
- if ((gpointer) source_object == (gpointer) priv->lpd_host)
- priv->lpd_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->lpd_host)
+ dialog->lpd_host = NULL;
add_devices_to_list (dialog, result->devices);
@@ -1451,12 +1400,11 @@ get_lpd_devices_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) priv->lpd_host)
- priv->lpd_host = NULL;
+ if ((gpointer) source_object == (gpointer) dialog->lpd_host)
+ dialog->lpd_host = NULL;
update_dialog_state (dialog);
}
@@ -1466,12 +1414,10 @@ get_lpd_devices_cb (GObject *source_object,
static void
get_cups_devices (PpNewPrinterDialog *dialog)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
-
- priv->cups_searching = TRUE;
+ dialog->cups_searching = TRUE;
update_dialog_state (dialog);
- get_cups_devices_async (priv->cancellable,
+ get_cups_devices_async (dialog->cancellable,
get_cups_devices_cb,
dialog);
}
@@ -1547,66 +1493,66 @@ search_for_remote_printers_free (THostSearchData *data)
static gboolean
search_for_remote_printers (THostSearchData *data)
{
- PpNewPrinterDialogPrivate *priv = data->dialog->priv;
+ PpNewPrinterDialog *dialog = data->dialog;
- g_cancellable_cancel (priv->remote_host_cancellable);
- g_clear_object (&priv->remote_host_cancellable);
+ g_cancellable_cancel (dialog->remote_host_cancellable);
+ g_clear_object (&dialog->remote_host_cancellable);
- priv->remote_host_cancellable = g_cancellable_new ();
+ dialog->remote_host_cancellable = g_cancellable_new ();
- priv->remote_cups_host = pp_host_new (data->host_name);
- priv->snmp_host = pp_host_new (data->host_name);
- priv->socket_host = pp_host_new (data->host_name);
- priv->lpd_host = pp_host_new (data->host_name);
+ dialog->remote_cups_host = pp_host_new (data->host_name);
+ dialog->snmp_host = pp_host_new (data->host_name);
+ dialog->socket_host = pp_host_new (data->host_name);
+ dialog->lpd_host = pp_host_new (data->host_name);
if (data->host_port != PP_HOST_UNSET_PORT)
{
- g_object_set (priv->remote_cups_host, "port", data->host_port, NULL);
- g_object_set (priv->snmp_host, "port", data->host_port, NULL);
+ g_object_set (dialog->remote_cups_host, "port", data->host_port, NULL);
+ g_object_set (dialog->snmp_host, "port", data->host_port, NULL);
/* Accept port different from the default one only if user specifies
* scheme (for socket and lpd printers).
*/
if (data->host_scheme != NULL &&
g_ascii_strcasecmp (data->host_scheme, "socket") == 0)
- g_object_set (priv->socket_host, "port", data->host_port, NULL);
+ g_object_set (dialog->socket_host, "port", data->host_port, NULL);
if (data->host_scheme != NULL &&
g_ascii_strcasecmp (data->host_scheme, "lpd") == 0)
- g_object_set (priv->lpd_host, "port", data->host_port, NULL);
+ g_object_set (dialog->lpd_host, "port", data->host_port, NULL);
}
- priv->samba_host = pp_samba_new (data->host_name);
+ dialog->samba_host = pp_samba_new (data->host_name);
update_dialog_state (data->dialog);
- pp_host_get_remote_cups_devices_async (priv->remote_cups_host,
- priv->remote_host_cancellable,
+ pp_host_get_remote_cups_devices_async (dialog->remote_cups_host,
+ dialog->remote_host_cancellable,
get_remote_cups_devices_cb,
data->dialog);
- pp_host_get_snmp_devices_async (priv->snmp_host,
- priv->remote_host_cancellable,
+ pp_host_get_snmp_devices_async (dialog->snmp_host,
+ dialog->remote_host_cancellable,
get_snmp_devices_cb,
data->dialog);
- pp_host_get_jetdirect_devices_async (priv->socket_host,
- priv->remote_host_cancellable,
+ pp_host_get_jetdirect_devices_async (dialog->socket_host,
+ dialog->remote_host_cancellable,
get_jetdirect_devices_cb,
data->dialog);
- pp_host_get_lpd_devices_async (priv->lpd_host,
- priv->remote_host_cancellable,
+ pp_host_get_lpd_devices_async (dialog->lpd_host,
+ dialog->remote_host_cancellable,
get_lpd_devices_cb,
data->dialog);
- pp_samba_get_devices_async (priv->samba_host,
+ pp_samba_get_devices_async (dialog->samba_host,
TRUE,
- priv->remote_host_cancellable,
+ dialog->remote_host_cancellable,
get_samba_host_devices_cb,
data->dialog);
- priv->host_search_timeout_id = 0;
+ dialog->host_search_timeout_id = 0;
return G_SOURCE_REMOVE;
}
@@ -1616,7 +1562,6 @@ search_address (const gchar *text,
PpNewPrinterDialog *dialog,
gboolean delay_search)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
PpPrintDevice *device;
GtkTreeIter iter;
gboolean found = FALSE;
@@ -1639,10 +1584,10 @@ search_address (const gchar *text,
{
words_length = g_strv_length (words);
- cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter);
while (cont)
{
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
DEVICE_COLUMN, &device,
-1);
@@ -1663,7 +1608,7 @@ search_address (const gchar *text,
if (subfound)
found = TRUE;
- gtk_list_store_set (GTK_LIST_STORE (priv->store), &iter,
+ gtk_list_store_set (GTK_LIST_STORE (dialog->store), &iter,
DEVICE_VISIBLE_COLUMN, subfound,
-1);
@@ -1671,7 +1616,7 @@ search_address (const gchar *text,
g_free (lowercase_name);
g_object_unref (device);
- cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter);
}
g_strfreev (words);
@@ -1683,15 +1628,15 @@ search_address (const gchar *text,
*/
if (!found && words_length == 1)
{
- cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter);
while (cont)
{
next_set = FALSE;
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
DEVICE_COLUMN, &device,
-1);
- gtk_list_store_set (GTK_LIST_STORE (priv->store), &iter,
+ gtk_list_store_set (GTK_LIST_STORE (dialog->store), &iter,
DEVICE_VISIBLE_COLUMN, TRUE,
-1);
@@ -1703,14 +1648,14 @@ search_address (const gchar *text,
acquisition_method == ACQUISITION_METHOD_LPD ||
acquisition_method == ACQUISITION_METHOD_SAMBA_HOST)
{
- if (!gtk_list_store_remove (priv->store, &iter))
+ if (!gtk_list_store_remove (dialog->store, &iter))
break;
else
next_set = TRUE;
}
if (!next_set)
- cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter);
}
if (text && text[0] != '\0')
@@ -1731,15 +1676,15 @@ search_address (const gchar *text,
search_data->host_port = port;
search_data->dialog = dialog;
- if (priv->host_search_timeout_id != 0)
+ if (dialog->host_search_timeout_id != 0)
{
- g_source_remove (priv->host_search_timeout_id);
- priv->host_search_timeout_id = 0;
+ g_source_remove (dialog->host_search_timeout_id);
+ dialog->host_search_timeout_id = 0;
}
if (delay_search)
{
- priv->host_search_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ dialog->host_search_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT,
HOST_SEARCH_DELAY,
(GSourceFunc)
search_for_remote_printers,
search_data,
@@ -1814,7 +1759,6 @@ set_device (PpNewPrinterDialog *dialog,
PpPrintDevice *device,
GtkTreeIter *iter)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkTreeIter titer;
gchar *description;
gint acquisition_method;
@@ -1849,10 +1793,10 @@ set_device (PpNewPrinterDialog *dialog,
}
if (iter == NULL)
- gtk_list_store_append (priv->store, &titer);
+ gtk_list_store_append (dialog->store, &titer);
- gtk_list_store_set (priv->store, iter == NULL ? &titer : iter,
- DEVICE_GICON_COLUMN, pp_print_device_is_network_device (device) ?
priv->remote_printer_icon : priv->local_printer_icon,
+ gtk_list_store_set (dialog->store, iter == NULL ? &titer : iter,
+ DEVICE_GICON_COLUMN, pp_print_device_is_network_device (device) ?
dialog->remote_printer_icon : dialog->local_printer_icon,
DEVICE_NAME_COLUMN, pp_print_device_get_device_name (device),
DEVICE_DISPLAY_NAME_COLUMN, pp_print_device_get_display_name (device),
DEVICE_DESCRIPTION_COLUMN, description,
@@ -1866,10 +1810,10 @@ set_device (PpNewPrinterDialog *dialog,
pp_print_device_get_host_name (device) != NULL)
{
if (iter == NULL)
- gtk_list_store_append (priv->store, &titer);
+ gtk_list_store_append (dialog->store, &titer);
- gtk_list_store_set (priv->store, iter == NULL ? &titer : iter,
- DEVICE_GICON_COLUMN, priv->authenticated_server_icon,
+ gtk_list_store_set (dialog->store, iter == NULL ? &titer : iter,
+ DEVICE_GICON_COLUMN, dialog->authenticated_server_icon,
DEVICE_NAME_COLUMN, pp_print_device_get_host_name (device),
DEVICE_DISPLAY_NAME_COLUMN, pp_print_device_get_host_name (device),
/* Translators: This item is a server which needs authentication to show its
printers */
@@ -1887,17 +1831,16 @@ replace_device (PpNewPrinterDialog *dialog,
PpPrintDevice *old_device,
PpPrintDevice *new_device)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
PpPrintDevice *device;
GtkTreeIter iter;
gboolean cont;
if (old_device != NULL && new_device != NULL)
{
- cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter);
while (cont)
{
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
DEVICE_COLUMN, &device,
-1);
@@ -1910,7 +1853,7 @@ replace_device (PpNewPrinterDialog *dialog,
g_object_unref (device);
- cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter);
+ cont = gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter);
}
}
}
@@ -1921,7 +1864,6 @@ cups_get_dests_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *dialog;
- PpNewPrinterDialogPrivate *priv;
PpCupsDests *dests;
PpCups *cups = (PpCups *) source_object;
g_autoptr(GError) error = NULL;
@@ -1932,10 +1874,9 @@ cups_get_dests_cb (GObject *source_object,
if (dests)
{
dialog = PP_NEW_PRINTER_DIALOG (user_data);
- priv = dialog->priv;
- priv->dests = dests->dests;
- priv->num_of_dests = dests->num_of_dests;
+ dialog->dests = dests->dests;
+ dialog->num_of_dests = dests->num_of_dests;
get_cups_devices (dialog);
}
@@ -1959,14 +1900,13 @@ row_activated_cb (GtkTreeView *tree_view,
gpointer user_data)
{
PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
- PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *widget;
gboolean authentication_needed;
gboolean selected;
- selected = gtk_tree_selection_get_selected (gtk_tree_view_get_selection (priv->treeview),
+ selected = gtk_tree_selection_get_selected (gtk_tree_view_get_selection (dialog->treeview),
&model,
&iter);
@@ -1981,7 +1921,7 @@ row_activated_cb (GtkTreeView *tree_view,
}
else
{
- gtk_dialog_response (GTK_DIALOG (priv->dialog), GTK_RESPONSE_OK);
+ gtk_dialog_response (GTK_DIALOG (dialog->dialog), GTK_RESPONSE_OK);
}
}
}
@@ -1994,13 +1934,12 @@ cell_data_func (GtkTreeViewColumn *tree_column,
gpointer user_data)
{
PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
- PpNewPrinterDialogPrivate *priv = dialog->priv;
gboolean selected = FALSE;
gchar *name = NULL;
gchar *description = NULL;
gchar *text;
- selected = gtk_tree_selection_iter_is_selected (gtk_tree_view_get_selection (priv->treeview), iter);
+ selected = gtk_tree_selection_iter_is_selected (gtk_tree_view_get_selection (dialog->treeview), iter);
gtk_tree_model_get (tree_model, iter,
DEVICE_DISPLAY_NAME_COLUMN, &name,
@@ -2040,60 +1979,59 @@ cell_data_func (GtkTreeViewColumn *tree_column,
static void
populate_devices_list (PpNewPrinterDialog *dialog)
{
- PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkTreeViewColumn *column;
PpSamba *samba;
GEmblem *emblem;
PpCups *cups;
GIcon *icon, *emblem_icon;
- g_signal_connect (gtk_tree_view_get_selection (priv->treeview),
+ g_signal_connect (gtk_tree_view_get_selection (dialog->treeview),
"changed", G_CALLBACK (device_selection_changed_cb), dialog);
- g_signal_connect (priv->treeview,
+ g_signal_connect (dialog->treeview,
"row-activated", G_CALLBACK (row_activated_cb), dialog);
- priv->local_printer_icon = g_themed_icon_new ("printer");
- priv->remote_printer_icon = g_themed_icon_new ("printer-network");
+ dialog->local_printer_icon = g_themed_icon_new ("printer");
+ dialog->remote_printer_icon = g_themed_icon_new ("printer-network");
icon = g_themed_icon_new ("network-server");
emblem_icon = g_themed_icon_new ("changes-prevent");
emblem = g_emblem_new (emblem_icon);
- priv->authenticated_server_icon = g_emblemed_icon_new (icon, emblem);
+ dialog->authenticated_server_icon = g_emblemed_icon_new (icon, emblem);
g_object_unref (icon);
g_object_unref (emblem_icon);
g_object_unref (emblem);
- priv->icon_renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (priv->icon_renderer, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
- gtk_cell_renderer_set_alignment (priv->icon_renderer, 1.0, 0.5);
- gtk_cell_renderer_set_padding (priv->icon_renderer, 4, 4);
- column = gtk_tree_view_column_new_with_attributes ("Icon", priv->icon_renderer,
+ dialog->icon_renderer = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (dialog->icon_renderer, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
+ gtk_cell_renderer_set_alignment (dialog->icon_renderer, 1.0, 0.5);
+ gtk_cell_renderer_set_padding (dialog->icon_renderer, 4, 4);
+ column = gtk_tree_view_column_new_with_attributes ("Icon", dialog->icon_renderer,
"gicon", DEVICE_GICON_COLUMN, NULL);
gtk_tree_view_column_set_max_width (column, -1);
gtk_tree_view_column_set_min_width (column, 80);
- gtk_tree_view_append_column (priv->treeview, column);
+ gtk_tree_view_append_column (dialog->treeview, column);
- priv->text_renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("Devices", priv->text_renderer,
+ dialog->text_renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("Devices", dialog->text_renderer,
NULL);
- gtk_tree_view_column_set_cell_data_func (column, priv->text_renderer, cell_data_func,
+ gtk_tree_view_column_set_cell_data_func (column, dialog->text_renderer, cell_data_func,
dialog, NULL);
- gtk_tree_view_append_column (priv->treeview, column);
+ gtk_tree_view_append_column (dialog->treeview, column);
- gtk_tree_model_filter_set_visible_column (priv->filter, DEVICE_VISIBLE_COLUMN);
+ gtk_tree_model_filter_set_visible_column (dialog->filter, DEVICE_VISIBLE_COLUMN);
cups = pp_cups_new ();
- pp_cups_get_dests_async (cups, priv->cancellable, cups_get_dests_cb, dialog);
+ pp_cups_get_dests_async (cups, dialog->cancellable, cups_get_dests_cb, dialog);
- priv->samba_searching = TRUE;
+ dialog->samba_searching = TRUE;
update_dialog_state (dialog);
samba = pp_samba_new (NULL);
- pp_samba_get_devices_async (samba, FALSE, priv->cancellable, get_samba_devices_cb, dialog);
+ pp_samba_get_devices_async (samba, FALSE, dialog->cancellable, get_samba_devices_cb, dialog);
}
static void
@@ -2137,7 +2075,6 @@ ppd_selection_cb (GtkDialog *_dialog,
gpointer user_data)
{
PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
- PpNewPrinterDialogPrivate *priv = dialog->priv;
PpNewPrinter *new_printer;
GList *original_names_list = NULL;
gchar *ppd_name;
@@ -2146,40 +2083,40 @@ ppd_selection_cb (GtkDialog *_dialog,
guint window_id = 0;
gint acquisition_method;
- ppd_name = pp_ppd_selection_dialog_get_ppd_name (priv->ppd_selection_dialog);
- ppd_display_name = pp_ppd_selection_dialog_get_ppd_display_name (priv->ppd_selection_dialog);
- pp_ppd_selection_dialog_free (priv->ppd_selection_dialog);
- priv->ppd_selection_dialog = NULL;
+ ppd_name = pp_ppd_selection_dialog_get_ppd_name (dialog->ppd_selection_dialog);
+ ppd_display_name = pp_ppd_selection_dialog_get_ppd_display_name (dialog->ppd_selection_dialog);
+ pp_ppd_selection_dialog_free (dialog->ppd_selection_dialog);
+ dialog->ppd_selection_dialog = NULL;
if (ppd_name)
{
- g_object_set (priv->new_device, "device-ppd", ppd_name, NULL);
+ g_object_set (dialog->new_device, "device-ppd", ppd_name, NULL);
- acquisition_method = pp_print_device_get_acquisition_method (priv->new_device);
+ acquisition_method = pp_print_device_get_acquisition_method (dialog->new_device);
if ((acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
acquisition_method == ACQUISITION_METHOD_LPD) &&
ppd_display_name != NULL)
{
- g_object_set (priv->new_device,
+ g_object_set (dialog->new_device,
"device-name", ppd_display_name,
"device-original-name", ppd_display_name,
NULL);
- gtk_tree_model_foreach (GTK_TREE_MODEL (priv->store),
+ gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->store),
prepend_original_name,
&original_names_list);
original_names_list = g_list_reverse (original_names_list);
printer_name = canonicalize_device_name (original_names_list,
- priv->local_cups_devices,
- priv->dests,
- priv->num_of_dests,
- priv->new_device);
+ dialog->local_cups_devices,
+ dialog->dests,
+ dialog->num_of_dests,
+ dialog->new_device);
g_list_free_full (original_names_list, g_free);
- g_object_set (priv->new_device,
+ g_object_set (dialog->new_device,
"device-name", printer_name,
"device-original-name", printer_name,
NULL);
@@ -2188,37 +2125,37 @@ ppd_selection_cb (GtkDialog *_dialog,
}
emit_pre_response (dialog,
- pp_print_device_get_device_name (priv->new_device),
- pp_print_device_get_device_location (priv->new_device),
- pp_print_device_get_device_make_and_model (priv->new_device),
- pp_print_device_is_network_device (priv->new_device));
+ pp_print_device_get_device_name (dialog->new_device),
+ pp_print_device_get_device_location (dialog->new_device),
+ pp_print_device_get_device_make_and_model (dialog->new_device),
+ pp_print_device_is_network_device (dialog->new_device));
- window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (gtk_window_get_transient_for
(GTK_WINDOW (priv->dialog)))));
+ window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (gtk_window_get_transient_for
(GTK_WINDOW (dialog->dialog)))));
new_printer = pp_new_printer_new ();
g_object_set (new_printer,
- "name", pp_print_device_get_device_name (priv->new_device),
- "original-name", pp_print_device_get_device_original_name (priv->new_device),
- "device-uri", pp_print_device_get_device_uri (priv->new_device),
- "device-id", pp_print_device_get_device_id (priv->new_device),
- "ppd-name", pp_print_device_get_device_ppd (priv->new_device),
- "ppd-file-name", pp_print_device_get_device_ppd (priv->new_device),
- "info", pp_print_device_get_device_info (priv->new_device),
- "location", pp_print_device_get_device_location (priv->new_device),
- "make-and-model", pp_print_device_get_device_make_and_model (priv->new_device),
- "host-name", pp_print_device_get_host_name (priv->new_device),
- "host-port", pp_print_device_get_host_port (priv->new_device),
- "is-network-device", pp_print_device_is_network_device (priv->new_device),
+ "name", pp_print_device_get_device_name (dialog->new_device),
+ "original-name", pp_print_device_get_device_original_name (dialog->new_device),
+ "device-uri", pp_print_device_get_device_uri (dialog->new_device),
+ "device-id", pp_print_device_get_device_id (dialog->new_device),
+ "ppd-name", pp_print_device_get_device_ppd (dialog->new_device),
+ "ppd-file-name", pp_print_device_get_device_ppd (dialog->new_device),
+ "info", pp_print_device_get_device_info (dialog->new_device),
+ "location", pp_print_device_get_device_location (dialog->new_device),
+ "make-and-model", pp_print_device_get_device_make_and_model (dialog->new_device),
+ "host-name", pp_print_device_get_host_name (dialog->new_device),
+ "host-port", pp_print_device_get_host_port (dialog->new_device),
+ "is-network-device", pp_print_device_is_network_device (dialog->new_device),
"window-id", window_id,
NULL);
- priv->cancellable = g_cancellable_new ();
+ dialog->cancellable = g_cancellable_new ();
pp_new_printer_add_async (new_printer,
- priv->cancellable,
+ dialog->cancellable,
printer_add_async_cb,
dialog);
- g_clear_object (&priv->new_device);
+ g_clear_object (&dialog->new_device);
}
}
@@ -2228,7 +2165,6 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
gpointer user_data)
{
PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
- PpNewPrinterDialogPrivate *priv = dialog->priv;
PpPrintDevice *device = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -2238,10 +2174,10 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
if (response_id == GTK_RESPONSE_OK)
{
- g_cancellable_cancel (priv->cancellable);
- g_clear_object (&priv->cancellable);
+ g_cancellable_cancel (dialog->cancellable);
+ g_clear_object (&dialog->cancellable);
- if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (priv->treeview), &model, &iter))
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (dialog->treeview), &model, &iter))
{
gtk_tree_model_get (model, &iter,
DEVICE_COLUMN, &device,
@@ -2259,10 +2195,10 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
acquisition_method == ACQUISITION_METHOD_LPD)
{
- priv->new_device = pp_print_device_copy (device);
- priv->ppd_selection_dialog =
- pp_ppd_selection_dialog_new (priv->parent,
- priv->list,
+ dialog->new_device = pp_print_device_copy (device);
+ dialog->ppd_selection_dialog =
+ pp_ppd_selection_dialog_new (dialog->parent,
+ dialog->list,
NULL,
ppd_selection_cb,
dialog);
@@ -2294,10 +2230,10 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
"window-id", window_id,
NULL);
- priv->cancellable = g_cancellable_new ();
+ dialog->cancellable = g_cancellable_new ();
pp_new_printer_add_async (new_printer,
- priv->cancellable,
+ dialog->cancellable,
printer_add_async_cb,
dialog);
}
diff --git a/panels/printers/pp-new-printer-dialog.h b/panels/printers/pp-new-printer-dialog.h
index b30fc8a80..54a0a2300 100644
--- a/panels/printers/pp-new-printer-dialog.h
+++ b/panels/printers/pp-new-printer-dialog.h
@@ -26,38 +26,9 @@
G_BEGIN_DECLS
-#define PP_TYPE_NEW_PRINTER_DIALOG (pp_new_printer_dialog_get_type ())
-#define PP_NEW_PRINTER_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object),
PP_TYPE_NEW_PRINTER_DIALOG, PpNewPrinterDialog))
-#define PP_NEW_PRINTER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PP_TYPE_NEW_PRINTER_DIALOG,
PpNewPrinterDialogClass))
-#define PP_IS_NEW_PRINTER_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object),
PP_TYPE_NEW_PRINTER_DIALOG))
-#define PP_IS_NEW_PRINTER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PP_TYPE_NEW_PRINTER_DIALOG))
-#define PP_NEW_PRINTER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PP_TYPE_NEW_PRINTER_DIALOG,
PpNewPrinterDialogClass))
+#define PP_TYPE_NEW_PRINTER_DIALOG (pp_new_printer_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (PpNewPrinterDialog, pp_new_printer_dialog, PP, NEW_PRINTER_DIALOG, GObject)
-typedef struct _PpNewPrinterDialog PpNewPrinterDialog;
-typedef struct _PpNewPrinterDialogClass PpNewPrinterDialogClass;
-typedef struct _PpNewPrinterDialogPrivate PpNewPrinterDialogPrivate;
-
-struct _PpNewPrinterDialog
-{
- GObject parent_instance;
- PpNewPrinterDialogPrivate *priv;
-};
-
-struct _PpNewPrinterDialogClass
-{
- GObjectClass parent_class;
-
- void (*pre_response) (PpNewPrinterDialog *dialog,
- const gchar *device_name,
- const gchar *device_location,
- const gchar *device_make_and_model,
- gboolean is_network_device);
-
- void (*response) (PpNewPrinterDialog *dialog,
- gint response_id);
-};
-
-GType pp_new_printer_dialog_get_type (void) G_GNUC_CONST;
PpNewPrinterDialog *pp_new_printer_dialog_new (GtkWindow *parent,
PPDList *ppd_list);
void pp_new_printer_dialog_set_ppd_list (PpNewPrinterDialog *dialog,
diff --git a/panels/printers/pp-new-printer.c b/panels/printers/pp-new-printer.c
index 8b037f836..35bd11acc 100644
--- a/panels/printers/pp-new-printer.c
+++ b/panels/printers/pp-new-printer.c
@@ -42,8 +42,10 @@
#define ippGetState(ipp) ipp->state
#endif
-struct _PpNewPrinterPrivate
+struct _PpNewPrinter
{
+ GObject parent_instance;
+
gchar *name;
gchar *original_name;
gchar *device_uri;
@@ -85,25 +87,23 @@ enum {
static void
pp_new_printer_finalize (GObject *object)
{
- PpNewPrinterPrivate *priv;
-
- priv = PP_NEW_PRINTER (object)->priv;
-
- if (priv->unlink_ppd_file && priv->ppd_file_name)
- g_unlink (priv->ppd_file_name);
-
- g_clear_pointer (&priv->name, g_free);
- g_clear_pointer (&priv->original_name, g_free);
- g_clear_pointer (&priv->device_uri, g_free);
- g_clear_pointer (&priv->device_id, g_free);
- g_clear_pointer (&priv->ppd_name, g_free);
- g_clear_pointer (&priv->ppd_file_name, g_free);
- g_clear_pointer (&priv->info, g_free);
- g_clear_pointer (&priv->location, g_free);
- g_clear_pointer (&priv->make_and_model, g_free);
- g_clear_pointer (&priv->host_name, g_free);
- g_clear_object (&priv->task);
- g_clear_object (&priv->cancellable);
+ PpNewPrinter *self = PP_NEW_PRINTER (object);
+
+ if (self->unlink_ppd_file && self->ppd_file_name)
+ g_unlink (self->ppd_file_name);
+
+ g_clear_pointer (&self->name, g_free);
+ g_clear_pointer (&self->original_name, g_free);
+ g_clear_pointer (&self->device_uri, g_free);
+ g_clear_pointer (&self->device_id, g_free);
+ g_clear_pointer (&self->ppd_name, g_free);
+ g_clear_pointer (&self->ppd_file_name, g_free);
+ g_clear_pointer (&self->info, g_free);
+ g_clear_pointer (&self->location, g_free);
+ g_clear_pointer (&self->make_and_model, g_free);
+ g_clear_pointer (&self->host_name, g_free);
+ g_clear_object (&self->task);
+ g_clear_object (&self->cancellable);
G_OBJECT_CLASS (pp_new_printer_parent_class)->finalize (object);
}
@@ -121,43 +121,43 @@ pp_new_printer_get_property (GObject *object,
switch (prop_id)
{
case PROP_NAME:
- g_value_set_string (value, self->priv->name);
+ g_value_set_string (value, self->name);
break;
case PROP_ORIGINAL_NAME:
- g_value_set_string (value, self->priv->original_name);
+ g_value_set_string (value, self->original_name);
break;
case PROP_DEVICE_URI:
- g_value_set_string (value, self->priv->device_uri);
+ g_value_set_string (value, self->device_uri);
break;
case PROP_DEVICE_ID:
- g_value_set_string (value, self->priv->device_id);
+ g_value_set_string (value, self->device_id);
break;
case PROP_PPD_NAME:
- g_value_set_string (value, self->priv->ppd_name);
+ g_value_set_string (value, self->ppd_name);
break;
case PROP_PPD_FILE_NAME:
- g_value_set_string (value, self->priv->ppd_file_name);
+ g_value_set_string (value, self->ppd_file_name);
break;
case PROP_INFO:
- g_value_set_string (value, self->priv->info);
+ g_value_set_string (value, self->info);
break;
case PROP_LOCATION:
- g_value_set_string (value, self->priv->location);
+ g_value_set_string (value, self->location);
break;
case PROP_MAKE_AND_MODEL:
- g_value_set_string (value, self->priv->make_and_model);
+ g_value_set_string (value, self->make_and_model);
break;
case PROP_HOST_NAME:
- g_value_set_string (value, self->priv->host_name);
+ g_value_set_string (value, self->host_name);
break;
case PROP_HOST_PORT:
- g_value_set_int (value, self->priv->host_port);
+ g_value_set_int (value, self->host_port);
break;
case PROP_IS_NETWORK_DEVICE:
- g_value_set_boolean (value, self->priv->is_network_device);
+ g_value_set_boolean (value, self->is_network_device);
break;
case PROP_WINDOW_ID:
- g_value_set_uint (value, self->priv->window_id);
+ g_value_set_uint (value, self->window_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -178,53 +178,53 @@ pp_new_printer_set_property (GObject *object,
switch (prop_id)
{
case PROP_NAME:
- g_free (self->priv->name);
- self->priv->name = g_value_dup_string (value);
+ g_free (self->name);
+ self->name = g_value_dup_string (value);
break;
case PROP_ORIGINAL_NAME:
- g_free (self->priv->original_name);
- self->priv->original_name = g_value_dup_string (value);
+ g_free (self->original_name);
+ self->original_name = g_value_dup_string (value);
break;
case PROP_DEVICE_URI:
- g_free (self->priv->device_uri);
- self->priv->device_uri = g_value_dup_string (value);
+ g_free (self->device_uri);
+ self->device_uri = g_value_dup_string (value);
break;
case PROP_DEVICE_ID:
- g_free (self->priv->device_id);
- self->priv->device_id = g_value_dup_string (value);
+ g_free (self->device_id);
+ self->device_id = g_value_dup_string (value);
break;
case PROP_PPD_NAME:
- g_free (self->priv->ppd_name);
- self->priv->ppd_name = g_value_dup_string (value);
+ g_free (self->ppd_name);
+ self->ppd_name = g_value_dup_string (value);
break;
case PROP_PPD_FILE_NAME:
- g_free (self->priv->ppd_file_name);
- self->priv->ppd_file_name = g_value_dup_string (value);
+ g_free (self->ppd_file_name);
+ self->ppd_file_name = g_value_dup_string (value);
break;
case PROP_INFO:
- g_free (self->priv->info);
- self->priv->info = g_value_dup_string (value);
+ g_free (self->info);
+ self->info = g_value_dup_string (value);
break;
case PROP_LOCATION:
- g_free (self->priv->location);
- self->priv->location = g_value_dup_string (value);
+ g_free (self->location);
+ self->location = g_value_dup_string (value);
break;
case PROP_MAKE_AND_MODEL:
- g_free (self->priv->make_and_model);
- self->priv->make_and_model = g_value_dup_string (value);
+ g_free (self->make_and_model);
+ self->make_and_model = g_value_dup_string (value);
break;
case PROP_HOST_NAME:
- g_free (self->priv->host_name);
- self->priv->host_name = g_value_dup_string (value);
+ g_free (self->host_name);
+ self->host_name = g_value_dup_string (value);
break;
case PROP_HOST_PORT:
- self->priv->host_port = g_value_get_int (value);
+ self->host_port = g_value_get_int (value);
break;
case PROP_IS_NETWORK_DEVICE:
- self->priv->is_network_device = g_value_get_boolean (value);
+ self->is_network_device = g_value_get_boolean (value);
break;
case PROP_WINDOW_ID:
- self->priv->window_id = g_value_get_uint (value);
+ self->window_id = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -239,8 +239,6 @@ pp_new_printer_class_init (PpNewPrinterClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (PpNewPrinterPrivate));
-
gobject_class->set_property = pp_new_printer_set_property;
gobject_class->get_property = pp_new_printer_get_property;
@@ -341,11 +339,7 @@ pp_new_printer_class_init (PpNewPrinterClass *klass)
static void
pp_new_printer_init (PpNewPrinter *printer)
{
- printer->priv = G_TYPE_INSTANCE_GET_PRIVATE (printer,
- PP_TYPE_NEW_PRINTER,
- PpNewPrinterPrivate);
-
- printer->priv->unlink_ppd_file = FALSE;
+ printer->unlink_ppd_file = FALSE;
}
PpNewPrinter *
@@ -360,18 +354,16 @@ static void
_pp_new_printer_add_async_cb (gboolean success,
PpNewPrinter *printer)
{
- PpNewPrinterPrivate *priv = printer->priv;
-
if (!success)
{
- g_task_return_new_error (priv->task,
+ g_task_return_new_error (printer->task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"Installation of the new printer failed.");
return;
}
- g_task_return_boolean (priv->task, success);
+ g_task_return_boolean (printer->task, success);
}
static void
@@ -403,7 +395,6 @@ printer_add_real_async_dbus_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinter *printer = (PpNewPrinter *) user_data;
- PpNewPrinterPrivate *priv = printer->priv;
GVariant *output;
g_autoptr(GError) error = NULL;
@@ -419,7 +410,7 @@ printer_add_real_async_dbus_cb (GObject *source_object,
g_variant_get (output, "(&s)", &ret_error);
if (ret_error[0] != '\0')
{
- g_warning ("cups-pk-helper: addition of printer %s failed: %s", priv->name, ret_error);
+ g_warning ("cups-pk-helper: addition of printer %s failed: %s", printer->name, ret_error);
}
g_variant_unref (output);
@@ -432,7 +423,7 @@ printer_add_real_async_dbus_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
- get_named_dest_async (priv->name,
+ get_named_dest_async (printer->name,
printer_add_real_async_cb,
printer);
}
@@ -441,11 +432,10 @@ printer_add_real_async_dbus_cb (GObject *source_object,
static void
printer_add_real_async (PpNewPrinter *printer)
{
- PpNewPrinterPrivate *priv = printer->priv;
GDBusConnection *bus;
g_autoptr(GError) error = NULL;
- if (!priv->ppd_name && !priv->ppd_file_name)
+ if (!printer->ppd_name && !printer->ppd_file_name)
{
_pp_new_printer_add_async_cb (FALSE, printer);
return;
@@ -463,13 +453,13 @@ printer_add_real_async (PpNewPrinter *printer)
MECHANISM_BUS,
"/",
MECHANISM_BUS,
- priv->ppd_name ? "PrinterAdd" : "PrinterAddWithPpdFile",
+ printer->ppd_name ? "PrinterAdd" : "PrinterAddWithPpdFile",
g_variant_new ("(sssss)",
- priv->name,
- priv->device_uri,
- priv->ppd_name ? priv->ppd_name : priv->ppd_file_name,
- priv->info ? priv->info : "",
- priv->location ? priv->location : ""),
+ printer->name,
+ printer->device_uri,
+ printer->ppd_name ? printer->ppd_name : printer->ppd_file_name,
+ printer->info ? printer->info : "",
+ printer->location ? printer->location : ""),
G_VARIANT_TYPE ("(s)"),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
@@ -544,7 +534,6 @@ printer_add_async_scb3 (GObject *source_object,
gpointer user_data)
{
PpNewPrinter *printer = (PpNewPrinter *) user_data;
- PpNewPrinterPrivate *priv = printer->priv;
GVariant *output;
PPDName *ppd_item = NULL;
g_autoptr(GError) error = NULL;
@@ -568,7 +557,7 @@ printer_add_async_scb3 (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
ppd_item && ppd_item->ppd_name)
{
- priv->ppd_name = g_strdup (ppd_item->ppd_name);
+ printer->ppd_name = g_strdup (ppd_item->ppd_name);
printer_add_real_async (printer);
}
else
@@ -588,7 +577,6 @@ install_printer_drivers_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- PpNewPrinterPrivate *priv;
PpNewPrinter *printer;
GVariant *output;
g_autoptr(GError) error = NULL;
@@ -614,7 +602,6 @@ install_printer_drivers_cb (GObject *source_object,
g_autoptr(GError) bus_error = NULL;
printer = (PpNewPrinter *) user_data;
- priv = printer->priv;
/* Try whether CUPS has a driver for the new printer */
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &bus_error);
@@ -626,13 +613,13 @@ install_printer_drivers_cb (GObject *source_object,
SCP_IFACE,
"GetBestDrivers",
g_variant_new ("(sss)",
- priv->device_id,
- priv->make_and_model ? priv->make_and_model : "",
- priv->device_uri ? priv->device_uri : ""),
+ printer->device_id,
+ printer->make_and_model ? printer->make_and_model : "",
+ printer->device_uri ? printer->device_uri : ""),
G_VARIANT_TYPE ("(a(ss))"),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT_LONG,
- priv->cancellable,
+ printer->cancellable,
printer_add_async_scb3,
printer);
}
@@ -650,7 +637,6 @@ printer_add_async_scb (GObject *source_object,
gpointer user_data)
{
PpNewPrinter *printer = (PpNewPrinter *) user_data;
- PpNewPrinterPrivate *priv = printer->priv;
GDBusConnection *bus;
GVariantBuilder array_builder;
GVariant *output;
@@ -686,7 +672,7 @@ printer_add_async_scb (GObject *source_object,
if (bus)
{
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
- g_variant_builder_add (&array_builder, "s", priv->device_id);
+ g_variant_builder_add (&array_builder, "s", printer->device_id);
g_dbus_connection_call (bus,
PACKAGE_KIT_BUS,
@@ -694,7 +680,7 @@ printer_add_async_scb (GObject *source_object,
PACKAGE_KIT_MODIFY_IFACE,
"InstallPrinterDrivers",
g_variant_new ("(uass)",
- priv->window_id,
+ printer->window_id,
&array_builder,
"hide-finished"),
G_VARIANT_TYPE ("()"),
@@ -712,7 +698,7 @@ printer_add_async_scb (GObject *source_object,
}
else if (ppd_item && ppd_item->ppd_name)
{
- priv->ppd_name = g_strdup (ppd_item->ppd_name);
+ printer->ppd_name = g_strdup (ppd_item->ppd_name);
printer_add_real_async (printer);
}
else
@@ -733,12 +719,11 @@ printer_add_async_scb4 (const gchar *ppd_filename,
gpointer user_data)
{
PpNewPrinter *printer = (PpNewPrinter *) user_data;
- PpNewPrinterPrivate *priv = printer->priv;
- priv->ppd_file_name = g_strdup (ppd_filename);
- if (priv->ppd_file_name)
+ printer->ppd_file_name = g_strdup (ppd_filename);
+ if (printer->ppd_file_name)
{
- priv->unlink_ppd_file = TRUE;
+ printer->unlink_ppd_file = TRUE;
printer_add_real_async (printer);
}
else
@@ -783,11 +768,11 @@ typedef struct
static void
printer_configure_async_finish (PCData *data)
{
- PpNewPrinterPrivate *priv = data->new_printer->priv;
+ PpNewPrinter *printer = data->new_printer;
if (data->set_accept_jobs_finished &&
data->set_enabled_finished &&
- (data->autoconfigure_finished || priv->is_network_device) &&
+ (data->autoconfigure_finished || printer->is_network_device) &&
data->set_media_size_finished &&
data->install_missing_executables_finished)
{
@@ -1198,7 +1183,6 @@ pp_maintenance_command_execute_cb (GObject *source_object,
static void
printer_configure_async (PpNewPrinter *new_printer)
{
- PpNewPrinterPrivate *priv = new_printer->priv;
GDBusConnection *bus;
PCData *data;
IMEData *ime_data;
@@ -1214,7 +1198,7 @@ printer_configure_async (PpNewPrinter *new_printer)
data->install_missing_executables_finished = FALSE;
/* Enable printer and make it accept jobs */
- if (priv->name)
+ if (new_printer->name)
{
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (bus)
@@ -1225,7 +1209,7 @@ printer_configure_async (PpNewPrinter *new_printer)
MECHANISM_BUS,
"PrinterSetAcceptJobs",
g_variant_new ("(sbs)",
- priv->name,
+ new_printer->name,
TRUE,
""),
G_VARIANT_TYPE ("(s)"),
@@ -1241,7 +1225,7 @@ printer_configure_async (PpNewPrinter *new_printer)
MECHANISM_BUS,
"PrinterSetEnabled",
g_variant_new ("(sb)",
- priv->name,
+ new_printer->name,
TRUE),
G_VARIANT_TYPE ("(s)"),
G_DBUS_CALL_FLAGS_NONE,
@@ -1264,10 +1248,10 @@ printer_configure_async (PpNewPrinter *new_printer)
}
/* Run autoconfiguration of printer */
- if (!priv->is_network_device)
+ if (!new_printer->is_network_device)
{
PpMaintenanceCommand *command;
- command = pp_maintenance_command_new (priv->name,
+ command = pp_maintenance_command_new (new_printer->name,
"autoconfigure",
NULL,
/* Translators: Name of job which makes printer to autoconfigure itself */
@@ -1283,18 +1267,18 @@ printer_configure_async (PpNewPrinter *new_printer)
values = g_new0 (gchar *, 2);
values[0] = g_strdup (get_page_size_from_locale ());
- printer_add_option_async (priv->name, "PageSize", values, FALSE, NULL, pao_cb, data);
+ printer_add_option_async (new_printer->name, "PageSize", values, FALSE, NULL, pao_cb, data);
g_strfreev (values);
/* Install missing executables for printer */
ime_data = g_new0 (IMEData, 1);
- ime_data->window_id = priv->window_id;
+ ime_data->window_id = new_printer->window_id;
if (data->cancellable)
ime_data->cancellable = g_object_ref (data->cancellable);
ime_data->user_data = data;
- printer_get_ppd_async (priv->name,
+ printer_get_ppd_async (new_printer->name,
NULL,
0,
printer_get_ppd_cb,
@@ -1307,18 +1291,17 @@ pp_new_printer_add_async (PpNewPrinter *printer,
GAsyncReadyCallback callback,
gpointer user_data)
{
- PpNewPrinterPrivate *priv = printer->priv;
g_autoptr(GTask) task = NULL;
- priv->task = g_task_new (printer, cancellable, callback, user_data);
- priv->cancellable = g_object_ref (cancellable);
+ printer->task = g_task_new (printer, cancellable, callback, user_data);
+ printer->cancellable = g_object_ref (cancellable);
- if (priv->ppd_name || priv->ppd_file_name)
+ if (printer->ppd_name || printer->ppd_file_name)
{
/* We have everything we need */
printer_add_real_async (printer);
}
- else if (priv->device_id)
+ else if (printer->device_id)
{
GDBusConnection *bus;
g_autoptr(GError) error = NULL;
@@ -1333,9 +1316,9 @@ pp_new_printer_add_async (PpNewPrinter *printer,
SCP_IFACE,
"GetBestDrivers",
g_variant_new ("(sss)",
- priv->device_id,
- priv->make_and_model ? priv->make_and_model : "",
- priv->device_uri ? priv->device_uri : ""),
+ printer->device_id,
+ printer->make_and_model ? printer->make_and_model : "",
+ printer->device_uri ? printer->device_uri : ""),
G_VARIANT_TYPE ("(a(ss))"),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT_LONG,
@@ -1349,12 +1332,12 @@ pp_new_printer_add_async (PpNewPrinter *printer,
_pp_new_printer_add_async_cb (FALSE, printer);
}
}
- else if (priv->original_name && priv->host_name)
+ else if (printer->original_name && printer->host_name)
{
/* Try to get PPD from remote CUPS */
- printer_get_ppd_async (priv->original_name,
- priv->host_name,
- priv->host_port,
+ printer_get_ppd_async (printer->original_name,
+ printer->host_name,
+ printer->host_port,
printer_add_async_scb4,
printer);
}
diff --git a/panels/printers/pp-new-printer.h b/panels/printers/pp-new-printer.h
index 83bcad41a..2f70d4531 100644
--- a/panels/printers/pp-new-printer.h
+++ b/panels/printers/pp-new-printer.h
@@ -26,29 +26,9 @@
G_BEGIN_DECLS
-#define PP_TYPE_NEW_PRINTER (pp_new_printer_get_type ())
-#define PP_NEW_PRINTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PP_TYPE_NEW_PRINTER, PpNewPrinter))
-#define PP_NEW_PRINTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PP_TYPE_NEW_PRINTER, PpNewPrinterClass))
-#define PP_IS_NEW_PRINTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PP_TYPE_NEW_PRINTER))
-#define PP_IS_NEW_PRINTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PP_TYPE_NEW_PRINTER))
-#define PP_NEW_PRINTER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PP_TYPE_NEW_PRINTER, PpNewPrinterClass))
+#define PP_TYPE_NEW_PRINTER (pp_new_printer_get_type ())
+G_DECLARE_FINAL_TYPE (PpNewPrinter, pp_new_printer, PP, NEW_PRINTER, GObject)
-typedef struct _PpNewPrinter PpNewPrinter;
-typedef struct _PpNewPrinterClass PpNewPrinterClass;
-typedef struct _PpNewPrinterPrivate PpNewPrinterPrivate;
-
-struct _PpNewPrinter
-{
- GObject parent_instance;
- PpNewPrinterPrivate *priv;
-};
-
-struct _PpNewPrinterClass
-{
- GObjectClass parent_class;
-};
-
-GType pp_new_printer_get_type (void) G_GNUC_CONST;
PpNewPrinter *pp_new_printer_new (void);
void pp_new_printer_add_async (PpNewPrinter *host,
diff --git a/panels/printers/pp-ppd-option-widget.c b/panels/printers/pp-ppd-option-widget.c
index 383823af9..a592a9b1e 100644
--- a/panels/printers/pp-ppd-option-widget.c
+++ b/panels/printers/pp-ppd-option-widget.c
@@ -29,17 +29,16 @@
#include "pp-ppd-option-widget.h"
#include "pp-utils.h"
-#define PP_PPD_OPTION_WIDGET_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), PP_TYPE_PPD_OPTION_WIDGET, PpPPDOptionWidgetPrivate))
-
static void pp_ppd_option_widget_finalize (GObject *object);
static gboolean construct_widget (PpPPDOptionWidget *widget);
static void update_widget (PpPPDOptionWidget *widget);
static void update_widget_real (PpPPDOptionWidget *widget);
-struct PpPPDOptionWidgetPrivate
+struct _PpPPDOptionWidget
{
+ GtkBox parent_instance;
+
GtkWidget *switch_button;
GtkWidget *combo;
GtkWidget *image;
@@ -140,77 +139,71 @@ pp_ppd_option_widget_class_init (PpPPDOptionWidgetClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->finalize = pp_ppd_option_widget_finalize;
-
- g_type_class_add_private (class, sizeof (PpPPDOptionWidgetPrivate));
}
static void
pp_ppd_option_widget_init (PpPPDOptionWidget *widget)
{
- PpPPDOptionWidgetPrivate *priv;
-
gtk_orientable_set_orientation (GTK_ORIENTABLE (widget),
GTK_ORIENTATION_HORIZONTAL);
- priv = widget->priv = PP_PPD_OPTION_WIDGET_GET_PRIVATE (widget);
- priv->switch_button = NULL;
- priv->combo = NULL;
- priv->image = NULL;
- priv->box = NULL;
+ widget->switch_button = NULL;
+ widget->combo = NULL;
+ widget->image = NULL;
+ widget->box = NULL;
- priv->printer_name = NULL;
- priv->option_name = NULL;
+ widget->printer_name = NULL;
+ widget->option_name = NULL;
- priv->destination = NULL;
- priv->destination_set = FALSE;
+ widget->destination = NULL;
+ widget->destination_set = FALSE;
- priv->ppd_filename = NULL;
- priv->ppd_filename_set = FALSE;
+ widget->ppd_filename = NULL;
+ widget->ppd_filename_set = FALSE;
}
static void
pp_ppd_option_widget_finalize (GObject *object)
{
PpPPDOptionWidget *widget = PP_PPD_OPTION_WIDGET (object);
- PpPPDOptionWidgetPrivate *priv = widget->priv;
- if (priv)
+ if (widget->destination)
{
- if (priv->option)
+ if (widget->option)
{
- cups_option_free (priv->option);
- priv->option = NULL;
+ cups_option_free (widget->option);
+ widget->option = NULL;
}
- if (priv->printer_name)
+ if (widget->printer_name)
{
- g_free (priv->printer_name);
- priv->printer_name = NULL;
+ g_free (widget->printer_name);
+ widget->printer_name = NULL;
}
- if (priv->option_name)
+ if (widget->option_name)
{
- g_free (priv->option_name);
- priv->option_name = NULL;
+ g_free (widget->option_name);
+ widget->option_name = NULL;
}
- if (priv->destination)
+ if (widget->destination)
{
- cupsFreeDests (1, priv->destination);
- priv->destination = NULL;
+ cupsFreeDests (1, widget->destination);
+ widget->destination = NULL;
}
- if (priv->ppd_filename)
+ if (widget->ppd_filename)
{
- g_unlink (priv->ppd_filename);
- g_free (priv->ppd_filename);
- priv->ppd_filename = NULL;
+ g_unlink (widget->ppd_filename);
+ g_free (widget->ppd_filename);
+ widget->ppd_filename = NULL;
}
- if (priv->cancellable)
+ if (widget->cancellable)
{
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
+ g_cancellable_cancel (widget->cancellable);
+ g_object_unref (widget->cancellable);
}
}
@@ -237,18 +230,15 @@ GtkWidget *
pp_ppd_option_widget_new (ppd_option_t *option,
const gchar *printer_name)
{
- PpPPDOptionWidgetPrivate *priv;
PpPPDOptionWidget *widget = NULL;
if (option && printer_name)
{
widget = g_object_new (PP_TYPE_PPD_OPTION_WIDGET, NULL);
- priv = PP_PPD_OPTION_WIDGET_GET_PRIVATE (widget);
-
- priv->printer_name = g_strdup (printer_name);
- priv->option = cups_option_copy (option);
- priv->option_name = g_strdup (option->keyword);
+ widget->printer_name = g_strdup (printer_name);
+ widget->option = cups_option_copy (option);
+ widget->option_name = g_strdup (option->keyword);
if (construct_widget (widget))
{
@@ -371,10 +361,9 @@ printer_add_option_async_cb (gboolean success,
gpointer user_data)
{
PpPPDOptionWidget *widget = (PpPPDOptionWidget *) user_data;
- PpPPDOptionWidgetPrivate *priv = widget->priv;
update_widget (user_data);
- g_clear_object (&priv->cancellable);
+ g_clear_object (&widget->cancellable);
}
static void
@@ -382,7 +371,6 @@ switch_changed_cb (GtkWidget *switch_button,
GParamSpec *pspec,
PpPPDOptionWidget *widget)
{
- PpPPDOptionWidgetPrivate *priv = widget->priv;
gchar **values;
values = g_new0 (gchar *, 2);
@@ -392,18 +380,18 @@ switch_changed_cb (GtkWidget *switch_button,
else
values[0] = g_strdup ("False");
- if (priv->cancellable)
+ if (widget->cancellable)
{
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
+ g_cancellable_cancel (widget->cancellable);
+ g_object_unref (widget->cancellable);
}
- priv->cancellable = g_cancellable_new ();
- printer_add_option_async (priv->printer_name,
- priv->option_name,
+ widget->cancellable = g_cancellable_new ();
+ printer_add_option_async (widget->printer_name,
+ widget->option_name,
values,
FALSE,
- priv->cancellable,
+ widget->cancellable,
printer_add_option_async_cb,
widget);
@@ -414,24 +402,23 @@ static void
combo_changed_cb (GtkWidget *combo,
PpPPDOptionWidget *widget)
{
- PpPPDOptionWidgetPrivate *priv = widget->priv;
gchar **values;
values = g_new0 (gchar *, 2);
values[0] = combo_box_get (combo);
- if (priv->cancellable)
+ if (widget->cancellable)
{
- g_cancellable_cancel (priv->cancellable);
- g_object_unref (priv->cancellable);
+ g_cancellable_cancel (widget->cancellable);
+ g_object_unref (widget->cancellable);
}
- priv->cancellable = g_cancellable_new ();
- printer_add_option_async (priv->printer_name,
- priv->option_name,
+ widget->cancellable = g_cancellable_new ();
+ printer_add_option_async (widget->printer_name,
+ widget->option_name,
values,
FALSE,
- priv->cancellable,
+ widget->cancellable,
printer_add_option_async_cb,
widget);
@@ -441,57 +428,56 @@ combo_changed_cb (GtkWidget *combo,
static gboolean
construct_widget (PpPPDOptionWidget *widget)
{
- PpPPDOptionWidgetPrivate *priv = widget->priv;
gint i;
/* Don't show options which has only one choice */
- if (priv->option && priv->option->num_choices > 1)
+ if (widget->option && widget->option->num_choices > 1)
{
- switch (priv->option->ui)
+ switch (widget->option->ui)
{
case PPD_UI_BOOLEAN:
- priv->switch_button = gtk_switch_new ();
- g_signal_connect (priv->switch_button, "notify::active", G_CALLBACK (switch_changed_cb),
widget);
- gtk_box_pack_start (GTK_BOX (widget), priv->switch_button, FALSE, FALSE, 0);
+ widget->switch_button = gtk_switch_new ();
+ g_signal_connect (widget->switch_button, "notify::active", G_CALLBACK (switch_changed_cb),
widget);
+ gtk_box_pack_start (GTK_BOX (widget), widget->switch_button, FALSE, FALSE, 0);
break;
case PPD_UI_PICKONE:
- priv->combo = combo_box_new ();
+ widget->combo = combo_box_new ();
- for (i = 0; i < priv->option->num_choices; i++)
+ for (i = 0; i < widget->option->num_choices; i++)
{
- combo_box_append (priv->combo,
- ppd_choice_translate (&priv->option->choices[i]),
- priv->option->choices[i].choice);
+ combo_box_append (widget->combo,
+ ppd_choice_translate (&widget->option->choices[i]),
+ widget->option->choices[i].choice);
}
- gtk_box_pack_start (GTK_BOX (widget), priv->combo, FALSE, FALSE, 0);
- g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
+ gtk_box_pack_start (GTK_BOX (widget), widget->combo, FALSE, FALSE, 0);
+ g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
break;
case PPD_UI_PICKMANY:
- priv->combo = combo_box_new ();
+ widget->combo = combo_box_new ();
- for (i = 0; i < priv->option->num_choices; i++)
+ for (i = 0; i < widget->option->num_choices; i++)
{
- combo_box_append (priv->combo,
- ppd_choice_translate (&priv->option->choices[i]),
- priv->option->choices[i].choice);
+ combo_box_append (widget->combo,
+ ppd_choice_translate (&widget->option->choices[i]),
+ widget->option->choices[i].choice);
}
- gtk_box_pack_start (GTK_BOX (widget), priv->combo, TRUE, TRUE, 0);
- g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
+ gtk_box_pack_start (GTK_BOX (widget), widget->combo, TRUE, TRUE, 0);
+ g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
break;
default:
break;
}
- priv->image = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_MENU);
- if (!priv->image)
- priv->image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (widget), priv->image, FALSE, FALSE, 0);
- gtk_widget_set_no_show_all (GTK_WIDGET (priv->image), TRUE);
+ widget->image = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_MENU);
+ if (!widget->image)
+ widget->image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (widget), widget->image, FALSE, FALSE, 0);
+ gtk_widget_set_no_show_all (GTK_WIDGET (widget->image), TRUE);
return TRUE;
}
@@ -504,21 +490,20 @@ construct_widget (PpPPDOptionWidget *widget)
static void
update_widget_real (PpPPDOptionWidget *widget)
{
- PpPPDOptionWidgetPrivate *priv = widget->priv;
ppd_option_t *option = NULL, *iter;
ppd_file_t *ppd_file;
gchar *value = NULL;
gint i;
- if (priv->option)
+ if (widget->option)
{
- option = cups_option_copy (priv->option);
- cups_option_free (priv->option);
- priv->option = NULL;
+ option = cups_option_copy (widget->option);
+ cups_option_free (widget->option);
+ widget->option = NULL;
}
- else if (priv->ppd_filename)
+ else if (widget->ppd_filename)
{
- ppd_file = ppdOpenFile (priv->ppd_filename);
+ ppd_file = ppdOpenFile (widget->ppd_filename);
ppdLocalize (ppd_file);
if (ppd_file)
@@ -527,7 +512,7 @@ update_widget_real (PpPPDOptionWidget *widget)
for (iter = ppdFirstOption(ppd_file); iter; iter = ppdNextOption(ppd_file))
{
- if (g_str_equal (iter->keyword, priv->option_name))
+ if (g_str_equal (iter->keyword, widget->option_name))
{
option = cups_option_copy (iter);
break;
@@ -537,9 +522,9 @@ update_widget_real (PpPPDOptionWidget *widget)
ppdClose (ppd_file);
}
- g_unlink (priv->ppd_filename);
- g_free (priv->ppd_filename);
- priv->ppd_filename = NULL;
+ g_unlink (widget->ppd_filename);
+ g_free (widget->ppd_filename);
+ widget->ppd_filename = NULL;
}
if (option)
@@ -556,24 +541,24 @@ update_widget_real (PpPPDOptionWidget *widget)
switch (option->ui)
{
case PPD_UI_BOOLEAN:
- g_signal_handlers_block_by_func (priv->switch_button, switch_changed_cb, widget);
+ g_signal_handlers_block_by_func (widget->switch_button, switch_changed_cb, widget);
if (g_ascii_strcasecmp (value, "True") == 0)
- gtk_switch_set_active (GTK_SWITCH (priv->switch_button), TRUE);
+ gtk_switch_set_active (GTK_SWITCH (widget->switch_button), TRUE);
else
- gtk_switch_set_active (GTK_SWITCH (priv->switch_button), FALSE);
- g_signal_handlers_unblock_by_func (priv->switch_button, switch_changed_cb, widget);
+ gtk_switch_set_active (GTK_SWITCH (widget->switch_button), FALSE);
+ g_signal_handlers_unblock_by_func (widget->switch_button, switch_changed_cb, widget);
break;
case PPD_UI_PICKONE:
- g_signal_handlers_block_by_func (priv->combo, combo_changed_cb, widget);
- combo_box_set (priv->combo, value);
- g_signal_handlers_unblock_by_func (priv->combo, combo_changed_cb, widget);
+ g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
+ combo_box_set (widget->combo, value);
+ g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
break;
case PPD_UI_PICKMANY:
- g_signal_handlers_block_by_func (priv->combo, combo_changed_cb, widget);
- combo_box_set (priv->combo, value);
- g_signal_handlers_unblock_by_func (priv->combo, combo_changed_cb, widget);
+ g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
+ combo_box_set (widget->combo, value);
+ g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
break;
default:
@@ -584,9 +569,9 @@ update_widget_real (PpPPDOptionWidget *widget)
}
if (option->conflicted)
- gtk_widget_show (priv->image);
+ gtk_widget_show (widget->image);
else
- gtk_widget_hide (priv->image);
+ gtk_widget_hide (widget->image);
}
cups_option_free (option);
@@ -597,15 +582,14 @@ get_named_dest_cb (cups_dest_t *dest,
gpointer user_data)
{
PpPPDOptionWidget *widget = (PpPPDOptionWidget *) user_data;
- PpPPDOptionWidgetPrivate *priv = widget->priv;
- if (priv->destination)
- cupsFreeDests (1, priv->destination);
+ if (widget->destination)
+ cupsFreeDests (1, widget->destination);
- priv->destination = dest;
- priv->destination_set = TRUE;
+ widget->destination = dest;
+ widget->destination_set = TRUE;
- if (priv->ppd_filename_set)
+ if (widget->ppd_filename_set)
{
update_widget_real (widget);
}
@@ -616,18 +600,17 @@ printer_get_ppd_cb (const gchar *ppd_filename,
gpointer user_data)
{
PpPPDOptionWidget *widget = (PpPPDOptionWidget *) user_data;
- PpPPDOptionWidgetPrivate *priv = widget->priv;
- if (priv->ppd_filename)
+ if (widget->ppd_filename)
{
- g_unlink (priv->ppd_filename);
- g_free (priv->ppd_filename);
+ g_unlink (widget->ppd_filename);
+ g_free (widget->ppd_filename);
}
- priv->ppd_filename = g_strdup (ppd_filename);
- priv->ppd_filename_set = TRUE;
+ widget->ppd_filename = g_strdup (ppd_filename);
+ widget->ppd_filename_set = TRUE;
- if (priv->destination_set)
+ if (widget->destination_set)
{
update_widget_real (widget);
}
@@ -636,16 +619,14 @@ printer_get_ppd_cb (const gchar *ppd_filename,
static void
update_widget (PpPPDOptionWidget *widget)
{
- PpPPDOptionWidgetPrivate *priv = widget->priv;
-
- priv->ppd_filename_set = FALSE;
- priv->destination_set = FALSE;
+ widget->ppd_filename_set = FALSE;
+ widget->destination_set = FALSE;
- get_named_dest_async (priv->printer_name,
+ get_named_dest_async (widget->printer_name,
get_named_dest_cb,
widget);
- printer_get_ppd_async (priv->printer_name,
+ printer_get_ppd_async (widget->printer_name,
NULL,
0,
printer_get_ppd_cb,
diff --git a/panels/printers/pp-ppd-option-widget.h b/panels/printers/pp-ppd-option-widget.h
index 60f38109c..2216a8aa9 100644
--- a/panels/printers/pp-ppd-option-widget.h
+++ b/panels/printers/pp-ppd-option-widget.h
@@ -27,32 +27,8 @@
G_BEGIN_DECLS
-#define PP_TYPE_PPD_OPTION_WIDGET (pp_ppd_option_widget_get_type ())
-#define PP_PPD_OPTION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
PP_TYPE_PPD_OPTION_WIDGET, PpPPDOptionWidget))
-#define PP_PPD_OPTION_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
PP_TYPE_PPD_OPTION_WIDGET, PpPPDOptionWidgetClass))
-#define PP_IS_PPD_OPTION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
PP_TYPE_PPD_OPTION_WIDGET))
-#define PP_IS_PPD_OPTION_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
PP_TYPE_PPD_OPTION_WIDGET))
-#define PP_PPD_OPTION_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
PP_TYPE_PPD_OPTION_WIDGET, PpPPDOptionWidgetClass))
-
-typedef struct _PpPPDOptionWidget PpPPDOptionWidget;
-typedef struct _PpPPDOptionWidgetClass PpPPDOptionWidgetClass;
-typedef struct PpPPDOptionWidgetPrivate PpPPDOptionWidgetPrivate;
-
-struct _PpPPDOptionWidget
-{
- GtkHBox parent_instance;
-
- PpPPDOptionWidgetPrivate *priv;
-};
-
-struct _PpPPDOptionWidgetClass
-{
- GtkHBoxClass parent_class;
-
- void (*changed) (PpPPDOptionWidget *widget);
-};
-
-GType pp_ppd_option_widget_get_type (void) G_GNUC_CONST;
+#define PP_TYPE_PPD_OPTION_WIDGET (pp_ppd_option_widget_get_type ())
+G_DECLARE_FINAL_TYPE (PpPPDOptionWidget, pp_ppd_option_widget, PP, PPD_OPTION_WIDGET, GtkBox)
GtkWidget *pp_ppd_option_widget_new (ppd_option_t *source,
const gchar *printer_name);
diff --git a/panels/printers/pp-print-device.c b/panels/printers/pp-print-device.c
index ec22e3b64..a75cbe394 100644
--- a/panels/printers/pp-print-device.c
+++ b/panels/printers/pp-print-device.c
@@ -20,10 +20,10 @@
#include "pp-print-device.h"
-G_DEFINE_TYPE (PpPrintDevice, pp_print_device, G_TYPE_OBJECT);
-
-struct _PpPrintDevicePrivate
+struct _PpPrintDevice
{
+ GObject parent_instance;
+
gchar *device_name;
gchar *display_name;
gchar *device_original_name;
@@ -40,6 +40,8 @@ struct _PpPrintDevicePrivate
gboolean is_network_device;
};
+G_DEFINE_TYPE (PpPrintDevice, pp_print_device, G_TYPE_OBJECT);
+
enum
{
PROP_0 = 0,
@@ -62,20 +64,18 @@ enum
static void
pp_print_device_finalize (GObject *object)
{
- PpPrintDevicePrivate *priv;
-
- priv = PP_PRINT_DEVICE (object)->priv;
+ PpPrintDevice *self = PP_PRINT_DEVICE (object);
- g_clear_pointer (&priv->device_name, g_free);
- g_clear_pointer (&priv->display_name, g_free);
- g_clear_pointer (&priv->device_original_name, g_free);
- g_clear_pointer (&priv->device_make_and_model, g_free);
- g_clear_pointer (&priv->device_location, g_free);
- g_clear_pointer (&priv->device_info, g_free);
- g_clear_pointer (&priv->device_uri, g_free);
- g_clear_pointer (&priv->device_id, g_free);
- g_clear_pointer (&priv->device_ppd, g_free);
- g_clear_pointer (&priv->host_name, g_free);
+ g_clear_pointer (&self->device_name, g_free);
+ g_clear_pointer (&self->display_name, g_free);
+ g_clear_pointer (&self->device_original_name, g_free);
+ g_clear_pointer (&self->device_make_and_model, g_free);
+ g_clear_pointer (&self->device_location, g_free);
+ g_clear_pointer (&self->device_info, g_free);
+ g_clear_pointer (&self->device_uri, g_free);
+ g_clear_pointer (&self->device_id, g_free);
+ g_clear_pointer (&self->device_ppd, g_free);
+ g_clear_pointer (&self->host_name, g_free);
G_OBJECT_CLASS (pp_print_device_parent_class)->finalize (object);
}
@@ -86,53 +86,51 @@ pp_print_device_get_property (GObject *object,
GValue *value,
GParamSpec *param_spec)
{
- PpPrintDevice *self;
-
- self = PP_PRINT_DEVICE (object);
+ PpPrintDevice *self = PP_PRINT_DEVICE (object);
switch (prop_id)
{
case PROP_DEVICE_NAME:
- g_value_set_string (value, self->priv->device_name);
+ g_value_set_string (value, self->device_name);
break;
case PROP_DISPLAY_NAME:
- g_value_set_string (value, self->priv->display_name);
+ g_value_set_string (value, self->display_name);
break;
case PROP_DEVICE_ORIGINAL_NAME:
- g_value_set_string (value, self->priv->device_original_name);
+ g_value_set_string (value, self->device_original_name);
break;
case PROP_DEVICE_MAKE_AND_MODEL:
- g_value_set_string (value, self->priv->device_make_and_model);
+ g_value_set_string (value, self->device_make_and_model);
break;
case PROP_DEVICE_LOCATION:
- g_value_set_string (value, self->priv->device_location);
+ g_value_set_string (value, self->device_location);
break;
case PROP_DEVICE_INFO:
- g_value_set_string (value, self->priv->device_info);
+ g_value_set_string (value, self->device_info);
break;
case PROP_DEVICE_URI:
- g_value_set_string (value, self->priv->device_uri);
+ g_value_set_string (value, self->device_uri);
break;
case PROP_DEVICE_ID:
- g_value_set_string (value, self->priv->device_id);
+ g_value_set_string (value, self->device_id);
break;
case PROP_DEVICE_PPD:
- g_value_set_string (value, self->priv->device_ppd);
+ g_value_set_string (value, self->device_ppd);
break;
case PROP_HOST_NAME:
- g_value_set_string (value, self->priv->host_name);
+ g_value_set_string (value, self->host_name);
break;
case PROP_HOST_PORT:
- g_value_set_int (value, self->priv->host_port);
+ g_value_set_int (value, self->host_port);
break;
case PROP_IS_AUTHENTICATED_SERVER:
- g_value_set_boolean (value, self->priv->is_authenticated_server);
+ g_value_set_boolean (value, self->is_authenticated_server);
break;
case PROP_ACQUISITION_METHOD:
- g_value_set_int (value, self->priv->acquisition_method);
+ g_value_set_int (value, self->acquisition_method);
break;
case PROP_IS_NETWORK_DEVICE:
- g_value_set_boolean (value, self->priv->is_network_device);
+ g_value_set_boolean (value, self->is_network_device);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -153,56 +151,56 @@ pp_print_device_set_property (GObject *object,
switch (prop_id)
{
case PROP_DEVICE_NAME:
- g_free (self->priv->device_name);
- self->priv->device_name = g_value_dup_string (value);
+ g_free (self->device_name);
+ self->device_name = g_value_dup_string (value);
break;
case PROP_DISPLAY_NAME:
- g_free (self->priv->display_name);
- self->priv->display_name = g_value_dup_string (value);
+ g_free (self->display_name);
+ self->display_name = g_value_dup_string (value);
break;
case PROP_DEVICE_ORIGINAL_NAME:
- g_free (self->priv->device_original_name);
- self->priv->device_original_name = g_value_dup_string (value);
+ g_free (self->device_original_name);
+ self->device_original_name = g_value_dup_string (value);
break;
case PROP_DEVICE_MAKE_AND_MODEL:
- g_free (self->priv->device_make_and_model);
- self->priv->device_make_and_model = g_value_dup_string (value);
+ g_free (self->device_make_and_model);
+ self->device_make_and_model = g_value_dup_string (value);
break;
case PROP_DEVICE_LOCATION:
- g_free (self->priv->device_location);
- self->priv->device_location = g_value_dup_string (value);
+ g_free (self->device_location);
+ self->device_location = g_value_dup_string (value);
break;
case PROP_DEVICE_INFO:
- g_free (self->priv->device_info);
- self->priv->device_info = g_value_dup_string (value);
+ g_free (self->device_info);
+ self->device_info = g_value_dup_string (value);
break;
case PROP_DEVICE_URI:
- g_free (self->priv->device_uri);
- self->priv->device_uri = g_value_dup_string (value);
+ g_free (self->device_uri);
+ self->device_uri = g_value_dup_string (value);
break;
case PROP_DEVICE_ID:
- g_free (self->priv->device_id);
- self->priv->device_id = g_value_dup_string (value);
+ g_free (self->device_id);
+ self->device_id = g_value_dup_string (value);
break;
case PROP_DEVICE_PPD:
- g_free (self->priv->device_ppd);
- self->priv->device_ppd = g_value_dup_string (value);
+ g_free (self->device_ppd);
+ self->device_ppd = g_value_dup_string (value);
break;
case PROP_HOST_NAME:
- g_free (self->priv->host_name);
- self->priv->host_name = g_value_dup_string (value);
+ g_free (self->host_name);
+ self->host_name = g_value_dup_string (value);
break;
case PROP_HOST_PORT:
- self->priv->host_port = g_value_get_int (value);
+ self->host_port = g_value_get_int (value);
break;
case PROP_IS_AUTHENTICATED_SERVER:
- self->priv->is_authenticated_server = g_value_get_boolean (value);
+ self->is_authenticated_server = g_value_get_boolean (value);
break;
case PROP_ACQUISITION_METHOD:
- self->priv->acquisition_method = g_value_get_int (value);
+ self->acquisition_method = g_value_get_int (value);
break;
case PROP_IS_NETWORK_DEVICE:
- self->priv->is_network_device = g_value_get_boolean (value);
+ self->is_network_device = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
@@ -217,8 +215,6 @@ pp_print_device_class_init (PpPrintDeviceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (PpPrintDevicePrivate));
-
gobject_class->set_property = pp_print_device_set_property;
gobject_class->get_property = pp_print_device_get_property;
@@ -340,9 +336,6 @@ pp_print_device_class_init (PpPrintDeviceClass *klass)
static void
pp_print_device_init (PpPrintDevice *printer)
{
- printer->priv = G_TYPE_INSTANCE_GET_PRIVATE (printer,
- PP_TYPE_PRINT_DEVICE,
- PpPrintDevicePrivate);
}
PpPrintDevice *
@@ -354,85 +347,85 @@ pp_print_device_new ()
gchar *
pp_print_device_get_device_name (PpPrintDevice *device)
{
- return device->priv->device_name;
+ return device->device_name;
}
gchar *
pp_print_device_get_display_name (PpPrintDevice *device)
{
- return device->priv->display_name;
+ return device->display_name;
}
gchar *
pp_print_device_get_device_original_name (PpPrintDevice *device)
{
- return device->priv->device_original_name;
+ return device->device_original_name;
}
gchar *
pp_print_device_get_device_make_and_model (PpPrintDevice *device)
{
- return device->priv->device_make_and_model;
+ return device->device_make_and_model;
}
gchar *
pp_print_device_get_device_location (PpPrintDevice *device)
{
- return device->priv->device_location;
+ return device->device_location;
}
gchar *
pp_print_device_get_device_info (PpPrintDevice *device)
{
- return device->priv->device_info;
+ return device->device_info;
}
gchar *
pp_print_device_get_device_uri (PpPrintDevice *device)
{
- return device->priv->device_uri;
+ return device->device_uri;
}
gchar *
pp_print_device_get_device_id (PpPrintDevice *device)
{
- return device->priv->device_id;
+ return device->device_id;
}
gchar *
pp_print_device_get_device_ppd (PpPrintDevice *device)
{
- return device->priv->device_ppd;
+ return device->device_ppd;
}
gchar *
pp_print_device_get_host_name (PpPrintDevice *device)
{
- return device->priv->host_name;
+ return device->host_name;
}
gint
pp_print_device_get_host_port (PpPrintDevice *device)
{
- return device->priv->host_port;
+ return device->host_port;
}
gboolean
pp_print_device_is_authenticated_server (PpPrintDevice *device)
{
- return device->priv->is_authenticated_server;
+ return device->is_authenticated_server;
}
gint
pp_print_device_get_acquisition_method (PpPrintDevice *device)
{
- return device->priv->acquisition_method;
+ return device->acquisition_method;
}
gboolean
pp_print_device_is_network_device (PpPrintDevice *device)
{
- return device->priv->is_network_device;
+ return device->is_network_device;
}
PpPrintDevice *
diff --git a/panels/printers/pp-print-device.h b/panels/printers/pp-print-device.h
index fde779317..ecf07a3ce 100644
--- a/panels/printers/pp-print-device.h
+++ b/panels/printers/pp-print-device.h
@@ -29,14 +29,6 @@ G_BEGIN_DECLS
#define PP_TYPE_PRINT_DEVICE (pp_print_device_get_type ())
G_DECLARE_FINAL_TYPE (PpPrintDevice, pp_print_device, PP, PRINT_DEVICE, GObject)
-typedef struct _PpPrintDevicePrivate PpPrintDevicePrivate;
-
-struct _PpPrintDevice
-{
- GObject parent_instance;
- PpPrintDevicePrivate *priv;
-};
-
PpPrintDevice *pp_print_device_new (void);
PpPrintDevice *pp_print_device_copy (PpPrintDevice *device);
gchar *pp_print_device_get_device_name (PpPrintDevice *device);
diff --git a/panels/printers/pp-printer-entry.c b/panels/printers/pp-printer-entry.c
index 47bdb7010..b534af884 100644
--- a/panels/printers/pp-printer-entry.c
+++ b/panels/printers/pp-printer-entry.c
@@ -1087,7 +1087,7 @@ pp_printer_entry_class_init (PpPrinterEntryClass *klass)
g_signal_new ("printer-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PpPrinterEntryClass, printer_changed),
+ 0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
@@ -1095,7 +1095,7 @@ pp_printer_entry_class_init (PpPrinterEntryClass *klass)
g_signal_new ("printer-delete",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PpPrinterEntryClass, printer_delete),
+ 0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
@@ -1103,7 +1103,7 @@ pp_printer_entry_class_init (PpPrinterEntryClass *klass)
g_signal_new ("printer-renamed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PpPrinterEntryClass, printer_renamed),
+ 0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_STRING);
diff --git a/panels/printers/pp-printer-entry.h b/panels/printers/pp-printer-entry.h
index d56424ffd..215517ac1 100644
--- a/panels/printers/pp-printer-entry.h
+++ b/panels/printers/pp-printer-entry.h
@@ -24,12 +24,7 @@
#include <cups/cups.h>
#define PP_PRINTER_ENTRY_TYPE (pp_printer_entry_get_type ())
-#define PP_PRINTER_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PP_PRINTER_ENTRY_TYPE, PpPrinterEntry))
-
-typedef struct _PpPrinterEntry PpPrinterEntry;
-typedef struct _PpPrinterEntryClass PpPrinterEntryClass;
-
-GType pp_printer_entry_get_type (void);
+G_DECLARE_FINAL_TYPE (PpPrinterEntry, pp_printer_entry, PP, PRINTER_ENTRY, GtkListBoxRow)
PpPrinterEntry *pp_printer_entry_new (cups_dest_t printer,
gboolean is_authorized);
diff --git a/panels/printers/pp-printer.c b/panels/printers/pp-printer.c
index e85ad6a5c..7063e037a 100644
--- a/panels/printers/pp-printer.c
+++ b/panels/printers/pp-printer.c
@@ -26,21 +26,13 @@
#define IPP_STATE_IDLE IPP_IDLE
#endif
-typedef struct _PpPrinter PpPrinter;
-typedef struct _PpPrinterPrivate PpPrinterPrivate;
-
struct _PpPrinter
{
- GObject parent_instance;
- PpPrinterPrivate *priv;
+ GObject parent_instance;
+ gchar *printer_name;
};
-struct _PpPrinterPrivate
-{
- gchar *printer_name;
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE (PpPrinter, pp_printer, G_TYPE_OBJECT)
+G_DEFINE_TYPE (PpPrinter, pp_printer, G_TYPE_OBJECT)
enum
{
@@ -51,9 +43,9 @@ enum
static void
pp_printer_dispose (GObject *object)
{
- PpPrinterPrivate *priv = PP_PRINTER (object)->priv;
+ PpPrinter *self = PP_PRINTER (object);
- g_free (priv->printer_name);
+ g_free (self->printer_name);
G_OBJECT_CLASS (pp_printer_parent_class)->dispose (object);
}
@@ -75,7 +67,7 @@ pp_printer_get_property (GObject *object,
switch (property_id)
{
case PROP_NAME:
- g_value_set_string (value, self->priv->printer_name);
+ g_value_set_string (value, self->printer_name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -94,8 +86,8 @@ pp_printer_set_property (GObject *object,
switch (property_id)
{
case PROP_NAME:
- g_free (self->priv->printer_name);
- self->priv->printer_name = g_value_dup_string (value);
+ g_free (self->printer_name);
+ self->printer_name = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -125,9 +117,6 @@ pp_printer_class_init (PpPrinterClass *klass)
static void
pp_printer_init (PpPrinter *printer)
{
- printer->priv = G_TYPE_INSTANCE_GET_PRIVATE (printer,
- PP_TYPE_PRINTER,
- PpPrinterPrivate);
}
PpPrinter *
diff --git a/panels/printers/pp-printer.h b/panels/printers/pp-printer.h
index 80b6b96c6..17594d3c8 100644
--- a/panels/printers/pp-printer.h
+++ b/panels/printers/pp-printer.h
@@ -29,7 +29,6 @@
G_BEGIN_DECLS
#define PP_TYPE_PRINTER (pp_printer_get_type ())
-
G_DECLARE_FINAL_TYPE (PpPrinter, pp_printer, PP, PRINTER, GObject)
GType pp_printer_get_type (void) G_GNUC_CONST;
diff --git a/panels/printers/pp-samba.c b/panels/printers/pp-samba.c
index ec9330928..f79fceb36 100644
--- a/panels/printers/pp-samba.c
+++ b/panels/printers/pp-samba.c
@@ -28,8 +28,10 @@
#define POLL_DELAY 100000
-struct _PpSambaPrivate
+struct _PpSamba
{
+ PpHost parent_instance;
+
/* Auth info */
gchar *server;
gchar *share;
@@ -44,15 +46,13 @@ G_DEFINE_TYPE (PpSamba, pp_samba, PP_TYPE_HOST);
static void
pp_samba_finalize (GObject *object)
{
- PpSambaPrivate *priv;
-
- priv = PP_SAMBA (object)->priv;
+ PpSamba *self = PP_SAMBA (object);
- g_free (priv->server);
- g_free (priv->share);
- g_free (priv->workgroup);
- g_free (priv->username);
- g_free (priv->password);
+ g_free (self->server);
+ g_free (self->share);
+ g_free (self->workgroup);
+ g_free (self->username);
+ g_free (self->password);
G_OBJECT_CLASS (pp_samba_parent_class)->finalize (object);
}
@@ -62,17 +62,12 @@ pp_samba_class_init (PpSambaClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (PpSambaPrivate));
-
gobject_class->finalize = pp_samba_finalize;
}
static void
pp_samba_init (PpSamba *samba)
{
- samba->priv = G_TYPE_INSTANCE_GET_PRIVATE (samba,
- PP_TYPE_SAMBA,
- PpSambaPrivate);
}
PpSamba *
@@ -120,21 +115,19 @@ pp_samba_set_auth_info (PpSamba *samba,
const gchar *username,
const gchar *password)
{
- PpSambaPrivate *priv = samba->priv;
-
- g_free (priv->username);
+ g_free (samba->username);
if ((username != NULL) && (username[0] != '\0'))
- priv->username = g_strdup (username);
+ samba->username = g_strdup (username);
else
- priv->username = NULL;
+ samba->username = NULL;
- g_free (priv->password);
+ g_free (samba->password);
if ((password != NULL) && (password[0] != '\0'))
- priv->password = g_strdup (password);
+ samba->password = g_strdup (password);
else
- priv->password = NULL;
+ samba->password = NULL;
- priv->waiting = FALSE;
+ samba->waiting = FALSE;
}
static void
@@ -157,11 +150,11 @@ auth_fn (SMBCCTX *smb_context,
if (!data->cancelled)
{
- samba->priv->server = g_strdup (server);
- samba->priv->share = g_strdup (share);
- samba->priv->workgroup = g_strdup (workgroup);
- samba->priv->username = g_strdup (username);
- samba->priv->password = g_strdup (password);
+ samba->server = g_strdup (server);
+ samba->share = g_strdup (share);
+ samba->workgroup = g_strdup (workgroup);
+ samba->username = g_strdup (username);
+ samba->password = g_strdup (password);
source = g_idle_source_new ();
g_source_set_callback (source,
@@ -170,14 +163,14 @@ auth_fn (SMBCCTX *smb_context,
NULL);
g_source_attach (source, data->context);
- samba->priv->waiting = TRUE;
+ samba->waiting = TRUE;
/*
* smbclient needs to get authentication data
* from this synchronous callback so we are blocking
* until we get them
*/
- while (samba->priv->waiting)
+ while (samba->waiting)
{
g_usleep (POLL_DELAY);
}
@@ -185,23 +178,23 @@ auth_fn (SMBCCTX *smb_context,
/* Samba tries to call the auth_fn again if we just set the values
* to NULL when we want to cancel the authentication
*/
- if (samba->priv->username == NULL && samba->priv->password == NULL)
+ if (samba->username == NULL && samba->password == NULL)
data->cancelled = TRUE;
- if (samba->priv->username != NULL)
+ if (samba->username != NULL)
{
- if (g_strcmp0 (username, samba->priv->username) != 0)
- g_strlcpy (username, samba->priv->username, unmaxlen);
+ if (g_strcmp0 (username, samba->username) != 0)
+ g_strlcpy (username, samba->username, unmaxlen);
}
else
{
username[0] = '\0';
}
- if (samba->priv->password != NULL)
+ if (samba->password != NULL)
{
- if (g_strcmp0 (password, samba->priv->password) != 0)
- g_strlcpy (password, samba->priv->password, pwmaxlen);
+ if (g_strcmp0 (password, samba->password) != 0)
+ g_strlcpy (password, samba->password, pwmaxlen);
}
else
{
diff --git a/panels/printers/pp-samba.h b/panels/printers/pp-samba.h
index d0a5023c1..cef347a66 100644
--- a/panels/printers/pp-samba.h
+++ b/panels/printers/pp-samba.h
@@ -26,29 +26,8 @@
G_BEGIN_DECLS
-#define PP_TYPE_SAMBA (pp_samba_get_type ())
-#define PP_SAMBA(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PP_TYPE_SAMBA, PpSamba))
-#define PP_SAMBA_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PP_TYPE_SAMBA, PpSambaClass))
-#define PP_IS_SAMBA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PP_TYPE_SAMBA))
-#define PP_IS_SAMBA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PP_TYPE_SAMBA))
-#define PP_SAMBA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PP_TYPE_SAMBA, PpSambaClass))
-
-typedef struct _PpSamba PpSamba;
-typedef struct _PpSambaClass PpSambaClass;
-typedef struct _PpSambaPrivate PpSambaPrivate;
-
-struct _PpSamba
-{
- PpHost parent_instance;
- PpSambaPrivate *priv;
-};
-
-struct _PpSambaClass
-{
- PpHostClass parent_class;
-};
-
-GType pp_samba_get_type (void) G_GNUC_CONST;
+#define PP_TYPE_SAMBA (pp_samba_get_type ())
+G_DECLARE_FINAL_TYPE (PpSamba, pp_samba, PP, SAMBA, PpHost)
PpSamba *pp_samba_new (const gchar *hostname);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]