[PATCH] Balsa does not prompt to install as GNOME mailto:// handler.
- From: "W. Michael Petullo" <mike flyn org>
- To: balsa-list gnome org
- Subject: [PATCH] Balsa does not prompt to install as GNOME mailto:// handler.
- Date: Thu, 15 Jan 2004 15:38:07 -0600
Balsa's install druid should ask if balsa should be used for the default
mailto handler in GNOME. If this is the case, balsa should update GConf's
/desktop/gnome/url-handlers/mailto/ records so that, for example, clicking
on a mailto link in epiphany will cause balsa to be fired up. Attached to
this email you should find a proposed patch that modifies balsa's druid
and fixes this.
This is similar to the following GNOME bounty:
http://www.gnome.org/bounties/Mailer.php3#127526
This patch is in GNOME bugzilla (131606) and is against 2.1.0.
--
Mike
:wq
diff -u --recursive --new-file balsa-2.1.0-vanilla/libinit_balsa/balsa-druid-page-defclient.c balsa-2.1.0/libinit_balsa/balsa-druid-page-defclient.c
--- balsa-2.1.0-vanilla/libinit_balsa/balsa-druid-page-defclient.c 1969-12-31 18:00:00.000000000 -0600
+++ balsa-2.1.0/libinit_balsa/balsa-druid-page-defclient.c 2004-01-15 15:20:00.000000000 -0600
@@ -0,0 +1,131 @@
+/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
+/* Balsa E-Mail Client
+ * Copyright (C) 1997-2002 Stuart Parmenter and others,
+ * See the file AUTHORS for a list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "balsa-druid-page-defclient.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "balsa-app.h"
+
+/* here are local prototypes */
+
+static void balsa_druid_page_defclient_init(BalsaDruidPageDefclient * defclient,
+ GnomeDruidPageStandard * page,
+ GnomeDruid * druid);
+static void balsa_druid_page_defclient_toggle(GnomeDruidPage * page,
+ BalsaDruidPageDefclient * defclient);
+static void balsa_druid_page_defclient_prepare(GnomeDruidPage * page,
+ GnomeDruid * druid,
+ BalsaDruidPageDefclient * defclient);
+static gboolean balsa_druid_page_defclient_next(GnomeDruidPage * page,
+ GnomeDruid * druid,
+ BalsaDruidPageDefclient * defclient);
+
+static void
+balsa_druid_page_defclient_init(BalsaDruidPageDefclient * defclient,
+ GnomeDruidPageStandard * page,
+ GnomeDruid * druid)
+{
+ GtkLabel *label;
+ GtkWidget *yes, *no;
+ gchar *preset;
+
+ defclient->default_client = 1;
+
+ label =
+ GTK_LABEL(gtk_label_new
+ (_("Use balsa as default email client?")));
+ gtk_label_set_justify(label, GTK_JUSTIFY_CENTER);
+ gtk_label_set_line_wrap(label, TRUE);
+
+ yes = gtk_radio_button_new_with_label(NULL, "Yes");
+ no = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(yes), "No");
+
+#if BALSA_MAJOR < 2
+ gtk_signal_connect(GTK_OBJECT(yes), "toggled",
+ GTK_SIGNAL_FUNC(balsa_druid_page_defclient_toggle),
+ defclient);
+#else
+ g_signal_connect(G_OBJECT(yes), "toggled",
+ G_CALLBACK(balsa_druid_page_defclient_toggle),
+ defclient);
+#endif
+
+ gtk_box_pack_start(GTK_BOX(page->vbox), GTK_WIDGET(label), TRUE, TRUE, 8);
+ gtk_box_pack_start(GTK_BOX(page->vbox), GTK_WIDGET(yes), TRUE, TRUE, 2);
+ gtk_box_pack_start(GTK_BOX(page->vbox), GTK_WIDGET(no), TRUE, TRUE, 2);
+
+ return;
+}
+
+void
+#if BALSA_MAJOR < 2
+balsa_druid_page_defclient(GnomeDruid * druid, GdkImlibImage * default_logo)
+#else
+balsa_druid_page_defclient(GnomeDruid * druid, GdkPixbuf * default_logo)
+#endif /* BALSA_MAJOR < 2 */
+{
+ BalsaDruidPageDefclient *defclient;
+ GnomeDruidPageStandard *page;
+
+ defclient = g_new0(BalsaDruidPageDefclient, 1);
+ page = GNOME_DRUID_PAGE_STANDARD(gnome_druid_page_standard_new());
+ gnome_druid_page_standard_set_title(page, _("Default Client"));
+ gnome_druid_page_standard_set_logo(page, default_logo);
+ balsa_druid_page_defclient_init(defclient, page, druid);
+ gnome_druid_append_page(druid, GNOME_DRUID_PAGE(page));
+#if BALSA_MAJOR < 2
+ gtk_signal_connect(GTK_OBJECT(page), "prepare",
+ GTK_SIGNAL_FUNC(balsa_druid_page_defclient_prepare),
+ defclient);
+ gtk_signal_connect(GTK_OBJECT(page), "next",
+ GTK_SIGNAL_FUNC(balsa_druid_page_defclient_next), defclient);
+#else
+ g_signal_connect(G_OBJECT(page), "prepare",
+ G_CALLBACK(balsa_druid_page_defclient_prepare),
+ defclient);
+ g_signal_connect(G_OBJECT(page), "next",
+ G_CALLBACK(balsa_druid_page_defclient_next), defclient);
+#endif /* BALSA_MAJOR < 2 */
+}
+
+static void
+balsa_druid_page_defclient_toggle(GnomeDruidPage * page,
+ BalsaDruidPageDefclient * defclient)
+{
+ defclient->default_client = ! (defclient->default_client);
+}
+
+static void
+balsa_druid_page_defclient_prepare(GnomeDruidPage * page, GnomeDruid * druid,
+ BalsaDruidPageDefclient * defclient)
+{
+ gnome_druid_set_show_finish(druid, FALSE);
+}
+
+static gboolean
+balsa_druid_page_defclient_next(GnomeDruidPage * page, GnomeDruid * druid,
+ BalsaDruidPageDefclient * defclient)
+{
+ balsa_app.default_client = defclient->default_client;
+ return FALSE;
+}
diff -u --recursive --new-file balsa-2.1.0-vanilla/libinit_balsa/balsa-druid-page-defclient.h balsa-2.1.0/libinit_balsa/balsa-druid-page-defclient.h
--- balsa-2.1.0-vanilla/libinit_balsa/balsa-druid-page-defclient.h 1969-12-31 18:00:00.000000000 -0600
+++ balsa-2.1.0/libinit_balsa/balsa-druid-page-defclient.h 2004-01-15 13:57:51.000000000 -0600
@@ -0,0 +1,64 @@
+/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
+/* Balsa E-Mail Client
+ * Copyright (C) 1997-2002 Stuart Parmenter and others,
+ * See the file AUTHORS for a list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+#ifndef __BALSA_DRUID_PAGE_DEFCLIENT_H__
+#define __BALSA_DRUID_PAGE_DEFCLIENT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+
+#include "config.h"
+#include <gnome.h>
+#include "helper.h"
+#include "balsa-initdruid.h"
+
+/*
+ * Main object structure
+ */
+#ifndef __TYPEDEF_BALSA_DRUID_PAGE_DEFCLIENT__
+#define __TYPEDEF_BALSA_DRUID_PAGE_DEFCLIENT__
+ typedef struct _BalsaDruidPageDefclient BalsaDruidPageDefclient;
+#endif
+#define BALSA_DRUID_PAGE_DEFCLIENT(obj) ((BalsaDruidPageDefclient *) obj)
+ struct _BalsaDruidPageDefclient {
+ int default_client;
+ };
+
+/*
+ * Public methods
+ */
+#if BALSA_MAJOR < 2
+ void balsa_druid_page_defclient(GnomeDruid * druid,
+ GdkImlibImage * default_logo);
+#else
+ void balsa_druid_page_defclient(GnomeDruid * druid,
+ GdkPixbuf * default_logo);
+#endif /* BALSA_MAJOR < 2 */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
diff -u --recursive --new-file balsa-2.1.0-vanilla/libinit_balsa/balsa-initdruid.c balsa-2.1.0/libinit_balsa/balsa-initdruid.c
--- balsa-2.1.0-vanilla/libinit_balsa/balsa-initdruid.c 2003-01-20 17:01:31.000000000 -0600
+++ balsa-2.1.0/libinit_balsa/balsa-initdruid.c 2004-01-15 09:15:04.000000000 -0600
@@ -26,6 +26,7 @@
#include "balsa-druid-page-welcome.h"
#include "balsa-druid-page-user.h"
#include "balsa-druid-page-directory.h"
+#include "balsa-druid-page-defclient.h"
#include "balsa-druid-page-finish.h"
/* here are local prototypes */
@@ -44,6 +45,7 @@
balsa_druid_page_welcome(druid, default_logo);
balsa_druid_page_user(druid, default_logo);
balsa_druid_page_directory(druid, default_logo);
+ balsa_druid_page_defclient(druid, default_logo);
balsa_druid_page_finish(druid, default_logo);
}
diff -u --recursive --new-file balsa-2.1.0-vanilla/libinit_balsa/Makefile.am balsa-2.1.0/libinit_balsa/Makefile.am
--- balsa-2.1.0-vanilla/libinit_balsa/Makefile.am 2003-09-09 12:26:00.000000000 -0500
+++ balsa-2.1.0/libinit_balsa/Makefile.am 2004-01-15 09:42:48.000000000 -0600
@@ -1,6 +1,8 @@
noinst_LIBRARIES = libinit_balsa.a
libinit_balsa_a_SOURCES = \
+ balsa-druid-page-defclient.c \
+ balsa-druid-page-defclient.h \
balsa-druid-page-directory.c \
balsa-druid-page-directory.h \
balsa-druid-page-finish.c \
diff -u --recursive --new-file balsa-2.1.0-vanilla/libinit_balsa/Makefile.in balsa-2.1.0/libinit_balsa/Makefile.in
--- balsa-2.1.0-vanilla/libinit_balsa/Makefile.in 2004-01-11 15:49:17.000000000 -0600
+++ balsa-2.1.0/libinit_balsa/Makefile.in 2004-01-15 09:44:42.000000000 -0600
@@ -128,6 +128,8 @@
noinst_LIBRARIES = libinit_balsa.a
libinit_balsa_a_SOURCES = \
+ balsa-druid-page-defclient.c \
+ balsa-druid-page-defclient.h \
balsa-druid-page-directory.c \
balsa-druid-page-directory.h \
balsa-druid-page-finish.c \
@@ -166,7 +168,7 @@
libinit_balsa_a_OBJECTS = balsa-druid-page-directory.$(OBJEXT) \
balsa-druid-page-finish.$(OBJEXT) balsa-druid-page-user.$(OBJEXT) \
balsa-druid-page-welcome.$(OBJEXT) balsa-initdruid.$(OBJEXT) \
-helper.$(OBJEXT) init_balsa.$(OBJEXT)
+helper.$(OBJEXT) init_balsa.$(OBJEXT) balsa-druid-page-defclient.$(OBJEXT)
AR = ar
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -296,6 +298,25 @@
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
+balsa-druid-page-defclient.o: balsa-druid-page-defclient.c \
+ balsa-druid-page-defclient.h ../config.h helper.h \
+ balsa-initdruid.h ../src/balsa-app.h ../libbalsa/libbalsa.h \
+ ../libbalsa/address.h ../libbalsa/message.h ../libbalsa/body.h \
+ ../libbalsa/files.h ../libbalsa/mime.h ../libbalsa/notify.h \
+ ../libbalsa/information.h ../libbalsa/server.h \
+ ../libbalsa/address-book.h ../libbalsa/address-book-vcard.h \
+ ../libbalsa/address-book-ldif.h \
+ ../libbalsa/address-book-extern.h \
+ ../libbalsa/address-book-ldap.h ../libbalsa/mailbox.h \
+ ../libbalsa/filter.h ../libbalsa/mailbox_local.h \
+ ../libbalsa/mailbox_remote.h ../libbalsa/mailbox_pop3.h \
+ ../libbalsa/mailbox_imap.h ../libbalsa/imap/imap.h \
+ ../libbalsa/mailbox_mbox.h ../libbalsa/mailbox_mh.h \
+ ../libbalsa/mailbox_maildir.h ../libbalsa/identity.h \
+ ../src/balsa-index.h ../src/mailbox-node.h \
+ ../src/balsa-mblist.h ../src/information-dialog.h \
+ ../src/main-window.h ../src/toolbar-factory.h \
+ ../libbalsa/misc.h ../src/save-restore.h ../libbalsa/url.h
balsa-druid-page-directory.o: balsa-druid-page-directory.c \
balsa-druid-page-directory.h ../config.h helper.h \
balsa-initdruid.h ../src/balsa-app.h ../libbalsa/libbalsa.h \
diff -u --recursive --new-file balsa-2.1.0-vanilla/src/balsa-app.h balsa-2.1.0/src/balsa-app.h
--- balsa-2.1.0-vanilla/src/balsa-app.h 2004-01-09 13:11:24.000000000 -0600
+++ balsa-2.1.0/src/balsa-app.h 2004-01-15 11:36:13.000000000 -0600
@@ -389,6 +389,9 @@
GHashTable *mailbox_views;
+ /* use as default email client for GNOME */
+ int default_client;
+
} balsa_app;
#define BALSA_IS_MAILBOX_SPECIAL(a) ((a)==balsa_app.inbox || (a)==balsa_app.trash || (a)==balsa_app.outbox||(a)==balsa_app.draftbox || (a)==balsa_app.sentbox)
diff -u --recursive --new-file balsa-2.1.0-vanilla/src/save-restore.c balsa-2.1.0/src/save-restore.c
--- balsa-2.1.0-vanilla/src/save-restore.c 2004-01-11 08:19:56.000000000 -0600
+++ balsa-2.1.0/src/save-restore.c 2004-01-15 13:32:29.000000000 -0600
@@ -22,6 +22,7 @@
#include <string.h>
#include <gnome.h>
+#include <gconf/gconf-client.h>
#include "balsa-app.h"
#include "save-restore.h"
#include "quote-color.h"
@@ -988,6 +989,9 @@
balsa_app.empty_trash_on_exit =
gnome_config_get_bool("EmptyTrash=false");
+ balsa_app.default_client =
+ gnome_config_get_bool("DefaultClient=false");
+
/* This setting is now per address book */
gnome_config_clean_key("AddressBookDistMode");
@@ -1017,6 +1021,50 @@
return TRUE;
} /* config_global_load */
+static void
+config_default_client_save(void)
+{
+ if (balsa_app.default_client) {
+ GError *err = NULL;
+ GConfClient *gc;
+ gc = gconf_client_get_default(); /* FIXME: error handling */
+ if (gc == NULL) {
+ balsa_information(LIBBALSA_INFORMATION_WARNING,
+ _("Error opening GConf database\n"));
+ return;
+ }
+ gconf_client_set_string(gc, "/desktop/gnome/url-handlers/mailto/command", "balsa -m \"%s\"", &err);
+ if (err) {
+ balsa_information(LIBBALSA_INFORMATION_WARNING,
+ _("Error setting GConf field: %s\n"), err->message);
+ g_error_free(err);
+ return;
+ }
+ gconf_client_set_string(gc, "/desktop/gnome/url-handlers/mailto/description", "Email", &err);
+ if (err) {
+ balsa_information(LIBBALSA_INFORMATION_WARNING,
+ _("Error setting GConf field: %s\n"), err->message);
+ g_error_free(err);
+ return;
+ }
+ gconf_client_set_bool(gc, "/desktop/gnome/url-handlers/mailto/need-terminal", FALSE, &err);
+ if (err) {
+ balsa_information(LIBBALSA_INFORMATION_WARNING,
+ _("Error setting GConf field: %s\n"), err->message);
+ g_error_free(err);
+ return;
+ }
+ gconf_client_set_bool(gc, "/desktop/gnome/url-handlers/mailto/enabled", TRUE, &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);
+ }
+}
+
gint
config_save(void)
{
@@ -1268,6 +1316,7 @@
gnome_config_set_bool("RememberOpenMailboxes",
balsa_app.remember_open_mboxes);
gnome_config_set_bool("EmptyTrash", balsa_app.empty_trash_on_exit);
+ gnome_config_set_bool("DefaultClient", balsa_app.default_client);
if (balsa_app.default_address_book) {
gnome_config_set_string("DefaultAddressBook",
@@ -1299,6 +1348,8 @@
save_mru(balsa_app.fcc_mru);
gnome_config_pop_prefix();
+ config_default_client_save();
+
gnome_config_sync();
return TRUE;
} /* config_global_save */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]