From 82925c6be94e9e48e4ef521a88a9feec24cf9eef Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 31 Oct 2010 16:02:30 -0400 Subject: 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. --- 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 ++++-- 4 files changed, 17 insertions(+), 26 deletions(-) (limited to 'e-util') diff --git a/e-util/e-alert-sink.c b/e-util/e-alert-sink.c index f26f114c71..2a8db40afb 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 35c56f95b1..da5ae7b06f 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 12bee6d78c..9f7a80162a 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 f9f0fc8559..4d6b2671b4 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); -- cgit v1.2.3