[balsa/gtk3] Migrate from GConf to GSettings
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Migrate from GConf to GSettings
- Date: Sat, 29 Jan 2011 02:41:36 +0000 (UTC)
commit 028ecb9c381021b6ae7cad6bc2573d3491e6ae83
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Fri Jan 28 21:41:04 2011 -0500
Migrate from GConf to GSettings
ChangeLog | 13 ++++
libinit_balsa/assistant_page_defclient.c | 29 ++++-----
src/ab-main.c | 8 ---
src/main.c | 12 ----
src/save-restore.c | 97 +++++------------------------
src/save-restore.h | 2 -
src/toolbar-factory.c | 46 +++++---------
7 files changed, 58 insertions(+), 149 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9eb380e..2e6c030 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2011-01-28 Peter Bloomfield
+ Migrate from GConf to GSettings
+
+ * libinit_balsa/assistant_page_defclient.c
+ (balsa_druid_page_defclient):
+ * src/ab-main.c (main):
+ * src/main.c (config_init), (mailboxes_init), (main):
+ * src/save-restore.c (config_global_load), (config_defclient_save):
+ * src/save-restore.h:
+ * src/toolbar-factory.c (tm_gsettings_change_cb),
+ (balsa_toolbar_model_new), (tm_default_style):
+
+2011-01-28 Peter Bloomfield
+
* src/balsa-index.c (balsa_index_load_mailbox_node): fix failed
assertion.
diff --git a/libinit_balsa/assistant_page_defclient.c b/libinit_balsa/assistant_page_defclient.c
index 522ddf7..d491900 100644
--- a/libinit_balsa/assistant_page_defclient.c
+++ b/libinit_balsa/assistant_page_defclient.c
@@ -31,7 +31,6 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
#include "balsa-app.h"
@@ -80,22 +79,18 @@ balsa_druid_page_defclient(GtkAssistant *druid, GdkPixbuf *default_logo)
{
BalsaDruidPageDefclient *defclient;
GtkWidget *page;
- GConfClient *gc;
-
- gc = gconf_client_get_default(); /* FIXME: error handling */
- if(gc) {
- GError *err = NULL;
- gchar *cmd;
- gboolean set_to_balsa_already;
- cmd =
- gconf_client_get_string
- (gc, "/desktop/gnome/url-handlers/mailto/command", &err);
- set_to_balsa_already = !err && cmd && strncmp(cmd,"balsa",5)==0;
- if(err) g_error_free(err);
- g_free(cmd);
- if(set_to_balsa_already)
- return;
- }
+ GSettings *settings;
+
+ gchar *cmd;
+ gboolean set_to_balsa_already;
+
+ settings = g_settings_new("org.gnome.url-handlers.mailto");
+ cmd = g_settings_get_string(settings, "command");
+ set_to_balsa_already = cmd && !strncmp(cmd, "balsa", 5);
+ g_free(cmd);
+ if (set_to_balsa_already)
+ return;
+
defclient = g_new0(BalsaDruidPageDefclient, 1);
page = gtk_vbox_new(FALSE, FALSE);
gtk_assistant_append_page(druid, page);
diff --git a/src/ab-main.c b/src/ab-main.c
index 842f157..f8c712d 100644
--- a/src/ab-main.c
+++ b/src/ab-main.c
@@ -27,10 +27,6 @@
#include <string.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
-#ifdef GTKHTML_HAVE_GCONF
-# include <gconf/gconf.h>
-#endif
-
#ifdef HAVE_LOCALE_H
#include <locale.h>
@@ -1109,10 +1105,6 @@ main(int argc, char *argv[])
/* FIXME: do we need to allow a non-GUI mode? */
gtk_init_check(&argc, &argv);
-#ifdef GTKHTML_HAVE_GCONF
- gconf_init(argc, argv, NULL);
-#endif
-
bab_init();
LIBBALSA_TYPE_ADDRESS_BOOK_VCARD;
LIBBALSA_TYPE_ADDRESS_BOOK_EXTERN;
diff --git a/src/main.c b/src/main.c
index d9441fe..b4a181f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,10 +28,6 @@
#include <unique/unique.h>
#endif /* HAVE_UNIQUE */
-#ifdef GTKHTML_HAVE_GCONF
-# include <gconf/gconf.h>
-#endif
-
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
@@ -436,9 +432,7 @@ config_init(gboolean check_only)
{
while(!config_load() && !check_only) {
balsa_init_begin();
-#if HAVE_GNOME
config_defclient_save();
-#endif
}
}
@@ -449,9 +443,7 @@ mailboxes_init(gboolean check_only)
if (!balsa_app.inbox && !check_only) {
g_warning("*** error loading mailboxes\n");
balsa_init_begin();
-#if HAVE_GNOME
config_defclient_save();
-#endif
return;
}
}
@@ -846,10 +838,6 @@ main(int argc, char *argv[])
}
#endif
-#ifdef GTKHTML_HAVE_GCONF
- gconf_init(argc, argv, NULL);
-#endif
-
balsa_app_init();
/* Initialize libbalsa */
diff --git a/src/save-restore.c b/src/save-restore.c
index 9efd06f..c8fb223 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -26,9 +26,6 @@
#include <stdlib.h>
#include <string.h>
-#if HAVE_GNOME
-#include <gconf/gconf-client.h>
-#endif
#include <glib/gi18n.h>
#include "balsa-app.h"
#include "server.h"
@@ -72,8 +69,6 @@ static void load_mru(GList **mru, const gchar * group);
static void config_address_books_save(void);
static void config_identities_load(void);
-static void check_for_old_sigs(GList * id_list_tmp);
-
static void config_filters_load(void);
#define folder_section_path(mn) \
@@ -616,9 +611,6 @@ config_global_load(void)
filter_strerror(filter_errno));
}
- /* find and convert old-style signature entries */
- check_for_old_sigs(balsa_app.identities);
-
/* Section for the balsa_information() settings... */
libbalsa_conf_push_group("InformationMessages");
@@ -2118,88 +2110,33 @@ save_mru(GList * mru, const gchar * group)
libbalsa_conf_pop_group();
}
-/* check_for_old_sigs:
- function for old style signature conversion (executable sigs prefixed
- with '|') to new style (filename and a checkbox).
- this function just strips the leading '|'.
-*/
-static void
-check_for_old_sigs(GList * id_list_tmp)
-{
- /* strip pipes and spaces,set executable flag if warranted */
- /* FIXME remove after a few stable releases.*/
-
- LibBalsaIdentity* id_tmp = NULL;
-
- for (id_list_tmp = balsa_app.identities; id_list_tmp;
- id_list_tmp = id_list_tmp->next) {
-
- id_tmp = LIBBALSA_IDENTITY(id_list_tmp->data);
- if(!id_tmp->signature_path) continue;
-
- id_tmp->signature_path = g_strstrip(id_tmp->signature_path);
- if(*id_tmp->signature_path == '|'){
- printf("Found old style signature for identity: %s\n"\
- "Converting: %s --> ", id_tmp->identity_name,
- id_tmp->signature_path);
- id_tmp->signature_path = g_strchug(id_tmp->signature_path+1);
- printf("%s \n", id_tmp->signature_path);
-
- /* set new-style executable var*/
- id_tmp->sig_executable=TRUE;
- printf("Setting converted signature as executable.\n");
- }
- }
-}
-
-#if HAVE_GNOME
void
config_defclient_save(void)
{
static struct {
const char *key, *val;
- } gconf_string[] = {
- {"/desktop/gnome/url-handlers/mailto/command", "balsa -m \"%s\""},
- {"/desktop/gnome/url-handlers/mailto/description", "Email" }};
+ } settings_string[] = { {
+ "command", "balsa -m \"%s\""}, {
+ "description", "Email"}};
static struct {
- const char *key; gboolean val;
- } gconf_bool[] = {
- {"/desktop/gnome/url-handlers/mailto/need-terminal", FALSE},
- {"/desktop/gnome/url-handlers/mailto/enabled", TRUE}};
+ const char *key;
+ gboolean val;
+ } settings_bool[] = { {
+ "need-terminal", FALSE}, {
+ "-handlers/mailto/enabled", TRUE}};
if (balsa_app.default_client) {
- GError *err = NULL;
- GConfClient *gc;
+ GSettings *settings;
unsigned i;
- gc = gconf_client_get_default(); /* FIXME: error handling */
- if (gc == NULL) {
- balsa_information(LIBBALSA_INFORMATION_WARNING,
- _("Error opening GConf database\n"));
- return;
- }
- for(i=0; i<ELEMENTS(gconf_string); i++) {
- gconf_client_set_string(gc, gconf_string[i].key,
- gconf_string[i].val, &err);
- if (err) {
- balsa_information(LIBBALSA_INFORMATION_WARNING,
- _("Error setting GConf field: %s\n"),
- err->message);
- g_error_free(err);
- return;
- }
+
+ settings = g_settings_new("desktop.gnome.url-handlers.mailto");
+ for (i = 0; i < G_N_ELEMENTS(settings_string); i++) {
+ g_settings_set_string(settings, settings_string[i].key,
+ settings_string[i].val);
}
- for(i=0; i<ELEMENTS(gconf_bool); i++) {
- gconf_client_set_bool(gc, gconf_bool[i].key,
- gconf_bool[i].val, &err);
- if (err) {
- balsa_information(LIBBALSA_INFORMATION_WARNING,
- _("Error setting GConf field: %s\n"),
- err->message);
- g_error_free(err);
- return;
- }
- g_object_unref(gc);
+ for (i = 0; i < G_N_ELEMENTS(settings_bool); i++) {
+ g_settings_set_boolean(settings, settings_bool[i].key,
+ settings_bool[i].val);
}
}
}
-#endif /* HAVE_GNOME */
diff --git a/src/save-restore.h b/src/save-restore.h
index 5079cb3..4f08f69 100644
--- a/src/save-restore.h
+++ b/src/save-restore.h
@@ -43,9 +43,7 @@ void config_mailbox_set_as_special(LibBalsaMailbox * mailbox,
gint config_load(void);
void config_load_sections(void);
gint config_save(void);
-#if HAVE_GNOME
void config_defclient_save(void);
-#endif
gchar *mailbox_get_pkey(const LibBalsaMailbox * mbox);
gint config_mailbox_add(LibBalsaMailbox * mailbox, const char *key_arg);
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index 75b79f0..6ed9a22 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -25,10 +25,6 @@
#include "toolbar-factory.h"
#include <string.h>
-#if HAVE_GNOME
-#include <gconf/gconf-client.h>
-#endif
-
#include <glib/gi18n.h>
#include "balsa-app.h"
@@ -267,17 +263,19 @@ tm_save_model(BalsaToolbarModel * model)
libbalsa_conf_pop_group();
}
-#if HAVE_GNOME
-/* GConfClientNotifyFunc
+/* GSettings change_cb
*/
static void
-tm_gconf_notify(GConfClient * client, guint cnxn_id, GConfEntry * entry,
- BalsaToolbarModel * model)
+tm_gsettings_change_cb(GSettings * settings,
+ const gchar * key,
+ gpointer user_data)
{
- if (model->style == (GtkToolbarStyle) (-1))
+ BalsaToolbarModel *model = user_data;
+
+ if (!strcmp(key, "toolbar_style") &&
+ model->style == (GtkToolbarStyle) (-1))
balsa_toolbar_model_changed(model);
}
-#endif /* HAVE_GNOME */
/* Create a BalsaToolbarModel structure.
*/
@@ -286,24 +284,16 @@ balsa_toolbar_model_new(BalsaToolbarType type, GSList * standard)
{
BalsaToolbarModel *model =
g_object_new(BALSA_TYPE_TOOLBAR_MODEL, NULL);
-#if HAVE_GNOME
- GConfClient *conf;
- guint notify_id;
-#endif
+ GSettings *settings;
model->type = type;
model->standard = standard;
tm_load_model(model);
-#if HAVE_GNOME
- conf = gconf_client_get_default();
- /* We never destroy a model, so we do nothing with the notify-id: */
- notify_id =
- gconf_client_notify_add(conf,
- "/desktop/gnome/interface/toolbar_style",
- (GConfClientNotifyFunc) tm_gconf_notify,
- model, NULL, NULL);
-#endif /* HAVE_GNOME */
+ settings = g_settings_new("org.gnome.desktop.interface");
+ g_signal_connect(G_OBJECT(settings), "changed",
+ G_CALLBACK(tm_gsettings_change_cb), model);
+ g_object_unref(settings);
return model;
}
@@ -535,15 +525,12 @@ static GtkToolbarStyle
tm_default_style(void)
{
GtkToolbarStyle default_style = GTK_TOOLBAR_BOTH;
-#if HAVE_GNOME
- GConfClient *conf;
+ GSettings *settings;
gchar *str;
/* Get global setting */
- conf = gconf_client_get_default();
- str = gconf_client_get_string(conf,
- "/desktop/gnome/interface/toolbar_style",
- NULL);
+ settings = g_settings_new("org.gnome.desktop.interface");
+ str = g_settings_get_string(settings, "toolbar-style");
if (str) {
guint i;
@@ -554,7 +541,6 @@ tm_default_style(void)
}
g_free(str);
}
-#endif /* HAVE_GNOME */
return default_style;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]