[gnome-settings-daemon] power: Return the backlight type along with the file path
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Return the backlight type along with the file path
- Date: Mon, 16 Feb 2015 17:08:44 +0000 (UTC)
commit 82bc476cb58e3e582bd87dc7b2df6c7d69e9dfd5
Author: Rui Matos <tiagomatos gmail com>
Date: Tue Feb 10 16:51:46 2015 +0100
power: Return the backlight type along with the file path
We'll need to apply an heuristic according to the backlight type, so
return it along with the path.
https://bugzilla.gnome.org/show_bug.cgi?id=744278
plugins/power/gpm-common.c | 2 +-
plugins/power/gsd-backlight-helper.c | 3 ++-
plugins/power/gsd-backlight-linux.c | 17 +++++++++++++----
plugins/power/gsd-backlight-linux.h | 8 +++++++-
4 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index 8bc9547..e03738a 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -378,7 +378,7 @@ backlight_available (GnomeRRScreen *rr_screen)
return (get_primary_output (rr_screen) != NULL);
#endif
- path = gsd_backlight_helper_get_best_backlight ();
+ path = gsd_backlight_helper_get_best_backlight (NULL);
if (path == NULL)
return FALSE;
diff --git a/plugins/power/gsd-backlight-helper.c b/plugins/power/gsd-backlight-helper.c
index 8adad4d..1eb264d 100644
--- a/plugins/power/gsd-backlight-helper.c
+++ b/plugins/power/gsd-backlight-helper.c
@@ -128,6 +128,7 @@ main (int argc, char *argv[])
gboolean get_brightness = FALSE;
gboolean get_max_brightness = FALSE;
gchar *filename = NULL;
+ GsdBacklightType type;
const GOptionEntry options[] = {
{ "set-brightness", '\0', 0, G_OPTION_ARG_INT, &set_brightness,
@@ -162,7 +163,7 @@ main (int argc, char *argv[])
}
/* find device */
- filename = gsd_backlight_helper_get_best_backlight ();
+ filename = gsd_backlight_helper_get_best_backlight (&type);
if (filename == NULL) {
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_NO_DEVICES;
g_print ("%s: %s\n",
diff --git a/plugins/power/gsd-backlight-linux.c b/plugins/power/gsd-backlight-linux.c
index 37e0f00..54d6f9d 100644
--- a/plugins/power/gsd-backlight-linux.c
+++ b/plugins/power/gsd-backlight-linux.c
@@ -46,7 +46,7 @@ gsd_backlight_helper_get_type (GList *devices, const gchar *type)
#endif /* HAVE_GUDEV */
char *
-gsd_backlight_helper_get_best_backlight (void)
+gsd_backlight_helper_get_best_backlight (GsdBacklightType *type)
{
#ifdef HAVE_GUDEV
gchar *path = NULL;
@@ -61,14 +61,23 @@ gsd_backlight_helper_get_best_backlight (void)
/* search the backlight devices and prefer the types:
* firmware -> platform -> raw */
path = gsd_backlight_helper_get_type (devices, "firmware");
- if (path != NULL)
+ if (path != NULL) {
+ if (type)
+ *type = GSD_BACKLIGHT_TYPE_FIRMWARE;
goto out;
+ }
path = gsd_backlight_helper_get_type (devices, "platform");
- if (path != NULL)
+ if (path != NULL) {
+ if (type)
+ *type = GSD_BACKLIGHT_TYPE_PLATFORM;
goto out;
+ }
path = gsd_backlight_helper_get_type (devices, "raw");
- if (path != NULL)
+ if (path != NULL) {
+ if (type)
+ *type = GSD_BACKLIGHT_TYPE_RAW;
goto out;
+ }
out:
g_object_unref (client);
g_list_foreach (devices, (GFunc) g_object_unref, NULL);
diff --git a/plugins/power/gsd-backlight-linux.h b/plugins/power/gsd-backlight-linux.h
index 023f392..a0997b2 100644
--- a/plugins/power/gsd-backlight-linux.h
+++ b/plugins/power/gsd-backlight-linux.h
@@ -19,4 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-char *gsd_backlight_helper_get_best_backlight (void);
+typedef enum {
+ GSD_BACKLIGHT_TYPE_FIRMWARE,
+ GSD_BACKLIGHT_TYPE_PLATFORM,
+ GSD_BACKLIGHT_TYPE_RAW,
+} GsdBacklightType;
+
+char *gsd_backlight_helper_get_best_backlight (GsdBacklightType *type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]