diff options
Diffstat (limited to 'e-util/e-alert-sink.c')
-rw-r--r-- | e-util/e-alert-sink.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/e-util/e-alert-sink.c b/e-util/e-alert-sink.c index de676ea778..f26f114c71 100644 --- a/e-util/e-alert-sink.c +++ b/e-util/e-alert-sink.c @@ -35,16 +35,13 @@ G_DEFINE_INTERFACE ( GTK_TYPE_WIDGET) static void -alert_sink_submit_alert (EAlertSink *alert_sink, - EAlert *alert) +alert_sink_fallback (GtkWidget *widget, + EAlert *alert) { GtkWidget *dialog; gpointer parent; - /* This is just a lame fallback handler. Implementors - * are strongly encouraged to override this method. */ - - parent = gtk_widget_get_toplevel (GTK_WIDGET (alert_sink)); + parent = gtk_widget_get_toplevel (widget); parent = gtk_widget_is_toplevel (parent) ? parent : NULL; dialog = e_alert_dialog_new (parent, alert); @@ -53,6 +50,15 @@ alert_sink_submit_alert (EAlertSink *alert_sink, } static void +alert_sink_submit_alert (EAlertSink *alert_sink, + EAlert *alert) +{ + /* This is just a lame fallback handler. Implementors + * are strongly encouraged to override this method. */ + alert_sink_fallback (GTK_WIDGET (alert_sink), alert); +} + +static void e_alert_sink_default_init (EAlertSinkInterface *interface) { interface->submit_alert = alert_sink_submit_alert; @@ -67,7 +73,7 @@ e_alert_sink_default_init (EAlertSinkInterface *interface) * 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 parents must implement #EAlertSink. + * Either @widget or one of its ancestors must implement #EAlertSink. * * The default behavior is to display the @alert in a dialog. **/ @@ -75,18 +81,20 @@ void e_alert_sink_submit_alert (GtkWidget *widget, EAlert *alert) { - EAlertSinkInterface *interface; + GtkWidget *ancestor; g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (E_IS_ALERT (alert)); - while (widget != NULL && !E_IS_ALERT_SINK (widget)) - widget = gtk_widget_get_parent (widget); + ancestor = gtk_widget_get_ancestor (widget, E_TYPE_ALERT_SINK); - g_return_if_fail (E_IS_ALERT_SINK (widget)); + if (E_IS_ALERT_SINK (ancestor)) { + EAlertSinkInterface *interface; - interface = E_ALERT_SINK_GET_INTERFACE (widget); - g_return_if_fail (interface->submit_alert != NULL); + interface = E_ALERT_SINK_GET_INTERFACE (ancestor); + g_return_if_fail (interface->submit_alert != NULL); - interface->submit_alert (E_ALERT_SINK (widget), alert); + interface->submit_alert (E_ALERT_SINK (ancestor), alert); + } else + alert_sink_fallback (widget, alert); } |