[gnome-power-manager] Add two properties to the DBus interface for gnome-shell
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] Add two properties to the DBus interface for gnome-shell
- Date: Wed, 27 Oct 2010 09:15:05 +0000 (UTC)
commit a85e6cf90e385fe5174c95b9ed1b6387313bc4e5
Author: Richard Hughes <richard hughsie com>
Date: Wed Oct 27 10:46:52 2010 +0100
Add two properties to the DBus interface for gnome-shell
src/gpm-manager.c | 44 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index c44872f..79bf84c 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -60,6 +60,12 @@ static const gchar *power_manager_introspection = ""
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<node name=\"/org/gnome/PowerManager\">"
"<interface name=\"org.gnome.PowerManager\">"
+ "<property name='Icon' type='s' access='read'>"
+ "</property>"
+ "<property name='Tooltip' type='s' access='read'>"
+ "</property>"
+ "<signal name=\"Changed\">"
+ "</signal>"
"</interface>"
"</node>";
@@ -2005,9 +2011,27 @@ gpm_manager_dbus_property_get (GDBusConnection *connection,
const gchar *interface_name, const gchar *property_name,
GError **error, gpointer user_data)
{
- /* GpmManager *manager = GPM_MANAGER (user_data); */
- /* do nothing, no properties defined (yet) */
- return NULL;
+ GpmManager *manager = GPM_MANAGER (user_data);
+ gchar *tooltip = NULL;
+ GIcon *icon = NULL;
+ GVariant *retval = NULL;
+
+ if (g_strcmp0 (property_name, "Icon") == 0) {
+ icon = gpm_engine_get_icon (manager->priv->engine);
+ tooltip = g_icon_to_string (icon);
+ retval = g_variant_new_string (tooltip);
+ goto out;
+ }
+ if (g_strcmp0 (property_name, "Tooltip") == 0) {
+ tooltip = gpm_engine_get_summary (manager->priv->engine);
+ retval = g_variant_new_string (tooltip);
+ goto out;
+ }
+out:
+ if (icon != NULL)
+ g_object_unref (icon);
+ g_free (tooltip);
+ return retval;
}
/**
@@ -2060,6 +2084,18 @@ gpm_manager_bus_acquired_cb (GDBusConnection *connection,
}
/**
+ * gpm_manager_engine_devices_changed_cb:
+ **/
+static void
+gpm_manager_engine_devices_changed_cb (GpmEngine *engine, GpmManager *manager)
+{
+ /* emit for the shell */
+ g_dbus_connection_emit_signal (manager->priv->bus_connection,
+ NULL, GPM_DBUS_PATH, GPM_DBUS_INTERFACE,
+ "Changed", NULL, NULL);
+}
+
+/**
* gpm_manager_name_lost_cb:
**/
static void
@@ -2187,6 +2223,8 @@ gpm_manager_init (GpmManager *manager)
G_CALLBACK (gpm_manager_engine_charge_critical_cb), manager);
g_signal_connect (manager->priv->engine, "charge-action",
G_CALLBACK (gpm_manager_engine_charge_action_cb), manager);
+ g_signal_connect (manager->priv->engine, "devices-changed",
+ G_CALLBACK (gpm_manager_engine_devices_changed_cb), manager);
/* set disk spindown threshold */
timeout = gpm_manager_get_spindown_timeout (manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]