[gnome-bluetooth/gnome-2-32] Port nautilus-sendto plugin to GSettings



commit d60bf650f32eef26fda2f613b70537dc9f25623f
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 17 23:05:37 2010 +0100

    Port nautilus-sendto plugin to GSettings

 configure.ac                                  |    2 +-
 sendto/Makefile.am                            |   10 ++++++++-
 sendto/gnome-bluetooth-nst                    |    2 +
 sendto/nautilus-sendto-plugin.c               |   28 ++++++++++--------------
 sendto/org.gnome.Bluetooth.nst.gschema.xml.in |    9 ++++++++
 5 files changed, 33 insertions(+), 18 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9a1f3d4..90541cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,7 +106,7 @@ AC_ARG_ENABLE(nautilus-sendto,
 if test "x$enable_nst" != "xno"; then
    PKG_CHECK_MODULES(NST,
    [
-      nautilus-sendto >= $NAUTILUS_SENDTO_REQUIRED gconf-2.0
+      nautilus-sendto >= $NAUTILUS_SENDTO_REQUIRED
    ], have_nst="yes", have_nst="no")
 else
    have_nst=no
diff --git a/sendto/Makefile.am b/sendto/Makefile.am
index e2564e3..55dfc39 100644
--- a/sendto/Makefile.am
+++ b/sendto/Makefile.am
@@ -28,8 +28,16 @@ libnstbluetooth_la_SOURCES = nautilus-sendto-plugin.c
 libnstbluetooth_la_LDFLAGS = -module -avoid-version
 libnstbluetooth_la_LIBADD = $(BLUETOOTH_LIBS) ../lib/libgnome-bluetooth.la
 
+convertdir=$(datadir)/GConf/gsettings
+convert_DATA=gnome-bluetooth-nst
+
+gsettingsschema_in_files = org.gnome.Bluetooth.nst.gschema.xml.in
+gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
 endif
 
-EXTRA_DIST = $(man_MANS) nautilus-sendto-plugin.c
+EXTRA_DIST = $(man_MANS) gnome-bluetooth-nst org.gnome.Bluetooth.nst.gschema.xml.in nautilus-sendto-plugin.c
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/sendto/gnome-bluetooth-nst b/sendto/gnome-bluetooth-nst
new file mode 100644
index 0000000..9a15e7c
--- /dev/null
+++ b/sendto/gnome-bluetooth-nst
@@ -0,0 +1,2 @@
+[org.gnome.Bluetooth.nst]
+last-used = /desktop/gnome/nautilus-sendto/last_obex_device
diff --git a/sendto/nautilus-sendto-plugin.c b/sendto/nautilus-sendto-plugin.c
index 0cad7fd..430f506 100644
--- a/sendto/nautilus-sendto-plugin.c
+++ b/sendto/nautilus-sendto-plugin.c
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
-/* 
+/*
  * Copyright (C) 2004 Roberto Majadas
  * Copyright (C) 2005, 2009 Bastien Nocera
  *
@@ -27,11 +27,11 @@
 #include <bluetooth-chooser-combo.h>
 #include <bluetooth-chooser.h>
 #include <glib/gi18n-lib.h>
-#include <gconf/gconf-client.h>
 
 #include "nautilus-sendto-plugin.h"
 
-#define LAST_OBEX_DEVICE "/desktop/gnome/nautilus-sendto/last_obex_device"
+#define SCHEMA_NAME "org.gnome.Bluetooth.nst"
+#define PREF_LAST_USED "last-used"
 
 static GtkWidget *combo;
 static char *cmd = NULL;
@@ -54,11 +54,11 @@ static void
 set_last_used_device (void)
 {
 	char *bdaddr;
-	GConfClient *gconfclient;
+	GSettings *settings;
 
-	gconfclient = gconf_client_get_default (); 
-	bdaddr = gconf_client_get_string (gconfclient, LAST_OBEX_DEVICE, NULL);
-	g_object_unref (gconfclient);
+	settings = g_settings_new (SCHEMA_NAME);
+	bdaddr = g_settings_get_string (settings, PREF_LAST_USED);
+	g_object_unref (settings);
 
 	if (bdaddr != NULL && *bdaddr != '\0') {
 		g_object_set (G_OBJECT (combo), "device", bdaddr, NULL);
@@ -95,15 +95,11 @@ get_contacts_widget (NstPlugin *plugin)
 static void
 save_last_used_obex_device (const char *bdaddr)
 {
-	GConfClient *client;
+	GSettings *settings;
 
-	client = gconf_client_get_default ();
-	gconf_client_set_string (client,
-				 LAST_OBEX_DEVICE,
-				 bdaddr,
-				 NULL);
-
-	g_object_unref (client);
+	settings = g_settings_new (SCHEMA_NAME);
+	g_settings_set (settings, PREF_LAST_USED, bdaddr);
+	g_object_unref (settings);
 }
 
 static gboolean
@@ -272,7 +268,7 @@ NstPluginInfo plugin_info = {
 	validate_destination,
 	send_files,
 	destroy
-}; 
+};
 
 NST_INIT_PLUGIN (plugin_info)
 
diff --git a/sendto/org.gnome.Bluetooth.nst.gschema.xml.in b/sendto/org.gnome.Bluetooth.nst.gschema.xml.in
new file mode 100644
index 0000000..53685d8
--- /dev/null
+++ b/sendto/org.gnome.Bluetooth.nst.gschema.xml.in
@@ -0,0 +1,9 @@
+<schemalist>
+  <schema id="org.gnome.Bluetooth.nst" path="/apps/bluetooth-sendto/" gettext-domain="gnome-bluetooth2">
+    <key name="last-used" type="s">
+      <default>''</default>
+      <summary>The last Bluetooth device we sent files to</summary>
+      <description>The last Bluetooth device we sent files to.</description>
+    </key>
+  </schema>
+</schemalist>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]