[evolution-patches] default-mailer patch
- From: Jonathan Dieter <jdieter99 gmx net>
- To: Not Zed <notzed ximian com>
- Cc: evolution-patches lists ximian com
- Subject: [evolution-patches] default-mailer patch
- Date: Thu, 17 Mar 2005 23:36:57 +0200
I took your advice and changed a number of things. Any other thoughts?
Not Zed wrote:
Hi,
Instead of doing below, you should probably use
em_utils_prompt_user(). It presents this type of question in a
standard way (i guess i didn't look closley enough to see if that had
been set). I think you can use it - it has a funny api so it might
not be usable in this specific case. If not, then please copy its
implementation - i.e. by using identical strings and layout.
Done.
default-client-mail-check is a bit of a mouthful, how about
"default-mailer"?
Done.
There are some stylistic things that you should try to follow closer
to the rest of the code - but to be honest i couldn't care less for a
plugin. e.g. dialogDefaultEmailApp - why not just call it "dialog".
I've changed all variables to at most two words.
I guess it is just about there though.
It would be better to use the newer method of i18n for error files too
- but i wont decline the patch based on that. It isn't in the
documentation properly, it is only in the eplugin skeleton i posted to
the evolution blog several months ago.
Do you have an example file somewhere that I could see? I looked at all
the .xml files in the errors subfolder and it looked like all of them
were in the old format.
Thanks,
Michael
diff -uprN evolution/configure.in evolution-new/configure.in
--- evolution/configure.in 2005-03-01 08:17:18.000000000 +0200
+++ evolution-new/configure.in 2005-03-17 21:42:58.385367545 +0200
@@ -1337,7 +1337,7 @@ AC_ARG_ENABLE(plugins, [ --enable-plugi
dnl Add any new plugins here
plugins_base="calendar-file calendar-http calendar-weather groupwise-account-setup itip-formatter plugin-manager send-options shared-folder groupwise-send-options exchange-account-setup groupwise-status-tracking default-source addressbook-file addressbook-groupwise startup-wizard"
-plugins_standard="bbdb subject-thread save-attachments prefer-plain save-calendar select-one-source copy-tool mail-to-task folder-unsubscribe mark-calendar-offline audio-inline mailing-list-actions new-mail-notify"
+plugins_standard="bbdb subject-thread save-attachments prefer-plain save-calendar select-one-source copy-tool mail-to-task folder-unsubscribe mark-calendar-offline audio-inline mailing-list-actions new-mail-notify default-mailer"
plugins_experimental="backup-restore folder-unsubscribe mail-to-meeting"
@@ -1587,6 +1587,7 @@ plugins/groupwise-send-options/Makefile
plugins/exchange-account-setup/Makefile
plugins/groupwise-status-tracking/Makefile
plugins/default-source/Makefile
+plugins/default-mailer/Makefile
plugins/addressbook-file/Makefile
plugins/addressbook-groupwise/Makefile
plugins/startup-wizard/Makefile
diff -uprN evolution/plugins/default-mailer/ChangeLog evolution-new/plugins/default-mailer/ChangeLog
--- evolution/plugins/default-mailer/ChangeLog 1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mailer/ChangeLog 2005-03-17 21:42:11.000000000 +0200
@@ -0,0 +1,34 @@
+2005-03-17 Jonathan Dieter <jdieter99 gmx net>
+
+ * default-mailer.c: renamed from default-mail-client-check.c
+ Renamed modules to fit new name and cleaned up code. Fixed
+ small memory leak.
+
+ * org-gnome-default-mailer.xml: renamed from
+ org-gnome-default-mail-client-check.xml
+
+ * org-gnome-default-mailer.eplug.in: renamed from
+ org-gnome-default-mail-client-check.eplug.in
+
+ * Makefile.am: Fixed references to fit new file names
+
+2005-03-15 Jonathan Dieter <jdieter99 gmx net>
+
+ * default-mail-client-check.c (check_default_mail_client):
+ Removed gtk_message_dialog()
+ call and replaced with e_error()
+
+ * Makefile.am: added necessary steps to build xml
+
+ * org-gnome-default-mail-client-check.xml: define the
+ message box that shows up on startup
+
+2005-03-07 Jonathan Dieter <jdieter99 gmx net>
+
+ * default-mail-client-check.c: Plugin implementation
+
+ * org-gnome-default-mail-client-check.eplug.in: define the
+ default mail client check plugin
+
+ * Makefile.am: build the default mail client check plugin
+
diff -uprN evolution/plugins/default-mailer/default-mailer.c evolution-new/plugins/default-mailer/default-mailer.c
--- evolution/plugins/default-mailer/default-mailer.c 1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mailer/default-mailer.c 2005-03-17 21:42:11.000000000 +0200
@@ -0,0 +1,109 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Author: Jonathan Dieter <jdieter99 gmx net>
+ *
+ * Copyright 2005 Jonathan Dieter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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 Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+#include <widgets/misc/e-error.h>
+
+#include <mail/em-utils.h>
+#include <mail/em-config.h>
+#include <e-util/e-config.h>
+#include <shell/es-event.h>
+
+#define GCONF_KEY_CHECKDEFAULT "/apps/evolution/mail/prompts/checkdefault"
+#define GCONF_KEY_MAILTO_ENABLED "/desktop/gnome/url-handlers/mailto/enabled"
+#define GCONF_KEY_MAILTO_COMMAND "/desktop/gnome/url-handlers/mailto/command"
+
+GtkWidget *mailer_check_box (EPlugin *ep, EConfigHookItemFactoryData *hook_data);
+static void set_mailer (GtkWidget *widget, EConfig *config);
+void check_mailer (EPlugin *ep, ESEventTargetUpgrade *target);
+
+/* Create checkbox in configuration menu */
+GtkWidget *
+mailer_check_box (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
+{
+ GtkWidget *response;
+
+ EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) hook_data->config->target;
+
+ /* Create checkbox */
+ response = gtk_check_button_new_with_label("Check whether Evolution is the default mail client on startup");
+
+ /* Set the toggle button to the current gconf setting */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (response),
+ gconf_client_get_bool (target->gconf, GCONF_KEY_CHECKDEFAULT, NULL));
+
+ /* Set up signal for checkbox being checked */
+ g_signal_connect (GTK_TOGGLE_BUTTON (response), "toggled", G_CALLBACK (set_mailer), hook_data->config);
+
+ /* Put the checkbox in the parent and show */
+ gtk_box_pack_start (GTK_BOX (hook_data->parent), response, FALSE, FALSE, 0);
+ gtk_widget_show (response);
+
+ return response;
+}
+
+/* Callback for when checkbox in configuration menu is toggled */
+static void
+set_mailer (GtkWidget *widget, EConfig *config)
+{
+ EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) config->target;
+
+ /* Save the new setting to gconf */
+ gconf_client_set_bool (target->gconf, GCONF_KEY_CHECKDEFAULT,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)), NULL);
+}
+
+void
+check_mailer (EPlugin *ep, ESEventTargetUpgrade *target)
+{
+ GConfClient *client;
+ gchar *mailer;
+ GConfValue *is_key;
+
+
+ client = gconf_client_get_default ();
+
+ /* See whether the check default mailer key has already been set */
+ is_key = gconf_client_get(client, GCONF_KEY_CHECKDEFAULT, NULL);
+ if(!is_key)
+ gconf_client_set_bool(client, GCONF_KEY_CHECKDEFAULT, TRUE, NULL);
+ g_free(is_key);
+
+ /* Check whether we're supposed to check whether or not we are the default mailer */
+ if(gconf_client_get_bool(client, GCONF_KEY_CHECKDEFAULT, NULL)) {
+ mailer = gconf_client_get_string(client, GCONF_KEY_MAILTO_COMMAND, NULL);
+
+ /* Check whether we are the default mailer */
+ if(mailer == NULL || (strcmp(mailer, "@evolution %s") != 0 && strcmp(mailer, "evolution %s") != 0)) {
+ /* Ask whether we should be the default mailer */
+ if(em_utils_prompt_user(NULL, GCONF_KEY_CHECKDEFAULT, "org.gnome.default.mailer:check-mailer", NULL)) {
+ gconf_client_set_bool(client, GCONF_KEY_MAILTO_ENABLED, TRUE, NULL);
+ gconf_client_set_string(client, GCONF_KEY_MAILTO_COMMAND, "evolution %s", NULL);
+ }
+ }
+
+ g_free(mailer);
+ }
+}
diff -uprN evolution/plugins/default-mailer/Makefile.am evolution-new/plugins/default-mailer/Makefile.am
--- evolution/plugins/default-mailer/Makefile.am 1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mailer/Makefile.am 2005-03-17 21:42:11.000000000 +0200
@@ -0,0 +1,25 @@
+INCLUDES = \
+ -I$(top_srcdir) \
+ $(EVOLUTION_MAIL_CFLAGS)
+
+ EVO_PLUGIN_RULE@
+
+error_DATA = org-gnome-default-mailer.xml
+error_i18n = $(error_DATA:.xml=.xml.h)
+errordir = $(privdatadir)/errors
+
+%.xml.h: %.xml
+ $(top_builddir)/e-util/e-error-tool $^
+
+plugin_DATA = org-gnome-default-mailer.eplug
+plugin_LTLIBRARIES = liborg-gnome-default-mailer.la
+
+liborg_gnome_default_mailer_la_SOURCES = default-mailer.c
+liborg_gnome_default_mailer_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = \
+ org-gnome-default-mailer.eplug.in \
+ $(error_DATA) \
+ $(error_i18n)
+
+BUILT_SOURCES = $(error_i18n)
diff -uprN evolution/plugins/default-mailer/org-gnome-default-mailer.eplug.in evolution-new/plugins/default-mailer/org-gnome-default-mailer.eplug.in
--- evolution/plugins/default-mailer/org-gnome-default-mailer.eplug.in 1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mailer/org-gnome-default-mailer.eplug.in 2005-03-17 21:42:11.000000000 +0200
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<e-plugin-list>
+ <e-plugin
+ id="org.gnome.evolution.default.mailer"
+ type="shlib"
+ name="Default Mail Client "
+ location="@PLUGINDIR@/liborg-gnome-default-mailer.so">
+
+ <description>Checks whether Evolution is the default mail client on startup.</description>
+ <author name="Jonathan Dieter" email="jdieter99 gmx net"/>
+
+ <hook class="org.gnome.evolution.shell.events:1.0">
+ <event
+ id="upgrade.done"
+ handle="check_mailer"
+ target="upgrade"
+ />
+ </hook>
+
+ <hook class="org.gnome.evolution.mail.config:1.0">
+ <group id="org.gnome.evolution.mail.prefs" target="prefs">
+ <item type="item"
+ path="00.general/30.notify/00.default_mailer"
+ label="Check whether Evolution is the default mail client on startup"
+ factory="mailer_check_box"/>
+ </group>
+ </hook>
+ </e-plugin>
+</e-plugin-list>
diff -uprN evolution/plugins/default-mailer/org-gnome-default-mailer.xml evolution-new/plugins/default-mailer/org-gnome-default-mailer.xml
--- evolution/plugins/default-mailer/org-gnome-default-mailer.xml 1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mailer/org-gnome-default-mailer.xml 2005-03-17 21:42:11.000000000 +0200
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<error-list domain="org.gnome.default.mailer">
+
+ <error id="check-mailer" type="question" default="GTK_RESPONSE_YES">
+ <title>Evolution</title>
+ <secondary>Do you want to make Evolution your default e-mail client?</secondary>
+ <button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
+ <button stock="gtk-no" response="GTK_RESPONSE_NO"/>
+ </error>
+
+</error-list>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]