[gnome-settings-daemon] power: Add backlight_available() function
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Add backlight_available() function
- Date: Wed, 23 Jan 2013 23:09:05 +0000 (UTC)
commit f79d8b32641da31d5190c25c65b61f21f96f9ce5
Author: Bastien Nocera <hadess hadess net>
Date: Wed Jan 23 23:45:17 2013 +0100
power: Add backlight_available() function
Checking both the XRandR backlight functionality and udev for a suitable
backlight.
configure.ac | 2 +-
plugins/power/Makefile.am | 4 ++++
plugins/power/gpm-common.c | 18 ++++++++++++++++++
plugins/power/gpm-common.h | 1 +
4 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dcf5983..116ce68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -234,7 +234,7 @@ PKG_CHECK_MODULES(SOUND, [libpulse >= $PA_REQUIRED_VERSION $GUDEV_PKG libpulse-m
# ---------------------------------------------------------------------------
# Power
# ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(POWER, upower-glib >= $UPOWER_REQUIRED_VERSION gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION libcanberra-gtk3 libnotify x11 xext xtst)
+PKG_CHECK_MODULES(POWER, upower-glib >= $UPOWER_REQUIRED_VERSION gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION $GUDEV_PKG libcanberra-gtk3 libnotify x11 xext xtst)
if test x$have_gudev != xno; then
PKG_CHECK_MODULES(BACKLIGHT_HELPER,
diff --git a/plugins/power/Makefile.am b/plugins/power/Makefile.am
index 371e8ba..a33cbc5 100644
--- a/plugins/power/Makefile.am
+++ b/plugins/power/Makefile.am
@@ -8,6 +8,8 @@ plugin_LTLIBRARIES = \
libpower_la_SOURCES = \
gpm-common.c \
gpm-common.h \
+ gsd-backlight-linux.c \
+ gsd-backlight-linux.h \
gsd-power-manager.c \
gsd-power-manager.h \
gsm-inhibitor-flag.h \
@@ -63,6 +65,8 @@ libexec_PROGRAMS = gsd-test-power
gsd_test_power_SOURCES = \
gpm-common.c \
gpm-common.h \
+ gsd-backlight-linux.c \
+ gsd-backlight-linux.h \
gsd-power-manager.c \
gsd-power-manager.h \
gsm-inhibitor-flag.h \
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index 2fcb0d2..1c20234 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -35,6 +35,7 @@
#include "gpm-common.h"
#include "gsd-power-manager.h"
+#include "gsd-backlight-linux.h"
#define XSCREENSAVER_WATCHDOG_TIMEOUT 120 /* seconds */
@@ -1190,6 +1191,23 @@ backlight_helper_disabled (void)
return FALSE;
}
+gboolean
+backlight_available (GnomeRRScreen *rr_screen)
+{
+ char *path;
+
+ if (!backlight_helper_disabled ())
+ return FALSE;
+ if (get_primary_output (rr_screen) != NULL)
+ return TRUE;
+ path = gsd_backlight_helper_get_best_backlight ();
+ if (path == NULL)
+ return FALSE;
+
+ g_free (path);
+ return TRUE;
+}
+
/**
* backlight_helper_get_value:
*
diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h
index b03b5b5..b5f544c 100644
--- a/plugins/power/gpm-common.h
+++ b/plugins/power/gpm-common.h
@@ -54,6 +54,7 @@ void reset_idletime (void);
#define PERCENTAGE_TO_ABS(min, max, value) (min + (((max - min) * value) / 100))
int gsd_power_backlight_abs_to_percentage (int min, int max, int value);
+gboolean backlight_available (GnomeRRScreen *rr_screen);
int backlight_get_abs (GnomeRRScreen *rr_screen, GError **error);
int backlight_get_percentage (GnomeRRScreen *rr_screen, GError **error);
int backlight_get_min (GnomeRRScreen *rr_screen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]