[gnome-power-manager] Remove the xrandr brightness settings code, it's now in gnome-settings-daemon
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] Remove the xrandr brightness settings code, it's now in gnome-settings-daemon
- Date: Mon, 25 Jul 2011 13:22:30 +0000 (UTC)
commit 437e766a0490ce33a827d6cdc1671de2d32c778c
Author: Richard Hughes <richard hughsie com>
Date: Mon Jul 4 12:55:06 2011 +0100
Remove the xrandr brightness settings code, it's now in gnome-settings-daemon
src/Makefile.am | 2 -
src/gpm-backlight.c | 34 +--
src/gpm-brightness.c | 1034 --------------------------------------------------
src/gpm-brightness.h | 69 ----
src/gpm-manager.c | 103 +++++
5 files changed, 108 insertions(+), 1134 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 565373e..3c7f4f2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,8 +48,6 @@ libgpmshared_a_SOURCES = \
egg-console-kit.c \
gpm-common.h \
gpm-common.c \
- gpm-brightness.h \
- gpm-brightness.c \
gpm-marshal.h \
gpm-marshal.c \
gpm-upower.c \
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index 7e025b8..1112845 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -42,7 +42,6 @@
#include "gpm-button.h"
#include "gpm-backlight.h"
-#include "gpm-brightness.h"
#include "gpm-control.h"
#include "gpm-common.h"
#include "gpm-dpms.h"
@@ -72,7 +71,6 @@ static const gchar *backlight_introspection = ""
struct GpmBacklightPrivate
{
UpClient *client;
- GpmBrightness *brightness;
GpmButton *button;
GSettings *settings;
GSettings *settings_gsd;
@@ -125,7 +123,7 @@ gpm_backlight_get_brightness (GpmBacklight *backlight, guint *brightness, GError
}
/* gets the current brightness */
- ret = gpm_brightness_get (backlight->priv->brightness, &level);
+ ret = FALSE;
if (ret) {
*brightness = level;
} else {
@@ -180,7 +178,7 @@ gpm_backlight_set_brightness (GpmBacklight *backlight, guint percentage, GError
backlight->priv->master_percentage = percentage;
/* sets the current policy brightness */
- ret = gpm_brightness_set (backlight->priv->brightness, percentage, &hw_changed);
+ ret = FALSE;
if (!ret) {
g_set_error_literal (error, gpm_backlight_error_quark (),
GPM_BACKLIGHT_ERROR_GENERAL,
@@ -220,7 +218,6 @@ gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean int
gboolean battery_reduce;
gboolean hw_changed;
guint value;
- guint old_value;
if (backlight->priv->can_dim == FALSE) {
g_warning ("no dimming hardware");
@@ -279,13 +276,10 @@ gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean int
value = (guint) ((brightness * 100.0f) + 0.5);
/* only do stuff if the brightness is different */
- gpm_brightness_get (backlight->priv->brightness, &old_value);
- if (old_value == value) {
- g_debug ("values are the same, no action");
- return FALSE;
- }
+ //old_value = 0;
- ret = gpm_brightness_set (backlight->priv->brightness, value, &hw_changed);
+ ret = FALSE;
+ //set value
/* we emit a signal for the brightness applet */
if (ret && hw_changed)
gpm_backlight_brightness_changed (backlight, value);
@@ -492,15 +486,6 @@ gpm_backlight_idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *ba
}
/**
- * gpm_backlight_brightness_changed_cb:
- **/
-static void
-gpm_backlight_brightness_changed_cb (GpmBrightness *brightness, guint percentage, GpmBacklight *backlight)
-{
- gpm_backlight_brightness_changed (backlight, percentage);
-}
-
-/**
* gpm_backlight_control_resume_cb:
* @control: The control class instance
* @power: This power class instance
@@ -641,7 +626,6 @@ gpm_backlight_finalize (GObject *object)
g_object_unref (backlight->priv->client);
g_object_unref (backlight->priv->button);
g_object_unref (backlight->priv->idle);
- g_object_unref (backlight->priv->brightness);
g_object_unref (backlight->priv->consolekit);
g_return_if_fail (backlight->priv != NULL);
@@ -675,19 +659,11 @@ gpm_backlight_init (GpmBacklight *backlight)
/* record our idle time */
backlight->priv->idle_timer = g_timer_new ();
- /* watch for manual brightness changes (for the popup widget) */
- backlight->priv->brightness = gpm_brightness_new ();
- g_signal_connect (backlight->priv->brightness, "brightness-changed",
- G_CALLBACK (gpm_backlight_brightness_changed_cb), backlight);
-
/* we use up_client for the ac-adapter-changed signal */
backlight->priv->client = up_client_new ();
g_signal_connect (backlight->priv->client, "changed",
G_CALLBACK (gpm_backlight_client_changed_cb), backlight);
- /* gets caps */
- backlight->priv->can_dim = gpm_brightness_has_hw (backlight->priv->brightness);
-
/* watch for dim value changes */
backlight->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
g_signal_connect (backlight->priv->settings, "changed", G_CALLBACK (gpm_settings_key_changed_cb), backlight);
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 05621c1..f8dae08 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -1073,6 +1073,109 @@ gpm_manager_init (GpmManager *manager)
g_object_unref);
}
+#if 0
+/**
+ * gpm_brightness_helper_strtoint:
+ * @text: The text the convert
+ * @value: The return numeric return value
+ *
+ * Converts a string into a signed integer value in a safe way.
+ *
+ * Return value: %TRUE if the string was converted correctly
+ **/
+static gboolean
+gpm_brightness_helper_strtoint (const gchar *text, gint *value)
+{
+ gchar *endptr = NULL;
+ gint64 value_raw;
+
+ /* invalid */
+ if (text == NULL)
+ return FALSE;
+
+ /* parse */
+ value_raw = g_ascii_strtoll (text, &endptr, 10);
+
+ /* parsing error */
+ if (endptr == text)
+ return FALSE;
+
+ /* out of range */
+ if (value_raw > G_MAXINT || value_raw < G_MININT)
+ return FALSE;
+
+ /* cast back down to value */
+ *value = (gint) value_raw;
+ return TRUE;
+}
+
+/**
+ * gpm_brightness_helper_get_value:
+ **/
+static gint
+gpm_brightness_helper_get_value (const gchar *argument)
+{
+ gboolean ret;
+ GError *error = NULL;
+ gchar *stdout_data = NULL;
+ gint exit_status = 0;
+ gint value = -1;
+ gchar *command = NULL;
+
+ /* get the data */
+ command = g_strdup_printf (SBINDIR "/gnome-power-backlight-helper --%s", argument);
+ ret = g_spawn_command_line_sync (command,
+ &stdout_data, NULL, &exit_status, &error);
+ if (!ret) {
+ g_error ("failed to get value: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ g_debug ("executing %s retval: %i", command, exit_status);
+
+ /* parse for a number */
+ ret = gpm_brightness_helper_strtoint (stdout_data, &value);
+ if (!ret)
+ goto out;
+out:
+ g_free (command);
+ g_free (stdout_data);
+ return value;
+}
+
+/**
+ * gpm_brightness_helper_set_value:
+ **/
+static gboolean
+gpm_brightness_helper_set_value (const gchar *argument, gint value)
+{
+ gboolean ret;
+ GError *error = NULL;
+ gint exit_status = 0;
+ gchar *command = NULL;
+
+ /* get the data */
+ command = g_strdup_printf ("pkexec " SBINDIR "/gnome-power-backlight-helper --%s %i", argument, value);
+ ret = g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error);
+ if (!ret) {
+ g_error ("failed to get value: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ g_debug ("executing %s retval: %i", command, exit_status);
+out:
+ g_free (command);
+ return ret;
+}
+
+{
+ if (brightness->priv->extension_levels < 0)
+ brightness->priv->extension_levels = gpm_brightness_helper_get_value ("get-max-brightness");
+ ret = gpm_brightness_helper_set_value ("set-brightness", brightness->priv->extension_current);
+ brightness->priv->extension_current = gpm_brightness_helper_get_value ("get-brightness");
+}
+#endif
+
/**
* gpm_manager_finalize:
* @object: The object to finalize
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]