[gnome-bluetooth] plugins: Use GSettings for geoclue plugin
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] plugins: Use GSettings for geoclue plugin
- Date: Wed, 16 Mar 2011 17:20:43 +0000 (UTC)
commit 62af6683530ee6ec289c28905c6ee1b581a407c1
Author: Bastien Nocera <hadess hadess net>
Date: Wed Mar 16 17:16:54 2011 +0000
plugins: Use GSettings for geoclue plugin
Now that Geoclue has been ported
configure.ac | 4 +-
lib/plugins/geoclue.c | 55 ++++++++++++++++++++++++++++++++-----------------
2 files changed, 38 insertions(+), 21 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e4e8129..7f6e563 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,7 +119,7 @@ else
fi
if test "x$enable_nautilus_sendto" = "xyes" -a "x$have_nst" != "xyes"; then
- AC_MSG_ERROR([Couldn't find nautilus-sendto dependencies.])
+ AC_MSG_ERROR([Could not find nautilus-sendto dependencies.])
fi
AM_CONDITIONAL(HAVE_NST, test "x$have_nst" = "xyes")
@@ -149,7 +149,7 @@ PKG_CHECK_MODULES(COMMON,
dnl Requires for the geoclue plugin
PKG_CHECK_MODULES(GEOCLUE,
- gconf-2.0
+ gio-2.0
dbus-glib-1)
dnl Requires for the plugins
diff --git a/lib/plugins/geoclue.c b/lib/plugins/geoclue.c
index 0a17033..af368f0 100644
--- a/lib/plugins/geoclue.c
+++ b/lib/plugins/geoclue.c
@@ -29,11 +29,11 @@
#include <gtk/gtk.h>
#include <bluetooth-plugin.h>
-#include <gconf/gconf-client.h>
#include "bluetooth-client.h"
-#define GPS_KEY "/apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice"
+#define GPS_ID "org.freedesktop.Geoclue"
+#define GPS_KEY "gps-device"
static char *
get_name_and_type (const char *address, BluetoothType *ret_type)
@@ -82,6 +82,21 @@ get_name_and_type (const char *address, BluetoothType *ret_type)
}
static gboolean
+has_geoclue_settings (void)
+{
+ const gchar * const * list;
+ guint i;
+
+ list = g_settings_list_schemas ();
+ for (i = 0; list[i] != NULL; i++) {
+ if (g_str_equal (list[i], GPS_ID)) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static gboolean
has_config_widget (const char *bdaddr, const char **uuids)
{
gboolean has_sp = FALSE;
@@ -89,6 +104,9 @@ has_config_widget (const char *bdaddr, const char **uuids)
char *name;
guint i;
+ if (has_geoclue_settings () == FALSE)
+ return FALSE;
+
if (uuids == NULL)
return FALSE;
for (i = 0; uuids[i] != NULL; i++) {
@@ -127,24 +145,24 @@ static void
toggle_button (GtkToggleButton *button, gpointer user_data)
{
gboolean state;
- GConfClient *client;
+ GSettings *settings;
const char *bdaddr;
- client = g_object_get_data (G_OBJECT (button), "client");
+ settings = g_object_get_data (G_OBJECT (button), "settings");
bdaddr = g_object_get_data (G_OBJECT (button), "bdaddr");
state = gtk_toggle_button_get_active (button);
if (state == FALSE) {
const char *old_bdaddr;
old_bdaddr = g_object_get_data (G_OBJECT (button), "old-bdaddr");
- gconf_client_set_string (client, GPS_KEY, old_bdaddr ? old_bdaddr : "", NULL);
+ g_settings_set_string (settings, GPS_KEY, old_bdaddr ? old_bdaddr : "");
} else {
char *old_bdaddr;
- old_bdaddr = gconf_client_get_string (client, GPS_KEY, NULL);
+ old_bdaddr = g_settings_get_string (settings, GPS_KEY);
g_object_set_data_full (G_OBJECT (button), "old-bdaddr",
old_bdaddr, g_free);
- gconf_client_set_string (client, GPS_KEY, bdaddr, NULL);
+ g_settings_set_string (settings, GPS_KEY, bdaddr);
}
}
@@ -152,19 +170,17 @@ static GtkWidget *
get_config_widgets (const char *bdaddr, const char **uuids)
{
GtkWidget *button;
- GConfClient *client;
+ GSettings *settings;
char *old_bdaddr;
- client = gconf_client_get_default ();
- if (client == NULL)
- return NULL;
+ settings = g_settings_new (GPS_ID);
button = gtk_check_button_new_with_label (_("Use this GPS device for Geolocation services"));
g_object_set_data_full (G_OBJECT (button), "bdaddr", g_strdup (bdaddr), g_free);
- g_object_set_data_full (G_OBJECT (button), "client", client, g_object_unref);
+ g_object_set_data_full (G_OBJECT (button), "settings", settings, g_object_unref);
/* Is it already setup? */
- old_bdaddr = gconf_client_get_string (client, GPS_KEY, NULL);
+ old_bdaddr = g_settings_get_string (settings, GPS_KEY);
if (g_strcmp0 (old_bdaddr, bdaddr) == 0) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_object_set_data (G_OBJECT (button), "bdaddr", old_bdaddr);
@@ -182,21 +198,22 @@ get_config_widgets (const char *bdaddr, const char **uuids)
static void
device_removed (const char *bdaddr)
{
- GConfClient *client;
+ GSettings *settings;
char *str;
- client = gconf_client_get_default ();
- if (client == NULL)
+ if (has_geoclue_settings () == FALSE)
return;
- str = gconf_client_get_string (client, GPS_KEY, NULL);
+ settings = g_settings_new (GPS_ID);
+
+ str = g_settings_get_string (settings, GPS_KEY);
if (g_strcmp0 (str, bdaddr) == 0) {
- gconf_client_set_string (client, GPS_KEY, "", NULL);
+ g_settings_set_string (settings, GPS_KEY, "");
g_debug ("Device '%s' got disabled as a Geoclue GPS", bdaddr);
}
g_free (str);
- g_object_unref (client);
+ g_object_unref (settings);
}
static GbtPluginInfo plugin_info = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]