[gnome-control-center] printers: Show connection type of found devices



commit 64ff0dd25a1a4a2cfad9a09ef6bde660741e6331
Author: Marek Kasik <mkasik redhat com>
Date:   Wed Feb 26 13:03:08 2014 +0100

    printers: Show connection type of found devices
    
    Parse URIs of devices found by the new printer dialog and
    show types of their connections for local printers or
    locations for network printers or addresses for network
    printers.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693183

 panels/printers/pp-new-printer-dialog.c |   53 +++++++++++++++++++++++++++++--
 1 files changed, 50 insertions(+), 3 deletions(-)
---
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 7b00afb..a379c7b 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -1694,6 +1694,42 @@ search_entry_changed_cb (GtkSearchEntry *entry,
                   TRUE);
 }
 
+static gchar *
+get_local_scheme_description_from_uri (gchar *device_uri)
+{
+  gchar *description = NULL;
+
+  if (device_uri != NULL)
+    {
+      if (g_str_has_prefix (device_uri, "usb") ||
+          g_str_has_prefix (device_uri, "hp:/usb/") ||
+          g_str_has_prefix (device_uri, "hpfax:/usb/"))
+        {
+          /* Translators: The found device is a printer connected via USB */
+          description = g_strdup (_("USB"));
+        }
+      else if (g_str_has_prefix (device_uri, "serial"))
+        {
+          /* Translators: The found device is a printer connected via serial port */
+          description = g_strdup (_("Serial Port"));
+        }
+      else if (g_str_has_prefix (device_uri, "parallel") ||
+               g_str_has_prefix (device_uri, "hp:/par/") ||
+               g_str_has_prefix (device_uri, "hpfax:/par/"))
+        {
+          /* Translators: The found device is a printer connected via parallel port */
+          description = g_strdup (_("Parallel Port"));
+        }
+      else if (g_str_has_prefix (device_uri, "bluetooth"))
+        {
+          /* Translators: The found device is a printer connected via Bluetooth */
+          description = g_strdup (_("Bluetooth"));
+        }
+    }
+
+  return description;
+}
+
 static void
 actualize_devices_list (PpNewPrinterDialog *dialog)
 {
@@ -1729,9 +1765,20 @@ actualize_devices_list (PpNewPrinterDialog *dialog)
            device->acquisition_method == ACQUISITION_METHOD_SAMBA) &&
           device->show)
         {
-          description = NULL;
-          if (device->device_location)
-            description = g_strdup (device->device_location);
+          description = get_local_scheme_description_from_uri (device->device_uri);
+          if (description == NULL)
+            {
+              if (device->device_location != NULL && device->device_location[0] != '\0')
+                {
+                  /* Translators: Location of found network printer (e.g. Kitchen, Reception) */
+                  description = g_strdup_printf (_("Location: %s"), device->device_location);
+                }
+              else if (device->host_name != NULL && device->host_name[0] != '\0')
+                {
+                  /* Translators: Network address of found printer */
+                  description = g_strdup_printf (_("Address: %s"), device->host_name);
+                }
+            }
 
           gtk_list_store_append (store, &iter);
           gtk_list_store_set (store, &iter,


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