mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
gpowerprofilemonitorportal: Set property value by default
When first creating the monitor, correctly set its property value to the value from the portal, rather than waiting for the portal value to change to set it. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2481
This commit is contained in:
@@ -108,6 +108,7 @@ g_power_profile_monitor_portal_initable_init (GInitable *initable,
|
||||
GPowerProfileMonitorPortal *ppm = G_POWER_PROFILE_MONITOR_PORTAL (initable);
|
||||
GDBusProxy *proxy;
|
||||
gchar *name_owner;
|
||||
GVariant *power_saver_enabled_v = NULL;
|
||||
|
||||
if (!glib_should_use_portal ())
|
||||
{
|
||||
@@ -143,6 +144,12 @@ g_power_profile_monitor_portal_initable_init (GInitable *initable,
|
||||
ppm->signal_id = g_signal_connect (proxy, "g-properties-changed",
|
||||
G_CALLBACK (proxy_properties_changed), ppm);
|
||||
|
||||
power_saver_enabled_v = g_dbus_proxy_get_cached_property (proxy, "power-saver-enabled");
|
||||
if (power_saver_enabled_v != NULL &&
|
||||
g_variant_is_of_type (power_saver_enabled_v, G_VARIANT_TYPE_BOOLEAN))
|
||||
ppm->power_saver_enabled = g_variant_get_boolean (power_saver_enabled_v);
|
||||
g_clear_pointer (&power_saver_enabled_v, g_variant_unref);
|
||||
|
||||
ppm->proxy = g_steal_pointer (&proxy);
|
||||
|
||||
return TRUE;
|
||||
|
Reference in New Issue
Block a user