summaryrefslogtreecommitdiff
path: root/mate-extra/mate-power-manager/files/mate-power-manager-1.8.0-r1-improve-UPower1-support.patch
blob: d3e9d855ef23d197b5cbcff79bf02a8ace3b593d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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;