From 2b8701fa2b3925ab94231884e211bbcdada5359f Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 21 Nov 2011 13:20:08 -0500 Subject: EPreviewPane: Implement EAlertSink. Means EMailBrowser no longer has to. Also, EMailReader now provides a default implementation for get_alert_sink() which just calls get_preview_pane() and casts. --- widgets/misc/e-preview-pane.c | 70 +++++++++++++++++++++++++++++++++++++++++-- widgets/misc/e-preview-pane.h | 1 + 2 files changed, 69 insertions(+), 2 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/e-preview-pane.c b/widgets/misc/e-preview-pane.c index 1a7a319ea4..42f338c75b 100644 --- a/widgets/misc/e-preview-pane.c +++ b/widgets/misc/e-preview-pane.c @@ -27,7 +27,13 @@ #include +#include +#include + +#include "e-alert-bar.h" + struct _EPreviewPanePrivate { + GtkWidget *alert_bar; GtkWidget *web_view; GtkWidget *search_bar; }; @@ -45,10 +51,17 @@ enum { static guint signals[LAST_SIGNAL]; -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_preview_pane_alert_sink_init + (EAlertSinkInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( EPreviewPane, e_preview_pane, - GTK_TYPE_VBOX) + GTK_TYPE_VBOX, + G_IMPLEMENT_INTERFACE ( + E_TYPE_ALERT_SINK, + e_preview_pane_alert_sink_init)) static void preview_pane_set_web_view (EPreviewPane *preview_pane, @@ -107,6 +120,11 @@ preview_pane_dispose (GObject *object) priv = E_PREVIEW_PANE (object)->priv; + if (priv->alert_bar != NULL) { + g_object_unref (priv->alert_bar); + priv->alert_bar = NULL; + } + if (priv->search_bar != NULL) { g_object_unref (priv->search_bar); priv->search_bar = NULL; @@ -129,6 +147,11 @@ preview_pane_constructed (GObject *object) priv = E_PREVIEW_PANE (object)->priv; + widget = e_alert_bar_new (); + gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0); + priv->alert_bar = g_object_ref (widget); + /* EAlertBar controls its own visibility. */ + widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (widget), @@ -159,6 +182,35 @@ preview_pane_show_search_bar (EPreviewPane *preview_pane) gtk_widget_show (search_bar); } +static void +preview_pane_submit_alert (EAlertSink *alert_sink, + EAlert *alert) +{ + EPreviewPane *preview_pane; + EAlertBar *alert_bar; + GtkWidget *dialog; + GtkWindow *parent; + + preview_pane = E_PREVIEW_PANE (alert_sink); + alert_bar = E_ALERT_BAR (preview_pane->priv->alert_bar); + + switch (e_alert_get_message_type (alert)) { + case GTK_MESSAGE_INFO: + case GTK_MESSAGE_WARNING: + case GTK_MESSAGE_QUESTION: + case GTK_MESSAGE_ERROR: + e_alert_bar_add_alert (alert_bar, alert); + break; + + default: + parent = GTK_WINDOW (alert_sink); + dialog = e_alert_dialog_new (parent, alert); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + break; + } +} + static void e_preview_pane_class_init (EPreviewPaneClass *class) { @@ -212,6 +264,12 @@ e_preview_pane_class_init (EPreviewPaneClass *class) "show-search-bar", 0); } +static void +e_preview_pane_alert_sink_init (EAlertSinkInterface *interface) +{ + interface->submit_alert = preview_pane_submit_alert; +} + static void e_preview_pane_init (EPreviewPane *preview_pane) { @@ -247,6 +305,14 @@ e_preview_pane_get_search_bar (EPreviewPane *preview_pane) return E_SEARCH_BAR (preview_pane->priv->search_bar); } +void +e_preview_pane_clear_alerts (EPreviewPane *preview_pane) +{ + g_return_if_fail (E_IS_PREVIEW_PANE (preview_pane)); + + e_alert_bar_clear (E_ALERT_BAR (preview_pane->priv->alert_bar)); +} + void e_preview_pane_show_search_bar (EPreviewPane *preview_pane) { diff --git a/widgets/misc/e-preview-pane.h b/widgets/misc/e-preview-pane.h index bd965ed307..1313193d97 100644 --- a/widgets/misc/e-preview-pane.h +++ b/widgets/misc/e-preview-pane.h @@ -67,6 +67,7 @@ GType e_preview_pane_get_type (void); GtkWidget * e_preview_pane_new (EWebView *web_view); EWebView * e_preview_pane_get_web_view (EPreviewPane *preview_pane); ESearchBar * e_preview_pane_get_search_bar (EPreviewPane *preview_pane); +void e_preview_pane_clear_alerts (EPreviewPane *preview_pane); void e_preview_pane_show_search_bar (EPreviewPane *preview_pane); G_END_DECLS -- cgit v1.2.3