[gnome-control-center] printers: Make PpPrintDevice a regular class



commit 7b21b22eef869b4b8a0dab703387ed31fa1f1868
Author: Marek Kasik <mkasik redhat com>
Date:   Thu Jul 30 15:28:08 2015 +0200

    printers: Make PpPrintDevice a regular class
    
    Create class PpPrintDevice with properties taken
    from the original PpPrintDevice structure.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749830

 panels/printers/Makefile.am             |    6 +-
 panels/printers/pp-host.c               |  117 +++++---
 panels/printers/pp-new-printer-dialog.c |  311 ++++++++++---------
 panels/printers/pp-print-device.c       |  505 +++++++++++++++++++++++++++++++
 panels/printers/pp-print-device.h       |   61 ++++
 panels/printers/pp-samba.c              |   61 +++--
 panels/printers/pp-utils.c              |  126 +++------
 panels/printers/pp-utils.h              |   24 +--
 panels/printers/test-canonicalization.c |   20 +-
 9 files changed, 897 insertions(+), 334 deletions(-)
---
diff --git a/panels/printers/Makefile.am b/panels/printers/Makefile.am
index 3a52dfe..c386486 100644
--- a/panels/printers/Makefile.am
+++ b/panels/printers/Makefile.am
@@ -43,6 +43,8 @@ libprinters_la_SOURCES =              \
        pp-authentication-dialog.h      \
        pp-samba.c                      \
        pp-samba.h                      \
+       pp-print-device.c               \
+       pp-print-device.h               \
        cc-printers-panel.c             \
        cc-printers-panel.h
 
@@ -65,9 +67,9 @@ CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES)
 EXTRA_DIST = $(resource_files) printers.gresource.xml
 
 noinst_PROGRAMS = test-shift test-canonicalization
-test_shift_SOURCES = pp-utils.c pp-utils.h test-shift.c
+test_shift_SOURCES = pp-print-device.c pp-print-device.h pp-utils.c pp-utils.h test-shift.c
 test_shift_LDADD = $(PANEL_LIBS) $(PRINTERS_PANEL_LIBS) $(CUPS_LIBS)
-test_canonicalization_SOURCES = pp-utils.c pp-utils.h test-canonicalization.c
+test_canonicalization_SOURCES = pp-print-device.c pp-print-device.h pp-utils.c pp-utils.h 
test-canonicalization.c
 test_canonicalization_LDADD = $(PANEL_LIBS) $(PRINTERS_PANEL_LIBS) $(CUPS_LIBS)
 
 EXTRA_DIST +=                          \
diff --git a/panels/printers/pp-host.c b/panels/printers/pp-host.c
index 2bf3271..02ce35a 100644
--- a/panels/printers/pp-host.c
+++ b/panels/printers/pp-host.c
@@ -275,6 +275,7 @@ _pp_host_get_snmp_devices_thread (GSimpleAsyncResult *res,
   if (exit_status == 0 && stdout_string)
     {
       gchar **printer_informations = NULL;
+      gchar  *device_name;
       gint    length;
 
       printer_informations = line_split (stdout_string);
@@ -282,22 +283,25 @@ _pp_host_get_snmp_devices_thread (GSimpleAsyncResult *res,
 
       if (length >= 4)
         {
-          device = g_new0 (PpPrintDevice, 1);
+          device_name = g_strdup (printer_informations[3]);
+          device_name = g_strcanon (device_name, ALLOWED_CHARACTERS, '-');
 
-          device->device_class = g_strdup (printer_informations[0]);
-          device->device_uri = g_strdup (printer_informations[1]);
-          device->device_make_and_model = g_strdup (printer_informations[2]);
-          device->device_info = g_strdup (printer_informations[3]);
-          device->device_name = g_strdup (printer_informations[3]);
-          device->device_name =
-            g_strcanon (device->device_name, ALLOWED_CHARACTERS, '-');
-          device->acquisition_method = ACQUISITION_METHOD_SNMP;
+          device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                 "device-class", printer_informations[0],
+                                 "device-uri", printer_informations[1],
+                                 "device-make-and-model", printer_informations[2],
+                                 "device-info", printer_informations[3],
+                                 "acquisition-method", ACQUISITION_METHOD_SNMP,
+                                 "device-name", device_name,
+                                 NULL);
+
+          g_free (device_name);
 
           if (length >= 5 && printer_informations[4][0] != '\0')
-            device->device_id = g_strdup (printer_informations[4]);
+            g_object_set (device, "device-id", printer_informations[4], NULL);
 
           if (length >= 6 && printer_informations[5][0] != '\0')
-            device->device_location = g_strdup (printer_informations[5]);
+            g_object_set (device, "device-location", printer_informations[5], NULL);
 
           data->devices->devices = g_list_append (data->devices->devices, device);
         }
@@ -368,7 +372,9 @@ _pp_host_get_remote_cups_devices_thread (GSimpleAsyncResult *res,
   PpHost        *host = (PpHost *) object;
   PpHostPrivate *priv = host->priv;
   PpPrintDevice *device;
+  const char    *device_location;
   http_t        *http;
+  gchar         *device_uri;
   gint           num_of_devices = 0;
   gint           port;
   gint           i;
@@ -391,19 +397,27 @@ _pp_host_get_remote_cups_devices_thread (GSimpleAsyncResult *res,
         {
           for (i = 0; i < num_of_devices; i++)
             {
-              device = g_new0 (PpPrintDevice, 1);
-              device->device_class = g_strdup ("network");
-              device->device_uri = g_strdup_printf ("ipp://%s:%d/printers/%s",
-                                           priv->hostname,
-                                           port,
-                                           dests[i].name);
-              device->device_name = g_strdup (dests[i].name);
-              device->device_location = g_strdup (cupsGetOption ("printer-location",
-                                                        dests[i].num_options,
-                                                        dests[i].options));
-              device->host_name = g_strdup (priv->hostname);
-              device->host_port = port;
-              device->acquisition_method = ACQUISITION_METHOD_REMOTE_CUPS_SERVER;
+              device_uri = g_strdup_printf ("ipp://%s:%d/printers/%s",
+                                            priv->hostname,
+                                            port,
+                                            dests[i].name);
+
+              device_location = cupsGetOption ("printer-location",
+                                               dests[i].num_options,
+                                               dests[i].options);
+
+              device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                     "device-class", "network",
+                                     "device-uri", device_uri,
+                                     "device-name", dests[i].name,
+                                     "device-location", device_location,
+                                     "host-name", priv->hostname,
+                                     "host-port", port,
+                                     "acquisition-method", ACQUISITION_METHOD_REMOTE_CUPS_SERVER,
+                                     NULL);
+
+              g_free (device_uri);
+
               data->devices->devices = g_list_append (data->devices->devices, device);
             }
         }
@@ -492,21 +506,28 @@ jetdirect_connection_test_cb (GObject      *source_object,
 
   if (connection != NULL)
     {
+      gchar *device_uri;
+
       g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
       g_object_unref (connection);
 
       priv = data->host->priv;
 
-      device = g_new0 (PpPrintDevice, 1);
-      device->device_class = g_strdup ("network");
-      device->device_uri = g_strdup_printf ("socket://%s:%d",
-                                            priv->hostname,
-                                            data->port);
-      /* Translators: The found device is a JetDirect printer */
-      device->device_name = g_strdup (_("JetDirect Printer"));
-      device->host_name = g_strdup (priv->hostname);
-      device->host_port = data->port;
-      device->acquisition_method = ACQUISITION_METHOD_JETDIRECT;
+      device_uri = g_strdup_printf ("socket://%s:%d",
+                                    priv->hostname,
+                                    data->port);
+
+      device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                             "device-class", "network",
+                             "device-uri", device_uri,
+                             /* Translators: The found device is a JetDirect printer */
+                             "device-name", _("JetDirect Printer"),
+                             "host-name", priv->hostname,
+                             "host-port", data->port,
+                             "acquisition-method", ACQUISITION_METHOD_JETDIRECT,
+                             NULL);
+
+      g_free (device_uri);
 
       data->devices->devices = g_list_append (data->devices->devices, device);
     }
@@ -680,6 +701,7 @@ _pp_host_get_lpd_devices_thread (GTask        *task,
   gchar             *found_queue = NULL;
   gchar             *candidate;
   gchar             *address;
+  gchar             *device_uri;
   gint               port;
   gint               i;
 
@@ -746,17 +768,22 @@ _pp_host_get_lpd_devices_thread (GTask        *task,
 
       if (found_queue != NULL)
         {
-          device = g_new0 (PpPrintDevice, 1);
-          device->device_class = g_strdup ("network");
-          device->device_uri = g_strdup_printf ("lpd://%s:%d/%s",
-                                                priv->hostname,
-                                                port,
-                                                found_queue);
-          /* Translators: The found device is a Line Printer Daemon printer */
-          device->device_name = g_strdup (_("LPD Printer"));
-          device->host_name = g_strdup (priv->hostname);
-          device->host_port = port;
-          device->acquisition_method = ACQUISITION_METHOD_LPD;
+          device_uri = g_strdup_printf ("lpd://%s:%d/%s",
+                                        priv->hostname,
+                                        port,
+                                        found_queue);
+
+          device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                 "device-class", "network",
+                                 "device-uri", device_uri,
+                                 /* Translators: The found device is a Line Printer Daemon printer */
+                                 "device-name", _("LPD Printer"),
+                                 "host-name", priv->hostname,
+                                 "host-port", port,
+                                 "acquisition-method", ACQUISITION_METHOD_LPD,
+                                 NULL);
+
+          g_free (device_uri);
 
           result->devices = g_list_append (result->devices, device);
         }
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index ed61104..9d3f0c2 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -272,7 +272,7 @@ get_authenticated_samba_devices_cb (GObject      *source_object,
       for (iter = result->devices; iter; iter = iter->next)
         {
           device = (PpPrintDevice *) iter->data;
-          if (device->is_authenticated_server)
+          if (pp_print_device_is_authenticated_server (device))
             {
               cancelled = TRUE;
               break;
@@ -292,7 +292,7 @@ get_authenticated_samba_devices_cb (GObject      *source_object,
               if (device != NULL)
                 {
                   widget = WID ("search-entry");
-                  gtk_entry_set_text (GTK_ENTRY (widget), device->device_location);
+                  gtk_entry_set_text (GTK_ENTRY (widget), pp_print_device_get_device_location (device));
                   search_entry_activated_cb (GTK_ENTRY (widget), dialog);
                 }
             }
@@ -449,10 +449,10 @@ pp_new_printer_dialog_finalize (GObject *object)
   if (priv->builder)
     g_clear_object (&priv->builder);
 
-  g_list_free_full (priv->devices, (GDestroyNotify) pp_print_device_free);
+  g_list_free_full (priv->devices, (GDestroyNotify) g_object_unref);
   priv->devices = NULL;
 
-  g_list_free_full (priv->local_cups_devices, (GDestroyNotify) pp_print_device_free);
+  g_list_free_full (priv->local_cups_devices, (GDestroyNotify) g_object_unref);
   priv->local_cups_devices = NULL;
 
   if (priv->num_of_dests > 0)
@@ -518,10 +518,10 @@ remove_device_from_list (PpNewPrinterDialog *dialog,
   for (iter = priv->devices; iter; iter = iter->next)
     {
       device = (PpPrintDevice *) iter->data;
-      if (g_strcmp0 (device->device_name, device_name) == 0)
+      if (g_strcmp0 (pp_print_device_get_device_name (device), device_name) == 0)
         {
           priv->devices = g_list_remove_link (priv->devices, iter);
-          pp_print_device_free (iter->data);
+          g_object_unref (PP_PRINT_DEVICE (iter->data));
           g_list_free (iter);
           break;
         }
@@ -534,28 +534,39 @@ 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;
 
   if (device)
     {
-      if (device->host_name == NULL)
-        device->host_name = guess_device_hostname (device);
-
-      if (device->device_id ||
-          device->device_ppd ||
-          (device->host_name &&
-           device->acquisition_method == ACQUISITION_METHOD_REMOTE_CUPS_SERVER) ||
-           device->acquisition_method == ACQUISITION_METHOD_SAMBA_HOST ||
-           device->acquisition_method == ACQUISITION_METHOD_SAMBA ||
-          (device->device_uri &&
-           (device->acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
-            device->acquisition_method == ACQUISITION_METHOD_LPD)))
+      if (pp_print_device_get_host_name (device) == NULL)
         {
+          host_name = guess_device_hostname (device);
+          g_object_set (device, "host-name", host_name, NULL);
+          g_free (host_name);
+        }
+
+      acquisistion_method = pp_print_device_get_acquisition_method (device);
+      if (pp_print_device_get_device_id (device) ||
+          pp_print_device_get_device_ppd (device) ||
+          (pp_print_device_get_host_name (device) &&
+           acquisistion_method == ACQUISITION_METHOD_REMOTE_CUPS_SERVER) ||
+           acquisistion_method == ACQUISITION_METHOD_SAMBA_HOST ||
+           acquisistion_method == ACQUISITION_METHOD_SAMBA ||
+          (pp_print_device_get_device_uri (device) &&
+           (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_free (store_device->device_original_name);
-          store_device->device_original_name = g_strdup (device->device_name);
-          store_device->network_device = g_strcmp0 (device->device_class, "network") == 0;
-          store_device->show = TRUE;
+          g_object_set (store_device,
+                        "device-original-name", pp_print_device_get_device_name (device),
+                        "is-network-device", is_network_device,
+                        "show", TRUE,
+                        NULL);
 
           canonicalized_name = canonicalize_device_name (priv->devices,
                                                          priv->local_cups_devices,
@@ -563,24 +574,27 @@ add_device_to_list (PpNewPrinterDialog  *dialog,
                                                          priv->num_of_dests,
                                                          store_device);
 
-          g_free (store_device->display_name);
-          store_device->display_name = g_strdup (canonicalized_name);
-          g_free (store_device->device_name);
-          store_device->device_name = canonicalized_name;
+          g_object_set (store_device,
+                        "display-name", canonicalized_name,
+                        "device-name", canonicalized_name,
+                        NULL);
+
+          g_free (canonicalized_name);
 
-          if (device->acquisition_method == ACQUISITION_METHOD_DEFAULT_CUPS_SERVER)
+          if (pp_print_device_get_acquisition_method (device) == ACQUISITION_METHOD_DEFAULT_CUPS_SERVER)
             priv->local_cups_devices = g_list_append (priv->local_cups_devices, store_device);
           else
             priv->devices = g_list_append (priv->devices, store_device);
         }
-      else if (device->is_authenticated_server &&
-               device->host_name != NULL)
+      else if (pp_print_device_is_authenticated_server (device) &&
+               pp_print_device_get_host_name (device) != NULL)
         {
-          store_device = g_new0 (PpPrintDevice, 1);
-          store_device->device_name = g_strdup (device->host_name);
-          store_device->host_name = g_strdup (device->host_name);
-          store_device->is_authenticated_server = device->is_authenticated_server;
-          store_device->show = TRUE;
+          store_device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                       "device-name", pp_print_device_get_host_name (device),
+                                       "host-name", pp_print_device_get_host_name (device),
+                                       "is-authenticated-server", pp_print_device_is_authenticated_server 
(device),
+                                       "show", TRUE,
+                                       NULL);
 
           priv->devices = g_list_append (priv->devices, store_device);
         }
@@ -610,8 +624,8 @@ device_in_list (gchar *device_uri,
     {
       device = (PpPrintDevice *) iter->data;
       /* GroupPhysicalDevices returns uris without port numbers */
-      if (device->device_uri != NULL &&
-          g_str_has_prefix (device->device_uri, device_uri))
+      if (pp_print_device_get_device_uri (device) != NULL &&
+          g_str_has_prefix (pp_print_device_get_device_uri (device), device_uri))
         return device;
     }
 
@@ -681,7 +695,7 @@ group_physical_devices_cb (gchar    ***device_uris,
                       if (iter != NULL && better_device != NULL)
                         {
                           iter->data = pp_print_device_copy (better_device);
-                          pp_print_device_free (device);
+                          g_object_unref (device);
                         }
                     }
                 }
@@ -834,11 +848,12 @@ get_cups_devices_cb (GList    *devices,
                   device = (PpPrintDevice *) iter->data;
                   if (device != NULL)
                     {
-                      all_devices[i] = g_new0 (PpPrintDevice, 1);
-                      all_devices[i]->device_id = g_strdup (device->device_id);
-                      all_devices[i]->device_make_and_model = g_strdup (device->device_make_and_model);
-                      all_devices[i]->device_class = device->network_device ? g_strdup ("network") : strdup 
("direct");
-                      all_devices[i]->device_uri = g_strdup (device->device_uri);
+                      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",
+                                                     "device-uri", pp_print_device_get_device_uri (device),
+                                                     NULL);
                       i++;
                     }
                 }
@@ -848,11 +863,12 @@ get_cups_devices_cb (GList    *devices,
                   pp_device = (PpPrintDevice *) iter->data;
                   if (pp_device != NULL)
                     {
-                      all_devices[i] = g_new0 (PpPrintDevice, 1);
-                      all_devices[i]->device_id = g_strdup (pp_device->device_id);
-                      all_devices[i]->device_make_and_model = g_strdup (pp_device->device_make_and_model);
-                      all_devices[i]->device_class = g_strdup (pp_device->device_class);
-                      all_devices[i]->device_uri = g_strdup (pp_device->device_uri);
+                      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),
+                                                     "device-uri", pp_print_device_get_device_uri 
(pp_device),
+                                                     NULL);
                       i++;
                     }
                 }
@@ -864,31 +880,31 @@ get_cups_devices_cb (GList    *devices,
 
                   for (i = 0; i < length; i++)
                     {
-                      if (all_devices[i]->device_uri)
+                      if (pp_print_device_get_device_uri (all_devices[i]))
                         {
                           g_variant_builder_init (&device_hash, G_VARIANT_TYPE ("a{ss}"));
 
-                          if (all_devices[i]->device_id)
+                          if (pp_print_device_get_device_id (all_devices[i]))
                             g_variant_builder_add (&device_hash,
                                                    "{ss}",
                                                    "device-id",
-                                                   all_devices[i]->device_id);
+                                                   pp_print_device_get_device_id (all_devices[i]));
 
-                          if (all_devices[i]->device_make_and_model)
+                          if (pp_print_device_get_device_make_and_model (all_devices[i]))
                             g_variant_builder_add (&device_hash,
                                                    "{ss}",
                                                    "device-make-and-model",
-                                                   all_devices[i]->device_make_and_model);
+                                                   pp_print_device_get_device_make_and_model 
(all_devices[i]));
 
-                          if (all_devices[i]->device_class)
+                          if (pp_print_device_get_device_class (all_devices[i]))
                             g_variant_builder_add (&device_hash,
                                                    "{ss}",
                                                    "device-class",
-                                                   all_devices[i]->device_class);
+                                                   pp_print_device_get_device_class (all_devices[i]));
 
                           g_variant_builder_add (&device_list,
                                                  "{sv}",
-                                                 all_devices[i]->device_uri,
+                                                 pp_print_device_get_device_uri (all_devices[i]),
                                                  g_variant_builder_end (&device_hash));
                         }
                     }
@@ -914,7 +930,7 @@ get_cups_devices_cb (GList    *devices,
                 }
 
               for (i = 0; i < length; i++)
-                pp_print_device_free (all_devices[i]);
+                g_object_unref (all_devices[i]);
               g_free (all_devices);
             }
           else
@@ -928,7 +944,7 @@ get_cups_devices_cb (GList    *devices,
         }
     }
 
-  g_list_free_full (devices, (GDestroyNotify) pp_print_device_free);
+  g_list_free_full (devices, (GDestroyNotify) g_object_unref);
 }
 
 static void
@@ -1407,6 +1423,7 @@ search_address (const gchar        *text,
   gchar                     **words;
   gint                        words_length = 0;
   gint                        i;
+  gint                        acquisition_method;
 
   lowercase_text = g_ascii_strdown (text, -1);
   words = g_strsplit_set (lowercase_text, " ", -1);
@@ -1420,9 +1437,9 @@ search_address (const gchar        *text,
         {
           device = iter->data;
 
-          lowercase_name = g_ascii_strdown (device->device_name, -1);
-          if (device->device_location)
-            lowercase_location = g_ascii_strdown (device->device_location, -1);
+          lowercase_name = g_ascii_strdown (pp_print_device_get_device_name (device), -1);
+          if (pp_print_device_get_device_location (device))
+            lowercase_location = g_ascii_strdown (pp_print_device_get_device_location (device), -1);
           else
             lowercase_location = NULL;
 
@@ -1436,12 +1453,12 @@ search_address (const gchar        *text,
 
           if (subfound)
             {
-              device->show = TRUE;
+              g_object_set (device, "show", TRUE, NULL);
               found = TRUE;
             }
           else
             {
-              device->show = FALSE;
+              g_object_set (device, "show", FALSE, NULL);
             }
 
           g_free (lowercase_location);
@@ -1457,18 +1474,19 @@ search_address (const gchar        *text,
       while (iter)
         {
           device = iter->data;
-          device->show = TRUE;
-
-          if (device->acquisition_method == ACQUISITION_METHOD_REMOTE_CUPS_SERVER ||
-              device->acquisition_method == ACQUISITION_METHOD_SNMP ||
-              device->acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
-              device->acquisition_method == ACQUISITION_METHOD_LPD ||
-              device->acquisition_method == ACQUISITION_METHOD_SAMBA_HOST)
+          g_object_set (device, "show", TRUE, NULL);
+
+          acquisition_method = pp_print_device_get_acquisition_method (device);
+          if (acquisition_method == ACQUISITION_METHOD_REMOTE_CUPS_SERVER ||
+              acquisition_method == ACQUISITION_METHOD_SNMP ||
+              acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
+              acquisition_method == ACQUISITION_METHOD_LPD ||
+              acquisition_method == ACQUISITION_METHOD_SAMBA_HOST)
             {
               tmp = iter;
               iter = iter->next;
               priv->devices = g_list_remove_link (priv->devices, tmp);
-              g_list_free_full (tmp, (GDestroyNotify) pp_print_device_free);
+              g_list_free_full (tmp, (GDestroyNotify) g_object_unref);
             }
           else
             iter = iter->next;
@@ -1584,6 +1602,7 @@ actualize_devices_list (PpNewPrinterDialog *dialog)
   gboolean                   no_device = TRUE;
   GList                     *item;
   gchar                     *description;
+  gint                       acquisition_method;
 
   store = GTK_LIST_STORE (gtk_builder_get_object (priv->builder, "devices-liststore"));
 
@@ -1593,52 +1612,53 @@ actualize_devices_list (PpNewPrinterDialog *dialog)
     {
       device = (PpPrintDevice *) item->data;
 
-      if (device->display_name &&
-          (device->device_id ||
-           device->device_ppd ||
-           (device->host_name &&
-            device->acquisition_method == ACQUISITION_METHOD_REMOTE_CUPS_SERVER) ||
-           (device->device_uri &&
-            (device->acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
-             device->acquisition_method == ACQUISITION_METHOD_LPD)) ||
-           device->acquisition_method == ACQUISITION_METHOD_SAMBA_HOST ||
-           device->acquisition_method == ACQUISITION_METHOD_SAMBA) &&
-          device->show)
+      acquisition_method = pp_print_device_get_acquisition_method (device);
+      if (pp_print_device_get_display_name (device) &&
+          (pp_print_device_get_device_id (device) ||
+           pp_print_device_get_device_ppd (device) ||
+           (pp_print_device_get_host_name (device) &&
+            acquisition_method == ACQUISITION_METHOD_REMOTE_CUPS_SERVER) ||
+           (pp_print_device_get_device_uri (device) &&
+            (acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
+             acquisition_method == ACQUISITION_METHOD_LPD)) ||
+           acquisition_method == ACQUISITION_METHOD_SAMBA_HOST ||
+           acquisition_method == ACQUISITION_METHOD_SAMBA) &&
+          pp_print_device_get_show (device))
         {
-          description = get_local_scheme_description_from_uri (device->device_uri);
+          description = get_local_scheme_description_from_uri (pp_print_device_get_device_uri (device));
           if (description == NULL)
             {
-              if (device->device_location != NULL && device->device_location[0] != '\0')
+              if (pp_print_device_get_device_location (device) != NULL && 
pp_print_device_get_device_location (device)[0] != '\0')
                 {
                   /* Translators: Location of found network printer (e.g. Kitchen, Reception) */
-                  description = g_strdup_printf (_("Location: %s"), device->device_location);
+                  description = g_strdup_printf (_("Location: %s"), pp_print_device_get_device_location 
(device));
                 }
-              else if (device->host_name != NULL && device->host_name[0] != '\0')
+              else if (pp_print_device_get_host_name (device) != NULL && pp_print_device_get_host_name 
(device)[0] != '\0')
                 {
                   /* Translators: Network address of found printer */
-                  description = g_strdup_printf (_("Address: %s"), device->host_name);
+                  description = g_strdup_printf (_("Address: %s"), pp_print_device_get_host_name (device));
                 }
             }
 
           gtk_list_store_append (store, &iter);
           gtk_list_store_set (store, &iter,
-                              DEVICE_GICON_COLUMN, device->network_device ? priv->remote_printer_icon : 
priv->local_printer_icon,
-                              DEVICE_NAME_COLUMN, device->device_name,
-                              DEVICE_DISPLAY_NAME_COLUMN, device->display_name,
+                              DEVICE_GICON_COLUMN, pp_print_device_is_network_device (device) ? 
priv->remote_printer_icon : priv->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,
                               -1);
           no_device = FALSE;
 
           g_free (description);
         }
-      else if (device->is_authenticated_server &&
-               device->host_name != NULL)
+      else if (pp_print_device_is_authenticated_server (device) &&
+               pp_print_device_get_host_name (device) != NULL)
         {
           gtk_list_store_append (store, &iter);
           gtk_list_store_set (store, &iter,
                               DEVICE_GICON_COLUMN, priv->authenticated_server_icon,
-                              DEVICE_NAME_COLUMN, device->host_name,
-                              DEVICE_DISPLAY_NAME_COLUMN, device->host_name,
+                              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 */
                               DEVICE_DESCRIPTION_COLUMN, _("Server requires authentication"),
                               SERVER_NEEDS_AUTHENTICATION_COLUMN, TRUE,
@@ -1880,6 +1900,7 @@ ppd_selection_cb (GtkDialog *_dialog,
   gchar                     *ppd_display_name;
   gchar                     *printer_name;
   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);
@@ -1888,17 +1909,17 @@ ppd_selection_cb (GtkDialog *_dialog,
 
   if (ppd_name)
     {
-      priv->new_device->device_ppd = ppd_name;
+      g_object_set (priv->new_device, "device-ppd", ppd_name, NULL);
 
-      if ((priv->new_device->acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
-           priv->new_device->acquisition_method == ACQUISITION_METHOD_LPD) &&
+      acquisition_method = pp_print_device_get_acquisition_method (priv->new_device);
+      if ((acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
+           acquisition_method == ACQUISITION_METHOD_LPD) &&
           ppd_display_name != NULL)
         {
-          g_free (priv->new_device->device_name);
-          g_free (priv->new_device->device_original_name);
-
-          priv->new_device->device_name = g_strdup (ppd_display_name);
-          priv->new_device->device_original_name = g_strdup (ppd_display_name);
+          g_object_set (priv->new_device,
+                        "device-name", ppd_display_name,
+                        "device-original-name", ppd_display_name,
+                        NULL);
 
           printer_name = canonicalize_device_name (priv->devices,
                                                    priv->local_cups_devices,
@@ -1906,35 +1927,36 @@ ppd_selection_cb (GtkDialog *_dialog,
                                                    priv->num_of_dests,
                                                    priv->new_device);
 
-          g_free (priv->new_device->device_name);
-          g_free (priv->new_device->device_original_name);
+          g_object_set (priv->new_device,
+                        "device-name", printer_name,
+                        "device-original-name", printer_name,
+                        NULL);
 
-          priv->new_device->device_name = printer_name;
-          priv->new_device->device_original_name = g_strdup (printer_name);
+          g_free (printer_name);
         }
 
       emit_pre_response (dialog,
-                         priv->new_device->device_name,
-                         priv->new_device->device_location,
-                         priv->new_device->device_make_and_model,
-                         priv->new_device->network_device);
+                         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));
 
       window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (gtk_window_get_transient_for 
(GTK_WINDOW (priv->dialog)))));
 
       new_printer = pp_new_printer_new ();
       g_object_set (new_printer,
-                    "name", priv->new_device->device_name,
-                    "original-name", priv->new_device->device_original_name,
-                    "device-uri", priv->new_device->device_uri,
-                    "device-id", priv->new_device->device_id,
-                    "ppd-name", priv->new_device->device_ppd,
-                    "ppd-file-name", priv->new_device->device_ppd,
-                    "info", priv->new_device->device_info,
-                    "location", priv->new_device->device_location,
-                    "make-and-model", priv->new_device->device_make_and_model,
-                    "host-name", priv->new_device->host_name,
-                    "host-port", priv->new_device->host_port,
-                    "is-network-device", priv->new_device->network_device,
+                    "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),
                     "window-id", window_id,
                     NULL);
       priv->cancellable = g_cancellable_new ();
@@ -1944,8 +1966,7 @@ ppd_selection_cb (GtkDialog *_dialog,
                                 printer_add_async_cb,
                                 dialog);
 
-      pp_print_device_free (priv->new_device);
-      priv->new_device = NULL;
+      g_clear_object (&priv->new_device);
     }
 }
 
@@ -1962,6 +1983,7 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
   GtkTreeIter                iter;
   GList                     *list_iter;
   gchar                     *device_name = NULL;
+  gint                       acquisition_method;
 
   gtk_widget_hide (GTK_WIDGET (_dialog));
 
@@ -1980,7 +2002,7 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
       for (list_iter = priv->devices; list_iter; list_iter = list_iter->next)
         {
           tmp = (PpPrintDevice *) list_iter->data;
-          if (tmp && g_strcmp0 (tmp->device_name, device_name) == 0)
+          if (tmp && g_strcmp0 (pp_print_device_get_device_name (tmp), device_name) == 0)
             {
               device = tmp;
               break;
@@ -1992,10 +2014,11 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
           PpNewPrinter *new_printer;
           guint         window_id = 0;
 
-          if (device->acquisition_method == ACQUISITION_METHOD_SAMBA ||
-              device->acquisition_method == ACQUISITION_METHOD_SAMBA_HOST ||
-              device->acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
-              device->acquisition_method == ACQUISITION_METHOD_LPD)
+          acquisition_method = pp_print_device_get_acquisition_method (device);
+          if (acquisition_method == ACQUISITION_METHOD_SAMBA ||
+              acquisition_method == ACQUISITION_METHOD_SAMBA_HOST ||
+              acquisition_method == ACQUISITION_METHOD_JETDIRECT ||
+              acquisition_method == ACQUISITION_METHOD_LPD)
             {
               priv->new_device = pp_print_device_copy (device);
               priv->ppd_selection_dialog =
@@ -2008,27 +2031,27 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
           else
             {
               emit_pre_response (dialog,
-                                 device->device_name,
-                                 device->device_location,
-                                 device->device_make_and_model,
-                                 device->network_device);
+                                 pp_print_device_get_device_name (device),
+                                 pp_print_device_get_device_location (device),
+                                 pp_print_device_get_device_make_and_model (device),
+                                 pp_print_device_is_network_device (device));
 
               window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET 
(gtk_window_get_transient_for (GTK_WINDOW (_dialog)))));
 
               new_printer = pp_new_printer_new ();
               g_object_set (new_printer,
-                            "name", device->device_name,
-                            "original-name""", device->device_original_name,
-                            "device-uri", device->device_uri,
-                            "device-id", device->device_id,
-                            "ppd-name", device->device_ppd,
-                            "ppd-file-name", device->device_ppd,
-                            "info", device->device_info,
-                            "location", device->device_location,
-                            "make-and-model", device->device_make_and_model,
-                            "host-name", device->host_name,
-                            "host-port", device->host_port,
-                            "is-network-device", device->network_device,
+                            "name", pp_print_device_get_device_name (device),
+                            "original-name", pp_print_device_get_device_original_name (device),
+                            "device-uri", pp_print_device_get_device_uri (device),
+                            "device-id", pp_print_device_get_device_id (device),
+                            "ppd-name", pp_print_device_get_device_ppd (device),
+                            "ppd-file-name", pp_print_device_get_device_ppd (device),
+                            "info", pp_print_device_get_device_info (device),
+                            "location", pp_print_device_get_device_location (device),
+                            "make-and-model", pp_print_device_get_device_make_and_model (device),
+                            "host-name", pp_print_device_get_host_name (device),
+                            "host-port", pp_print_device_get_host_port (device),
+                            "is-network-device", pp_print_device_is_network_device (device),
                             "window-id", window_id,
                             NULL);
 
diff --git a/panels/printers/pp-print-device.c b/panels/printers/pp-print-device.c
new file mode 100644
index 0000000..4b1533f
--- /dev/null
+++ b/panels/printers/pp-print-device.c
@@ -0,0 +1,505 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright 2015  Red Hat, Inc,
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marek Kasik <mkasik redhat com>
+ */
+
+#include "pp-print-device.h"
+
+G_DEFINE_TYPE (PpPrintDevice, pp_print_device, G_TYPE_OBJECT);
+
+struct _PpPrintDevicePrivate
+{
+  gchar    *device_name;
+  gchar    *display_name;
+  gchar    *device_original_name;
+  gchar    *device_make_and_model;
+  gchar    *device_class;
+  gchar    *device_location;
+  gchar    *device_info;
+  gchar    *device_uri;
+  gchar    *device_id;
+  gchar    *device_ppd;
+  gchar    *host_name;
+  gint      host_port;
+  gboolean  is_authenticated_server;
+  gint      acquisition_method;
+  gboolean  is_network_device;
+  gboolean  show;
+};
+
+enum
+{
+  PROP_0 = 0,
+  PROP_DEVICE_NAME,
+  PROP_DISPLAY_NAME,
+  PROP_DEVICE_ORIGINAL_NAME,
+  PROP_DEVICE_MAKE_AND_MODEL,
+  PROP_DEVICE_CLASS,
+  PROP_DEVICE_LOCATION,
+  PROP_DEVICE_INFO,
+  PROP_DEVICE_URI,
+  PROP_DEVICE_ID,
+  PROP_DEVICE_PPD,
+  PROP_HOST_NAME,
+  PROP_HOST_PORT,
+  PROP_IS_AUTHENTICATED_SERVER,
+  PROP_ACQUISITION_METHOD,
+  PROP_IS_NETWORK_DEVICE,
+  PROP_SHOW
+};
+
+static void
+pp_print_device_finalize (GObject *object)
+{
+  PpPrintDevicePrivate *priv;
+
+  priv = PP_PRINT_DEVICE (object)->priv;
+
+  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_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);
+  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_OBJECT_CLASS (pp_print_device_parent_class)->finalize (object);
+}
+
+static void
+pp_print_device_get_property (GObject    *object,
+                              guint       prop_id,
+                              GValue     *value,
+                              GParamSpec *param_spec)
+{
+  PpPrintDevice *self;
+
+  self = PP_PRINT_DEVICE (object);
+
+  switch (prop_id)
+    {
+      case PROP_DEVICE_NAME:
+        g_value_set_string (value, self->priv->device_name);
+        break;
+      case PROP_DISPLAY_NAME:
+        g_value_set_string (value, self->priv->display_name);
+        break;
+      case PROP_DEVICE_ORIGINAL_NAME:
+        g_value_set_string (value, self->priv->device_original_name);
+        break;
+      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;
+      case PROP_DEVICE_INFO:
+        g_value_set_string (value, self->priv->device_info);
+        break;
+      case PROP_DEVICE_URI:
+        g_value_set_string (value, self->priv->device_uri);
+        break;
+      case PROP_DEVICE_ID:
+        g_value_set_string (value, self->priv->device_id);
+        break;
+      case PROP_DEVICE_PPD:
+        g_value_set_string (value, self->priv->device_ppd);
+        break;
+      case PROP_HOST_NAME:
+        g_value_set_string (value, self->priv->host_name);
+        break;
+      case PROP_HOST_PORT:
+        g_value_set_int (value, self->priv->host_port);
+        break;
+      case PROP_IS_AUTHENTICATED_SERVER:
+        g_value_set_boolean (value, self->priv->is_authenticated_server);
+        break;
+      case PROP_ACQUISITION_METHOD:
+        g_value_set_int (value, self->priv->acquisition_method);
+        break;
+      case PROP_IS_NETWORK_DEVICE:
+        g_value_set_boolean (value, self->priv->is_network_device);
+        break;
+      case PROP_SHOW:
+        g_value_set_boolean (value, self->priv->show);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                           prop_id,
+                                           param_spec);
+      break;
+    }
+}
+
+static void
+pp_print_device_set_property (GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *param_spec)
+{
+  PpPrintDevice *self = PP_PRINT_DEVICE (object);
+
+  switch (prop_id)
+    {
+      case PROP_DEVICE_NAME:
+        g_free (self->priv->device_name);
+        self->priv->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);
+        break;
+      case PROP_DEVICE_ORIGINAL_NAME:
+        g_free (self->priv->device_original_name);
+        self->priv->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);
+        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);
+        break;
+      case PROP_DEVICE_INFO:
+        g_free (self->priv->device_info);
+        self->priv->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);
+        break;
+      case PROP_DEVICE_ID:
+        g_free (self->priv->device_id);
+        self->priv->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);
+        break;
+      case PROP_HOST_NAME:
+        g_free (self->priv->host_name);
+        self->priv->host_name = g_value_dup_string (value);
+        break;
+      case PROP_HOST_PORT:
+        self->priv->host_port = g_value_get_int (value);
+        break;
+      case PROP_IS_AUTHENTICATED_SERVER:
+        self->priv->is_authenticated_server = g_value_get_boolean (value);
+        break;
+      case PROP_ACQUISITION_METHOD:
+        self->priv->acquisition_method = g_value_get_int (value);
+        break;
+      case PROP_IS_NETWORK_DEVICE:
+        self->priv->is_network_device = g_value_get_boolean (value);
+        break;
+      case PROP_SHOW:
+        self->priv->show = g_value_get_boolean (value);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                           prop_id,
+                                           param_spec);
+        break;
+    }
+}
+
+static void
+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;
+
+  gobject_class->finalize = pp_print_device_finalize;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEVICE_NAME,
+                                   g_param_spec_string ("device-name",
+                                                        "Device name",
+                                                        "Name of the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DISPLAY_NAME,
+                                   g_param_spec_string ("display-name",
+                                                        "Display name",
+                                                        "Name of the device formated for users",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEVICE_ORIGINAL_NAME,
+                                   g_param_spec_string ("device-original-name",
+                                                        "Device original name",
+                                                        "Original name of the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEVICE_MAKE_AND_MODEL,
+                                   g_param_spec_string ("device-make-and-model",
+                                                        "Device make and model",
+                                                        "Make and model of the device",
+                                                        NULL,
+                                                        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",
+                                                        "Locaton of the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEVICE_INFO,
+                                   g_param_spec_string ("device-info",
+                                                        "Device info",
+                                                        "Information about the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEVICE_URI,
+                                   g_param_spec_string ("device-uri",
+                                                        "Device URI",
+                                                        "URI of the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEVICE_ID,
+                                   g_param_spec_string ("device-id",
+                                                        "DeviceID",
+                                                        "DeviceID of the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEVICE_PPD,
+                                   g_param_spec_string ("device-ppd",
+                                                        "Device PPD",
+                                                        "Name of the PPD of the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_HOST_NAME,
+                                   g_param_spec_string ("host-name",
+                                                        "Host name",
+                                                        "Hostname of the device",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_HOST_PORT,
+                                   g_param_spec_int ("host-port",
+                                                     "Host port",
+                                                     "The port of the host",
+                                                     0, G_MAXINT32, 0,
+                                                     G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_IS_AUTHENTICATED_SERVER,
+                                   g_param_spec_boolean ("is-authenticated-server",
+                                                         "Is authenticated server",
+                                                         "Whether the device is a server which needs 
authentication",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACQUISITION_METHOD,
+                                   g_param_spec_int ("acquisition-method",
+                                                     "Acquisition method",
+                                                     "Acquisition method of the device",
+                                                     0, G_MAXINT32, 0,
+                                                     G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_IS_NETWORK_DEVICE,
+                                   g_param_spec_boolean ("is-network-device",
+                                                         "Network device",
+                                                         "Whether the device is a network device",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SHOW,
+                                   g_param_spec_boolean ("show",
+                                                         "Show",
+                                                         "Whether to show the device",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE));
+}
+
+static void
+pp_print_device_init (PpPrintDevice *printer)
+{
+  printer->priv = G_TYPE_INSTANCE_GET_PRIVATE (printer,
+                                               PP_TYPE_PRINT_DEVICE,
+                                               PpPrintDevicePrivate);
+}
+
+PpPrintDevice *
+pp_print_device_new ()
+{
+  return g_object_new (PP_TYPE_PRINT_DEVICE, NULL);
+}
+
+gchar *
+pp_print_device_get_device_name (PpPrintDevice *device)
+{
+  return device->priv->device_name;
+}
+
+gchar *
+pp_print_device_get_display_name (PpPrintDevice *device)
+{
+  return device->priv->display_name;
+}
+
+gchar *
+pp_print_device_get_device_original_name (PpPrintDevice *device)
+{
+  return device->priv->device_original_name;
+}
+
+gchar *
+pp_print_device_get_device_make_and_model (PpPrintDevice *device)
+{
+  return device->priv->device_make_and_model;
+}
+
+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;
+}
+
+gchar *
+pp_print_device_get_device_info (PpPrintDevice *device)
+{
+  return device->priv->device_info;
+}
+
+gchar *
+pp_print_device_get_device_uri (PpPrintDevice *device)
+{
+  return device->priv->device_uri;
+}
+
+gchar *
+pp_print_device_get_device_id (PpPrintDevice *device)
+{
+  return device->priv->device_id;
+}
+
+gchar *
+pp_print_device_get_device_ppd (PpPrintDevice *device)
+{
+  return device->priv->device_ppd;
+}
+
+gchar *
+pp_print_device_get_host_name (PpPrintDevice *device)
+{
+  return device->priv->host_name;
+}
+
+gint
+pp_print_device_get_host_port (PpPrintDevice *device)
+{
+  return device->priv->host_port;
+}
+
+gboolean
+pp_print_device_is_authenticated_server (PpPrintDevice *device)
+{
+  return device->priv->is_authenticated_server;
+}
+
+gint
+pp_print_device_get_acquisition_method (PpPrintDevice *device)
+{
+  return device->priv->acquisition_method;
+}
+
+gboolean
+pp_print_device_is_network_device (PpPrintDevice *device)
+{
+  return device->priv->is_network_device;
+}
+
+gboolean
+pp_print_device_get_show (PpPrintDevice *device)
+{
+  return device->priv->show;
+}
+
+PpPrintDevice *
+pp_print_device_copy (PpPrintDevice *device)
+{
+  return g_object_new (PP_TYPE_PRINT_DEVICE,
+                       "device-name", pp_print_device_get_device_name (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),
+                       "device-id", pp_print_device_get_device_id (device),
+                       "device-ppd", pp_print_device_get_device_ppd (device),
+                       "host-name", pp_print_device_get_host_name (device),
+                       "host-port", pp_print_device_get_host_port (device),
+                       "is-authenticated-server", pp_print_device_is_authenticated_server (device),
+                       "acquisition-method", pp_print_device_get_acquisition_method (device),
+                       "is-network-device", pp_print_device_is_network_device (device),
+                       "show", pp_print_device_get_show (device),
+                       NULL);
+}
diff --git a/panels/printers/pp-print-device.h b/panels/printers/pp-print-device.h
new file mode 100644
index 0000000..f26a0d9
--- /dev/null
+++ b/panels/printers/pp-print-device.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright 2015  Red Hat, Inc,
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marek Kasik <mkasik redhat com>
+ */
+
+#ifndef __PP_PRINT_DEVICE_H__
+#define __PP_PRINT_DEVICE_H__
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+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);
+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);
+gchar         *pp_print_device_get_device_id             (PpPrintDevice *device);
+gchar         *pp_print_device_get_device_ppd            (PpPrintDevice *device);
+gchar         *pp_print_device_get_host_name             (PpPrintDevice *device);
+gint           pp_print_device_get_host_port             (PpPrintDevice *device);
+gboolean       pp_print_device_is_authenticated_server   (PpPrintDevice *device);
+gint           pp_print_device_get_acquisition_method    (PpPrintDevice *device);
+gboolean       pp_print_device_is_network_device         (PpPrintDevice *device);
+gboolean       pp_print_device_get_show                  (PpPrintDevice *device);
+
+G_END_DECLS
+
+#endif /* __PP_PRINT_DEVICE_H__ */
diff --git a/panels/printers/pp-samba.c b/panels/printers/pp-samba.c
index d8c51c9..235ab6a 100644
--- a/panels/printers/pp-samba.c
+++ b/panels/printers/pp-samba.c
@@ -340,6 +340,7 @@ list_dir (SMBCCTX      *smb_context,
   smbc_readdir_fn     smbclient_readdir;
   smbc_opendir_fn     smbclient_opendir;
   PpPrintDevice      *device;
+  const gchar        *host_name;
   SMBCFILE           *dir;
 
   if (!g_cancellable_is_cancelled (cancellable))
@@ -351,6 +352,11 @@ list_dir (SMBCCTX      *smb_context,
       dir = smbclient_opendir (smb_context, dirname);
       if (!dir && errno == EACCES)
         {
+          if (g_str_has_prefix (dirname, "smb://"))
+            host_name = dirname + 6;
+          else
+            host_name = dirname;
+
           if (data->auth_if_needed)
             {
               data->cancelled = FALSE;
@@ -360,9 +366,10 @@ list_dir (SMBCCTX      *smb_context,
 
               if (data->cancelled)
                 {
-                  device = g_new0 (PpPrintDevice, 1);
-                  device->host_name = g_str_has_prefix (dirname, "smb://") ? g_strdup (dirname + 6) : 
g_strdup (dirname);
-                  device->is_authenticated_server = TRUE;
+                  device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                         "host-name", host_name,
+                                         "is-authenticated-server", TRUE,
+                                         NULL);
 
                   data->devices->devices = g_list_append (data->devices->devices, device);
 
@@ -373,10 +380,10 @@ list_dir (SMBCCTX      *smb_context,
             }
           else
             {
-              device = g_new0 (PpPrintDevice, 1);
-
-              device->host_name = g_str_has_prefix (dirname, "smb://") ? g_strdup (dirname + 6) : g_strdup 
(dirname);
-              device->is_authenticated_server = TRUE;
+              device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                     "host-name", host_name,
+                                     "is-authenticated-server", TRUE,
+                                     NULL);
 
               data->devices->devices = g_list_append (data->devices->devices, device);
             }
@@ -384,6 +391,8 @@ list_dir (SMBCCTX      *smb_context,
 
       while (dir && (dirent = smbclient_readdir (smb_context, dir)))
         {
+          gchar *device_name;
+          gchar *device_uri;
           gchar *subdirname = NULL;
           gchar *subpath = NULL;
           gchar *uri;
@@ -402,27 +411,29 @@ list_dir (SMBCCTX      *smb_context,
 
           if (dirent->smbc_type == SMBC_PRINTER_SHARE)
             {
-              device = g_new0 (PpPrintDevice, 1);
-
               uri = g_strdup_printf ("%s/%s", dirname, dirent->name);
-              device->device_uri = g_uri_escape_string (uri,
-                                                        G_URI_RESERVED_CHARS_GENERIC_DELIMITERS
-                                                        G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS,
-                                                        FALSE);
+              device_uri = g_uri_escape_string (uri,
+                                                G_URI_RESERVED_CHARS_GENERIC_DELIMITERS
+                                                G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS,
+                                                FALSE);
+
+              device_name = g_strdup (dirent->name);
+              device_name = g_strcanon (device_name, ALLOWED_CHARACTERS, '-');
+
+              device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                     "device-uri", device_uri,
+                                     "device-class", "network",
+                                     "device-info", dirent->comment,
+                                     "device-name", device_name,
+                                     "acquisition-method", data->hostname_set ? 
ACQUISITION_METHOD_SAMBA_HOST : ACQUISITION_METHOD_SAMBA,
+                                     "device-location", path,
+                                     "host-name", dirname,
+                                     NULL);
+
+              g_free (device_name);
+              g_free (device_uri);
               g_free (uri);
 
-              device->device_class = g_strdup ("network");
-              device->device_info = g_strdup (dirent->comment);
-              device->device_name = g_strdup (dirent->name);
-              device->device_name =
-                g_strcanon (device->device_name, ALLOWED_CHARACTERS, '-');
-              if (data->hostname_set)
-                device->acquisition_method = ACQUISITION_METHOD_SAMBA_HOST;
-              else
-                device->acquisition_method = ACQUISITION_METHOD_SAMBA;
-              device->device_location = g_strdup (path);
-              device->host_name = g_strdup (dirname);
-
               data->devices->devices = g_list_append (data->devices->devices, device);
             }
 
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index 3fe533c..3225bb9 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -3231,7 +3231,7 @@ pp_devices_list_free (PpDevicesList *result)
 {
   if (result)
     {
-      g_list_free_full (result->devices, (GDestroyNotify) pp_print_device_free);
+      g_list_free_full (result->devices, (GDestroyNotify) g_object_unref);
       g_free (result);
     }
 }
@@ -3525,25 +3525,27 @@ get_cups_devices_async_dbus_cb (GObject      *source_object,
                   if (index >= 0)
                     {
                       if (!devices[index])
-                        devices[index] = g_new0 (PpPrintDevice, 1);
+                        devices[index] = pp_print_device_new ();
 
                       if (g_str_has_prefix (key, "device-class"))
-                        devices[index]->device_class = g_strdup (value);
+                        g_object_set (devices[index], "device-class", value, NULL);
                       else if (g_str_has_prefix (key, "device-id"))
-                        devices[index]->device_id = g_strdup (value);
+                        g_object_set (devices[index], "device-id", value, NULL);
                       else if (g_str_has_prefix (key, "device-info"))
-                        devices[index]->device_info = g_strdup (value);
+                        g_object_set (devices[index], "device-info", value, NULL);
                       else if (g_str_has_prefix (key, "device-make-and-model"))
                         {
-                          devices[index]->device_make_and_model = g_strdup (value);
-                          devices[index]->device_name = g_strdup (value);
+                          g_object_set (devices[index],
+                                        "device-make-and-model", value,
+                                        "device-name", value,
+                                        NULL);
                         }
                       else if (g_str_has_prefix (key, "device-uri"))
-                        devices[index]->device_uri = g_strdup (value);
+                        g_object_set (devices[index], "device-uri", value, NULL);
                       else if (g_str_has_prefix (key, "device-location"))
-                        devices[index]->device_location = g_strdup (value);
+                        g_object_set (devices[index], "device-location", value, NULL);
 
-                      devices[index]->acquisition_method = ACQUISITION_METHOD_DEFAULT_CUPS_SERVER;
+                      g_object_set (devices[index], "acquisition-method", 
ACQUISITION_METHOD_DEFAULT_CUPS_SERVER, NULL);
                     }
 
                   g_free (key);
@@ -3715,56 +3717,6 @@ get_cups_devices_async (GCancellable *cancellable,
                           data);
 }
 
-void
-pp_print_device_free (PpPrintDevice *device)
-{
-  if (device)
-    {
-      g_free (device->device_class);
-      g_free (device->device_id);
-      g_free (device->device_info);
-      g_free (device->device_make_and_model);
-      g_free (device->device_uri);
-      g_free (device->device_location);
-      g_free (device->device_name);
-      g_free (device->device_ppd);
-      g_free (device->host_name);
-      g_free (device->display_name);
-      g_free (device->device_original_name);
-      g_free (device);
-    }
-}
-
-PpPrintDevice *
-pp_print_device_copy (PpPrintDevice *device)
-{
-  PpPrintDevice *result = NULL;
-
-  if (device)
-    {
-      result = g_new (PpPrintDevice, 1);
-
-      result->is_authenticated_server = device->is_authenticated_server;
-      result->device_class = g_strdup (device->device_class);
-      result->device_id = g_strdup (device->device_id);
-      result->device_info = g_strdup (device->device_info);
-      result->device_make_and_model = g_strdup (device->device_make_and_model);
-      result->device_uri = g_strdup (device->device_uri);
-      result->device_location = g_strdup (device->device_location);
-      result->device_name = g_strdup (device->device_name);
-      result->device_ppd = g_strdup (device->device_ppd);
-      result->host_name = g_strdup (device->host_name);
-      result->host_port = device->host_port;
-      result->acquisition_method = device->acquisition_method;
-      result->display_name = g_strdup (device->display_name);
-      result->device_original_name = g_strdup (device->device_original_name);
-      result->network_device = device->network_device;
-      result->show = device->show;
-    }
-
-  return result;
-}
-
 typedef struct
 {
   gchar        *printer_name;
@@ -4043,15 +3995,15 @@ guess_device_hostname (PpPrintDevice *device)
   gchar             *hostname_begin;
   gchar             *hostname_end = NULL;
 
-  if (device != NULL && device->device_uri != NULL)
+  if (device != NULL && pp_print_device_get_device_uri (device) != NULL)
     {
-      if (g_str_has_prefix (device->device_uri, "socket") ||
-          g_str_has_prefix (device->device_uri, "lpd") ||
-          g_str_has_prefix (device->device_uri, "ipp") ||
-          g_str_has_prefix (device->device_uri, "smb"))
+      if (g_str_has_prefix (pp_print_device_get_device_uri (device), "socket") ||
+          g_str_has_prefix (pp_print_device_get_device_uri (device), "lpd") ||
+          g_str_has_prefix (pp_print_device_get_device_uri (device), "ipp") ||
+          g_str_has_prefix (pp_print_device_get_device_uri (device), "smb"))
         {
           status = httpSeparateURI (HTTP_URI_CODING_ALL,
-                                    device->device_uri,
+                                    pp_print_device_get_device_uri (device),
                                     scheme, HTTP_MAX_URI,
                                     username, HTTP_MAX_URI,
                                     hostname, HTTP_MAX_URI,
@@ -4062,27 +4014,27 @@ guess_device_hostname (PpPrintDevice *device)
               hostname[0] != '\0')
             result = g_strdup (hostname);
         }
-      else if ((g_str_has_prefix (device->device_uri, "dnssd") ||
-                g_str_has_prefix (device->device_uri, "mdns")) &&
-               device->device_info != NULL)
+      else if ((g_str_has_prefix (pp_print_device_get_device_uri (device), "dnssd") ||
+                g_str_has_prefix (pp_print_device_get_device_uri (device), "mdns")) &&
+               pp_print_device_get_device_info (device) != NULL)
         {
           /*
            * CUPS browses its printers as
            * "PrinterName @ ComputerName" or "PrinterInfo @ ComputerName"
            * through DNS-SD.
            */
-          hostname_begin = g_strrstr (device->device_info, " @ ");
+          hostname_begin = g_strrstr (pp_print_device_get_device_info (device), " @ ");
           if (hostname_begin != NULL)
             result = g_strdup (hostname_begin + 3);
         }
-      else if (g_str_has_prefix (device->device_uri, "hp:/net/") ||
-               g_str_has_prefix (device->device_uri, "hpfax:/net/"))
+      else if (g_str_has_prefix (pp_print_device_get_device_uri (device), "hp:/net/") ||
+               g_str_has_prefix (pp_print_device_get_device_uri (device), "hpfax:/net/"))
         {
           /*
            * HPLIP printers have URI of form hp:/net/%s?ip=%s&port=%d
            * or hp:/net/%s?ip=%s.
            */
-          hostname_begin = g_strrstr (device->device_uri, "ip=");
+          hostname_begin = g_strrstr (pp_print_device_get_device_uri (device), "ip=");
           if (hostname_begin != NULL)
             {
               hostname_begin += 3;
@@ -4133,32 +4085,32 @@ canonicalize_device_name (GList         *devices,
     "-zxs",
     "-pxl"};
 
-  if (device->device_id != NULL)
+  if (pp_print_device_get_device_id (device) != NULL)
     {
-      name = get_tag_value (device->device_id, "mdl");
+      name = get_tag_value (pp_print_device_get_device_id (device), "mdl");
       if (name == NULL)
-        name = get_tag_value (device->device_id, "model");
+        name = get_tag_value (pp_print_device_get_device_id (device), "model");
     }
 
   if (name == NULL &&
-      device->device_make_and_model != NULL &&
-      device->device_make_and_model[0] != '\0')
+      pp_print_device_get_device_make_and_model (device) != NULL &&
+      pp_print_device_get_device_make_and_model (device)[0] != '\0')
     {
-      name = g_strdup (device->device_make_and_model);
+      name = g_strdup (pp_print_device_get_device_make_and_model (device));
     }
 
   if (name == NULL &&
-      device->device_original_name != NULL &&
-      device->device_original_name[0] != '\0')
+      pp_print_device_get_device_original_name (device) != NULL &&
+      pp_print_device_get_device_original_name (device)[0] != '\0')
     {
-      name = g_strdup (device->device_original_name);
+      name = g_strdup (pp_print_device_get_device_original_name (device));
     }
 
   if (name == NULL &&
-      device->device_info != NULL &&
-      device->device_info[0] != '\0')
+      pp_print_device_get_device_info (device) != NULL &&
+      pp_print_device_get_device_info (device)[0] != '\0')
     {
-      name = g_strdup (device->device_info);
+      name = g_strdup (pp_print_device_get_device_info (device));
     }
 
   if (name == NULL)
@@ -4221,14 +4173,14 @@ canonicalize_device_name (GList         *devices,
       for (iter = devices; iter; iter = iter->next)
         {
           item = (PpPrintDevice *) iter->data;
-          if (g_strcmp0 (item->device_original_name, new_name) == 0)
+          if (g_strcmp0 (pp_print_device_get_device_original_name (item), new_name) == 0)
             already_present = TRUE;
         }
 
       for (iter = local_cups_devices; iter; iter = iter->next)
         {
           item = (PpPrintDevice *) iter->data;
-          if (g_strcmp0 (item->device_original_name, new_name) == 0)
+          if (g_strcmp0 (pp_print_device_get_device_original_name (item), new_name) == 0)
             already_present = TRUE;
         }
 
diff --git a/panels/printers/pp-utils.h b/panels/printers/pp-utils.h
index c307879..284f881 100644
--- a/panels/printers/pp-utils.h
+++ b/panels/printers/pp-utils.h
@@ -23,6 +23,8 @@
 #include <gtk/gtk.h>
 #include <cups/cups.h>
 
+#include "pp-print-device.h"
+
 #define ALLOWED_CHARACTERS "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
 
 #define MECHANISM_BUS "org.opensuse.CupsPkHelper.Mechanism"
@@ -272,28 +274,6 @@ void job_set_hold_until_async (gint          job_id,
                                GCancellable *cancellable,
                                JSHUCallback  callback,
                                gpointer      user_data);
-typedef struct
-{
-  gboolean  is_authenticated_server;
-  gchar    *device_class;
-  gchar    *device_id;
-  gchar    *device_info;
-  gchar    *device_make_and_model;
-  gchar    *device_uri;
-  gchar    *device_location;
-  gchar    *device_name;
-  gchar    *device_ppd;
-  gchar    *host_name;
-  gint      host_port;
-  gint      acquisition_method;
-  gchar    *display_name;
-  gchar    *device_original_name;
-  gboolean  network_device;
-  gboolean  show;
-} PpPrintDevice;
-
-void           pp_print_device_free (PpPrintDevice *device);
-PpPrintDevice *pp_print_device_copy (PpPrintDevice *device);
 
 void         pp_devices_list_free (PpDevicesList *result);
 
diff --git a/panels/printers/test-canonicalization.c b/panels/printers/test-canonicalization.c
index 596e6fa..f2d3acd 100644
--- a/panels/printers/test-canonicalization.c
+++ b/panels/printers/test-canonicalization.c
@@ -66,17 +66,19 @@ main (int argc, char **argv)
 
           for (j = 0; already_present_printers[j] != NULL; j++)
             {
-              tmp = g_new0 (PpPrintDevice, 1);
-              tmp->device_original_name = g_strdup (already_present_printers[j]);
+              tmp = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                  "device-original-name", already_present_printers[j],
+                                  NULL);
 
               devices = g_list_append (devices, tmp);
             }
 
-          device = g_new0 (PpPrintDevice, 1);
-          device->device_id = g_strdup (items[1]);
-          device->device_make_and_model = g_strdup (items[2]);
-          device->device_original_name = g_strdup (items[3]);
-          device->device_info = g_strdup (items[4]);
+          device = g_object_new (PP_TYPE_PRINT_DEVICE,
+                                 "device-id", items[1],
+                                 "device-make-and-model", items[2],
+                                 "device-original-name", items[3],
+                                 "device-info", items[4],
+                                 NULL);
 
           canonicalized_name =
             canonicalize_device_name (devices, NULL, NULL, 0, device);
@@ -93,8 +95,8 @@ main (int argc, char **argv)
             }
 
           g_free (canonicalized_name);
-          pp_print_device_free (device);
-          g_list_free_full (devices, (GDestroyNotify) pp_print_device_free);
+          g_object_unref (device);
+          g_list_free_full (devices, (GDestroyNotify) g_object_unref);
           g_strfreev (already_present_printers);
         }
       else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]