[balsa/gtk3] Migrate from GConf
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Migrate from GConf
- Date: Thu, 14 Apr 2011 02:26:42 +0000 (UTC)
commit ce61a7fbcc2eda02b38f4ad8a96502d0b0e77a74
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Wed Apr 13 22:26:04 2011 -0400
Migrate from GConf
* configure.in: do not check gconf-2.0.
* libinit_balsa/assistant_page_defclient.c
(balsa_druid_page_defclient_init), (balsa_druid_page_defclient),
(balsa_druid_page_defclient_toggle): use GAppInfo to check
default mailer.
* src/save-restore.c (config_defclient_save): use GAppInfo to
set default mailer.
* website/faq.html: update.
ChangeLog | 13 ++++++
configure.in | 1 -
libinit_balsa/assistant_page_defclient.c | 23 +++++-----
src/save-restore.c | 70 +++++++++++-------------------
website/faq.html | 14 +-----
5 files changed, 51 insertions(+), 70 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ed64baa..f516052 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-04-13 Peter Bloomfield
+
+ Migrate from GConf
+
+ * configure.in: do not check gconf-2.0.
+ * libinit_balsa/assistant_page_defclient.c
+ (balsa_druid_page_defclient_init), (balsa_druid_page_defclient),
+ (balsa_druid_page_defclient_toggle): use GAppInfo to check
+ default mailer.
+ * src/save-restore.c (config_defclient_save): use GAppInfo to
+ set default mailer.
+ * website/faq.html: update.
+
2011-04-06 Peter Bloomfield
* src/main-window.c: implement alt-n to switch to mailbox n.
diff --git a/configure.in b/configure.in
index 1c0d5b7..81d9024 100644
--- a/configure.in
+++ b/configure.in
@@ -282,7 +282,6 @@ dnl GNOME libs
dnl #####################################################################
if test x$with_gnome != xno; then
- gnome_extras="gconf-2.0"
AC_MSG_CHECKING([whether we have gnome-keyring])
if $PKG_CONFIG --atleast-version=1.0 gnome-keyring-1; then
gnome_extras="$gnome_extras gnome-keyring-1"
diff --git a/libinit_balsa/assistant_page_defclient.c b/libinit_balsa/assistant_page_defclient.c
index 522ddf7..1d92578 100644
--- a/libinit_balsa/assistant_page_defclient.c
+++ b/libinit_balsa/assistant_page_defclient.c
@@ -31,7 +31,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include <glib/gi18n.h>
#include "balsa-app.h"
@@ -53,6 +53,7 @@ balsa_druid_page_defclient_init(BalsaDruidPageDefclient * defclient,
GtkWidget *yes, *no;
defclient->default_client = 1;
+ balsa_app.default_client = defclient->default_client;
label =
GTK_LABEL(gtk_label_new
@@ -78,24 +79,21 @@ balsa_druid_page_defclient_init(BalsaDruidPageDefclient * defclient,
void
balsa_druid_page_defclient(GtkAssistant *druid, GdkPixbuf *default_logo)
{
+ GAppInfo *info;
BalsaDruidPageDefclient *defclient;
GtkWidget *page;
- GConfClient *gc;
- gc = gconf_client_get_default(); /* FIXME: error handling */
- if(gc) {
- GError *err = NULL;
- gchar *cmd;
+ info = g_app_info_get_default_for_uri_scheme("mailto");
+ if (info) {
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);
+
+ set_to_balsa_already = !strcmp(g_app_info_get_name(info), "Balsa");
+ g_object_unref(info);
+
if(set_to_balsa_already)
return;
}
+
defclient = g_new0(BalsaDruidPageDefclient, 1);
page = gtk_vbox_new(FALSE, FALSE);
gtk_assistant_append_page(druid, page);
@@ -112,6 +110,7 @@ balsa_druid_page_defclient_toggle(GtkWidget * page,
BalsaDruidPageDefclient * defclient)
{
defclient->default_client = ! (defclient->default_client);
+ balsa_app.default_client = defclient->default_client;
}
#endif /* HAVE_GNOME */
diff --git a/src/save-restore.c b/src/save-restore.c
index 5444e24..47ab67f 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
#if HAVE_GNOME
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#endif
#include <glib/gi18n.h>
#include "balsa-app.h"
@@ -2123,50 +2123,30 @@ save_mru(GList * mru, const gchar * group)
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" }};
- static struct {
- const char *key; gboolean val;
- } gconf_bool[] = {
- {"/desktop/gnome/url-handlers/mailto/need-terminal", FALSE},
- {"/desktop/gnome/url-handlers/mailto/enabled", TRUE}};
-
- if (balsa_app.default_client) {
- GError *err = NULL;
- GConfClient *gc;
- 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;
- }
- }
- 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);
- }
+ GAppInfo *info;
+ GError *err;
+
+ if (!balsa_app.default_client)
+ return;
+
+ err = NULL;
+ info = g_app_info_create_from_commandline
+ ("balsa -m \"%s\"", "Balsa",
+ G_APP_INFO_CREATE_SUPPORTS_URIS |
+ G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION, &err);
+ if (!info) {
+ g_warning("Failed to create default application for Balsa "
+ "for \"mailto\": %s", err->message);
+ g_error_free(err);
+ return;
+ }
+
+ if (!g_app_info_set_as_default_for_type
+ (info, "x-scheme-handler/mailto", &err)) {
+ g_warning("Failed to set Balsa as the default application "
+ "for \"mailto\": %s", err->message);
+ g_error_free(err);
}
+ g_object_unref(info);
}
#endif /* HAVE_GNOME */
diff --git a/website/faq.html b/website/faq.html
index ddf19de..e27dcb4 100644
--- a/website/faq.html
+++ b/website/faq.html
@@ -265,18 +265,8 @@ is correct to select it. See RFC 2046.</dd>
<a name="faq20"></a>
<dl>
<dt>Is there any way to change the default browser that Balsa calls?</dt>
-<dd>Yes, there is. Start by checking settings in your Gnome Control Center.
-If your version of <tt>gnomecc</tt> does provide option to change the default
-browser, you will need to create a file named gnome-moz-remote in your .gnome
-directory. It should contain the following:
-<pre>[Mozilla]
-filename=/path/to/your/browser
-</pre>
-One has to use the gconf editor to set the browser with more recent GNOME versions that use GConf. Run:
-<pre>gconftool-2 -t string -s /desktop/gnome/url-handlers/http/command 'mozilla "%s"'
-</pre>
-By the way, you can similarly set balsa as the <tt>mailto</tt> handler:
-<pre>gconftool-2 -t string -s /desktop/gnome/url-handlers/mailto/command 'balsa -m "%s"'
+<dd>Yes, there is, using Gnome Control Center. It may be accessed using the
+<tt>System Settings</tt> menu; go to <tt>System Info</tt>, then <tt>Default Applications</tt>. You can also set <tt>Balsa</tt> to be the default mailer in the same way.
</pre>
</dd>
</dl>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]