[evolution-patches] Ask user to make evolution default mail app bug #127526 (Mail)
- From: Niklas Nylund <ninylund abo fi>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] Ask user to make evolution default mail app bug #127526 (Mail)
- Date: Mon, 16 Aug 2004 00:31:47 +0300
This is a patch for bug 12752
(http://www.gnome.org/bounties/Mailer.html#127526).
The patch adds the features listed on the URL. As specified I added two
gconf keys on if the user wants evolution to check if it's the default
mail app at all and on key which specifies the default mail app.
When Evolution is launched I first check the "prompt key" and if needed
the default mail app key. I don't know how useful this is if say the
user first selects Evolution as his/hers default app. and checks "Don't
ask this again". Later another application changes the default mail app.
key, then Evolution will not notify the user the next time it's started
(Since the prompt flag is still false). Should I add something which
fixes this to Tools->Settings or is this to be taken care of by
gconf-editor or some similar Gnome application?
One annoying thing exists though, the first time the user launches
Evolution both the wizard and the default mail app. dialog box appears,
since I added my function check_default_mail_app() to the end of
mail_component_init. But surely anyone with more experience from the
code knows a better place to put the check.
Niklas
Index: mail-component.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component.c,v
retrieving revision 1.95
diff -u -p -r1.95 mail-component.c
--- mail-component.c 26 Jul 2004 06:41:39 -0000 1.95
+++ mail-component.c 15 Aug 2004 21:26:12 -0000
@@ -70,6 +70,9 @@
#include "e-task-bar.h"
#include <gtk/gtklabel.h>
+#include <gtk/gtkcheckbutton.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtkstock.h>
#include <e-util/e-mktemp.h>
@@ -829,6 +832,78 @@ mail_component_class_init (MailComponent
epv->upgradeFromVersion = impl_upgradeFromVersion;
}
+void
+check_default_mail_app_dialog_callback (GtkDialog *dialog, int button, void *checkbutton)
+{
+ GConfClient *client;
+ client = gconf_client_get_default();
+
+ if (button == GTK_RESPONSE_YES)
+ gconf_client_set_string(client, "/desktop/gnome/url-handlers/mailto", "evolution", NULL);
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton)))
+ gconf_client_set_bool(client, "/apps/evolution/mail/prompts/default_mailer", FALSE, NULL);
+ else
+ gconf_client_set_bool(client, "/apps/evolution/mail/prompts/default_mailer", TRUE, NULL);
+
+ gconf_client_suggest_sync(client, NULL);
+ g_object_unref(client);
+}
+
+void
+check_default_mail_app_dialog (void)
+{
+ GtkWidget *dialog, *label, *checkbutton;
+
+ dialog = gtk_dialog_new_with_buttons("Set default mail application", NULL, GTK_DIALOG_MODAL, GTK_STOCK_YES, GTK_RESPONSE_YES, GTK_STOCK_NO, GTK_RESPONSE_NO, NULL);
+ label = gtk_label_new("Evolution is not your current default mail application!\nWould you like evolution to be your default mail application?");
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
+
+ checkbutton = gtk_check_button_new_with_label("Don't ask this again");
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), checkbutton);
+
+ g_signal_connect(dialog, "response", G_CALLBACK(check_default_mail_app_dialog_callback), checkbutton);
+ g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
+ gtk_widget_show_all(dialog);
+}
+
+static void
+check_default_mail_app() {
+ GConfClient *client;
+ GConfValue *val;
+ gboolean prompt;
+ gchar *mailapp;
+ GtkWidget *dialog;
+
+ gconf_init(0, NULL, NULL);
+ client = gconf_client_get_default();
+
+ val = gconf_client_get(client, "/apps/evolution/mail/prompts/default_mailer", NULL);
+ if (val)
+ prompt = gconf_value_get_bool(val);
+ else {
+ gconf_client_set_bool(client, "/apps/evolution/mail/prompts/default_mailer", TRUE, NULL);
+ prompt = TRUE;
+ }
+
+ val = gconf_client_get(client, "/desktop/gnome/url-handlers/mailto", NULL);
+ if (val) {
+ mailapp = (gchar *) gconf_value_get_string(val);
+ if (strcmp(mailapp, "evolution") == 0)
+ prompt = FALSE;
+ g_free(mailapp);
+ } else {
+ gconf_client_set_string(client, "/desktop/gnome/url-handlers/mailto", "unset", NULL);
+ prompt = TRUE;
+ }
+
+ if (prompt == TRUE)
+ check_default_mail_app_dialog();
+
+ g_object_unref(client);
+}
+
+
static void
mail_component_init (MailComponent *component)
{
@@ -857,6 +932,8 @@ mail_component_init (MailComponent *comp
offline = mail_offline_handler_new();
bonobo_object_add_interface((BonoboObject *)component, (BonoboObject *)offline);
+
+ check_default_mail_app();
}
/* Public API. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]