[evolution/wip/gsettings] Pass an EAlertSink to e_alert_sink_submit_alert().



commit 4a929caada81820d7499b09875870b84e9900912
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Oct 31 16:02:30 2010 -0400

    Pass an EAlertSink to e_alert_sink_submit_alert().
    
    Passing a random GtkWidget and then searching its ancestors for an
    EAlertSink turned out to be not as useful as I thought.  Most of the
    time we know about and have access to the widget that implements
    EAlertSink, so just pass it directly as an EAlertSink.

 calendar/gui/dialogs/comp-editor.c              |    4 +-
 composer/e-composer-actions.c                   |    4 +-
 composer/e-msg-composer.c                       |    8 +++---
 e-util/e-alert-sink.c                           |   25 ++++++----------------
 e-util/e-alert-sink.h                           |    2 +-
 e-util/e-alert.c                                |   10 ++++----
 e-util/e-alert.h                                |    6 +++-
 mail/e-mail-backend.c                           |    3 +-
 mail/em-composer-utils.c                        |    9 ++++---
 mail/mail-mt.c                                  |    5 ++-
 modules/offline-alert/evolution-offline-alert.c |    5 ++-
 widgets/misc/e-signature-editor.c               |    6 ++--
 12 files changed, 41 insertions(+), 46 deletions(-)
---
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index eb908d1..af5b23d 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -834,7 +834,7 @@ action_save_cb (GtkAction *action,
 
 	if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) {
 		e_alert_submit (
-			GTK_WIDGET (editor),
+			E_ALERT_SINK (editor),
 			"calendar:prompt-read-only-cal-editor",
 			e_source_peek_name (
 				e_cal_get_source (priv->client)),
@@ -1881,7 +1881,7 @@ prompt_and_save_changes (CompEditor *editor, gboolean send)
 	case GTK_RESPONSE_YES: /* Save */
 		if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) {
 			e_alert_submit (
-				GTK_WIDGET (editor),
+				E_ALERT_SINK (editor),
 				"calendar:prompt-read-only-cal-editor",
 				e_source_peek_name (
 					e_cal_get_source (priv->client)),
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index 5e57e6d..3b2aabf 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -131,7 +131,7 @@ action_save_cb (GtkAction *action,
 				return;
 		} else {
 			e_alert_submit (
-				GTK_WIDGET (composer),
+				E_ALERT_SINK (composer),
 				E_ALERT_NO_SAVE_FILE, filename,
 				g_strerror (errno_saved), NULL);
 			return;
@@ -141,7 +141,7 @@ action_save_cb (GtkAction *action,
 
 	if (!gtkhtml_editor_save (editor, filename, TRUE, &error)) {
 		e_alert_submit (
-			GTK_WIDGET (composer),
+			E_ALERT_SINK (composer),
 			E_ALERT_NO_SAVE_FILE,
 			filename, error->message, NULL);
 		g_error_free (error);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 4edaeea..2bca57d 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -3516,7 +3516,7 @@ msg_composer_send_cb (EMsgComposer *composer,
 		g_warn_if_fail (message == NULL);
 		async_context_free (context);
 		e_alert_submit (
-			GTK_WIDGET (composer),
+			E_ALERT_SINK (composer),
 			"mail-composer:no-build-message",
 			error->message, NULL);
 		g_error_free (error);
@@ -3600,7 +3600,7 @@ msg_composer_save_to_drafts_cb (EMsgComposer *composer,
 		g_warn_if_fail (message == NULL);
 		async_context_free (context);
 		e_alert_submit (
-			GTK_WIDGET (composer),
+			E_ALERT_SINK (composer),
 			"mail-composer:no-build-message",
 			error->message, NULL);
 		g_error_free (error);
@@ -3676,7 +3676,7 @@ msg_composer_save_to_outbox_cb (EMsgComposer *composer,
 		g_warn_if_fail (message == NULL);
 		async_context_free (context);
 		e_alert_submit (
-			GTK_WIDGET (composer),
+			E_ALERT_SINK (composer),
 			"mail-composer:no-build-message",
 			error->message, NULL);
 		g_error_free (error);
@@ -3759,7 +3759,7 @@ msg_composer_print_cb (EMsgComposer *composer,
 		g_warn_if_fail (message == NULL);
 		async_context_free (context);
 		e_alert_submit (
-			GTK_WIDGET (composer),
+			E_ALERT_SINK (composer),
 			"mail-composer:no-build-message",
 			error->message, NULL);
 		g_error_free (error);
diff --git a/e-util/e-alert-sink.c b/e-util/e-alert-sink.c
index f26f114..2a8db40 100644
--- a/e-util/e-alert-sink.c
+++ b/e-util/e-alert-sink.c
@@ -66,35 +66,24 @@ e_alert_sink_default_init (EAlertSinkInterface *interface)
 
 /**
  * e_alert_sink_submit_alert:
- * @widget: a #GtkWidget, either itself an #EAlertSink or a child of one
+ * @alert_sink: an #EAlertSink
  * @alert: an #EAlert
  *
  * This function is a place to pass #EAlert objects.  Beyond that it has no
  * well-defined behavior.  It's up to the widget implementing the #EAlertSink
  * interface to decide what to do with them.
- *
- * Either @widget or one of its ancestors must implement #EAlertSink.
- *
- * The default behavior is to display the @alert in a dialog.
  **/
 void
-e_alert_sink_submit_alert (GtkWidget *widget,
+e_alert_sink_submit_alert (EAlertSink *alert_sink,
                            EAlert *alert)
 {
-	GtkWidget *ancestor;
+	EAlertSinkInterface *interface;
 
-	g_return_if_fail (GTK_IS_WIDGET (widget));
+	g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
 	g_return_if_fail (E_IS_ALERT (alert));
 
-	ancestor = gtk_widget_get_ancestor (widget, E_TYPE_ALERT_SINK);
-
-	if (E_IS_ALERT_SINK (ancestor)) {
-		EAlertSinkInterface *interface;
-
-		interface = E_ALERT_SINK_GET_INTERFACE (ancestor);
-		g_return_if_fail (interface->submit_alert != NULL);
+	interface = E_ALERT_SINK_GET_INTERFACE (alert_sink);
+	g_return_if_fail (interface->submit_alert != NULL);
 
-		interface->submit_alert (E_ALERT_SINK (ancestor), alert);
-	} else
-		alert_sink_fallback (widget, alert);
+	interface->submit_alert (alert_sink, alert);
 }
diff --git a/e-util/e-alert-sink.h b/e-util/e-alert-sink.h
index 35c56f9..da5ae7b 100644
--- a/e-util/e-alert-sink.h
+++ b/e-util/e-alert-sink.h
@@ -54,7 +54,7 @@ struct _EAlertSinkInterface {
 };
 
 GType		e_alert_sink_get_type		(void);
-void		e_alert_sink_submit_alert	(GtkWidget *widget,
+void		e_alert_sink_submit_alert	(EAlertSink *alert_sink,
 						 EAlert *alert);
 
 G_END_DECLS
diff --git a/e-util/e-alert.c b/e-util/e-alert.c
index 12bee6d..9f7a801 100644
--- a/e-util/e-alert.c
+++ b/e-util/e-alert.c
@@ -907,28 +907,28 @@ e_alert_response (EAlert *alert,
 }
 
 void
-e_alert_submit (GtkWidget *widget,
+e_alert_submit (EAlertSink *alert_sink,
                 const gchar *tag,
                 ...)
 {
 	va_list va;
 
 	va_start (va, tag);
-	e_alert_submit_valist (widget, tag, va);
+	e_alert_submit_valist (alert_sink, tag, va);
 	va_end (va);
 }
 
 void
-e_alert_submit_valist (GtkWidget *widget,
+e_alert_submit_valist (EAlertSink *alert_sink,
                        const gchar *tag,
                        va_list va)
 {
 	EAlert *alert;
 
-	g_return_if_fail (GTK_IS_WIDGET (widget));
+	g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
 	g_return_if_fail (tag != NULL);
 
 	alert = e_alert_new_valist (tag, va);
-	e_alert_sink_submit_alert (widget, alert);
+	e_alert_sink_submit_alert (alert_sink, alert);
 	g_object_unref (alert);
 }
diff --git a/e-util/e-alert.h b/e-util/e-alert.h
index f9f0fc8..4d6b267 100644
--- a/e-util/e-alert.h
+++ b/e-util/e-alert.h
@@ -57,6 +57,8 @@
 
 G_BEGIN_DECLS
 
+struct _EAlertSink;
+
 typedef struct _EAlert EAlert;
 typedef struct _EAlertClass EAlertClass;
 typedef struct _EAlertPrivate EAlertPrivate;
@@ -103,10 +105,10 @@ GtkWidget *	e_alert_create_image		(EAlert *alert,
 void		e_alert_response		(EAlert *alert,
 						 gint response_id);
 
-void		e_alert_submit			(GtkWidget *widget,
+void		e_alert_submit			(struct _EAlertSink *alert_sink,
 						 const gchar *tag,
 						 ...) G_GNUC_NULL_TERMINATED;
-void		e_alert_submit_valist		(GtkWidget *widget,
+void		e_alert_submit_valist		(struct _EAlertSink *alert_sink,
 						 const gchar *tag,
 						 va_list va);
 
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 36b244d..09cbcae 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -29,6 +29,7 @@
 
 #include "e-util/e-account-utils.h"
 #include "e-util/e-alert-dialog.h"
+#include "e-util/e-alert-sink.h"
 
 #include "misc/e-account-combo-box.h"
 
@@ -637,6 +638,6 @@ e_mail_backend_submit_alert (EMailBackend *backend,
 	shell_content = e_shell_view_get_shell_content (shell_view);
 
 	va_start (va, tag);
-	e_alert_submit_valist (GTK_WIDGET (shell_content), tag, va);
+	e_alert_submit_valist (E_ALERT_SINK (shell_content), tag, va);
 	va_end (va);
 }
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 6aebe52..85d5bb2 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -39,6 +39,7 @@
 
 #include "e-util/e-account-utils.h"
 #include "e-util/e-alert-dialog.h"
+#include "e-util/e-alert-sink.h"
 #include "e-util/e-util.h"
 
 #include "shell/e-shell.h"
@@ -302,7 +303,7 @@ composer_presend_check_recipients (EMsgComposer *composer)
 	/* I'm sensing a lack of love, er, I mean recipients. */
 	if (num == 0 && num_post == 0) {
 		e_alert_submit (
-			GTK_WIDGET (composer),
+			E_ALERT_SINK (composer),
 			"mail:send-no-recipients", NULL);
 		goto finished;
 	}
@@ -349,7 +350,7 @@ composer_presend_check_account (EMsgComposer *composer)
 
 	if (!check_passed)
 		e_alert_submit (
-			GTK_WIDGET (composer),
+			E_ALERT_SINK (composer),
 			"mail:send-no-account-enabled", NULL);
 
 	return check_passed;
@@ -614,7 +615,7 @@ composer_save_to_drafts_cleanup (CamelFolder *drafts_folder,
 	if (error != NULL) {
 		g_warn_if_fail (context->message_uid == NULL);
 		e_alert_submit (
-			GTK_WIDGET (context->composer),
+			E_ALERT_SINK (context->composer),
 			"mail-composer:save-to-drafts-error",
 			error->message, NULL);
 		async_context_free (context);
@@ -774,7 +775,7 @@ composer_save_to_outbox_completed (CamelFolder *outbox_folder,
 
 	if (error != NULL) {
 		e_alert_submit (
-			GTK_WIDGET (context->composer),
+			E_ALERT_SINK (context->composer),
 			"mail-composer:append-to-outbox-error",
 			error->message, NULL);
 		g_error_free (error);
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 8e507e4..21471c5 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -27,6 +27,7 @@
 
 #include <libedataserver/e-flag.h>
 
+#include <e-util/e-alert-sink.h>
 #include <shell/e-shell-view.h>
 
 #include "mail-mt.h"
@@ -252,13 +253,13 @@ mail_msg_check_error (gpointer msg)
 
 	if (m->info->desc && (what = m->info->desc (m))) {
 		e_alert_submit (
-			GTK_WIDGET (shell_content),
+			E_ALERT_SINK (shell_content),
 			"mail:async-error", what,
 			m->error->message, NULL);
 		g_free (what);
 	} else
 		e_alert_submit (
-			GTK_WIDGET (shell_content),
+			E_ALERT_SINK (shell_content),
 			"mail:async-error-nodescribe",
 			m->error->message, NULL);
 }
diff --git a/modules/offline-alert/evolution-offline-alert.c b/modules/offline-alert/evolution-offline-alert.c
index 8b1de84..c759e50 100644
--- a/modules/offline-alert/evolution-offline-alert.c
+++ b/modules/offline-alert/evolution-offline-alert.c
@@ -96,7 +96,8 @@ offline_alert_network_available_cb (EShell *shell,
 		if (!E_IS_SHELL_WINDOW (window))
 			continue;
 
-		e_alert_sink_submit_alert (window, extension->alert);
+		e_alert_sink_submit_alert (
+			E_ALERT_SINK (window), extension->alert);
 	}
 
 	g_object_unref (extension->alert);
@@ -148,7 +149,7 @@ offline_alert_window_created_cb (EShell *shell,
 	g_object_add_weak_pointer (
 		G_OBJECT (extension->alert), &extension->alert);
 
-	e_alert_sink_submit_alert (GTK_WIDGET (window), extension->alert);
+	e_alert_sink_submit_alert (E_ALERT_SINK (window), extension->alert);
 
 	g_object_unref (extension->alert);
 }
diff --git a/widgets/misc/e-signature-editor.c b/widgets/misc/e-signature-editor.c
index 6a18d58..fcc76c8 100644
--- a/widgets/misc/e-signature-editor.c
+++ b/widgets/misc/e-signature-editor.c
@@ -153,7 +153,7 @@ action_save_and_close_cb (GtkAction *action,
 
 	if (error != NULL) {
 		e_alert_submit (
-			GTK_WIDGET (editor),
+			E_ALERT_SINK (editor),
 			"mail:no-save-signature",
 			error->message, NULL);
 		g_clear_error (&error);
@@ -168,7 +168,7 @@ action_save_and_close_cb (GtkAction *action,
 	/* Make sure the signature name is not blank. */
 	if (*signature_name == '\0') {
 		e_alert_submit (
-			GTK_WIDGET (editor),
+			E_ALERT_SINK (editor),
 			"mail:blank-signature", NULL);
 		gtk_widget_grab_focus (entry);
 		g_free (signature_name);
@@ -180,7 +180,7 @@ action_save_and_close_cb (GtkAction *action,
 		e_signature_list_find_by_name (signature_list, signature_name);
 	if (same_name != NULL && !e_signature_is_equal (signature, same_name)) {
 		e_alert_submit (
-			GTK_WIDGET (editor),
+			E_ALERT_SINK (editor),
 			"mail:signature-already-exists",
 			signature_name, NULL);
 		gtk_widget_grab_focus (entry);



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