[evolution-patches] Re: [Evolution-hackers] gtk_message_dialog() alternatives



Okay, here it is. Sorry about the confusion on configure and configure.in. That was my fault, I wasn't working from CVS. I'm using e-error now instead of calling gtk_message_dialog() directly.

Jonathan

Not Zed wrote:

On Mon, 2005-03-07 at 23:44 +0200, Jonathan Dieter wrote:

Okay, I've put together a plugin that implements the functionality in my original patch that incorporates the standards on variable naming, etc. The one thing I'm not sure is what evolution-specific function to use that calls gtk_message_dialog() (or something similar). The closest I've found is e_notice(), but that doesn't seem to let you use Yes/No buttons. When looking through code in other plugins (save-calendar for instance), I note that they use gtk_message_dialog(). Any thoughts?
Yes, use e-error, as i suggested below. Just grep the source for usage, or look in misc/widgets/e-error.c and devel-docs/misc/errors.txt. The bit about using e-error-tool is a bit out of date, but the rest is valid.

While working on the plugin, I've modified configure.in to put my plugin, default-mail-client-check, in the experimental plugin section and autoreconf'd it to create the new configure script. How should I send the patch to the list? The changes to both configure and configure.in are quite extensive.
You should be working on a checkout from cvs. Then you just use cvs diff -up to generate the diff of the modified files, and it will only diff the cvs files (configure is a generated file and not stored in cvs). I don't understand why your changes would need to be 'extensive', it should only be a one line change in configure.in?

Jonathan

Not Zed wrote:


Evolution patches list is probably as good a place as any. Use evolution-hackers if you need to ask questions like this one. You should subscribe to evolution-hackers at any rate.

There is a shell event recently added "upgrade.done" which is called at startup after the configuration is setup to the current version. You can probably use that.

The class is "org.gnome.evolution.shell.events:1.0"

You might want to look at the other code, it uses a few things - like e-error, which you should be using as well, for any messages - don't use gtk_message_dialog() directly.



On Thu, 2005-03-03 at 08:23 +0200, Jonathan Dieter wrote:

Thanks for the quick response. I've just gone through the published eplugin API and I haven't seen any hooks for either evolution startup or the mail component startup. If you know what they are, or could at least point me in the right direction to look for this information, I'd sure appreciate it. Also, would you want me to send the plugin to the evolution-patches mailing-list or would it be better to send it elsewhere?

Thanks,
Jonathan Dieter
jdieter99 gmx net <mailto:jdieter99 gmx net> <mailto:jdieter99 gmx net <mailto:jdieter99 gmx net>>

Not Zed wrote:



Hmm, we actually had a patch all but complete for this last year, from Niklas Nylund <ninylund abo fi <mailto:ninylund abo fi> <mailto:ninylund abo fi <mailto:ninylund abo fi>> <mailto:ninylund abo fi <mailto:ninylund abo fi> <mailto:ninylund abo fi <mailto:ninylund abo fi>>>>, but then the thread seemed to peter out.

I don't really know what we should do about this, since the other patch was so close.

As for your patch - this functionality should now be done via the plugin interface.

Also you're using java-style mixedCaps, we don't do that anywhere, we use lower-case names for everthing, usually with _ separating words (its easier for non-english speakers apparently).

Michael

On Thu, 2005-03-03 at 00:08 +0200, Jonathan Dieter wrote:

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

_______________________________________________
evolution-hackers maillist  -  evolution-hackers lists ximian com <mailto:evolution-hackers lists ximian com>
http://lists.ximian.com/mailman/listinfo/evolution-hackers
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-16 15:45:56.976454815 +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-mail-client-check" 
 
 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-mail-client-check/Makefile
 plugins/addressbook-file/Makefile
 plugins/addressbook-groupwise/Makefile
 plugins/startup-wizard/Makefile
diff -uprN evolution/plugins/default-mail-client-check/ChangeLog evolution-new/plugins/default-mail-client-check/ChangeLog
--- evolution/plugins/default-mail-client-check/ChangeLog	1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mail-client-check/ChangeLog	2005-03-16 15:45:00.000000000 +0200
@@ -0,0 +1,19 @@
+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-mail-client-check/default-mail-client-check.c evolution-new/plugins/default-mail-client-check/default-mail-client-check.c
--- evolution/plugins/default-mail-client-check/default-mail-client-check.c	1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mail-client-check/default-mail-client-check.c	2005-03-16 15:45:00.000000000 +0200
@@ -0,0 +1,123 @@
+/* -*- 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 <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+#include <widgets/misc/e-error.h>
+#include <e-util/e-config.h>
+#include <e-util/e-dialog-utils.h>
+#include <mail/em-config.h>
+#include <shell/es-event.h>
+#include <string.h>
+
+#define GCONF_KEY_NOCHECKDEFAULT "/apps/evolution/mail/prompts/nocheckdefault"
+#define GCONF_KEY_MAILTO_ENABLED "/desktop/gnome/url-handlers/mailto/enabled"
+#define GCONF_KEY_MAILTO_COMMAND "/desktop/gnome/url-handlers/mailto/command"
+
+GtkWidget   *default_mail_client_check (EPlugin *ep, EConfigHookItemFactoryData *hook_data);
+static void  set_mail_client_check     (GtkWidget *widget, EConfig *config);
+void         check_default_mail_client (EPlugin *ep, ESEventTargetUpgrade *target);
+
+/* Create checkbox in configuration menu */
+GtkWidget *
+default_mail_client_check (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 */
+	if(gconf_client_get_bool (target->gconf, GCONF_KEY_NOCHECKDEFAULT, NULL) == TRUE) {
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (response), FALSE);
+	} else {
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (response), TRUE);
+	}
+
+	/* Set up signal for checkbox being checked */
+	g_signal_connect (GTK_TOGGLE_BUTTON (response), "toggled", G_CALLBACK (set_mail_client_check), 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_mail_client_check (GtkWidget *widget, EConfig *config)
+{
+	EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) config->target;
+	
+	/* Save the new setting to gconf */
+	if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE) {
+		gconf_client_set_bool (target->gconf, GCONF_KEY_NOCHECKDEFAULT, FALSE, NULL);
+	} else {
+		gconf_client_set_bool (target->gconf, GCONF_KEY_NOCHECKDEFAULT, TRUE, NULL);
+	}
+}
+
+void
+check_default_mail_client (EPlugin *ep, ESEventTargetUpgrade *target)
+{
+	GtkWidget   *dialogDefaultEmailApp, *checkAlways;
+	GConfClient *client;
+	gchar       *mailer;
+	gboolean    enabled;
+	gint        result;
+	
+	
+	client = gconf_client_get_default ();
+	
+	/* Check whether we're supposed to check whether or not we are the default mailer */
+	if(!gconf_client_get_bool(client, GCONF_KEY_NOCHECKDEFAULT, NULL)) { 
+		enabled = gconf_client_get_bool  (client, GCONF_KEY_MAILTO_ENABLED, NULL);
+		mailer  = gconf_client_get_string(client, GCONF_KEY_MAILTO_COMMAND, NULL);
+
+		/* Check whether we are the mailer */
+		if(enabled == FALSE || mailer == NULL || (strcmp(mailer, "@evolution %s") != 0 && strcmp(mailer, "evolution %s") != 0)) { 
+			/*Create modal MessageDialog */
+			dialogDefaultEmailApp = e_error_new(NULL, "org.gnome.default-mail-client-check:ask-default-mail", NULL);
+			
+			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(client, GCONF_KEY_MAILTO_ENABLED, TRUE, NULL);
+				gconf_client_set_string(client, GCONF_KEY_MAILTO_COMMAND, "evolution %s", NULL);
+			}
+			if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkAlways)) == FALSE) {
+				gconf_client_set_bool(client, GCONF_KEY_NOCHECKDEFAULT, TRUE, NULL);
+			}
+			gtk_widget_destroy(dialogDefaultEmailApp);
+		}
+	}
+}
diff -uprN evolution/plugins/default-mail-client-check/Makefile.am evolution-new/plugins/default-mail-client-check/Makefile.am
--- evolution/plugins/default-mail-client-check/Makefile.am	1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mail-client-check/Makefile.am	2005-03-16 15:45:00.000000000 +0200
@@ -0,0 +1,25 @@
+INCLUDES =						\
+	-I$(top_srcdir)					\
+	$(EVOLUTION_MAIL_CFLAGS)
+
+ EVO_PLUGIN_RULE@
+
+error_DATA = org-gnome-default-mail-client-check.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-mail-client-check.eplug 
+plugin_LTLIBRARIES = liborg-gnome-default-mail-client-check.la
+
+liborg_gnome_default_mail_client_check_la_SOURCES = default-mail-client-check.c
+liborg_gnome_default_mail_client_check_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = \
+	org-gnome-default-mail-client-check.eplug.in	\
+	$(error_DATA)					\
+	$(error_i18n)
+
+BUILT_SOURCES = $(error_i18n)
\ No newline at end of file
diff -uprN evolution/plugins/default-mail-client-check/org-gnome-default-mail-client-check.eplug.in evolution-new/plugins/default-mail-client-check/org-gnome-default-mail-client-check.eplug.in
--- evolution/plugins/default-mail-client-check/org-gnome-default-mail-client-check.eplug.in	1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mail-client-check/org-gnome-default-mail-client-check.eplug.in	2005-03-16 15:45:00.000000000 +0200
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<e-plugin-list>
+	<e-plugin
+	id="org.gnome.evolution.default_mail_client_check" 
+	type="shlib" 
+	name="Default Mail Client " 
+	location="@PLUGINDIR@/liborg-gnome-default-mail-client-check.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_default_mail_client"
+				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_mail_client_check" 
+				label="Check whether Evolution is the default mail client on startup" 
+				factory="default_mail_client_check"/>
+			</group>
+		</hook>
+	</e-plugin>
+</e-plugin-list>
diff -uprN evolution/plugins/default-mail-client-check/org-gnome-default-mail-client-check.xml evolution-new/plugins/default-mail-client-check/org-gnome-default-mail-client-check.xml
--- evolution/plugins/default-mail-client-check/org-gnome-default-mail-client-check.xml	1970-01-01 02:00:00.000000000 +0200
+++ evolution-new/plugins/default-mail-client-check/org-gnome-default-mail-client-check.xml	2005-03-16 15:45:00.000000000 +0200
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<error-list domain="org.gnome.default-mail-client-check">
+
+ <error id="ask-default-mail" 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]