[gnome-power-manager] Remove GetPreferencesOptions() and untie the preferences fro the daemon. Fixes #617529
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] Remove GetPreferencesOptions() and untie the preferences fro the daemon. Fixes #617529
- Date: Tue, 11 May 2010 11:09:03 +0000 (UTC)
commit d23f4afbb99ad914ca0e33feff365d15a1e60532
Author: Richard Hughes <richard hughsie com>
Date: Tue May 11 12:08:37 2010 +0100
Remove GetPreferencesOptions() and untie the preferences fro the daemon. Fixes #617529
src/Makefile.am | 8 +--
src/gpm-backlight.c | 17 -----
src/gpm-engine.c | 36 +---------
src/gpm-manager.c | 17 -----
src/gpm-manager.h | 3 -
src/gpm-prefs-core.c | 93 +++++++++++----------------
src/gpm-prefs-server.c | 138 ----------------------------------------
src/gpm-prefs-server.h | 67 -------------------
src/org.gnome.PowerManager.xml | 3 -
9 files changed, 43 insertions(+), 339 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 5aea83e..4db3e03 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,6 +76,8 @@ 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 \
@@ -145,8 +147,6 @@ gnome_power_manager_SOURCES = \
gpm-phone.c \
gpm-backlight.h \
gpm-backlight.c \
- gpm-prefs-server.h \
- gpm-prefs-server.c \
gpm-idle.h \
gpm-idle.c \
gpm-load.h \
@@ -157,8 +157,6 @@ gnome_power_manager_SOURCES = \
gpm-control.c \
gpm-button.h \
gpm-button.c \
- gpm-brightness.h \
- gpm-brightness.c \
gpm-main.c \
gpm-manager.h \
gpm-manager.c \
@@ -217,8 +215,6 @@ gnome_power_self_test_SOURCES = \
egg-array-float.c \
egg-console-kit.h \
egg-console-kit.c \
- gpm-prefs-server.h \
- gpm-prefs-server.c \
gpm-control.h \
gpm-control.c \
gpm-networkmanager.h \
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index 72861bc..9a293fd 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -53,7 +53,6 @@
#include "gpm-idle.h"
#include "gpm-marshal.h"
#include "gpm-stock-icons.h"
-#include "gpm-prefs-server.h"
#include "egg-console-kit.h"
#define GPM_BACKLIGHT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_BACKLIGHT, GpmBacklightPrivate))
@@ -724,9 +723,6 @@ gpm_backlight_class_init (GpmBacklightClass *klass)
static void
gpm_backlight_init (GpmBacklight *backlight)
{
- gboolean lid_is_present = TRUE;
- GpmPrefsServer *prefs_server;
-
backlight->priv = GPM_BACKLIGHT_GET_PRIVATE (backlight);
/* record our idle time */
@@ -745,19 +741,6 @@ gpm_backlight_init (GpmBacklight *backlight)
/* gets caps */
backlight->priv->can_dim = gpm_brightness_has_hw (backlight->priv->brightness);
- /* we use DeviceKit-power to see if we should show the lid UI */
- g_object_get (backlight->priv->client,
- "lid-is-present", &lid_is_present,
- NULL);
-
- /* expose ui in prefs program */
- prefs_server = gpm_prefs_server_new ();
- 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);
- g_object_unref (prefs_server);
-
/* watch for dim value changes */
backlight->priv->conf = gconf_client_get_default ();
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index 967147e..6efe66a 100644
--- a/src/gpm-engine.c
+++ b/src/gpm-engine.c
@@ -34,7 +34,6 @@
#include "gpm-marshal.h"
#include "gpm-engine.h"
#include "gpm-stock-icons.h"
-#include "gpm-prefs-server.h"
#include "gpm-phone.h"
static void gpm_engine_finalize (GObject *object);
@@ -823,12 +822,8 @@ static gboolean
gpm_engine_coldplug_idle_cb (GpmEngine *engine)
{
guint i;
- GPtrArray *array;
- gboolean has_battery = FALSE;
- gboolean has_ups = FALSE;
- GpmPrefsServer *prefs_server;
+ GPtrArray *array = NULL;
UpDevice *device;
- UpDeviceKind kind;
gboolean ret;
GError *error = NULL;
@@ -843,44 +838,21 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
goto out;
}
- /* get the devices */
- array = up_client_get_devices (engine->priv->client);
-
- /* do we have specific device types? */
- for (i=0;i<array->len;i++) {
- device = g_ptr_array_index (array, i);
-
- /* get device properties */
- g_object_get (device,
- "kind", &kind,
- NULL);
-
- if (kind == UP_DEVICE_KIND_BATTERY)
- has_battery = TRUE;
- else if (kind == UP_DEVICE_KIND_UPS)
- has_ups = TRUE;
- }
-
- /* only show the battery prefs section if we have batteries */
- prefs_server = gpm_prefs_server_new ();
- if (has_battery)
- gpm_prefs_server_set_capability (prefs_server, GPM_PREFS_SERVER_BATTERY);
- if (has_ups)
- gpm_prefs_server_set_capability (prefs_server, GPM_PREFS_SERVER_UPS);
- g_object_unref (prefs_server);
-
/* connected mobile phones */
gpm_phone_coldplug (engine->priv->phone);
gpm_engine_recalculate_state (engine);
/* add to database */
+ array = up_client_get_devices (engine->priv->client);
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (array, i);
gpm_engine_device_add (engine, device);
gpm_engine_check_recall (engine, device);
}
out:
+ if (array != NULL)
+ g_ptr_array_unref (array);
/* never repeat */
return FALSE;
}
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 50ac2cf..9aa1646 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -56,7 +56,6 @@
#include "gpm-backlight.h"
#include "gpm-session.h"
#include "gpm-stock-icons.h"
-#include "gpm-prefs-server.h"
#include "gpm-tray-icon.h"
#include "gpm-engine.h"
#include "gpm-upower.h"
@@ -81,7 +80,6 @@ struct GpmManagerPrivate
GpmDisks *disks;
GpmDpms *dpms;
GpmIdle *idle;
- GpmPrefsServer *prefs_server;
GpmControl *control;
GpmScreensaver *screensaver;
GpmTrayIcon *tray_icon;
@@ -726,17 +724,6 @@ gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const
}
/**
- * gpm_manager_get_preferences_options:
- **/
-gboolean
-gpm_manager_get_preferences_options (GpmManager *manager, gint *capability, GError **error)
-{
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GPM_IS_MANAGER (manager), FALSE);
- return gpm_prefs_server_get_capability (manager->priv->prefs_server, capability);
-}
-
-/**
* gpm_manager_idle_do_sleep:
* @manager: This class instance
*
@@ -1897,9 +1884,6 @@ gpm_manager_init (GpmManager *manager)
/* don't apply policy when not active, so listen to ConsoleKit */
manager->priv->console = egg_console_kit_new ();
- /* this is a singleton, so we keep a master copy open here */
- manager->priv->prefs_server = gpm_prefs_server_new ();
-
manager->priv->notification_general = NULL;
manager->priv->notification_warning_low = NULL;
manager->priv->notification_discharging = NULL;
@@ -2052,7 +2036,6 @@ gpm_manager_finalize (GObject *object)
g_object_unref (manager->priv->engine);
g_object_unref (manager->priv->tray_icon);
g_object_unref (manager->priv->screensaver);
- g_object_unref (manager->priv->prefs_server);
g_object_unref (manager->priv->control);
g_object_unref (manager->priv->button);
g_object_unref (manager->priv->backlight);
diff --git a/src/gpm-manager.h b/src/gpm-manager.h
index 1d31b75..a78509a 100644
--- a/src/gpm-manager.h
+++ b/src/gpm-manager.h
@@ -73,9 +73,6 @@ gboolean gpm_manager_can_suspend (GpmManager *manager,
gboolean gpm_manager_can_hibernate (GpmManager *manager,
gboolean *can_hibernate,
GError **error);
-gboolean gpm_manager_get_preferences_options (GpmManager *manager,
- gint *capability,
- GError **error);
G_END_DECLS
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index e9c7fda..74a5d82 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -40,7 +40,7 @@
#include "gpm-common.h"
#include "gpm-prefs-core.h"
#include "gpm-stock-icons.h"
-#include "gpm-prefs-server.h"
+#include "gpm-brightness.h"
static void gpm_prefs_finalize (GObject *object);
@@ -119,46 +119,6 @@ gpm_prefs_activate_window (GpmPrefs *prefs)
}
/**
- * gpm_dbus_get_caps:
- * @method: The g-p-m DBUS method name, e.g. "AllowedSuspend"
- **/
-static gint
-gpm_dbus_get_caps (GpmPrefs *prefs)
-{
- DBusGConnection *connection;
- DBusGProxy *proxy = NULL;
- GError *error = NULL;
- gboolean ret;
- gint value = 0;
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (connection == NULL) {
- egg_warning ("Couldn't connect to g-p-m %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- proxy = dbus_g_proxy_new_for_name (connection,
- GPM_DBUS_SERVICE,
- GPM_DBUS_PATH,
- GPM_DBUS_INTERFACE);
- ret = dbus_g_proxy_call (proxy, "GetPreferencesOptions", &error,
- G_TYPE_INVALID,
- G_TYPE_INT, &value,
- G_TYPE_INVALID);
- if (!ret) {
- /* abort as the DBUS method failed */
- egg_warning ("GetPreferencesOptions failed: %s", error->message);
- g_error_free (error);
- goto out;
- }
-out:
- if (proxy != NULL)
- g_object_unref (proxy);
- return value;
-}
-
-/**
* gpm_prefs_help_cb:
* @widget: The GtkWidget object
* @prefs: This prefs class instance
@@ -899,9 +859,14 @@ gpm_prefs_init (GpmPrefs *prefs)
{
GtkWidget *main_window;
GtkWidget *widget;
- gint caps;
guint retval;
GError *error = NULL;
+ GPtrArray *devices = NULL;
+ UpDevice *device;
+ UpDeviceKind kind;
+ GpmBrightness *brightness;
+ gboolean ret;
+ guint i;
prefs->priv = GPM_PREFS_GET_PRIVATE (prefs);
@@ -918,25 +883,41 @@ gpm_prefs_init (GpmPrefs *prefs)
/* get value of delay in gnome-session */
prefs->priv->idle_delay = gconf_client_get_int (prefs->priv->conf, GPM_CONF_IDLE_DELAY, NULL);
- caps = gpm_dbus_get_caps (prefs);
- egg_debug ("caps=%i", caps);
-
- /* get properties from gnome-power-manager */
- prefs->priv->has_batteries = ((caps & GPM_PREFS_SERVER_BATTERY) > 0);
- prefs->priv->has_ups = ((caps & GPM_PREFS_SERVER_UPS) > 0);
- prefs->priv->has_lcd = ((caps & GPM_PREFS_SERVER_BACKLIGHT) > 0);
- prefs->priv->has_button_lid = ((caps & GPM_PREFS_SERVER_LID) > 0);
- prefs->priv->has_button_suspend = TRUE;
-
/* are we allowed to shutdown? */
prefs->priv->can_shutdown = TRUE;
egg_console_kit_can_stop (prefs->priv->console, &prefs->priv->can_shutdown, NULL);
/* get values from UpClient */
- g_object_get (prefs->priv->client,
- "can-suspend", &prefs->priv->can_suspend,
- "can-hibernate", &prefs->priv->can_hibernate,
- NULL);
+ prefs->priv->can_suspend = up_client_get_can_suspend (prefs->priv->client);
+ prefs->priv->can_hibernate = up_client_get_can_hibernate (prefs->priv->client);
+ prefs->priv->has_button_lid = up_client_get_lid_is_present (prefs->priv->client);
+ prefs->priv->has_button_suspend = TRUE;
+
+ /* find if we have brightness hardware */
+ brightness = gpm_brightness_new ();
+ prefs->priv->has_lcd = gpm_brightness_has_hw (brightness);
+ g_object_unref (brightness);
+
+ /* get device list */
+ ret = up_client_enumerate_devices_sync (prefs->priv->client, NULL, &error);
+ if (!ret) {
+ egg_warning ("failed to get device list: %s", error->message);
+ g_error_free (error);
+ }
+
+ devices = up_client_get_devices (prefs->priv->client);
+ for (i=0; i<devices->len; i++) {
+ device = g_ptr_array_index (devices, i);
+ //kind = up_device_get_kind (device);
+ g_object_get (device,
+ "kind", &kind,
+ NULL);
+ if (kind == UP_DEVICE_KIND_BATTERY)
+ prefs->priv->has_batteries = TRUE;
+ if (kind == UP_DEVICE_KIND_UPS)
+ prefs->priv->has_ups = TRUE;
+ }
+ g_ptr_array_unref (devices);
prefs->priv->builder = gtk_builder_new ();
retval = gtk_builder_add_from_file (prefs->priv->builder, GPM_DATA "/gpm-prefs.ui", &error);
diff --git a/src/org.gnome.PowerManager.xml b/src/org.gnome.PowerManager.xml
index 0b7aa34..a88f1f4 100644
--- a/src/org.gnome.PowerManager.xml
+++ b/src/org.gnome.PowerManager.xml
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/">
<interface name="org.gnome.PowerManager">
- <method name="GetPreferencesOptions">
- <arg type="i" name="capability" direction="out"/>
- </method>
</interface>
</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]