evolution r34977 - in trunk: e-util mail



Author: mbarnes
Date: Fri Feb  8 14:43:44 2008
New Revision: 34977
URL: http://svn.gnome.org/viewvc/evolution?rev=34977&view=rev

Log:
2008-02-08  Matthew Barnes  <mbarnes redhat com>

	** Fixes part of bug #509741

	* mail/mail-session.c (user_message_exec):
	Use the number of dialog buttons as a heuristic for whether to
	display a message in the status bar or immediately present the
	dialog to the user.

	* e-util/e-error.c (e_error_newv):
	If the error dialog has no primary text, fallback to the window
	title for the "primary" data key.  This is what gets displayed
	in the status bar.

	* e-util/e-error.c (e_error_count_buttons):
	New function counts buttons in a dialog's action area.



Modified:
   trunk/e-util/ChangeLog
   trunk/e-util/e-error.c
   trunk/e-util/e-error.h
   trunk/mail/ChangeLog
   trunk/mail/mail-session.c

Modified: trunk/e-util/e-error.c
==============================================================================
--- trunk/e-util/e-error.c	(original)
+++ trunk/e-util/e-error.c	Fri Feb  8 14:43:44 2008
@@ -533,7 +533,8 @@
 		ee_build_label(oerr, dgettext(table->translation_domain, e->primary), args);
 		perr = g_strdup (oerr->str);
 		g_string_free (oerr, TRUE);
-	}
+	} else
+		perr = g_strdup (gtk_window_get_title (GTK_WINDOW (dialog)));
 	
 	if (e->secondary) {
 		ee_build_label(out, dgettext(table->translation_domain, e->secondary), args);
@@ -640,6 +641,36 @@
 	return res;
 }
 
+/**
+ * e_error_count_buttons:
+ * @dialog: a #GtkDialog
+ *
+ * Counts the number of buttons in @dialog's action area.
+ *
+ * Returns: number of action area buttons
+ **/
+guint
+e_error_count_buttons (GtkDialog *dialog)
+{
+	GtkContainer *action_area;
+	GList *children, *iter;
+	guint n_buttons = 0;
+
+	g_return_val_if_fail (GTK_DIALOG (dialog), 0);
+
+	action_area = GTK_CONTAINER (dialog->action_area);
+	children = gtk_container_get_children (action_area);
+
+	/* Iterate over the children looking for buttons. */
+	for (iter = children; iter != NULL; iter = iter->next)
+		if (GTK_IS_BUTTON (iter->data))
+			n_buttons++;
+
+	g_list_free (children);
+
+	return n_buttons;
+}
+
 static void
 remove_parent(GtkWidget *w, GtkWidget *parent)
 {

Modified: trunk/e-util/e-error.h
==============================================================================
--- trunk/e-util/e-error.h	(original)
+++ trunk/e-util/e-error.h	Fri Feb  8 14:43:44 2008
@@ -23,6 +23,7 @@
 #define _E_ERROR_H
 
 #include <stdarg.h>
+#include <gtk/gtk.h>
 
 struct _GtkWindow;
 
@@ -54,6 +55,8 @@
 int e_error_run(struct _GtkWindow *parent, const char *tag, const char *arg0, ...);
 int e_error_runv(struct _GtkWindow *parent, const char *tag, const char *arg0, va_list ap);
 
+guint e_error_count_buttons (GtkDialog *dialog);
+
 void e_error_default_parent(struct _GtkWindow *parent);
 
 #endif /* !_E_ERROR_H */

Modified: trunk/mail/mail-session.c
==============================================================================
--- trunk/mail/mail-session.c	(original)
+++ trunk/mail/mail-session.c	Fri Feb  8 14:43:44 2008
@@ -342,23 +342,31 @@
 		user_message_dialog, "allow_shrink", TRUE,
 		"allow_grow", TRUE, NULL);
 
-	/* We only need to wait for the result if we allow cancel
-	 * otherwise show but send result back instantly */
-	if (m->allow_cancel && m->ismain) {
-		gint response = gtk_dialog_run (user_message_dialog);
-		user_message_response (user_message_dialog, response, m);
+	/* Use the number of dialog buttons as a heuristic for whether to
+	 * emit a status bar message or present the dialog immediately, the
+	 * thought being if there's more than one button then something is
+	 * probably blocked until the user responds. */
+	if (e_error_count_buttons (user_message_dialog) > 1) {
+		if (m->ismain) {
+			gint response;
+
+			response = gtk_dialog_run (user_message_dialog);
+			user_message_response (
+				user_message_dialog, response, m);
+		} else {
+			g_signal_connect (
+				user_message_dialog, "response",
+				G_CALLBACK (user_message_response), m);
+			gtk_widget_show (user_message_dialog);
+		}
 	} else {
-		g_object_set_data ((GObject *) user_message_dialog, "response-handled", GINT_TO_POINTER(TRUE));
 		g_signal_connect (
 			user_message_dialog, "response",
 			G_CALLBACK (user_message_response), m);
-
-		/* If the dialog has no "primary" text, there's nothing to
-		 * display in the status bar.  So just show the dialog. */
-		if (g_object_get_data (user_message_dialog, "primary"))
-			em_utils_show_error_silent (user_message_dialog);
-		else
-			gtk_widget_show (user_message_dialog);
+		g_object_set_data (
+			user_message_dialog, "response-handled",
+			GINT_TO_POINTER (TRUE));
+		em_utils_show_error_silent (user_message_dialog);
 	}
 }
 



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