mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
color-manager: Set up a D-Bus proxy to org.gnome.SettingsDaemon.Color
gsd-color provides this API, which exposes details about the night light state. Currently, gsd-color also turns this state into CRTC gamma changes, but this will eventually change, and this is a preparation for this. The proxy isn't yet used for anything. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
This commit is contained in:
parent
0dc6d76371
commit
43cd70089e
7
data/dbus-interfaces/org.gnome.SettingsDaemon.Color.xml
Normal file
7
data/dbus-interfaces/org.gnome.SettingsDaemon.Color.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<node>
|
||||||
|
<interface name="org.gnome.SettingsDaemon.Color">
|
||||||
|
<property name="DisabledUntilTomorrow" type="b" access="readwrite"/>
|
||||||
|
<property name="NightLightActive" type="b" access="read"/>
|
||||||
|
<property name="Temperature" type="u" access="readwrite"/>
|
||||||
|
</interface>
|
||||||
|
</node>
|
@ -51,6 +51,8 @@
|
|||||||
#include "backends/meta-color-device.h"
|
#include "backends/meta-color-device.h"
|
||||||
#include "backends/meta-monitor.h"
|
#include "backends/meta-monitor.h"
|
||||||
|
|
||||||
|
#include "meta-dbus-gsd-color.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -70,6 +72,8 @@ typedef struct _MetaColorManagerPrivate
|
|||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
|
|
||||||
GHashTable *devices;
|
GHashTable *devices;
|
||||||
|
|
||||||
|
MetaDbusSettingsDaemonColor *gsd_color;
|
||||||
} MetaColorManagerPrivate;
|
} MetaColorManagerPrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (MetaColorManager, meta_color_manager, G_TYPE_OBJECT)
|
G_DEFINE_TYPE_WITH_PRIVATE (MetaColorManager, meta_color_manager, G_TYPE_OBJECT)
|
||||||
@ -201,6 +205,33 @@ cd_client_connect_cb (GObject *source_object,
|
|||||||
color_manager);
|
color_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_gsd_color_ready (GObject *source_object,
|
||||||
|
GAsyncResult *res,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MetaColorManager *color_manager = META_COLOR_MANAGER (user_data);
|
||||||
|
MetaColorManagerPrivate *priv =
|
||||||
|
meta_color_manager_get_instance_private (color_manager);
|
||||||
|
MetaDbusSettingsDaemonColor *gsd_color;
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
|
gsd_color =
|
||||||
|
meta_dbus_settings_daemon_color_proxy_new_for_bus_finish (res, &error);
|
||||||
|
if (!gsd_color)
|
||||||
|
{
|
||||||
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_warning ("Failed to create gsd-color D-Bus proxy: %s", error->message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_COLOR,
|
||||||
|
"Connection to org.gnome.SettingsDaemon.Color established");
|
||||||
|
priv->gsd_color = gsd_color;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_color_manager_constructed (GObject *object)
|
meta_color_manager_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
@ -213,6 +244,15 @@ meta_color_manager_constructed (GObject *object)
|
|||||||
priv->cd_client = cd_client_new ();
|
priv->cd_client = cd_client_new ();
|
||||||
cd_client_connect (priv->cd_client, priv->cancellable, cd_client_connect_cb,
|
cd_client_connect (priv->cd_client, priv->cancellable, cd_client_connect_cb,
|
||||||
color_manager);
|
color_manager);
|
||||||
|
|
||||||
|
meta_dbus_settings_daemon_color_proxy_new_for_bus (
|
||||||
|
G_BUS_TYPE_SESSION,
|
||||||
|
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||||
|
"org.gnome.SettingsDaemon.Color",
|
||||||
|
"/org/gnome/SettingsDaemon/Color",
|
||||||
|
priv->cancellable,
|
||||||
|
on_gsd_color_ready,
|
||||||
|
color_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -225,6 +265,7 @@ meta_color_manager_finalize (GObject *object)
|
|||||||
g_cancellable_cancel (priv->cancellable);
|
g_cancellable_cancel (priv->cancellable);
|
||||||
g_clear_object (&priv->cancellable);
|
g_clear_object (&priv->cancellable);
|
||||||
g_clear_pointer (&priv->devices, g_hash_table_unref);
|
g_clear_pointer (&priv->devices, g_hash_table_unref);
|
||||||
|
g_clear_object (&priv->gsd_color);
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_color_manager_parent_class)->finalize (object);
|
G_OBJECT_CLASS (meta_color_manager_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -918,6 +918,13 @@ dbus_rtkit_built_sources = gnome.gdbus_codegen('meta-dbus-rtkit1',
|
|||||||
)
|
)
|
||||||
mutter_built_sources += dbus_rtkit_built_sources
|
mutter_built_sources += dbus_rtkit_built_sources
|
||||||
|
|
||||||
|
dbus_gsd_color_built_sources = gnome.gdbus_codegen('meta-dbus-gsd-color',
|
||||||
|
join_paths(dbus_interfaces_dir, 'org.gnome.SettingsDaemon.Color.xml'),
|
||||||
|
interface_prefix: 'org.gnome.',
|
||||||
|
namespace: 'MetaDbus',
|
||||||
|
)
|
||||||
|
mutter_built_sources += dbus_gsd_color_built_sources
|
||||||
|
|
||||||
wayland_protocol_server_headers = []
|
wayland_protocol_server_headers = []
|
||||||
wayland_protocol_client_headers = []
|
wayland_protocol_client_headers = []
|
||||||
wayland_protocol_sources = []
|
wayland_protocol_sources = []
|
||||||
|
31
src/tests/dbusmock-templates/gsd-color.py
Normal file
31
src/tests/dbusmock-templates/gsd-color.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
'''gsd-color proxy mock template
|
||||||
|
'''
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
# Software Foundation; either version 3 of the License, or (at your option) any
|
||||||
|
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
|
||||||
|
# of the license.
|
||||||
|
|
||||||
|
__author__ = 'Jonas Ådahl'
|
||||||
|
__copyright__ = '(c) 2021 Red Hat Inc.'
|
||||||
|
|
||||||
|
import dbus
|
||||||
|
import os
|
||||||
|
from dbusmock import MOCK_IFACE
|
||||||
|
|
||||||
|
|
||||||
|
BUS_NAME = 'org.gnome.SettingsDaemon.Color'
|
||||||
|
MAIN_OBJ = '/org/gnome/SettingsDaemon/Color'
|
||||||
|
MAIN_IFACE = BUS_NAME
|
||||||
|
SYSTEM_BUS = False
|
||||||
|
|
||||||
|
|
||||||
|
def load(mock, parameters=None):
|
||||||
|
mock.night_light_active = False
|
||||||
|
mock.temperature = 6500
|
||||||
|
|
||||||
|
mock.AddProperty(MAIN_IFACE, 'NightLightActive', dbus.Boolean())
|
||||||
|
mock.AddProperty(MAIN_IFACE, 'Temperature', dbus.UInt32())
|
||||||
|
mock.Set(MAIN_IFACE, 'NightLightActive', mock.night_light_active)
|
||||||
|
mock.Set(MAIN_IFACE, 'Temperature', dbus.UInt32(mock.temperature))
|
@ -43,6 +43,7 @@ class MutterDBusTestCase(DBusTestCase):
|
|||||||
|
|
||||||
klass.start_from_local_template('localed')
|
klass.start_from_local_template('localed')
|
||||||
klass.start_from_local_template('colord')
|
klass.start_from_local_template('colord')
|
||||||
|
klass.start_from_local_template('gsd-color')
|
||||||
|
|
||||||
klass.system_bus_con = klass.get_dbus(system_bus=True)
|
klass.system_bus_con = klass.get_dbus(system_bus=True)
|
||||||
klass.session_bus_con = klass.get_dbus(system_bus=False)
|
klass.session_bus_con = klass.get_dbus(system_bus=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user