[gnome-bluetooth/wip/hadess/fix-devices-moving: 1/2] settings-widget: Add a "time-created" property for settings rows




commit 0d686bf856b1ca67ab5a606c4287f3250b01a432
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Feb 19 14:43:19 2021 +0100

    settings-widget: Add a "time-created" property for settings rows
    
    This captures when the device was discovered, or when a widget was
    created for it, which should be good enough to know when a particular
    device was discovered after another.

 lib/bluetooth-settings-row.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/lib/bluetooth-settings-row.c b/lib/bluetooth-settings-row.c
index d9be4ff2..619db396 100644
--- a/lib/bluetooth-settings-row.c
+++ b/lib/bluetooth-settings-row.c
@@ -52,6 +52,7 @@ struct _BluetoothSettingsRowPrivate {
        char *alias;
        char *bdaddr;
        gboolean legacy_pairing;
+       gint64 time_created;
 
        gboolean pairing;
 };
@@ -67,7 +68,8 @@ enum {
        PROP_ALIAS,
        PROP_ADDRESS,
        PROP_PAIRING,
-       PROP_LEGACY_PAIRING
+       PROP_LEGACY_PAIRING,
+       PROP_TIME_CREATED
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE(BluetoothSettingsRow, bluetooth_settings_row, GTK_TYPE_LIST_BOX_ROW)
@@ -102,6 +104,8 @@ bluetooth_settings_row_init (BluetoothSettingsRow *self)
                                priv->status, "visible", G_BINDING_INVERT_BOOLEAN | G_BINDING_BIDIRECTIONAL);
        g_object_bind_property (priv->spinner, "active",
                                priv->status, "visible", G_BINDING_INVERT_BOOLEAN | G_BINDING_BIDIRECTIONAL);
+
+       priv->time_created = g_get_monotonic_time();
 }
 
 static void
@@ -158,6 +162,9 @@ bluetooth_settings_row_get_property (GObject        *object,
        case PROP_LEGACY_PAIRING:
                g_value_set_boolean (value, priv->legacy_pairing);
                break;
+       case PROP_TIME_CREATED:
+               g_value_set_int64 (value, priv->time_created);
+               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
                break;
@@ -288,6 +295,10 @@ bluetooth_settings_row_class_init (BluetoothSettingsRowClass *klass)
                                         g_param_spec_boolean ("legacy-pairing", NULL,
                                                              "Legacy pairing",
                                                              FALSE, G_PARAM_READWRITE));
+       g_object_class_install_property (object_class, PROP_TIME_CREATED,
+                                        g_param_spec_int64 ("time-created", NULL,
+                                                           "Time Created",
+                                                           G_MININT64, G_MAXINT64, 0, G_PARAM_READABLE));
 
        /* Bind class to template */
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/bluetooth/bluetooth-settings-row.ui");


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