summaryrefslogtreecommitdiff
path: root/src/gpm-engine.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-10-31 01:41:08 -0700
committerStefano Karapetsas <[email protected]>2012-10-31 01:41:08 -0700
commit83dc101045267b2e793af3af4716f1cf02089ac6 (patch)
tree631437e0c5df2754ed31d4b5e31a1b5ca9d134e3 /src/gpm-engine.c
parent543b06f44cafd70fe708fd54a82cba198a6da73b (diff)
parentaa88be1d4a4e545b4141b0065b094d49d3d3a81b (diff)
downloadmate-power-manager-83dc101045267b2e793af3af4716f1cf02089ac6.tar.bz2
mate-power-manager-83dc101045267b2e793af3af4716f1cf02089ac6.tar.xz
Merge pull request #18 from bhull2010/master
Fix for two batteries appearing
Diffstat (limited to 'src/gpm-engine.c')
-rw-r--r--src/gpm-engine.c37
1 files changed, 5 insertions, 32 deletions
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index 1ca78b8..0b1bb62 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);
@@ -816,12 +815,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;
@@ -835,31 +830,6 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
g_error_free (error);
goto out;
}
- engine->priv->array = up_client_get_devices (engine->priv->client);
-
- /* do we have specific device types? */
- array = engine->priv->array;
- for (i=0;i<array->len;i++) {
- device = g_ptr_array_index (engine->priv->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);
@@ -867,12 +837,15 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
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 (engine->priv->array, 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;
}