diff options
author | Y.C cheng <yc.cheng@canonical.com> | 2014-03-05 13:32:26 +0800 |
---|---|---|
committer | Y.C cheng <yc.cheng@canonical.com> | 2014-03-05 13:32:26 +0800 |
commit | 6a577e1b2d6941af7eef77a7a6a8c4c064dcbcf4 (patch) | |
tree | 529d29099094a6cc4488df5c88b3fd8634ffefdf /src/ib-brightness-powerd-control.c | |
parent | 18fd0fa741f818ed8a6d09b8a2a4623e85d6bbdf (diff) | |
download | ayatana-indicator-power-6a577e1b2d6941af7eef77a7a6a8c4c064dcbcf4.tar.gz ayatana-indicator-power-6a577e1b2d6941af7eef77a7a6a8c4c064dcbcf4.tar.bz2 ayatana-indicator-power-6a577e1b2d6941af7eef77a7a6a8c4c064dcbcf4.zip |
clean up / wrong code fix
Diffstat (limited to 'src/ib-brightness-powerd-control.c')
-rw-r--r-- | src/ib-brightness-powerd-control.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/ib-brightness-powerd-control.c b/src/ib-brightness-powerd-control.c index 3395bda..e7d4e0e 100644 --- a/src/ib-brightness-powerd-control.c +++ b/src/ib-brightness-powerd-control.c @@ -40,8 +40,8 @@ powerd_get_proxy(void) &error); if (error != NULL) { - g_error_free (error); g_debug ("could not connect to powerd: %s", error->message); + g_error_free (error); return NULL; } return powerd_proxy; @@ -109,11 +109,12 @@ static void ib_brightness_init(IbBrightnessPowerdControl *control) { gboolean ret = getBrightnessParams(control->powerd_proxy, &(control->min), &(control->max), &(control->dflt), &(control->ab_supported)); - if (! ret) return; - - ib_brightness_powerd_control_set_value(control, control->max); + if (! ret) + return; control->inited = TRUE; + + ib_brightness_powerd_control_set_value(control, control->max * 8 / 10); } IbBrightnessPowerdControl* @@ -134,8 +135,16 @@ void ib_brightness_powerd_control_set_value (IbBrightnessPowerdControl* self, gint value) { gboolean ret; - if (! self->inited) return; - if (value > self->max || value < self->min) return; + if (! self->inited) + return; + if (value > self->max) + { + value = self->max; + } + else if (value < self->min) + { + value = self->min; + } ret = setUserBrightness(self->powerd_proxy, value); if (ret) { @@ -146,14 +155,16 @@ ib_brightness_powerd_control_set_value (IbBrightnessPowerdControl* self, gint va gint ib_brightness_powerd_control_get_value (IbBrightnessPowerdControl* self) { - if (! self->inited) return 0; + if (! self->inited) + return 0; return self->current; } gint ib_brightness_powerd_control_get_max_value (IbBrightnessPowerdControl* self) { - if (! self->inited) return 0; + if (! self->inited) + return 0; return self->max; } |