[gnome-control-center] printers: Merge device-class and is-network-device properties
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Merge device-class and is-network-device properties
- Date: Thu, 30 Jul 2015 14:28:34 +0000 (UTC)
commit 60bf057bab3935d0327eea85e4f0904ec6e794ad
Author: Marek Kasik <mkasik redhat com>
Date: Thu Jul 30 15:40:59 2015 +0200
printers: Merge device-class and is-network-device properties
'device-class' property of PpPrintDevice can contain "network"
or "direct" values. This information can be stored in already
present property 'is-network-device' as well.
https://bugzilla.gnome.org/show_bug.cgi?id=749830
panels/printers/pp-host.c | 10 ++++++----
panels/printers/pp-new-printer-dialog.c | 24 +++++++++++++-----------
panels/printers/pp-print-device.c | 25 -------------------------
panels/printers/pp-print-device.h | 1 -
panels/printers/pp-samba.c | 2 +-
panels/printers/pp-utils.c | 6 +++++-
6 files changed, 25 insertions(+), 43 deletions(-)
---
diff --git a/panels/printers/pp-host.c b/panels/printers/pp-host.c
index 02ce35a..fbfb434 100644
--- a/panels/printers/pp-host.c
+++ b/panels/printers/pp-host.c
@@ -241,6 +241,7 @@ _pp_host_get_snmp_devices_thread (GSimpleAsyncResult *res,
PpHost *host = (PpHost *) object;
PpHostPrivate *priv = host->priv;
PpPrintDevice *device;
+ gboolean is_network_device;
GSDData *data;
GError *error;
gchar **argv;
@@ -285,9 +286,10 @@ _pp_host_get_snmp_devices_thread (GSimpleAsyncResult *res,
{
device_name = g_strdup (printer_informations[3]);
device_name = g_strcanon (device_name, ALLOWED_CHARACTERS, '-');
+ is_network_device = g_strcmp0 (printer_informations[0], "network") == 0;
device = g_object_new (PP_TYPE_PRINT_DEVICE,
- "device-class", printer_informations[0],
+ "is-network-device", is_network_device,
"device-uri", printer_informations[1],
"device-make-and-model", printer_informations[2],
"device-info", printer_informations[3],
@@ -407,7 +409,7 @@ _pp_host_get_remote_cups_devices_thread (GSimpleAsyncResult *res,
dests[i].options);
device = g_object_new (PP_TYPE_PRINT_DEVICE,
- "device-class", "network",
+ "is-network-device", TRUE,
"device-uri", device_uri,
"device-name", dests[i].name,
"device-location", device_location,
@@ -518,7 +520,7 @@ jetdirect_connection_test_cb (GObject *source_object,
data->port);
device = g_object_new (PP_TYPE_PRINT_DEVICE,
- "device-class", "network",
+ "is-network-device", TRUE,
"device-uri", device_uri,
/* Translators: The found device is a JetDirect printer */
"device-name", _("JetDirect Printer"),
@@ -774,7 +776,7 @@ _pp_host_get_lpd_devices_thread (GTask *task,
found_queue);
device = g_object_new (PP_TYPE_PRINT_DEVICE,
- "device-class", "network",
+ "is-network-device", TRUE,
"device-uri", device_uri,
/* Translators: The found device is a Line Printer Daemon printer */
"device-name", _("LPD Printer"),
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 9d3f0c2..15139c6 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -534,7 +534,6 @@ add_device_to_list (PpNewPrinterDialog *dialog,
{
PpNewPrinterDialogPrivate *priv = dialog->priv;
PpPrintDevice *store_device;
- gboolean is_network_device;
gchar *canonicalized_name = NULL;
gchar *host_name;
gint acquisistion_method;
@@ -559,12 +558,10 @@ add_device_to_list (PpNewPrinterDialog *dialog,
(acquisistion_method == ACQUISITION_METHOD_JETDIRECT ||
acquisistion_method == ACQUISITION_METHOD_LPD)))
{
- is_network_device = g_strcmp0 (pp_print_device_get_device_class (device), "network") == 0;
-
store_device = pp_print_device_copy (device);
g_object_set (store_device,
"device-original-name", pp_print_device_get_device_name (device),
- "is-network-device", is_network_device,
+ "is-network-device", pp_print_device_is_network_device (device),
"show", TRUE,
NULL);
@@ -818,6 +815,7 @@ get_cups_devices_cb (GList *devices,
PpPrintDevice **all_devices;
PpPrintDevice *pp_device;
PpPrintDevice *device;
+ const gchar *device_class;
GError *error = NULL;
GList *iter;
gint length, i;
@@ -851,7 +849,7 @@ get_cups_devices_cb (GList *devices,
all_devices[i] = g_object_new (PP_TYPE_PRINT_DEVICE,
"device-id", pp_print_device_get_device_id (device),
"device-make-and-model",
pp_print_device_get_device_make_and_model (device),
- "device-class", pp_print_device_is_network_device
(device) ? "network" : "direct",
+ "is-network-device", pp_print_device_is_network_device
(device),
"device-uri", pp_print_device_get_device_uri (device),
NULL);
i++;
@@ -866,7 +864,7 @@ get_cups_devices_cb (GList *devices,
all_devices[i] = g_object_new (PP_TYPE_PRINT_DEVICE,
"device-id", pp_print_device_get_device_id (pp_device),
"device-make-and-model",
pp_print_device_get_device_make_and_model (pp_device),
- "device-class", pp_print_device_get_device_class
(pp_device),
+ "is-network-device", pp_print_device_is_network_device
(pp_device),
"device-uri", pp_print_device_get_device_uri
(pp_device),
NULL);
i++;
@@ -896,11 +894,15 @@ get_cups_devices_cb (GList *devices,
"device-make-and-model",
pp_print_device_get_device_make_and_model
(all_devices[i]));
- if (pp_print_device_get_device_class (all_devices[i]))
- g_variant_builder_add (&device_hash,
- "{ss}",
- "device-class",
- pp_print_device_get_device_class (all_devices[i]));
+ if (pp_print_device_is_network_device (all_devices[i]))
+ device_class = "network";
+ else
+ device_class = "direct";
+
+ g_variant_builder_add (&device_hash,
+ "{ss}",
+ "device-class",
+ device_class);
g_variant_builder_add (&device_list,
"{sv}",
diff --git a/panels/printers/pp-print-device.c b/panels/printers/pp-print-device.c
index 4b1533f..bee43b0 100644
--- a/panels/printers/pp-print-device.c
+++ b/panels/printers/pp-print-device.c
@@ -28,7 +28,6 @@ struct _PpPrintDevicePrivate
gchar *display_name;
gchar *device_original_name;
gchar *device_make_and_model;
- gchar *device_class;
gchar *device_location;
gchar *device_info;
gchar *device_uri;
@@ -49,7 +48,6 @@ enum
PROP_DISPLAY_NAME,
PROP_DEVICE_ORIGINAL_NAME,
PROP_DEVICE_MAKE_AND_MODEL,
- PROP_DEVICE_CLASS,
PROP_DEVICE_LOCATION,
PROP_DEVICE_INFO,
PROP_DEVICE_URI,
@@ -74,7 +72,6 @@ pp_print_device_finalize (GObject *object)
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_class, 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);
@@ -109,9 +106,6 @@ pp_print_device_get_property (GObject *object,
case PROP_DEVICE_MAKE_AND_MODEL:
g_value_set_string (value, self->priv->device_make_and_model);
break;
- case PROP_DEVICE_CLASS:
- g_value_set_string (value, self->priv->device_class);
- break;
case PROP_DEVICE_LOCATION:
g_value_set_string (value, self->priv->device_location);
break;
@@ -179,10 +173,6 @@ pp_print_device_set_property (GObject *object,
g_free (self->priv->device_make_and_model);
self->priv->device_make_and_model = g_value_dup_string (value);
break;
- case PROP_DEVICE_CLASS:
- g_free (self->priv->device_class);
- self->priv->device_class = 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);
@@ -275,14 +265,6 @@ pp_print_device_class_init (PpPrintDeviceClass *klass)
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- PROP_DEVICE_CLASS,
- g_param_spec_string ("device-class",
- "Device class",
- "Class of the device",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class,
PROP_DEVICE_LOCATION,
g_param_spec_string ("device-location",
"Device location",
@@ -410,12 +392,6 @@ pp_print_device_get_device_make_and_model (PpPrintDevice *device)
}
gchar *
-pp_print_device_get_device_class (PpPrintDevice *device)
-{
- return device->priv->device_class;
-}
-
-gchar *
pp_print_device_get_device_location (PpPrintDevice *device)
{
return device->priv->device_location;
@@ -489,7 +465,6 @@ pp_print_device_copy (PpPrintDevice *device)
"display-name", pp_print_device_get_display_name (device),
"device-original-name", pp_print_device_get_device_original_name (device),
"device-make-and-model", pp_print_device_get_device_make_and_model (device),
- "device-class", pp_print_device_get_device_class (device),
"device-location", pp_print_device_get_device_location (device),
"device-info", pp_print_device_get_device_info (device),
"device-uri", pp_print_device_get_device_uri (device),
diff --git a/panels/printers/pp-print-device.h b/panels/printers/pp-print-device.h
index f26a0d9..82dad9b 100644
--- a/panels/printers/pp-print-device.h
+++ b/panels/printers/pp-print-device.h
@@ -43,7 +43,6 @@ gchar *pp_print_device_get_device_name (PpPrintDevice *device)
gchar *pp_print_device_get_display_name (PpPrintDevice *device);
gchar *pp_print_device_get_device_original_name (PpPrintDevice *device);
gchar *pp_print_device_get_device_make_and_model (PpPrintDevice *device);
-gchar *pp_print_device_get_device_class (PpPrintDevice *device);
gchar *pp_print_device_get_device_location (PpPrintDevice *device);
gchar *pp_print_device_get_device_info (PpPrintDevice *device);
gchar *pp_print_device_get_device_uri (PpPrintDevice *device);
diff --git a/panels/printers/pp-samba.c b/panels/printers/pp-samba.c
index 235ab6a..0aa0363 100644
--- a/panels/printers/pp-samba.c
+++ b/panels/printers/pp-samba.c
@@ -422,7 +422,7 @@ list_dir (SMBCCTX *smb_context,
device = g_object_new (PP_TYPE_PRINT_DEVICE,
"device-uri", device_uri,
- "device-class", "network",
+ "is-network-device", TRUE,
"device-info", dirent->comment,
"device-name", device_name,
"acquisition-method", data->hostname_set ?
ACQUISITION_METHOD_SAMBA_HOST : ACQUISITION_METHOD_SAMBA,
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index 3225bb9..fda88b5 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -3479,6 +3479,7 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
{
const gchar *ret_error;
GVariant *devices_variant = NULL;
+ gboolean is_network_device;
g_variant_get (output, "(&s a{ss})",
&ret_error,
@@ -3528,7 +3529,10 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
devices[index] = pp_print_device_new ();
if (g_str_has_prefix (key, "device-class"))
- g_object_set (devices[index], "device-class", value, NULL);
+ {
+ is_network_device = g_strcmp0 (value, "network") == 0;
+ g_object_set (devices[index], "is-network-device", is_network_device, NULL);
+ }
else if (g_str_has_prefix (key, "device-id"))
g_object_set (devices[index], "device-id", value, NULL);
else if (g_str_has_prefix (key, "device-info"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]