diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-10-16 02:51:13 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-10-19 00:32:36 +0800 |
commit | 51ebf20237270a785af0aa0e614db42275a05c62 (patch) | |
tree | 328b2fe9b7aa111f0cb21f23b11bc2eaf6da3ac8 /e-util/e-alert-sink.c | |
parent | 2197e6401ec8c5e1b77fa51e085ac068daa39e6a (diff) | |
download | gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.gz gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.zst gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.zip |
EAlert: Allow arbitrary actions to be added.
You can now amend the predefined actions in an EAlert by calling
e_alert_add_action(). Useful for adding actions from an existing
GtkUIManager.
Call e_alert_peek_actions() to obtain a combined list of predefined
and custom actions. These will typically serve as "related" actions
for GtkButtons (cf. gtk_activatable_set_related_action()).
Also, both EShellWindow and EShellView now implement EAlertSink. Use
EShellWindow for application-wide alerts, EShellView for view-specific
alerts.
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); } |