Merge lp:~ycheng-twn/indicator-power/indicator-power_set-brightness-via-powerd into lp:indicator-power/14.04
- indicator-power_set-brightness-via-powerd
- Merge into trunk.14.04
Status: | Merged |
---|---|
Approved by: | Ricardo Salveti |
Approved revision: | 234 |
Merged at revision: | 235 |
Proposed branch: | lp:~ycheng-twn/indicator-power/indicator-power_set-brightness-via-powerd |
Merge into: | lp:indicator-power/14.04 |
Diff against target: |
353 lines (+269/-4) 4 files modified
src/Makefile.am (+2/-0) src/ib-brightness-powerd-control.c (+181/-0) src/ib-brightness-powerd-control.h (+42/-0) src/service.c (+44/-4) |
To merge this branch: | bzr merge lp:~ycheng-twn/indicator-power/indicator-power_set-brightness-via-powerd |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Salveti (community) | Approve | ||
Yuan-Chen Cheng (community) | Needs Resubmitting | ||
Charles Kerr (community) | Approve | ||
Review via email: mp+209200@code.launchpad.net |
Commit message
Set brightness via powerd if it exist (using dbus)
Description of the change
use powerd dbus interface to control panel brightness if available.
fall back to existing way if powerd does not running.
Yuan-Chen Cheng (ycheng-twn) wrote : | # |
Charles Kerr (charlesk) wrote : | # |
Thanks for the patch, Yuan-Chen! I like the idea of using powerd-via-dbus as the primary method and I appreciate the patch.
Some issues:
* If we're able to get the powerd_proxy but then getBrightnessPa
* In powerd_get_proxy(), error->message is accessed after error's been freed
* In _brightness_init(), why is ib_brightness_
* In _brightness_init(), the call to ib_brightness_
* In _control_set_value, wouldn't it be better to CLAMP(value,
* In -powerd-control.c, please put "return;" statements on their own line for readability.
* In -powerd-control.c, need to use a cancellable when making dbus calls.
* In service.c's get_brightness_
* In service.c's dispose(), no need for the NULL check before calling g_clear_pointer(). g_clear_pointer() contains its own NULL test.
* In service.c's init(), no need to NULL out brightness_control and brightness_
* Not a blocker, but I'd be happier if this didn't introduce extra conditional logic into service.c. It would be nicer if there was a simpler wrapper that owned the two controls privately and gave service.c a unified API to call.
* Not a blocker, but I'd be happier if avoided _sync calls. If you choose make them async, this will require a little extra plumbing that could be put into the wrapper class suggested above.
Yuan-Chen Cheng (ycheng-twn) wrote : | # |
Charles, Thanks a lot for review, I learned a lot.
I modify the code and change as requested except two non-blocker and the cancellable one.
As using cancellable with sync dbus call, I have another branch for that, not sure whether that's the right way to handle it.
lp:~ycheng-twn/indicator-power/indicator-power_set-brightness-via-powerd_add-gcancellable
BTW, what's the recommended way to use gcancellable with async dbus call in our case ? One new cancellable object per request, and cancel previous request if not finished before issue another new one ?
One more thing, there seems no procedure for indicator-power to shutdown gracefully except it lost the bus name. It seems to be an non-issue.
Charles Kerr (charlesk) wrote : | # |
Oh this is a nice revision, thank you for all the fixes!
I like the way that brightness_params_t eliminates the whole 'initialized' flag in ib-brightness-
There's one more thing I'd like to see fixed. Right now running this on the desktop generates an error that we don't really need to log:
> (process:17523): Indicator-
> GDBus.Error:
> was not provided by any .service files
which we could silence by changing the getBrightnessParams dbus call's error checking to:
> if (!ret) {
> if (error != NULL) {
> if (!g_error_matches (error, G_DBUS_ERROR, G_DBUS_
> g_warning(
> g_error_
> }
> return FALSE;
> }
There are a handful of things that you can fix if you like, but are minor and I won't block on them:
* In _service_init(), typo "brigtness"
* In powerd-control.c, we don't need to #include gudev.h, errno.h, stdlib.h, fcntl.h, or string.h.
* In _powerd_
* In _powerd_
* In _powerd_
* In _service_init(), dead store "= NULL;" when powerd_proxy is defined
I hope this doesn't look like I'm piling on -- again, I like this proposal and appreciate the fixes that you made :)
Charles Kerr (charlesk) wrote : | # |
Regarding GCancellable, I agree it's more an issue of code correctness at this point, especially since the _sync calls are staying in there -- there's no way for the _control_free() function to get called while the thread is blocked...
Charles Kerr (charlesk) wrote : | # |
Looks good. Thank you!
Ricardo Salveti (rsalveti) wrote : | # |
2 --- debian/changelog 2014-02-07 16:32:36 +0000
3 +++ debian/changelog 2014-03-06 03:27:42 +0000
Just please remove the changes in debian/changelog as that's now handled by the CI train.
- 234. By Yuan-Chen Cheng
-
remove modificaiton in changelog for CI
Yuan-Chen Cheng (ycheng-twn) wrote : | # |
remove modificaiton in changelog for CI
Ricardo Salveti (rsalveti) wrote : | # |
Code looks fine, also tested and works as expected.
Thanks!
Preview Diff
1 | === modified file 'src/Makefile.am' | |||
2 | --- src/Makefile.am 2013-10-03 20:42:50 +0000 | |||
3 | +++ src/Makefile.am 2014-03-26 04:59:30 +0000 | |||
4 | @@ -46,6 +46,8 @@ | |||
5 | 46 | libindicatorpower_service_a_SOURCES = \ | 46 | libindicatorpower_service_a_SOURCES = \ |
6 | 47 | ib-brightness-control.c \ | 47 | ib-brightness-control.c \ |
7 | 48 | ib-brightness-control.h \ | 48 | ib-brightness-control.h \ |
8 | 49 | ib-brightness-powerd-control.c \ | ||
9 | 50 | ib-brightness-powerd-control.h \ | ||
10 | 49 | device-provider.c \ | 51 | device-provider.c \ |
11 | 50 | device-provider.h \ | 52 | device-provider.h \ |
12 | 51 | device.c \ | 53 | device.c \ |
13 | 52 | 54 | ||
14 | === added file 'src/ib-brightness-powerd-control.c' | |||
15 | --- src/ib-brightness-powerd-control.c 1970-01-01 00:00:00 +0000 | |||
16 | +++ src/ib-brightness-powerd-control.c 2014-03-26 04:59:30 +0000 | |||
17 | @@ -0,0 +1,181 @@ | |||
18 | 1 | /* | ||
19 | 2 | * Copyright 2014 Canonical Ltd. | ||
20 | 3 | * | ||
21 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
22 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
23 | 6 | * by the Free Software Foundation. | ||
24 | 7 | * | ||
25 | 8 | * This program is distributed in the hope that it will be useful, but | ||
26 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
27 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
28 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
29 | 12 | * | ||
30 | 13 | * You should have received a copy of the GNU General Public License along | ||
31 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
32 | 15 | * | ||
33 | 16 | * Authors: | ||
34 | 17 | * Yuan-Chen Cheng <yc.cheng@canonical.com> | ||
35 | 18 | */ | ||
36 | 19 | |||
37 | 20 | #include "ib-brightness-powerd-control.h" | ||
38 | 21 | |||
39 | 22 | static gboolean getBrightnessParams(GDBusProxy* powerd_proxy, int *min, int *max, | ||
40 | 23 | int *dflt, gboolean *ab_supported); | ||
41 | 24 | |||
42 | 25 | GDBusProxy* | ||
43 | 26 | powerd_get_proxy(brightness_params_t *params) | ||
44 | 27 | { | ||
45 | 28 | GError *error = NULL; | ||
46 | 29 | gboolean ret; | ||
47 | 30 | |||
48 | 31 | g_return_val_if_fail (params != NULL, NULL); | ||
49 | 32 | |||
50 | 33 | GDBusProxy* powerd_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, | ||
51 | 34 | G_DBUS_PROXY_FLAGS_NONE, | ||
52 | 35 | NULL, | ||
53 | 36 | "com.canonical.powerd", | ||
54 | 37 | "/com/canonical/powerd", | ||
55 | 38 | "com.canonical.powerd", | ||
56 | 39 | NULL, | ||
57 | 40 | &error); | ||
58 | 41 | |||
59 | 42 | if (error != NULL) | ||
60 | 43 | { | ||
61 | 44 | g_debug ("could not connect to powerd: %s", error->message); | ||
62 | 45 | g_error_free (error); | ||
63 | 46 | return NULL; | ||
64 | 47 | } | ||
65 | 48 | |||
66 | 49 | ret = getBrightnessParams(powerd_proxy, &(params->min), &(params->max), | ||
67 | 50 | &(params->dflt), &(params->ab_supported)); | ||
68 | 51 | |||
69 | 52 | if (! ret) | ||
70 | 53 | { | ||
71 | 54 | g_debug ("can't get brightness parameters from powerd"); | ||
72 | 55 | g_object_unref (powerd_proxy); | ||
73 | 56 | return NULL; | ||
74 | 57 | } | ||
75 | 58 | |||
76 | 59 | return powerd_proxy; | ||
77 | 60 | } | ||
78 | 61 | |||
79 | 62 | |||
80 | 63 | static gboolean | ||
81 | 64 | getBrightnessParams(GDBusProxy* powerd_proxy, int *min, int *max, int *dflt, gboolean *ab_supported) | ||
82 | 65 | { | ||
83 | 66 | GVariant *ret = NULL; | ||
84 | 67 | GError *error = NULL; | ||
85 | 68 | |||
86 | 69 | ret = g_dbus_proxy_call_sync(powerd_proxy, | ||
87 | 70 | "getBrightnessParams", | ||
88 | 71 | NULL, | ||
89 | 72 | G_DBUS_CALL_FLAGS_NONE, | ||
90 | 73 | 400, NULL, &error); // timeout: 400 ms | ||
91 | 74 | if (!ret) | ||
92 | 75 | { | ||
93 | 76 | if (error != NULL) | ||
94 | 77 | { | ||
95 | 78 | if (!g_error_matches(error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN)) | ||
96 | 79 | { | ||
97 | 80 | g_warning("getBrightnessParams from powerd failed: %s", error->message); | ||
98 | 81 | } | ||
99 | 82 | g_error_free(error); | ||
100 | 83 | } | ||
101 | 84 | return FALSE; | ||
102 | 85 | } | ||
103 | 86 | |||
104 | 87 | g_variant_get(ret, "((iiib))", min, max, dflt, ab_supported); | ||
105 | 88 | g_variant_unref(ret); | ||
106 | 89 | return TRUE; | ||
107 | 90 | } | ||
108 | 91 | |||
109 | 92 | static gboolean setUserBrightness(GDBusProxy* powerd_proxy, GCancellable *gcancel, int brightness) | ||
110 | 93 | { | ||
111 | 94 | GVariant *ret = NULL; | ||
112 | 95 | GError *error = NULL; | ||
113 | 96 | |||
114 | 97 | ret = g_dbus_proxy_call_sync(powerd_proxy, | ||
115 | 98 | "setUserBrightness", | ||
116 | 99 | g_variant_new("(i)", brightness), | ||
117 | 100 | G_DBUS_CALL_FLAGS_NONE, | ||
118 | 101 | -1, gcancel, &error); | ||
119 | 102 | if (!ret) { | ||
120 | 103 | g_warning("setUserBrightness via powerd failed: %s", error->message); | ||
121 | 104 | g_error_free(error); | ||
122 | 105 | return FALSE; | ||
123 | 106 | } else { | ||
124 | 107 | g_variant_unref(ret); | ||
125 | 108 | return TRUE; | ||
126 | 109 | } | ||
127 | 110 | } | ||
128 | 111 | |||
129 | 112 | struct _IbBrightnessPowerdControl | ||
130 | 113 | { | ||
131 | 114 | GDBusProxy *powerd_proxy; | ||
132 | 115 | GCancellable *gcancel; | ||
133 | 116 | |||
134 | 117 | int min; | ||
135 | 118 | int max; | ||
136 | 119 | int dflt; // defalut value | ||
137 | 120 | gboolean ab_supported; | ||
138 | 121 | |||
139 | 122 | int current; | ||
140 | 123 | }; | ||
141 | 124 | |||
142 | 125 | IbBrightnessPowerdControl* | ||
143 | 126 | ib_brightness_powerd_control_new (GDBusProxy* powerd_proxy, brightness_params_t params) | ||
144 | 127 | { | ||
145 | 128 | IbBrightnessPowerdControl *control; | ||
146 | 129 | |||
147 | 130 | control = g_new0 (IbBrightnessPowerdControl, 1); | ||
148 | 131 | control->powerd_proxy = powerd_proxy; | ||
149 | 132 | control->gcancel = g_cancellable_new(); | ||
150 | 133 | |||
151 | 134 | control->min = params.min; | ||
152 | 135 | control->max = params.max; | ||
153 | 136 | control->dflt = params.dflt; | ||
154 | 137 | control->ab_supported = params.ab_supported; | ||
155 | 138 | |||
156 | 139 | // XXX: set the brightness value is the only way to sync the brightness value with | ||
157 | 140 | // powerd, and we should set the user prefered / last set brightness value upon startup. | ||
158 | 141 | // Before we have code to store last set brightness value or other mechanism, we set | ||
159 | 142 | // it to default brightness that powerd proposed. | ||
160 | 143 | ib_brightness_powerd_control_set_value(control, control->dflt); | ||
161 | 144 | |||
162 | 145 | return control; | ||
163 | 146 | } | ||
164 | 147 | |||
165 | 148 | void | ||
166 | 149 | ib_brightness_powerd_control_set_value (IbBrightnessPowerdControl* self, gint value) | ||
167 | 150 | { | ||
168 | 151 | gboolean ret; | ||
169 | 152 | |||
170 | 153 | value = CLAMP(value, self->min, self->max); | ||
171 | 154 | ret = setUserBrightness(self->powerd_proxy, self->gcancel, value); | ||
172 | 155 | if (ret) | ||
173 | 156 | { | ||
174 | 157 | self->current = value; | ||
175 | 158 | } | ||
176 | 159 | } | ||
177 | 160 | |||
178 | 161 | gint | ||
179 | 162 | ib_brightness_powerd_control_get_value (IbBrightnessPowerdControl* self) | ||
180 | 163 | { | ||
181 | 164 | return self->current; | ||
182 | 165 | } | ||
183 | 166 | |||
184 | 167 | gint | ||
185 | 168 | ib_brightness_powerd_control_get_max_value (IbBrightnessPowerdControl* self) | ||
186 | 169 | { | ||
187 | 170 | return self->max; | ||
188 | 171 | } | ||
189 | 172 | |||
190 | 173 | void | ||
191 | 174 | ib_brightness_powerd_control_free (IbBrightnessPowerdControl *self) | ||
192 | 175 | { | ||
193 | 176 | g_cancellable_cancel (self->gcancel); | ||
194 | 177 | g_object_unref (self->gcancel); | ||
195 | 178 | g_object_unref (self->powerd_proxy); | ||
196 | 179 | g_free (self); | ||
197 | 180 | } | ||
198 | 181 | |||
199 | 0 | 182 | ||
200 | === added file 'src/ib-brightness-powerd-control.h' | |||
201 | --- src/ib-brightness-powerd-control.h 1970-01-01 00:00:00 +0000 | |||
202 | +++ src/ib-brightness-powerd-control.h 2014-03-26 04:59:30 +0000 | |||
203 | @@ -0,0 +1,42 @@ | |||
204 | 1 | /* | ||
205 | 2 | * Copyright 2014 Canonical Ltd. | ||
206 | 3 | * | ||
207 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
208 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
209 | 6 | * by the Free Software Foundation. | ||
210 | 7 | * | ||
211 | 8 | * This program is distributed in the hope that it will be useful, but | ||
212 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
213 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
214 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
215 | 12 | * | ||
216 | 13 | * You should have received a copy of the GNU General Public License along | ||
217 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
218 | 15 | * | ||
219 | 16 | * Authors: | ||
220 | 17 | * Y.C Cheng <yc.cheng@canonical.com> | ||
221 | 18 | */ | ||
222 | 19 | |||
223 | 20 | #ifndef __IB_BRIGHTNESS_POWERD_CONTROL_H__ | ||
224 | 21 | #define __IB_BRIGHTNESS_POWERD_CONTROL_H__ | ||
225 | 22 | |||
226 | 23 | #include <gio/gio.h> | ||
227 | 24 | |||
228 | 25 | typedef struct { | ||
229 | 26 | int max; | ||
230 | 27 | int min; | ||
231 | 28 | int dflt; | ||
232 | 29 | gboolean ab_supported; | ||
233 | 30 | } brightness_params_t; | ||
234 | 31 | |||
235 | 32 | GDBusProxy* powerd_get_proxy(brightness_params_t *); | ||
236 | 33 | |||
237 | 34 | typedef struct _IbBrightnessPowerdControl IbBrightnessPowerdControl; | ||
238 | 35 | |||
239 | 36 | IbBrightnessPowerdControl* ib_brightness_powerd_control_new (GDBusProxy* powerd_proxy, brightness_params_t params); | ||
240 | 37 | void ib_brightness_powerd_control_set_value (IbBrightnessPowerdControl* self, gint value); | ||
241 | 38 | gint ib_brightness_powerd_control_get_value (IbBrightnessPowerdControl* self); | ||
242 | 39 | gint ib_brightness_powerd_control_get_max_value (IbBrightnessPowerdControl* self); | ||
243 | 40 | void ib_brightness_powerd_control_free (IbBrightnessPowerdControl *self); | ||
244 | 41 | |||
245 | 42 | #endif | ||
246 | 0 | 43 | ||
247 | === modified file 'src/service.c' | |||
248 | --- src/service.c 2014-03-13 22:27:29 +0000 | |||
249 | +++ src/service.c 2014-03-26 04:59:30 +0000 | |||
250 | @@ -27,6 +27,7 @@ | |||
251 | 27 | #include "device.h" | 27 | #include "device.h" |
252 | 28 | #include "device-provider.h" | 28 | #include "device-provider.h" |
253 | 29 | #include "ib-brightness-control.h" | 29 | #include "ib-brightness-control.h" |
254 | 30 | #include "ib-brightness-powerd-control.h" | ||
255 | 30 | #include "service.h" | 31 | #include "service.h" |
256 | 31 | 32 | ||
257 | 32 | #define BUS_NAME "com.canonical.indicator.power" | 33 | #define BUS_NAME "com.canonical.indicator.power" |
258 | @@ -104,6 +105,7 @@ | |||
259 | 104 | GSettings * settings; | 105 | GSettings * settings; |
260 | 105 | 106 | ||
261 | 106 | IbBrightnessControl * brightness_control; | 107 | IbBrightnessControl * brightness_control; |
262 | 108 | IbBrightnessPowerdControl * brightness_powerd_control; | ||
263 | 107 | 109 | ||
264 | 108 | guint own_id; | 110 | guint own_id; |
265 | 109 | guint actions_export_id; | 111 | guint actions_export_id; |
266 | @@ -457,7 +459,16 @@ | |||
267 | 457 | static void | 459 | static void |
268 | 458 | get_brightness_range (IndicatorPowerService * self, gint * low, gint * high) | 460 | get_brightness_range (IndicatorPowerService * self, gint * low, gint * high) |
269 | 459 | { | 461 | { |
271 | 460 | const int max = ib_brightness_control_get_max_value (self->priv->brightness_control); | 462 | priv_t * p = self->priv; |
272 | 463 | int max = 0; | ||
273 | 464 | if (p->brightness_control) | ||
274 | 465 | { | ||
275 | 466 | max = ib_brightness_control_get_max_value (self->priv->brightness_control); | ||
276 | 467 | } | ||
277 | 468 | else if (p->brightness_powerd_control) | ||
278 | 469 | { | ||
279 | 470 | max = ib_brightness_powerd_control_get_max_value (self->priv->brightness_powerd_control); | ||
280 | 471 | } | ||
281 | 461 | *low = max * 0.05; /* 5% minimum -- don't let the screen go completely dark */ | 472 | *low = max * 0.05; /* 5% minimum -- don't let the screen go completely dark */ |
282 | 462 | *high = max; | 473 | *high = max; |
283 | 463 | } | 474 | } |
284 | @@ -500,7 +511,15 @@ | |||
285 | 500 | action_state_for_brightness (IndicatorPowerService * self) | 511 | action_state_for_brightness (IndicatorPowerService * self) |
286 | 501 | { | 512 | { |
287 | 502 | priv_t * p = self->priv; | 513 | priv_t * p = self->priv; |
289 | 503 | const gint brightness = ib_brightness_control_get_value (p->brightness_control); | 514 | gint brightness = 0; |
290 | 515 | if (p->brightness_control) | ||
291 | 516 | { | ||
292 | 517 | brightness = ib_brightness_control_get_value (p->brightness_control); | ||
293 | 518 | } | ||
294 | 519 | else if (p->brightness_powerd_control) | ||
295 | 520 | { | ||
296 | 521 | brightness = ib_brightness_powerd_control_get_value (p->brightness_powerd_control); | ||
297 | 522 | } | ||
298 | 504 | return g_variant_new_double (brightness_to_percentage (self, brightness)); | 523 | return g_variant_new_double (brightness_to_percentage (self, brightness)); |
299 | 505 | } | 524 | } |
300 | 506 | 525 | ||
301 | @@ -519,7 +538,16 @@ | |||
302 | 519 | IndicatorPowerService * self = INDICATOR_POWER_SERVICE (gself); | 538 | IndicatorPowerService * self = INDICATOR_POWER_SERVICE (gself); |
303 | 520 | const gdouble percentage = g_variant_get_double (parameter); | 539 | const gdouble percentage = g_variant_get_double (parameter); |
304 | 521 | const int brightness = percentage_to_brightness (self, percentage); | 540 | const int brightness = percentage_to_brightness (self, percentage); |
306 | 522 | ib_brightness_control_set_value (self->priv->brightness_control, brightness); | 541 | |
307 | 542 | if (self->priv->brightness_control) | ||
308 | 543 | { | ||
309 | 544 | ib_brightness_control_set_value (self->priv->brightness_control, brightness); | ||
310 | 545 | } | ||
311 | 546 | else if (self->priv->brightness_powerd_control) | ||
312 | 547 | { | ||
313 | 548 | ib_brightness_powerd_control_set_value (self->priv->brightness_powerd_control, brightness); | ||
314 | 549 | } | ||
315 | 550 | |||
316 | 523 | update_brightness_action_state (self); | 551 | update_brightness_action_state (self); |
317 | 524 | } | 552 | } |
318 | 525 | 553 | ||
319 | @@ -1016,7 +1044,9 @@ | |||
320 | 1016 | 1044 | ||
321 | 1017 | g_clear_object (&p->conn); | 1045 | g_clear_object (&p->conn); |
322 | 1018 | 1046 | ||
323 | 1047 | // g_clear_pointer has NULL check inside. | ||
324 | 1019 | g_clear_pointer (&p->brightness_control, ib_brightness_control_free); | 1048 | g_clear_pointer (&p->brightness_control, ib_brightness_control_free); |
325 | 1049 | g_clear_pointer (&p->brightness_powerd_control, ib_brightness_powerd_control_free); | ||
326 | 1020 | 1050 | ||
327 | 1021 | indicator_power_service_set_device_provider (self, NULL); | 1051 | indicator_power_service_set_device_provider (self, NULL); |
328 | 1022 | 1052 | ||
329 | @@ -1030,6 +1060,8 @@ | |||
330 | 1030 | static void | 1060 | static void |
331 | 1031 | indicator_power_service_init (IndicatorPowerService * self) | 1061 | indicator_power_service_init (IndicatorPowerService * self) |
332 | 1032 | { | 1062 | { |
333 | 1063 | GDBusProxy *powerd_proxy; | ||
334 | 1064 | brightness_params_t powerd_brightness_params; | ||
335 | 1033 | priv_t * p = G_TYPE_INSTANCE_GET_PRIVATE (self, | 1065 | priv_t * p = G_TYPE_INSTANCE_GET_PRIVATE (self, |
336 | 1034 | INDICATOR_TYPE_POWER_SERVICE, | 1066 | INDICATOR_TYPE_POWER_SERVICE, |
337 | 1035 | IndicatorPowerServicePrivate); | 1067 | IndicatorPowerServicePrivate); |
338 | @@ -1039,7 +1071,15 @@ | |||
339 | 1039 | 1071 | ||
340 | 1040 | p->settings = g_settings_new ("com.canonical.indicator.power"); | 1072 | p->settings = g_settings_new ("com.canonical.indicator.power"); |
341 | 1041 | 1073 | ||
343 | 1042 | p->brightness_control = ib_brightness_control_new (); | 1074 | powerd_proxy = powerd_get_proxy(&powerd_brightness_params); |
344 | 1075 | if (powerd_proxy != NULL) | ||
345 | 1076 | { | ||
346 | 1077 | p->brightness_powerd_control = ib_brightness_powerd_control_new(powerd_proxy, powerd_brightness_params); | ||
347 | 1078 | } | ||
348 | 1079 | else | ||
349 | 1080 | { | ||
350 | 1081 | p->brightness_control = ib_brightness_control_new (); | ||
351 | 1082 | } | ||
352 | 1043 | 1083 | ||
353 | 1044 | init_gactions (self); | 1084 | init_gactions (self); |
354 | 1045 | 1085 |
1. powerd also need to be updated (to accept dbus command from non-root user)
2. as tested on n4, it seems not introduce noticeable delay (it seems to have bit latency before change)