diff options
author | Nachanon Vetjasit <[email protected]> | 2015-09-12 16:32:11 +0700 |
---|---|---|
committer | Wolfgang Ulbrich <[email protected]> | 2015-11-05 20:27:48 +0100 |
commit | 8978c98c76dbef09d2912a55fac1ac72a7918ef5 (patch) | |
tree | 4ef15526a72eab1ba2a9f576a51d011595d8ce01 | |
parent | e11db558736253011ca1ce4af13962adeb4fe567 (diff) | |
download | mate-power-manager-8978c98c76dbef09d2912a55fac1ac72a7918ef5.tar.bz2 mate-power-manager-8978c98c76dbef09d2912a55fac1ac72a7918ef5.tar.xz |
Save AC-power backlight set via brightness keys in GSettings
Based on a patch by Flos Lonicerae.
-rw-r--r-- | src/gpm-backlight.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c index d2938a4..72cb66b 100644 --- a/src/gpm-backlight.c +++ b/src/gpm-backlight.c @@ -433,6 +433,7 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli GError *error = NULL; guint percentage; gboolean hw_changed; + gboolean on_battery; egg_debug ("Button press event type=%s", type); if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_UP) == 0) { @@ -448,6 +449,13 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli gpm_backlight_dialog_show (backlight); /* save the new percentage */ backlight->priv->master_percentage = percentage; + /* if using AC power supply, save the new brightness settings */ + g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL); + if (!on_battery) { + egg_debug ("saving brightness for ac supply: %i", percentage); + g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC, + percentage*1.0); + } } /* we emit a signal for the brightness applet */ if (ret && hw_changed) { @@ -467,6 +475,13 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli gpm_backlight_dialog_show (backlight); /* save the new percentage */ backlight->priv->master_percentage = percentage; + /* if using AC power supply, save the new brightness settings */ + g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL); + if (!on_battery) { + egg_debug ("saving brightness for ac supply: %i", percentage); + g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC, + percentage*1.0); + } } /* we emit a signal for the brightness applet */ if (ret && hw_changed) { |