[network-manager-applet] applet: port to GSettings
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] applet: port to GSettings
- Date: Mon, 25 Jun 2012 18:50:05 +0000 (UTC)
commit 96ffc8809165235b17170989a1d1b5ada79ca5fb
Author: Dan Winship <danw gnome org>
Date: Wed May 16 13:53:16 2012 -0400
applet: port to GSettings
Port from GConf to GSettings, and install a gsettings-data-convert
.convert file to migrate old GConf settings over.
GConf is now only required if building the migration tool.
https://bugzilla.gnome.org/show_bug.cgi?id=662767
.gitignore | 3 +-
Makefile.am | 25 +++++-------
configure.ac | 20 +++++----
nm-applet.convert | 7 +++
nm-applet.schemas.in | 76 ------------------------------------
org.gnome.nm-applet.gschema.xml.in | 47 ++++++++++++++++++++++
po/POTFILES.in | 2 +-
src/Makefile.am | 4 +-
src/applet-device-wifi.c | 18 +++-----
src/applet.c | 59 ++++++++++------------------
src/applet.h | 15 +++----
src/wireless-security/Makefile.am | 2 -
src/wireless-security/eap-method.c | 49 ++++++++++-------------
13 files changed, 137 insertions(+), 190 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e470b84..8b70645 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,7 +34,8 @@ m4/lt*.m4
nm-applet.conf
nm-applet.desktop
nm-connection-editor.desktop
-nm-applet.schemas
+org.gnome.nm-applet.gschema.xml
+org.gnome.nm-applet.gschema.valid
src/connection-editor/nm-connection-editor
src/connection-editor/nm-connection-editor-service-glue.h
src/libnm-gtk/libnm-gtk.pc
diff --git a/Makefile.am b/Makefile.am
index 319066d..6bdfb0d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+include $(GLIB_MAKEFILE)
+
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = src icons po
@@ -21,31 +23,24 @@ desktop_in_files = nm-connection-editor.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-schemasdir = @GCONF_SCHEMA_FILE_DIR@
-schemas_in_files = nm-applet.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
+schema_in_files = org.gnome.nm-applet.gschema.xml.in
+gsettingsschema_DATA = $(schema_in_files:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+convertdir=$(datadir)/GConf/gsettings
+convert_DATA=nm-applet.convert
DISTCHECK_CONFIGURE_FLAGS = --enable-more-warnings=yes
EXTRA_DIST += \
- $(schemas_in_files) \
+ $(schema_in_files) \
+ $(convert_DATA) \
$(autostart_in_files) \
$(desktop_in_files)
CLEANFILES = \
$(autostart_DATA) \
$(desktop_DATA) \
- $(schemas_DATA)
+ $(gsettingsschema_DATA)
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
-
-install-data-local:
-if GCONF_SCHEMAS_INSTALL
- if test -z "$(DESTDIR)" ; then \
- for p in $(schemas_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/$$p >&1 > /dev/null; \
- done \
- fi
-endif
diff --git a/configure.ac b/configure.ac
index fbd814f..e58ad89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,7 +97,7 @@ PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
PKG_CHECK_MODULES(NMA,
[dbus-glib-1 >= 0.74
- glib-2.0 >= 2.16
+ gio-2.0 >= 2.26
NetworkManager >= 0.9.4
libnm-glib >= 0.9.4
libnm-util >= 0.9.4
@@ -121,14 +121,20 @@ AC_ARG_ENABLE([migration],
fi])
AC_MSG_RESULT([$enable_migration])
if test "$enable_migration" = "yes"; then
+ PKG_CHECK_MODULES(GCONF, [gconf-2.0], :,
+ [AC_MSG_ERROR([
+Could not find GConf devel files, which are needed for
+nm-applet-migration-tool. You can configure with --disable-migration
+if you want to build without the code to migrate GConf settings from
+older (< 0.9) nm-applet releases.])])
+
+ AC_SUBST(GCONF_CFLAGS)
+ AC_SUBST(GCONF_LIBS)
+
AC_DEFINE(BUILD_MIGRATION_TOOL, 1, [Define when building nm-applet-migration-tool])
fi
AM_CONDITIONAL(BUILD_MIGRATION_TOOL, test "$enable_migration" = "yes")
-PKG_CHECK_MODULES(GCONF, [gconf-2.0])
-AC_SUBST(GCONF_CFLAGS)
-AC_SUBST(GCONF_LIBS)
-
PKG_CHECK_MODULES(GNOME_KEYRING, [gnome-keyring-1])
AC_SUBST(GNOME_KEYRING_CFLAGS)
AC_SUBST(GNOME_KEYRING_LIBS)
@@ -195,10 +201,6 @@ AM_CONDITIONAL(HAVE_GBT, test x"$have_gbt" = "xyes")
GLIB_CONFIG_NMA
-dnl GConf stuff
-AC_PATH_PROG(GCONFTOOL, gconftool-2)
-AM_GCONF_SOURCE_2
-
dnl
dnl Compiler flags
dnl
diff --git a/nm-applet.convert b/nm-applet.convert
new file mode 100644
index 0000000..a062f71
--- /dev/null
+++ b/nm-applet.convert
@@ -0,0 +1,7 @@
+[org.gnome.nm-applet]
+disable-connected-notifications = /apps/nm-applet/disable-connected-notifications
+disable-disconnected-notifications = /apps/nm-applet/disable-disconnected-notifications
+disable-vpn-notifications = /apps/nm-applet/disable-vpn-notifications
+suppress-wireless-networks-available = /apps/nm-applet/suppress-wireless-networks-available
+stamp = /apps/nm-applet/stamp
+disable-wifi-create = /apps/nm-applet/disable-wifi-create
diff --git a/org.gnome.nm-applet.gschema.xml.in b/org.gnome.nm-applet.gschema.xml.in
new file mode 100644
index 0000000..71b6a29
--- /dev/null
+++ b/org.gnome.nm-applet.gschema.xml.in
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist gettext-domain="nm-applet">
+ <schema id="org.gnome.nm-applet" path="/org/gnome/nm-applet/">
+ <key name="disable-connected-notifications" type="b">
+ <default>false</default>
+ <_summary>Disable connected notifications</_summary>
+ <_description>Set this to true to disable notifications when connecting to a network.</_description>
+ </key>
+ <key name="disable-disconnected-notifications" type="b">
+ <default>false</default>
+ <_summary>Disable disconnected notifications</_summary>
+ <_description>Set this to true to disable notifications when disconnecting from a network.</_description>
+ </key>
+ <key name="disable-vpn-notifications" type="b">
+ <default>false</default>
+ <_summary>Disable VPN notifications</_summary>
+ <_description>Set this to true to disable notifications when connecting to or disconnecting from a VPN.</_description>
+ </key>
+ <key name="suppress-wireless-networks-available" type="b">
+ <default>false</default>
+ <_summary>Suppress networks available notifications</_summary>
+ <_description>Set this to true to disable notifications when wireless networks are available.</_description>
+ </key>
+ <key name="stamp" type="i">
+ <default>0</default>
+ <_summary>Stamp</_summary>
+ <_description>Used to determine whether settings should be migrated to a new version.</_description>
+ </key>
+ <key name="disable-wifi-create" type="b">
+ <default>false</default>
+ <_summary>Disable WiFi Create</_summary>
+ <_description>Set to true to disable creation of adhoc networks when using the applet.</_description>
+ </key>
+ </schema>
+ <schema id="org.gnome.nm-applet.eap">
+ <key name="ignore-ca-cert" type="b">
+ <default>false</default>
+ <_summary>Ignore CA certificate</_summary>
+ <_description>Set this to true to disable warnings about CA certificates in EAP authentication.</_description>
+ </key>
+ <key name="ignore-phase2-ca-cert" type="b">
+ <default>false</default>
+ <_summary>Ignore CA certificate</_summary>
+ <_description>Set this to true to disable warnings about CA certificates in phase 2 of EAP authentication.</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5ac6bf6..f255ea7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,8 +2,8 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
nm-applet.desktop.in
-nm-applet.schemas.in
nm-connection-editor.desktop.in
+org.gnome.nm-applet.gschema.xml.in
src/applet-device-bt.c
src/applet-device-cdma.c
src/applet-device-gsm.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 412f2df..7f7c07f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,6 @@ bin_PROGRAMS = nm-applet
nm_applet_CPPFLAGS = \
$(GTK_CFLAGS) \
$(NMA_CFLAGS) \
- $(GCONF_CFLAGS) \
$(GNOME_KEYRING_CFLAGS) \
$(NOTIFY_CFLAGS) \
-DICONDIR=\""$(datadir)/icons"\" \
@@ -66,7 +65,6 @@ nm_applet_LDADD = \
-lm \
$(GTK_LIBS) \
$(NMA_LIBS) \
- $(GCONF_LIBS) \
$(GNOME_KEYRING_LIBS) \
$(NOTIFY_LIBS) \
${top_builddir}/src/marshallers/libmarshallers.la \
@@ -83,6 +81,7 @@ endif
nm_applet_migration_tool_CPPFLAGS = \
$(nm_applet_CPPFLAGS) \
+ $(GCONF_CFLAGS) \
-I${top_srcdir}/src/gconf-helpers
nm_applet_migration_tool_SOURCES = \
@@ -90,6 +89,7 @@ nm_applet_migration_tool_SOURCES = \
nm_applet_migration_tool_LDADD = \
$(nm_applet_LDADD) \
+ $(GCONF_LIBS) \
${top_builddir}/src/gconf-helpers/libgconf-helpers.la
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index ff0e374..7ec7e90 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -109,7 +109,6 @@ applet_wifi_can_create_wifi_network (NMApplet *applet)
{
gboolean disabled, allowed = FALSE;
NMClientPermissionResult perm;
- GError *error = NULL;
/* FIXME: check WIFI_SHARE_PROTECTED too, and make the wireless dialog
* handle the permissions as well so that admins can restrict open network
@@ -117,10 +116,9 @@ applet_wifi_can_create_wifi_network (NMApplet *applet)
*/
perm = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN);
if (perm == NM_CLIENT_PERMISSION_RESULT_YES || perm == NM_CLIENT_PERMISSION_RESULT_AUTH) {
- disabled = gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_WIFI_CREATE, &error);
- if (!disabled && !error)
+ disabled = g_settings_get_boolean (applet->gsettings, PREF_DISABLE_WIFI_CREATE);
+ if (!disabled)
allowed = TRUE;
- g_clear_error (&error);
}
return allowed;
}
@@ -983,10 +981,9 @@ wifi_available_dont_show_cb (NotifyNotification *notify,
if (!id || strcmp (id, "dont-show"))
return;
- gconf_client_set_bool (applet->gconf_client,
- PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
- TRUE,
- NULL);
+ g_settings_set_boolean (applet->gsettings,
+ PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
+ TRUE);
}
@@ -1087,9 +1084,8 @@ queue_avail_access_point_notification (NMDevice *device)
if (data->id != 0)
return;
- if (gconf_client_get_bool (data->applet->gconf_client,
- PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
- NULL))
+ if (g_settings_get_boolean (data->applet->gsettings,
+ PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE))
return;
data->id = g_timeout_add_seconds (3, idle_check_avail_access_point_notification, data);
diff --git a/src/applet.c b/src/applet.c
index 8cda23f..50c80bc 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -64,7 +64,6 @@
#include <nm-active-connection.h>
#include <nm-secret-agent.h>
-#include <gconf/gconf-client.h>
#include <libnotify/notify.h>
#include "applet.h"
@@ -909,7 +908,7 @@ notify_dont_show_cb (NotifyNotification *notify,
&& strcmp (id, PREF_DISABLE_VPN_NOTIFICATIONS))
return;
- gconf_client_set_bool (applet->gconf_client, id, TRUE, NULL);
+ g_settings_set_boolean (applet->gsettings, id, TRUE);
}
void applet_do_notify_with_pref (NMApplet *applet,
@@ -918,7 +917,7 @@ void applet_do_notify_with_pref (NMApplet *applet,
const char *icon,
const char *pref)
{
- if (gconf_client_get_bool (applet->gconf_client, pref, NULL))
+ if (g_settings_get_boolean (applet->gsettings, pref))
return;
applet_do_notify (applet, NOTIFY_URGENCY_LOW, summary, message, icon, pref,
@@ -1793,22 +1792,18 @@ nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet)
state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
- gconf_client_set_bool (applet->gconf_client,
- PREF_DISABLE_CONNECTED_NOTIFICATIONS,
- !state,
- NULL);
- gconf_client_set_bool (applet->gconf_client,
- PREF_DISABLE_DISCONNECTED_NOTIFICATIONS,
- !state,
- NULL);
- gconf_client_set_bool (applet->gconf_client,
- PREF_DISABLE_VPN_NOTIFICATIONS,
- !state,
- NULL);
- gconf_client_set_bool (applet->gconf_client,
- PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
- !state,
- NULL);
+ g_settings_set_boolean (applet->gsettings,
+ PREF_DISABLE_CONNECTED_NOTIFICATIONS,
+ !state);
+ g_settings_set_boolean (applet->gsettings,
+ PREF_DISABLE_DISCONNECTED_NOTIFICATIONS,
+ !state);
+ g_settings_set_boolean (applet->gsettings,
+ PREF_DISABLE_VPN_NOTIFICATIONS,
+ !state);
+ g_settings_set_boolean (applet->gsettings,
+ PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
+ !state);
}
/*
@@ -1961,10 +1956,10 @@ nma_context_menu_update (NMApplet *applet)
/* Enabled notifications */
g_signal_handler_block (G_OBJECT (applet->notifications_enabled_item),
applet->notifications_enabled_toggled_id);
- if ( gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_CONNECTED_NOTIFICATIONS, NULL)
- && gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS, NULL)
- && gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_VPN_NOTIFICATIONS, NULL)
- && gconf_client_get_bool (applet->gconf_client, PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE, NULL))
+ if ( g_settings_get_boolean (applet->gsettings, PREF_DISABLE_CONNECTED_NOTIFICATIONS)
+ && g_settings_get_boolean (applet->gsettings, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS)
+ && g_settings_get_boolean (applet->gsettings, PREF_DISABLE_VPN_NOTIFICATIONS)
+ && g_settings_get_boolean (applet->gsettings, PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE))
notifications_enabled = FALSE;
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->notifications_enabled_item), notifications_enabled);
g_signal_handler_unblock (G_OBJECT (applet->notifications_enabled_item),
@@ -3340,15 +3335,7 @@ constructor (GType type,
goto error;
}
- applet->gconf_client = gconf_client_get_default ();
- if (!applet->gconf_client)
- goto error;
-
- /* Note that we don't care about change notifications for prefs values... */
- gconf_client_add_dir (applet->gconf_client,
- APPLET_PREFS_PATH,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
+ applet->gsettings = g_settings_new (APPLET_PREFS_SCHEMA);
/* Load pixmaps and create applet widgets */
if (!setup_widgets (applet))
@@ -3466,12 +3453,8 @@ static void finalize (GObject *object)
if (applet->info_dialog_ui)
g_object_unref (applet->info_dialog_ui);
- if (applet->gconf_client) {
- gconf_client_remove_dir (applet->gconf_client,
- APPLET_PREFS_PATH,
- NULL);
- g_object_unref (applet->gconf_client);
- }
+ if (applet->gsettings)
+ g_object_unref (applet->gsettings);
if (applet->status_icon)
g_object_unref (applet->status_icon);
diff --git a/src/applet.h b/src/applet.h
index ab21ece..fd52045 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -31,7 +31,6 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#include <gconf/gconf-client.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <net/ethernet.h>
@@ -60,12 +59,12 @@ typedef struct
GObjectClass parent_class;
} NMAppletClass;
-#define APPLET_PREFS_PATH "/apps/nm-applet"
-#define PREF_DISABLE_CONNECTED_NOTIFICATIONS APPLET_PREFS_PATH "/disable-connected-notifications"
-#define PREF_DISABLE_DISCONNECTED_NOTIFICATIONS APPLET_PREFS_PATH "/disable-disconnected-notifications"
-#define PREF_DISABLE_VPN_NOTIFICATIONS APPLET_PREFS_PATH "/disable-vpn-notifications"
-#define PREF_DISABLE_WIFI_CREATE APPLET_PREFS_PATH "/disable-wifi-create"
-#define PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE APPLET_PREFS_PATH "/suppress-wireless-networks-available"
+#define APPLET_PREFS_SCHEMA "org.gnome.nm-applet"
+#define PREF_DISABLE_CONNECTED_NOTIFICATIONS "disable-connected-notifications"
+#define PREF_DISABLE_DISCONNECTED_NOTIFICATIONS "disable-disconnected-notifications"
+#define PREF_DISABLE_VPN_NOTIFICATIONS "disable-vpn-notifications"
+#define PREF_DISABLE_WIFI_CREATE "disable-wifi-create"
+#define PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE "suppress-wireless-networks-available"
#define ICON_LAYER_LINK 0
#define ICON_LAYER_VPN 1
@@ -94,7 +93,7 @@ typedef struct
NMRemoteSettings *settings;
AppletAgent *agent;
- GConfClient * gconf_client;
+ GSettings *gsettings;
/* Permissions */
NMClientPermissionResult permissions[NM_CLIENT_PERMISSION_LAST + 1];
diff --git a/src/wireless-security/Makefile.am b/src/wireless-security/Makefile.am
index 7204a33..5f47fcf 100644
--- a/src/wireless-security/Makefile.am
+++ b/src/wireless-security/Makefile.am
@@ -34,14 +34,12 @@ libwireless_security_la_CPPFLAGS = \
$(GTK_CFLAGS) \
-DUIDIR=\""$(uidir)"\" \
$(NMA_CFLAGS) \
- $(GCONF_CFLAGS) \
$(DISABLE_DEPRECATED) \
-I${top_srcdir}/src/utils
libwireless_security_la_LIBADD = \
$(GTK_LIBS) \
$(NMA_LIBS) \
- $(GCONF_LIBS) \
${top_builddir}/src/utils/libutils.la
uidir = $(datadir)/nm-applet
diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c
index 04d4c32..0129ef6 100644
--- a/src/wireless-security/eap-method.c
+++ b/src/wireless-security/eap-method.c
@@ -32,9 +32,6 @@
#include <fcntl.h>
#include <unistd.h>
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
-
#include <nm-setting-connection.h>
#include <nm-setting-8021x.h>
#include "eap-method.h"
@@ -114,32 +111,31 @@ nag_dialog_destroyed (gpointer data, GObject *dialog_ptr)
g_free (info);
}
-static char *
-_get_ca_ignore_path (const char *uuid, gboolean phase2)
+static GSettings *
+_get_ca_ignore_settings (const char *uuid)
{
- return g_strdup_printf ("/apps/nm-applet/%s/%s",
- phase2 ? "ignore-phase2-ca-cert" : "ignore-ca-cert",
- uuid);
+ GSettings *settings;
+ char *path = NULL;
+
+ path = g_strdup_printf ("/org/gnome/nm-applet/eap/%s", uuid);
+ settings = g_settings_new_with_path ("org.gnome.nm-applet.eap", path);
+ g_free (path);
+
+ return settings;
}
static void
_set_ignore_ca_cert (const char *uuid, gboolean phase2, gboolean ignore)
{
- GConfClient *client;
- char *key = NULL;
+ GSettings *settings;
+ const char *key;
g_return_if_fail (uuid != NULL);
- client = gconf_client_get_default ();
-
- key = _get_ca_ignore_path (uuid, phase2);
- if (ignore)
- gconf_client_set_bool (client, key, ignore, NULL);
- else
- gconf_client_unset (client, key, NULL);
- g_free (key);
-
- g_object_unref (client);
+ settings = _get_ca_ignore_settings (uuid);
+ key = phase2 ? "ignore-phase2-ca-cert" : "ignore-ca-cert";
+ g_settings_set_boolean (settings, key, ignore);
+ g_object_unref (settings);
}
static void
@@ -211,19 +207,18 @@ eap_method_nag_user (EAPMethod *method)
static gboolean
_get_ignore_ca_cert (const char *uuid, gboolean phase2)
{
- GConfClient *client;
- char *key = NULL;
+ GSettings *settings;
+ const char *key;
gboolean ignore = FALSE;
g_return_val_if_fail (uuid != NULL, FALSE);
- client = gconf_client_get_default ();
+ settings = _get_ca_ignore_settings (uuid);
- key = _get_ca_ignore_path (uuid, phase2);
- ignore = gconf_client_get_bool (client, key, NULL);
- g_free (key);
+ key = phase2 ? "ignore-phase2-ca-cert" : "ignore-ca-cert";
+ ignore = g_settings_get_boolean (settings, key);
- g_object_unref (client);
+ g_object_unref (settings);
return ignore;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]