aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-11-22 02:20:08 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-11-22 13:12:36 +0800
commit2b8701fa2b3925ab94231884e211bbcdada5359f (patch)
tree95dabbabe0f0cb62a865339d28bf4725cf669852 /widgets
parent451179909849e4e4058180f095e6ae889d97b797 (diff)
downloadgsoc2013-evolution-2b8701fa2b3925ab94231884e211bbcdada5359f.tar.gz
gsoc2013-evolution-2b8701fa2b3925ab94231884e211bbcdada5359f.tar.zst
gsoc2013-evolution-2b8701fa2b3925ab94231884e211bbcdada5359f.zip
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.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-preview-pane.c70
-rw-r--r--widgets/misc/e-preview-pane.h1
2 files changed, 69 insertions, 2 deletions
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 <gdk/gdkkeysyms.h>
+#include <e-util/e-alert-sink.h>
+#include <e-util/e-alert-dialog.h>
+
+#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),
@@ -160,6 +183,35 @@ preview_pane_show_search_bar (EPreviewPane *preview_pane)
}
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)
{
GObjectClass *object_class;
@@ -213,6 +265,12 @@ e_preview_pane_class_init (EPreviewPaneClass *class)
}
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)
{
preview_pane->priv = G_TYPE_INSTANCE_GET_PRIVATE (
@@ -248,6 +306,14 @@ e_preview_pane_get_search_bar (EPreviewPane *preview_pane)
}
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)
{
g_return_if_fail (E_IS_PREVIEW_PANE (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