diff options
author | Stefano Karapetsas <[email protected]> | 2014-04-24 18:17:35 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2014-04-24 18:17:35 +0200 |
commit | 1fb28703f76a97421f3554d5c553b06707f890a7 (patch) | |
tree | 6c266235ee3e863c9cd0a53299ed62c9d4c89340 /src/gpm-engine.c | |
parent | a5d7e923a8effd2dc329bc25b63bd64bf0c38178 (diff) | |
download | mate-power-manager-1fb28703f76a97421f3554d5c553b06707f890a7.tar.bz2 mate-power-manager-1fb28703f76a97421f3554d5c553b06707f890a7.tar.xz |
Improve UPower1 support
Diffstat (limited to 'src/gpm-engine.c')
-rw-r--r-- | src/gpm-engine.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/gpm-engine.c b/src/gpm-engine.c index e6c6bf2..fe458e3 100644 --- a/src/gpm-engine.c +++ b/src/gpm-engine.c @@ -82,6 +82,9 @@ G_DEFINE_TYPE (GpmEngine, gpm_engine, G_TYPE_OBJECT) static UpDevice *gpm_engine_get_composite_device (GpmEngine *engine, UpDevice *original_device); static UpDevice *gpm_engine_update_composite_device (GpmEngine *engine, UpDevice *original_device); +#if UP_CHECK_VERSION (0, 99, 0) +static void gpm_engine_device_changed_cb (UpDevice *device, GParamSpec *pspec, GpmEngine *engine); +#endif typedef enum { GPM_ENGINE_WARNING_NONE = 0, @@ -757,6 +760,13 @@ gpm_engine_device_add (GpmEngine *engine, UpDevice *device) g_object_get (composite, "state", &state, NULL); g_object_set_data (G_OBJECT(composite), "engine-state-old", GUINT_TO_POINTER(state)); } + +#if UP_CHECK_VERSION (0, 99, 0) + if (kind == UP_DEVICE_KIND_BATTERY || kind == UP_DEVICE_KIND_UPS || kind == UP_DEVICE_KIND_LINE_POWER) + return; + g_signal_connect (device, "notify", G_CALLBACK (gpm_engine_device_changed_cb), engine); +#endif + } /** @@ -851,19 +861,20 @@ gpm_engine_device_removed_cb (UpClient *client, UpDevice *device, GpmEngine *eng **/ static void #if UP_CHECK_VERSION(0, 99, 0) -gpm_engine_device_changed_cb (UpClient *client, GParamSpec *pspec, GpmEngine *engine) -{ - gpm_engine_recalculate_state (engine); -} +gpm_engine_device_changed_cb (UpDevice *device, GParamSpec *pspec, GpmEngine *engine) #else gpm_engine_device_changed_cb (UpClient *client, UpDevice *device, GpmEngine *engine) +#endif { +#if !UP_CHECK_VERSION(0, 99, 0) UpDeviceKind kind; +#endif UpDeviceState state; UpDeviceState state_old; GpmEngineWarning warning_old; GpmEngineWarning warning; +#if !UP_CHECK_VERSION(0, 99, 0) /* get device properties */ g_object_get (device, "kind", &kind, @@ -874,6 +885,7 @@ gpm_engine_device_changed_cb (UpClient *client, UpDevice *device, GpmEngine *eng egg_debug ("updating because %s changed", up_device_get_object_path (device)); device = gpm_engine_update_composite_device (engine, device); } +#endif /* get device properties (may be composite) */ g_object_get (device, @@ -917,7 +929,6 @@ gpm_engine_device_changed_cb (UpClient *client, UpDevice *device, GpmEngine *eng gpm_engine_recalculate_state (engine); } -#endif /** * gpm_engine_get_devices: @@ -1042,10 +1053,7 @@ gpm_engine_init (GpmEngine *engine) G_CALLBACK (gpm_engine_device_added_cb), engine); g_signal_connect (engine->priv->client, "device-removed", G_CALLBACK (gpm_engine_device_removed_cb), engine); -#if UP_CHECK_VERSION(0, 99, 0) - g_signal_connect (engine->priv->client, "notify", - G_CALLBACK (gpm_engine_device_changed_cb), engine); -#else +#if !UP_CHECK_VERSION(0, 99, 0) g_signal_connect (engine->priv->client, "device-changed", G_CALLBACK (gpm_engine_device_changed_cb), engine); #endif @@ -1075,6 +1083,11 @@ gpm_engine_init (GpmEngine *engine) #endif /* create a fake virtual composite battery */ +#if UP_CHECK_VERSION(0, 99, 0) + engine->priv->battery_composite = up_client_get_display_device (engine->priv->client); + g_signal_connect (engine->priv->client, "notify", + G_CALLBACK (gpm_engine_device_changed_cb), engine); +#else engine->priv->battery_composite = up_device_new (); g_object_set (engine->priv->battery_composite, "kind", UP_DEVICE_KIND_BATTERY, @@ -1083,6 +1096,7 @@ gpm_engine_init (GpmEngine *engine) "power-supply", TRUE, "is-present", TRUE, NULL); +#endif engine->priv->previous_icon = NULL; engine->priv->previous_summary = NULL; |