diff options
-rw-r--r-- | mail/e-mail-browser.c | 58 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 11 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-content.c | 15 | ||||
-rw-r--r-- | widgets/misc/e-preview-pane.c | 70 | ||||
-rw-r--r-- | widgets/misc/e-preview-pane.h | 1 |
5 files changed, 80 insertions, 75 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c index dbc2500713..e9c837206f 100644 --- a/mail/e-mail-browser.c +++ b/mail/e-mail-browser.c @@ -30,12 +30,10 @@ #include "e-util/e-util.h" #include "e-util/e-plugin-ui.h" -#include "e-util/e-alert-dialog.h" #include "e-util/gconf-bridge.h" #include "shell/e-shell.h" #include "shell/e-shell-utils.h" #include "shell/e-shell-settings.h" -#include "widgets/misc/e-alert-bar.h" #include "widgets/misc/e-popup-action.h" #include "widgets/misc/e-preview-pane.h" @@ -63,7 +61,6 @@ struct _EMailBrowserPrivate { GtkWidget *main_menu; GtkWidget *main_toolbar; GtkWidget *message_list; - GtkWidget *alert_bar; GtkWidget *preview_pane; GtkWidget *statusbar; @@ -106,8 +103,6 @@ static const gchar *ui = " </menubar>" "</ui>"; -static void e_mail_browser_alert_sink_init - (EAlertSinkInterface *interface); static void e_mail_browser_reader_init (EMailReaderInterface *interface); @@ -116,8 +111,6 @@ G_DEFINE_TYPE_WITH_CODE ( e_mail_browser, GTK_TYPE_WINDOW, G_IMPLEMENT_INTERFACE ( - E_TYPE_ALERT_SINK, e_mail_browser_alert_sink_init) - G_IMPLEMENT_INTERFACE ( E_TYPE_MAIL_READER, e_mail_browser_reader_init) G_IMPLEMENT_INTERFACE ( E_TYPE_EXTENSIBLE, NULL)) @@ -524,11 +517,6 @@ mail_browser_dispose (GObject *object) priv->message_list = NULL; } - if (priv->alert_bar != NULL) { - g_object_unref (priv->alert_bar); - priv->alert_bar = NULL; - } - if (priv->preview_pane != NULL) { g_object_unref (priv->preview_pane); priv->preview_pane = NULL; @@ -696,11 +684,6 @@ mail_browser_constructed (GObject *object) gtk_widget_get_style_context (widget), GTK_STYLE_CLASS_PRIMARY_TOOLBAR); - widget = e_alert_bar_new (); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - browser->priv->alert_bar = g_object_ref (widget); - /* EAlertBar controls its own visibility. */ - gtk_widget_show (GTK_WIDGET (web_view)); widget = e_preview_pane_new (web_view); @@ -746,34 +729,6 @@ mail_browser_key_press_event (GtkWidget *widget, key_press_event (widget, event); } -static void -mail_browser_submit_alert (EAlertSink *alert_sink, - EAlert *alert) -{ - EMailBrowser *browser; - EAlertBar *alert_bar; - GtkWidget *dialog; - GtkWindow *parent; - - browser = E_MAIL_BROWSER (alert_sink); - alert_bar = E_ALERT_BAR (browser->priv->alert_bar); - - switch (e_alert_get_message_type (alert)) { - case GTK_MESSAGE_INFO: - case GTK_MESSAGE_WARNING: - 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 GtkActionGroup * mail_browser_get_action_group (EMailReader *reader, EMailReaderActionGroup group) @@ -794,12 +749,6 @@ mail_browser_get_action_group (EMailReader *reader, return g_object_get_data (G_OBJECT (reader), group_name); } -static EAlertSink * -mail_browser_get_alert_sink (EMailReader *reader) -{ - return E_ALERT_SINK (reader); -} - static EMailBackend * mail_browser_get_backend (EMailReader *reader) { @@ -967,16 +916,9 @@ e_mail_browser_class_init (EMailBrowserClass *class) } static void -e_mail_browser_alert_sink_init (EAlertSinkInterface *interface) -{ - interface->submit_alert = mail_browser_submit_alert; -} - -static void e_mail_browser_reader_init (EMailReaderInterface *interface) { interface->get_action_group = mail_browser_get_action_group; - interface->get_alert_sink = mail_browser_get_alert_sink; interface->get_backend = mail_browser_get_backend; interface->get_formatter = mail_browser_get_formatter; interface->get_hide_deleted = mail_browser_get_hide_deleted; diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 7e475014a9..b38a2c2220 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -2766,6 +2766,16 @@ mail_reader_emit_folder_loaded (EMailReader *reader) g_signal_emit (reader, signals[FOLDER_LOADED], 0); } +static EAlertSink * +mail_reader_get_alert_sink (EMailReader *reader) +{ + EPreviewPane *preview_pane; + + preview_pane = e_mail_reader_get_preview_pane (reader); + + return E_ALERT_SINK (preview_pane); +} + static GPtrArray * mail_reader_get_selected_uids (EMailReader *reader) { @@ -3395,6 +3405,7 @@ e_mail_reader_default_init (EMailReaderInterface *interface) { quark_private = g_quark_from_static_string ("e-mail-reader-private"); + interface->get_alert_sink = mail_reader_get_alert_sink; interface->get_selected_uids = mail_reader_get_selected_uids; interface->get_folder = mail_reader_get_folder; interface->enable_show_folder = mail_reader_get_enable_show_folder; diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index ed94b45af3..e3b9f1f5ff 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -281,20 +281,6 @@ mail_shell_content_get_action_group (EMailReader *reader, return e_shell_window_get_action_group (shell_window, group_name); } -static EAlertSink * -mail_shell_content_get_alert_sink (EMailReader *reader) -{ - EMailShellContent *mail_shell_content; - - mail_shell_content = E_MAIL_SHELL_CONTENT (reader); - - /* Forward this to our internal EMailView, which - * also implements the EMailReader interface. */ - reader = E_MAIL_READER (mail_shell_content->priv->mail_view); - - return e_mail_reader_get_alert_sink (reader); -} - static EMailBackend * mail_shell_content_get_backend (EMailReader *reader) { @@ -476,7 +462,6 @@ static void mail_shell_content_reader_init (EMailReaderInterface *interface) { interface->get_action_group = mail_shell_content_get_action_group; - interface->get_alert_sink = mail_shell_content_get_alert_sink; interface->get_backend = mail_shell_content_get_backend; interface->get_formatter = mail_shell_content_get_formatter; interface->get_hide_deleted = mail_shell_content_get_hide_deleted; 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 |