[gnome-nettool] Use gsettings (Bug #625900)
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nettool] Use gsettings (Bug #625900)
- Date: Thu, 4 Nov 2010 22:23:37 +0000 (UTC)
commit e3ad23d0d27f7f46329514b373995ba0a8a9e13e
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Nov 4 11:49:06 2010 +1100
Use gsettings (Bug #625900)
configure.ac | 13 +--
data/Makefile.am | 9 +-
data/org.gnome.gnome-nettool.gschema.xml.in | 20 +++++
po/POTFILES.in | 1 +
src/gn-combo-history.c | 122 ++++++++-------------------
src/main.c | 14 ++--
6 files changed, 73 insertions(+), 106 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index de03ae1..6587bf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,8 +30,8 @@ AC_CHECK_HEADERS(sys/socket.h ifaddrs.h,,AC_MSG_ERROR(Required header not found:
dnl ******************************************
dnl ** pkg-config dependacy checks **
dnl ******************************************
+GIO_REQUIRED=2.25.10
GTK_REQUIRED=2.90.0
-GCONF_REQUIRED=1.1.11
AC_MSG_CHECKING([which gtk+ version to compile against])
AC_ARG_WITH([gtk],
@@ -54,7 +54,7 @@ esac
PKG_CHECK_MODULES(NETTOOL,
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED
- gconf-2.0 >= $GCONF_REQUIRED
+ gio-2.0 >= $GIO_REQUIRED
gmodule-export-2.0
gnome-doc-utils
libgtop-2.0)
@@ -74,14 +74,9 @@ AM_GLIB_GNU_GETTEXT
GNOME_DOC_INIT
dnl
-dnl GConf stuff
+dnl GSettings stuff
dnl
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-if test x"$GCONFTOOL" = xno; then
- AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
-fi
-AM_GCONF_SOURCE_2
-
+GLIB_GSETTINGS
dnl
dnl Debugging flags
diff --git a/data/Makefile.am b/data/Makefile.am
index 58fcd50..3a8f70b 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,17 +1,16 @@
uidir = $(pkgdatadir)/ui
ui_DATA = gnome-nettool.ui
+gsettings_SCHEMAS = org.gnome.gnome-nettool.gschema.xml
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
desktopdir = $(datadir)/applications
desktop_in_in_files = gnome-nettool.desktop.in.in
desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- @$(NORMAL_INSTALL)
-endif
-
EXTRA_DIST = \
$(desktop_in_in_files) \
$(ui_DATA)
diff --git a/data/org.gnome.gnome-nettool.gschema.xml.in b/data/org.gnome.gnome-nettool.gschema.xml.in
new file mode 100644
index 0000000..4173e88
--- /dev/null
+++ b/data/org.gnome.gnome-nettool.gschema.xml.in
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <schema path="/apps/gnome-nettool/" id="org.gnome.gnome-nettool" gettext-domain="gnome-nettool">
+ <key type="as" name="hostnames">
+ <default>[]</default>
+ <_summary>Historically used hostnames</_summary>
+ <_description>A list of hostnames previously used</_description>
+ </key>
+ <key type="as" name="usernames">
+ <default>[]</default>
+ <_summary>Historically used usernames</_summary>
+ <_description>A list of usernames previously used</_description>
+ </key>
+ <key type="as" name="domains">
+ <default>[]</default>
+ <_summary>Historically used domains</_summary>
+ <_description>A list of domains previously used</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7247eb7..c2758ad 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
src/callbacks.c
src/callbacks.h
data/gnome-nettool.desktop.in.in
+data/gnome-nettool.gschema.xml.in
[type: gettext/glade]data/gnome-nettool.ui
src/info.c
src/info.h
diff --git a/src/gn-combo-history.c b/src/gn-combo-history.c
index ccfc28d..09e2566 100644
--- a/src/gn-combo-history.c
+++ b/src/gn-combo-history.c
@@ -18,7 +18,6 @@
*/
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include "gn-combo-history.h"
@@ -38,8 +37,7 @@ struct _GnComboHistoryPrivate {
GSList *items;
- GConfClient *gconf_client;
- guint gconf_notify;
+ GSettings *settings;
};
static void gn_combo_history_init (GnComboHistory *history);
@@ -55,9 +53,9 @@ static void gn_combo_history_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-static void gn_combo_history_gconf_register_id (GnComboHistory *history);
-static void gn_combo_history_gconf_load (GnComboHistory *history);
-static void gn_combo_history_gconf_save (GnComboHistory *history);
+static void gn_combo_history_settings_register_id (GnComboHistory *history);
+static void gn_combo_history_settings_load (GnComboHistory *history);
+static void gn_combo_history_settings_save (GnComboHistory *history);
static void gn_combo_history_set_popdown_strings (GnComboHistory *history);
static GObjectClass *parent_class = NULL;
@@ -95,8 +93,7 @@ gn_combo_history_init (GnComboHistory *history)
history->priv->id = NULL;
history->priv->max_history = 10;
history->priv->items = NULL;
- history->priv->gconf_client = gconf_client_get_default ();
- history->priv->gconf_notify = 0;
+ history->priv->settings = g_settings_new ("org.gnome.gnome-nettool");
}
static void
@@ -151,16 +148,8 @@ gn_combo_history_finalize (GObject *object)
gn_combo_free_items (history);
- if (history->priv->gconf_notify != 0) {
- gconf_client_notify_remove (history->priv->gconf_client,
- history->priv->gconf_notify);
- history->priv->gconf_notify = 0;
- }
-
- if (history->priv->gconf_client) {
- g_object_unref (G_OBJECT (history->priv->gconf_client));
- history->priv->gconf_client = NULL;
- }
+ g_object_unref (G_OBJECT (history->priv->settings));
+ history->priv->settings = NULL;
}
if (G_OBJECT_CLASS (parent_class)->finalize)
@@ -229,58 +218,40 @@ gn_combo_history_new (void)
}
static void
-gn_combo_history_gconf_load (GnComboHistory *history)
+gn_combo_history_settings_load (GnComboHistory *history)
{
- gchar *key;
- GSList *gconf_items, *last;
+ gchar **items;
+ gint i;
g_return_if_fail (GN_IS_COMBO_HISTORY (history));
- g_return_if_fail (history->priv->gconf_client != NULL);
g_return_if_fail (history->priv->id != NULL);
gn_combo_free_items (history);
+ history->priv->items = NULL;
- key = g_strconcat ("/apps/gnome-settings/",
- "gnome-nettool",
- "/history-",
- history->priv->id,
- NULL);
-
- gconf_items = gconf_client_get_list (history->priv->gconf_client,
- key, GCONF_VALUE_STRING, NULL);
- g_free (key);
-
- /* truncate the list */
- last = g_slist_nth (gconf_items, history->priv->max_history - 1);
- if (last) {
- g_slist_foreach (last->next, (GFunc) g_free, NULL);
- g_slist_free (last->next);
- last->next = NULL;
- }
+ items = g_settings_get_strv (history->priv->settings, history->priv->id);
- history->priv->items = gconf_items;
+ for (i = 0; items[i] && i < history->priv->max_history; i++)
+ history->priv->items = g_slist_append (history->priv->items, g_strdup (items[i]));
+ g_strfreev (items);
}
static void
-gn_combo_history_gconf_save (GnComboHistory *history)
+gn_combo_history_settings_save (GnComboHistory *history)
{
- gchar *key;
-
+ const gchar **items;
+ GSList *item;
+ gint i;
+
g_return_if_fail (GN_IS_COMBO_HISTORY (history));
- g_return_if_fail (history->priv->gconf_client != NULL);
g_return_if_fail (history->priv->id != NULL);
- key = g_strconcat ("/apps/gnome-settings/",
- "gnome-nettool",
- "/history-",
- history->priv->id,
- NULL);
-
- gconf_client_set_list (history->priv->gconf_client,
- key, GCONF_VALUE_STRING,
- history->priv->items, NULL);
-
- g_free (key);
+ items = g_malloc (sizeof (gchar *) * (g_slist_length (history->priv->items) + 1));
+ for (item = history->priv->items, i = 0; item; item = item->next, i++)
+ items[i] = item->data;
+ items[i] = NULL;
+ g_settings_set_strv (history->priv->settings, history->priv->id, items);
+ g_free (items);
}
static void
@@ -339,7 +310,7 @@ gn_combo_history_set_combo (GnComboHistory *history, GtkComboBox *combo)
history->priv->combo = combo;
- gn_combo_history_gconf_load (history);
+ gn_combo_history_settings_load (history);
gn_combo_history_set_popdown_strings (history);
@@ -362,43 +333,24 @@ gn_combo_history_get_combo (GnComboHistory *history)
}
static void
-gn_on_gconf_history_changed (GConfClient *client, guint cnxn_id,
- GConfEntry *entry, gpointer gdata)
+gn_on_settings_history_changed (GSettings *settings, gchar *key, gpointer gdata)
{
GnComboHistory *history;
history = GN_COMBO_HISTORY (gdata);
- gn_combo_history_gconf_load (history);
+ if (!g_str_equal (key, history->priv->id))
+ return;
+
+ gn_combo_history_settings_load (history);
gn_combo_history_set_popdown_strings (history);
}
static void
-gn_combo_history_gconf_register_id (GnComboHistory *history)
+gn_combo_history_settings_register_id (GnComboHistory *history)
{
- gchar *key;
-
g_return_if_fail (GN_IS_COMBO_HISTORY (history));
-
- if (!history->priv->gconf_client)
- history->priv->gconf_client = gconf_client_get_default ();
-
- key = g_strconcat ("/apps/gnome-settings/",
- "gnome-nettool",
- "/history-",
- history->priv->id,
- NULL);
-
- gconf_client_add_dir (history->priv->gconf_client,
- key, GCONF_CLIENT_PRELOAD_NONE,
- NULL);
-
- history->priv->gconf_notify = gconf_client_notify_add (
- history->priv->gconf_client, key,
- gn_on_gconf_history_changed,
- (gpointer) history, NULL, NULL);
-
- g_free (key);
+ g_signal_connect (history->priv->settings, "changed", G_CALLBACK (gn_on_settings_history_changed), history);
}
void
@@ -412,7 +364,7 @@ gn_combo_history_set_id (GnComboHistory *history, const gchar *history_id)
history->priv->id = g_strdup (history_id);
- gn_combo_history_gconf_register_id (history);
+ gn_combo_history_settings_register_id (history);
}
const gchar *
@@ -452,7 +404,7 @@ gn_combo_history_add (GnComboHistory *history, const gchar *text)
gn_combo_history_set_popdown_strings (history);
- gn_combo_history_gconf_save (history);
+ gn_combo_history_settings_save (history);
}
void
@@ -462,7 +414,7 @@ gn_combo_history_clear (GnComboHistory *history)
if (history->priv->items) {
gn_combo_free_items (history);
- gn_combo_history_gconf_save (history);
+ gn_combo_history_settings_save (history);
}
}
diff --git a/src/main.c b/src/main.c
index e503c79..9297850 100644
--- a/src/main.c
+++ b/src/main.c
@@ -327,7 +327,7 @@ load_ping_widgets_from_builder (GtkBuilder * builder)
g_object_unref (model);
pinger->history = gn_combo_history_new ();
- gn_combo_history_set_id (pinger->history, "GNOME_Network_netinfo_host");
+ gn_combo_history_set_id (pinger->history, "hostnames");
gn_combo_history_set_combo (pinger->history, GTK_COMBO_BOX (pinger->host));
g_signal_connect (G_OBJECT (entry_host), "activate",
@@ -406,7 +406,7 @@ load_traceroute_widgets_from_builder (GtkBuilder * builder)
g_object_unref (model);
tracer->history = gn_combo_history_new ();
- gn_combo_history_set_id (tracer->history, "GNOME_Network_netinfo_host");
+ gn_combo_history_set_id (tracer->history, "hostnames");
gn_combo_history_set_combo (tracer->history, GTK_COMBO_BOX (tracer->host));
g_signal_connect (G_OBJECT (entry_host), "activate",
@@ -645,7 +645,7 @@ load_scan_widgets_from_builder (GtkBuilder * builder)
g_object_unref (model);
scan->history = gn_combo_history_new ();
- gn_combo_history_set_id (scan->history, "GNOME_Network_netinfo_host");
+ gn_combo_history_set_id (scan->history, "hostnames");
gn_combo_history_set_combo (scan->history, GTK_COMBO_BOX (scan->host));
g_signal_connect (G_OBJECT (entry_host), "activate",
@@ -769,7 +769,7 @@ load_lookup_widgets_from_builder (GtkBuilder * builder)
g_object_unref (model);
lookup->history = gn_combo_history_new ();
- gn_combo_history_set_id (lookup->history, "GNOME_Network_netinfo_host");
+ gn_combo_history_set_id (lookup->history, "hostnames");
gn_combo_history_set_combo (lookup->history, GTK_COMBO_BOX (lookup->host));
g_signal_connect (G_OBJECT (entry_host), "activate",
@@ -852,7 +852,7 @@ load_finger_widgets_from_builder (GtkBuilder * builder)
g_object_unref (model);
finger->history_user = gn_combo_history_new ();
- gn_combo_history_set_id (finger->history_user, "GNOME_Network_netinfo_user");
+ gn_combo_history_set_id (finger->history_user, "usernames");
gn_combo_history_set_combo (finger->history_user, GTK_COMBO_BOX (finger->user));
g_signal_connect (G_OBJECT (entry_host), "activate",
@@ -875,7 +875,7 @@ load_finger_widgets_from_builder (GtkBuilder * builder)
g_object_unref (model);
finger->history = gn_combo_history_new ();
- gn_combo_history_set_id (finger->history, "GNOME_Network_netinfo_host");
+ gn_combo_history_set_id (finger->history, "hostnames");
gn_combo_history_set_combo (finger->history, GTK_COMBO_BOX (finger->host));
g_signal_connect (G_OBJECT (entry_host), "activate",
@@ -956,7 +956,7 @@ load_whois_widgets_from_builder (GtkBuilder * builder)
g_object_unref (model);
whois->history = gn_combo_history_new ();
- gn_combo_history_set_id (whois->history, "GNOME_Network_netinfo_domain");
+ gn_combo_history_set_id (whois->history, "domains");
gn_combo_history_set_combo (whois->history, GTK_COMBO_BOX (whois->host));
g_signal_connect (G_OBJECT (entry_host), "activate",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]