[gnome-bluetooth/wip/hadess/use-alias: 1/5] settings-row: Add "alias" property




commit e508ccf3ae96ee608e7e7a3bd26add3f4e68e8d1
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Dec 9 15:33:48 2020 +0100

    settings-row: Add "alias" property

 lib/bluetooth-settings-row.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/lib/bluetooth-settings-row.c b/lib/bluetooth-settings-row.c
index ff8c523b..d9be4ff2 100644
--- a/lib/bluetooth-settings-row.c
+++ b/lib/bluetooth-settings-row.c
@@ -49,6 +49,7 @@ struct _BluetoothSettingsRowPrivate {
        BluetoothType type;
        gboolean connected;
        char *name;
+       char *alias;
        char *bdaddr;
        gboolean legacy_pairing;
 
@@ -63,6 +64,7 @@ enum {
        PROP_TYPE,
        PROP_CONNECTED,
        PROP_NAME,
+       PROP_ALIAS,
        PROP_ADDRESS,
        PROP_PAIRING,
        PROP_LEGACY_PAIRING
@@ -110,6 +112,7 @@ bluetooth_settings_row_finalize (GObject *object)
 
        g_clear_object (&priv->proxy);
        g_clear_pointer (&priv->name, g_free);
+       g_clear_pointer (&priv->alias, g_free);
        g_clear_pointer (&priv->bdaddr, g_free);
 
        G_OBJECT_CLASS(bluetooth_settings_row_parent_class)->finalize(object);
@@ -143,6 +146,9 @@ bluetooth_settings_row_get_property (GObject        *object,
        case PROP_NAME:
                g_value_set_string (value, priv->name);
                break;
+       case PROP_ALIAS:
+               g_value_set_string (value, priv->alias);
+               break;
        case PROP_ADDRESS:
                g_value_set_string (value, priv->bdaddr);
                break;
@@ -168,7 +174,7 @@ update_row (BluetoothSettingsRow *self)
                                    bluetooth_type_to_string (priv->type));
                gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
        } else {
-               gtk_label_set_text (GTK_LABEL (priv->label), priv->name);
+               gtk_label_set_text (GTK_LABEL (priv->label), priv->alias);
                gtk_widget_set_sensitive (GTK_WIDGET (self), TRUE);
        }
 }
@@ -208,6 +214,11 @@ bluetooth_settings_row_set_property (GObject        *object,
                priv->name = g_value_dup_string (value);
                update_row (self);
                break;
+       case PROP_ALIAS:
+               g_free (priv->alias);
+               priv->alias = g_value_dup_string (value);
+               update_row (self);
+               break;
        case PROP_ADDRESS:
                g_free (priv->bdaddr);
                priv->bdaddr = g_value_dup_string (value);
@@ -261,6 +272,10 @@ bluetooth_settings_row_class_init (BluetoothSettingsRowClass *klass)
                                         g_param_spec_string ("name", NULL,
                                                              "Name",
                                                              NULL, G_PARAM_READWRITE));
+       g_object_class_install_property (object_class, PROP_ALIAS,
+                                        g_param_spec_string ("alias", NULL,
+                                                             "Alias",
+                                                             NULL, G_PARAM_READWRITE));
        g_object_class_install_property (object_class, PROP_ADDRESS,
                                         g_param_spec_string ("address", NULL,
                                                              "Address",


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