[gnome-power-manager] Remove a little bit more of our HAL dep, and use the lid-is-present DK-p property
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-power-manager] Remove a little bit more of our HAL dep, and use the lid-is-present DK-p property
- Date: Fri, 3 Jul 2009 12:53:54 +0000 (UTC)
commit c02269895a787e674597f86ea548177a24868796
Author: Richard Hughes <richard hughsie com>
Date: Fri Jul 3 11:01:53 2009 +0100
Remove a little bit more of our HAL dep, and use the lid-is-present DK-p property
libhal-glib/hal-manager.c | 31 -------------------------------
libhal-glib/hal-manager.h | 1 -
src/gpm-backlight.c | 27 +++++++++++++--------------
src/gpm-common.h | 4 ++++
4 files changed, 17 insertions(+), 46 deletions(-)
---
diff --git a/libhal-glib/hal-manager.c b/libhal-glib/hal-manager.c
index c386461..caa0059 100644
--- a/libhal-glib/hal-manager.c
+++ b/libhal-glib/hal-manager.c
@@ -321,37 +321,6 @@ hal_manager_init (HalManager *manager)
}
/**
- * hal_manager_is_laptop:
- *
- * @manager: This class instance
- * Return value: TRUE is computer is identified as a laptop
- *
- * Returns true if system.formfactor is "laptop"
- **/
-gboolean
-hal_manager_is_laptop (HalManager *manager)
-{
- gboolean ret = TRUE;
- gchar *formfactor = NULL;
-
- g_return_val_if_fail (HAL_IS_MANAGER (manager), FALSE);
-
- /* always present */
- hal_device_get_string (manager->priv->computer, "system.formfactor", &formfactor, NULL);
- if (formfactor == NULL) {
- /* no need to free */
- return FALSE;
- }
- if (strcmp (formfactor, "laptop") != 0) {
- egg_warning ("This machine is not identified as a laptop."
- "system.formfactor is %s.", formfactor);
- ret = FALSE;
- }
- g_free (formfactor);
- return ret;
-}
-
-/**
* hal_manager_finalize:
* @object: This class instance
**/
diff --git a/libhal-glib/hal-manager.h b/libhal-glib/hal-manager.h
index fdb0c95..cc331fc 100644
--- a/libhal-glib/hal-manager.h
+++ b/libhal-glib/hal-manager.h
@@ -80,7 +80,6 @@ gboolean hal_manager_find_capability (HalManager *manager,
const gchar *capability,
gchar ***value,
GError **error);
-gboolean hal_manager_is_laptop (HalManager *manager);
G_END_DECLS
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index b2b1046..d85889e 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -42,8 +42,6 @@
#include <gconf/gconf-client.h>
#include <devkit-power-gobject/devicekit-power.h>
-#include <hal-manager.h>
-
#include "gpm-button.h"
#include "gpm-backlight.h"
#include "gpm-brightness.h"
@@ -73,7 +71,6 @@ struct GpmBacklightPrivate
GpmLightSensor *light_sensor;
gboolean can_dim;
gboolean can_sense;
- gboolean is_laptop;
gboolean system_is_idle;
GTimer *idle_timer;
gfloat ambient_sensor_value;
@@ -659,8 +656,8 @@ gpm_backlight_class_init (GpmBacklightClass *klass)
static void
gpm_backlight_init (GpmBacklight *backlight)
{
- HalManager *hal_manager;
guint value;
+ gboolean lid_is_present = TRUE;
GpmPrefsServer *prefs_server;
backlight->priv = GPM_BACKLIGHT_GET_PRIVATE (backlight);
@@ -678,18 +675,25 @@ gpm_backlight_init (GpmBacklight *backlight)
g_signal_connect (backlight->priv->brightness, "brightness-changed",
G_CALLBACK (brightness_changed_cb), backlight);
+ /* we use dkp_client for the ac-adapter-changed signal */
+ backlight->priv->client = dkp_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);
backlight->priv->can_sense = gpm_light_sensor_has_hw (backlight->priv->light_sensor);
- /* we use hal to see if we are a laptop */
- hal_manager = hal_manager_new ();
- backlight->priv->is_laptop = hal_manager_is_laptop (hal_manager);
- g_object_unref (hal_manager);
+ /* we use DeviceKit-power to see if we should show the lid UI */
+#if DKP_CHECK_VERSION(0x009)
+ g_object_get (backlight->priv->client,
+ "lid-is-present", &lid_is_present,
+ NULL);
+#endif
/* expose ui in prefs program */
prefs_server = gpm_prefs_server_new ();
- if (backlight->priv->is_laptop)
+ if (lid_is_present)
gpm_prefs_server_set_capability (prefs_server, GPM_PREFS_SERVER_LID);
if (backlight->priv->can_dim)
gpm_prefs_server_set_capability (prefs_server, GPM_PREFS_SERVER_BACKLIGHT);
@@ -715,11 +719,6 @@ gpm_backlight_init (GpmBacklight *backlight)
g_signal_connect (backlight->priv->button, "button-pressed",
G_CALLBACK (gpm_backlight_button_pressed_cb), backlight);
- /* we use dkp_client for the ac-adapter-changed signal */
- backlight->priv->client = dkp_client_new ();
- g_signal_connect (backlight->priv->client, "changed",
- G_CALLBACK (gpm_backlight_client_changed_cb), backlight);
-
/* watch for idle mode changes */
backlight->priv->idle = gpm_idle_new ();
g_signal_connect (backlight->priv->idle, "idle-changed",
diff --git a/src/gpm-common.h b/src/gpm-common.h
index 1fb42db..363a027 100644
--- a/src/gpm-common.h
+++ b/src/gpm-common.h
@@ -26,6 +26,10 @@
G_BEGIN_DECLS
+/* do this until we depend on DeviceKit-power 009 */
+#ifndef DKP_CHECK_VERSION
+#define DKP_CHECK_VERSION(o) (0)
+#endif
#define GPM_DBUS_SERVICE "org.freedesktop.PowerManagement"
#define GPM_DBUS_INTERFACE "org.freedesktop.PowerManagement"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]