[gnome-bluetooth] lib: Add new function to display device types in filters



commit 282ff9319d2e9aa3df0562013f80bf006f9c18b5
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Nov 29 11:54:47 2016 +0100

    lib: Add new function to display device types in filters
    
    So that we can use this in situations where the device type is not known
    yet.

 lib/bluetooth-utils.c       |   25 +++++++++++++++++++++++--
 lib/bluetooth-utils.h       |    9 +++++----
 lib/gnome-bluetooth.symbols |    1 +
 3 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/lib/bluetooth-utils.c b/lib/bluetooth-utils.c
index 5e78d16..fa7f41a 100644
--- a/lib/bluetooth-utils.c
+++ b/lib/bluetooth-utils.c
@@ -55,8 +55,6 @@ const gchar *
 bluetooth_type_to_string (BluetoothType type)
 {
        switch (type) {
-       case BLUETOOTH_TYPE_ANY:
-               return _("All types");
        case BLUETOOTH_TYPE_PHONE:
                return _("Phone");
        case BLUETOOTH_TYPE_MODEM:
@@ -102,6 +100,29 @@ bluetooth_type_to_string (BluetoothType type)
 }
 
 /**
+ * bluetooth_type_to_filter_string:
+ * @type: a #BluetoothType
+ *
+ * Returns a human-readable string representation of @type usable for display to users,
+ * when type filters are displayed. Do not free the return value.
+ * The returned string is already translated with gettext().
+ *
+ * Return value: a string.
+ **/
+const gchar *
+bluetooth_type_to_filter_string (BluetoothType type)
+{
+       switch (type) {
+       case BLUETOOTH_TYPE_ANY:
+               return _("All types");
+       default:
+               return bluetooth_type_to_string (type);
+       }
+
+       g_assert_not_reached ();
+}
+
+/**
  * bluetooth_verify_address:
  * @bdaddr: a string representing a Bluetooth address
  *
diff --git a/lib/bluetooth-utils.h b/lib/bluetooth-utils.h
index c27e109..f78b950 100644
--- a/lib/bluetooth-utils.h
+++ b/lib/bluetooth-utils.h
@@ -60,10 +60,11 @@ G_BEGIN_DECLS
 #define BLUETOOTH_UUID_GENERIC_NET     0x1201
 #define BLUETOOTH_UUID_VDP_SOURCE      0x1303
 
-BluetoothType  bluetooth_class_to_type  (guint32 class);
-const gchar   *bluetooth_type_to_string (guint type);
-gboolean       bluetooth_verify_address (const char *bdaddr);
-const char    *bluetooth_uuid_to_string (const char *uuid);
+BluetoothType  bluetooth_class_to_type         (guint32 class);
+const gchar   *bluetooth_type_to_string        (guint type);
+const gchar   *bluetooth_type_to_filter_string (guint type);
+gboolean       bluetooth_verify_address        (const char *bdaddr);
+const char    *bluetooth_uuid_to_string        (const char *uuid);
 
 void bluetooth_send_to_address (const char *address,
                                const char *alias);
diff --git a/lib/gnome-bluetooth.symbols b/lib/gnome-bluetooth.symbols
index 6840979..21f99e2 100644
--- a/lib/gnome-bluetooth.symbols
+++ b/lib/gnome-bluetooth.symbols
@@ -31,6 +31,7 @@ bluetooth_client_set_trusted
 bluetooth_client_get_device
 bluetooth_class_to_type
 bluetooth_type_to_string
+bluetooth_type_to_filter_string
 bluetooth_verify_address
 bluetooth_uuid_to_string
 bluetooth_send_to_address


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