diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2014-10-02 16:26:05 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2014-10-02 16:26:05 +1300 |
commit | 527e6ad16b92a736bcd8e0723f5fef1aaf57dd42 (patch) | |
tree | 2902d6303ad69a866fce0a510dcfbd7809507a2c /src | |
parent | 8c5c82b31ff81f8d74ad29f4eef3b6f063309973 (diff) | |
download | lightdm-527e6ad16b92a736bcd8e0723f5fef1aaf57dd42.tar.gz |
Support login1 properties changing where the value is provided in the PropertyChanged signal
Diffstat (limited to 'src')
-rw-r--r-- | src/login1.c | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/src/login1.c b/src/login1.c index f799e3ed..01de48ea 100644 --- a/src/login1.c +++ b/src/login1.c @@ -82,6 +82,16 @@ login1_service_get_instance (void) } static void +update_property (Login1Seat *seat, const gchar *name, GVariant *value) +{ + if (strcmp (name, "CanGraphical") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + { + seat->priv->can_graphical = g_variant_get_boolean (value); + g_signal_emit (seat, seat_signals[CAN_GRAPHICAL_CHANGED], 0); + } +} + +static void seat_properties_changed_cb (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, @@ -91,43 +101,39 @@ seat_properties_changed_cb (GDBusConnection *connection, gpointer user_data) { Login1Seat *seat = user_data; + GVariantIter *iter; GVariantIter *invalidated_properties; - const gchar *property_name; - - g_variant_get (parameters, "(sa{sv}as)", NULL, NULL, &invalidated_properties); - while (g_variant_iter_loop (invalidated_properties, "&s", &property_name)) + const gchar *name; + GVariant *value; + + g_variant_get (parameters, "(sa{sv}as)", NULL, &iter, &invalidated_properties); + while (g_variant_iter_loop (iter, "{&sv}", &name, &value)) + update_property (seat, name, value); + g_variant_iter_free (iter); + while (g_variant_iter_loop (invalidated_properties, "&s", &name)) { - if (strcmp (property_name, "CanGraphical") == 0) - { - GVariant *result; - GError *error = NULL; - - result = g_dbus_connection_call_sync (connection, - LOGIN1_SERVICE_NAME, - seat->priv->path, - "org.freedesktop.DBus.Properties", - "Get", - g_variant_new ("(ss)", "org.freedesktop.login1.Seat", property_name), - G_VARIANT_TYPE ("(v)"), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); - if (error) - g_warning ("Error updating CanGraphical: %s", error->message); - g_clear_error (&error); - if (result) - { - GVariant *value; - - g_variant_get (result, "(v)", &value); - seat->priv->can_graphical = g_variant_get_boolean (value); - g_variant_unref (value); - - g_signal_emit (seat, seat_signals[CAN_GRAPHICAL_CHANGED], 0); + GVariant *result; + GError *error = NULL; - g_variant_unref (result); - } + result = g_dbus_connection_call_sync (connection, + LOGIN1_SERVICE_NAME, + seat->priv->path, + "org.freedesktop.DBus.Properties", + "Get", + g_variant_new ("(ss)", "org.freedesktop.login1.Seat", name), + G_VARIANT_TYPE ("(v)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (error) + g_warning ("Error updating seat property %s: %s", name, error->message); + g_clear_error (&error); + if (result) + { + g_variant_get (result, "(v)", &value); + update_property (seat, name, value); + g_variant_unref (result); } } g_variant_iter_free (invalidated_properties); |