[evolution-patches] Bug 127526: Ask user to make Evolution default mail app for GNOME



This patch will ask the user if they would like Evolution to be the default mailer for GNOME the first time that Evolution is run. If the user says "yes", Evolution sets itself to be the default mailer. If the user says "no", Evolution won't change anything. There is a check box that asks whether the user wants to be asked this question every time Evolution is started. If the check box is not checked, Evolution will never ask the question again. If it is checked, Evolution will only ask if there is either no mailer set up or if another mailer is set as the default one.

This is my first attempt at a patch, so any feedback would be appreciated. Thanks,

Jonathan Dieter
jdieter99 at gmx dot net
diff -Naur evolution-2.0.2/mail/mail-component.c evolution-2.0.2-new/mail/mail-component.c
--- evolution-2.0.2/mail/mail-component.c	2004-09-24 18:49:29.000000000 +0300
+++ evolution-2.0.2-new/mail/mail-component.c	2005-03-02 23:34:40.373233696 +0200
@@ -70,6 +70,9 @@
 #include "e-task-bar.h"
 
 #include <gtk/gtklabel.h>
+#include <gtk/gtk.h>
+
+#include <gconf/gconf.h>
 
 #include <e-util/e-mktemp.h>
 
@@ -834,6 +837,49 @@
 	epv->upgradeFromVersion      = impl_upgradeFromVersion;
 }
 
+/* Check whether or not we are the default mailer */
+static void
+dialogCheckForDefault ()
+{
+	GtkWidget   *dialogDefaultEmailApp, *checkAlways;
+	GConfClient *gconfclientDefault;
+	gchar       *mailer;
+	gboolean    nocheckDefault, enabled;
+	gint        result;
+	
+	gconfclientDefault = gconf_client_get_default();
+	nocheckDefault = gconf_client_get_bool(gconfclientDefault, "/apps/evolution/mail/prompts/nocheckdefault", NULL);
+	
+	if(nocheckDefault == FALSE) { /* Check whether we're supposed to check whether or not we are the default mailer */
+		enabled = gconf_client_get_bool  (gconfclientDefault, "/desktop/gnome/url-handlers/mailto/enabled", NULL);
+		mailer  = gconf_client_get_string(gconfclientDefault, "/desktop/gnome/url-handlers/mailto/command", NULL);
+		
+		if(enabled == FALSE || mailer == NULL || strcmp(mailer, "@evolution %s") != 0) { /* Check whether we are the mailer */
+			/*Create modal MessageDialog */
+			dialogDefaultEmailApp = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Do you want to make Evolution your default e-mail application?");
+			
+			checkAlways           = gtk_check_button_new_with_label("Always ask this question");
+			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkAlways), TRUE);
+			
+			gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialogDefaultEmailApp)->vbox), checkAlways);
+		
+			gtk_widget_show_all(dialogDefaultEmailApp);
+			
+			result = gtk_dialog_run(GTK_DIALOG(dialogDefaultEmailApp));
+			
+			/* Check results */
+			if(result == GTK_RESPONSE_YES) {
+				gconf_client_set_bool(gconfclientDefault, "/desktop/gnome/url-handlers/mailto/enabled", TRUE, NULL);
+				gconf_client_set_string(gconfclientDefault, "/desktop/gnome/url-handlers/mailto/command", "@evolution %s", NULL);
+			}
+			if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkAlways)) == FALSE) {
+				gconf_client_set_bool(gconfclientDefault, "/apps/evolution/mail/prompts/nocheckdefault", TRUE, NULL);
+			}
+			gtk_widget_destroy(dialogDefaultEmailApp);
+		}
+	}
+}
+
 static void
 mail_component_init (MailComponent *component)
 {
@@ -862,6 +908,8 @@
 	
 	offline = mail_offline_handler_new();
 	bonobo_object_add_interface((BonoboObject *)component, (BonoboObject *)offline);
+	
+	dialogCheckForDefault();
 }
 
 /* Public API.  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]