[evolution] EMFolderTree: Add an EAlertSink property.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EMFolderTree: Add an EAlertSink property.
- Date: Tue, 24 May 2011 18:43:00 +0000 (UTC)
commit ff9fcffeca2bdc37a91e0c2f0cb51f871a3cd7a1
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue May 24 11:02:59 2011 -0400
EMFolderTree: Add an EAlertSink property.
Now EMFolderTree has access to both an EShellBackend and an EAlertSink;
everything it needs to build and submit EActivity instances.
mail/e-mail-sidebar.c | 8 +++-
mail/e-mail-sidebar.h | 3 +-
mail/em-folder-selector.c | 10 ++++--
mail/em-folder-tree.c | 61 +++++++++++++++++++++++++++++++++--
mail/em-folder-tree.h | 5 ++-
modules/mail/e-mail-shell-sidebar.c | 4 ++-
shell/e-shell-sidebar.c | 32 ++++++++++++++++++
7 files changed, 112 insertions(+), 11 deletions(-)
---
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c
index 80043f0..45d16a8 100644
--- a/mail/e-mail-sidebar.c
+++ b/mail/e-mail-sidebar.c
@@ -473,12 +473,16 @@ e_mail_sidebar_get_type (void)
}
GtkWidget *
-e_mail_sidebar_new (EMailBackend *backend)
+e_mail_sidebar_new (EMailBackend *backend,
+ EAlertSink *alert_sink)
{
g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL);
return g_object_new (
- E_TYPE_MAIL_SIDEBAR, "backend", backend, NULL);
+ E_TYPE_MAIL_SIDEBAR,
+ "alert-sink", alert_sink,
+ "backend", backend, NULL);
}
GKeyFile *
diff --git a/mail/e-mail-sidebar.h b/mail/e-mail-sidebar.h
index 8941c99..84d8183 100644
--- a/mail/e-mail-sidebar.h
+++ b/mail/e-mail-sidebar.h
@@ -76,7 +76,8 @@ struct _EMailSidebarClass {
};
GType e_mail_sidebar_get_type (void);
-GtkWidget * e_mail_sidebar_new (EMailBackend *backend);
+GtkWidget * e_mail_sidebar_new (EMailBackend *backend,
+ EAlertSink *alert_sink);
GKeyFile * e_mail_sidebar_get_key_file (EMailSidebar *sidebar);
void e_mail_sidebar_set_key_file (EMailSidebar *sidebar,
GKeyFile *key_file);
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index 24f619d..2ac1d06 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -47,10 +47,14 @@ enum {
PROP_BACKEND
};
-G_DEFINE_TYPE (
+/* XXX EMFolderSelector is an EAlertSink, but it just uses the default
+ * message dialog implementation. We should do something nicer. */
+
+G_DEFINE_TYPE_WITH_CODE (
EMFolderSelector,
em_folder_selector,
- GTK_TYPE_DIALOG)
+ GTK_TYPE_DIALOG,
+ G_IMPLEMENT_INTERFACE (E_TYPE_ALERT_SINK, NULL))
static void
folder_selector_set_backend (EMFolderSelector *emfs,
@@ -286,7 +290,7 @@ folder_selector_construct (EMFolderSelector *emfs,
container = widget;
- widget = em_folder_tree_new (backend);
+ widget = em_folder_tree_new (backend, E_ALERT_SINK (emfs));
emu_restore_folder_tree_state (EM_FOLDER_TREE (widget));
gtk_container_add (GTK_CONTAINER (widget), widget);
emfs->priv->folder_tree = EM_FOLDER_TREE (widget);
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 613f10d..8d856c1 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -78,6 +78,7 @@ struct _selected_uri {
struct _EMFolderTreePrivate {
EMailBackend *backend;
+ EAlertSink *alert_sink;
/* selected_uri structures of each path pending selection. */
GSList *select_uris;
@@ -119,6 +120,7 @@ struct _EMFolderTreePrivate {
enum {
PROP_0,
+ PROP_ALERT_SINK,
PROP_BACKEND,
PROP_COPY_TARGET_LIST,
PROP_ELLIPSIZE,
@@ -719,6 +721,16 @@ exit:
}
static void
+folder_tree_set_alert_sink (EMFolderTree *folder_tree,
+ EAlertSink *alert_sink)
+{
+ g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
+ g_return_if_fail (folder_tree->priv->alert_sink == NULL);
+
+ folder_tree->priv->alert_sink = g_object_ref (alert_sink);
+}
+
+static void
folder_tree_set_backend (EMFolderTree *folder_tree,
EMailBackend *backend)
{
@@ -765,6 +777,12 @@ folder_tree_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_ALERT_SINK:
+ folder_tree_set_alert_sink (
+ EM_FOLDER_TREE (object),
+ g_value_get_object (value));
+ return;
+
case PROP_BACKEND:
folder_tree_set_backend (
EM_FOLDER_TREE (object),
@@ -788,6 +806,13 @@ folder_tree_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_ALERT_SINK:
+ g_value_set_object (
+ value,
+ em_folder_tree_get_alert_sink (
+ EM_FOLDER_TREE (object)));
+ return;
+
case PROP_BACKEND:
g_value_set_object (
value,
@@ -847,6 +872,11 @@ folder_tree_dispose (GObject *object)
priv->autoexpand_id = 0;
}
+ if (priv->alert_sink != NULL) {
+ g_object_unref (priv->alert_sink);
+ priv->alert_sink = NULL;
+ }
+
if (priv->backend != NULL) {
g_object_unref (priv->backend);
priv->backend = NULL;
@@ -1107,6 +1137,18 @@ folder_tree_class_init (EMFolderTreeClass *class)
g_object_class_install_property (
object_class,
+ PROP_ALERT_SINK,
+ g_param_spec_object (
+ "alert-sink",
+ NULL,
+ NULL,
+ E_TYPE_ALERT_SINK,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_BACKEND,
g_param_spec_object (
"backend",
@@ -1114,7 +1156,8 @@ folder_tree_class_init (EMFolderTreeClass *class)
NULL,
E_TYPE_MAIL_BACKEND,
G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/* Inherited from ESelectableInterface */
g_object_class_override_property (
@@ -1704,12 +1747,14 @@ em_folder_tree_get_type (void)
}
GtkWidget *
-em_folder_tree_new (EMailBackend *backend)
+em_folder_tree_new (EMailBackend *backend,
+ EAlertSink *alert_sink)
{
EMailSession *session;
const gchar *data_dir;
g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL);
session = e_mail_backend_get_session (backend);
data_dir = e_shell_backend_get_data_dir (E_SHELL_BACKEND (backend));
@@ -1717,7 +1762,9 @@ em_folder_tree_new (EMailBackend *backend)
e_mail_store_init (session, data_dir);
return g_object_new (
- EM_TYPE_FOLDER_TREE, "backend", backend, NULL);
+ EM_TYPE_FOLDER_TREE,
+ "alert-sink", alert_sink,
+ "backend", backend, NULL);
}
PangoEllipsizeMode
@@ -1742,6 +1789,14 @@ em_folder_tree_set_ellipsize (EMFolderTree *folder_tree,
g_object_notify (G_OBJECT (folder_tree), "ellipsize");
}
+EAlertSink *
+em_folder_tree_get_alert_sink (EMFolderTree *folder_tree)
+{
+ g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), NULL);
+
+ return folder_tree->priv->alert_sink;
+}
+
EMailBackend *
em_folder_tree_get_backend (EMFolderTree *folder_tree)
{
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index 9b94fe7..d2cd643 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -25,6 +25,7 @@
#define EM_FOLDER_TREE_H
#include <gtk/gtk.h>
+#include <e-util/e-alert-sink.h>
#include <mail/e-mail-backend.h>
#include <mail/em-folder-tree-model.h>
@@ -89,11 +90,13 @@ struct _EMFolderTreeClass {
};
GType em_folder_tree_get_type (void);
-GtkWidget * em_folder_tree_new (EMailBackend *backend);
+GtkWidget * em_folder_tree_new (EMailBackend *backend,
+ EAlertSink *alert_sink);
PangoEllipsizeMode
em_folder_tree_get_ellipsize (EMFolderTree *folder_tree);
void em_folder_tree_set_ellipsize (EMFolderTree *folder_tree,
PangoEllipsizeMode ellipsize);
+EAlertSink * em_folder_tree_get_alert_sink (EMFolderTree *folder_tree);
EMailBackend * em_folder_tree_get_backend (EMFolderTree *folder_tree);
void em_folder_tree_enable_drag_and_drop
(EMFolderTree *folder_tree);
diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c
index 760ebb0..643bc63 100644
--- a/modules/mail/e-mail-shell-sidebar.c
+++ b/modules/mail/e-mail-shell-sidebar.c
@@ -149,7 +149,9 @@ mail_shell_sidebar_constructed (GObject *object)
container = widget;
- widget = e_mail_sidebar_new (E_MAIL_BACKEND (shell_backend));
+ widget = e_mail_sidebar_new (
+ E_MAIL_BACKEND (shell_backend),
+ E_ALERT_SINK (shell_sidebar));
gtk_container_add (GTK_CONTAINER (container), widget);
mail_shell_sidebar->priv->folder_tree = g_object_ref (widget);
gtk_widget_show (widget);
diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c
index d99e66a..b72a210 100644
--- a/shell/e-shell-sidebar.c
+++ b/shell/e-shell-sidebar.c
@@ -27,6 +27,7 @@
#include "e-shell-sidebar.h"
+#include <e-util/e-alert-sink.h>
#include <e-util/e-extensible.h>
#include <e-util/e-unicode.h>
#include <shell/e-shell-view.h>
@@ -50,11 +51,17 @@ enum {
PROP_SHELL_VIEW
};
+/* Forward Declarations */
+static void e_shell_sidebar_alert_sink_init
+ (EAlertSinkInterface *interface);
+
G_DEFINE_TYPE_WITH_CODE (
EShellSidebar,
e_shell_sidebar,
GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (
+ E_TYPE_ALERT_SINK, e_shell_sidebar_alert_sink_init)
+ G_IMPLEMENT_INTERFACE (
E_TYPE_EXTENSIBLE, NULL))
static void
@@ -300,6 +307,25 @@ shell_sidebar_forall (GtkContainer *container,
}
static void
+shell_sidebar_submit_alert (EAlertSink *alert_sink,
+ EAlert *alert)
+{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
+
+ /* EShellSidebar is a proxy alert sink. Forward the alert
+ * to the EShellContent widget for display to the user. */
+
+ shell_sidebar = E_SHELL_SIDEBAR (alert_sink);
+ shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ alert_sink = E_ALERT_SINK (shell_content);
+ e_alert_sink_submit_alert (alert_sink, alert);
+}
+
+static void
e_shell_sidebar_class_init (EShellSidebarClass *class)
{
GObjectClass *object_class;
@@ -387,6 +413,12 @@ e_shell_sidebar_class_init (EShellSidebarClass *class)
}
static void
+e_shell_sidebar_alert_sink_init (EAlertSinkInterface *interface)
+{
+ interface->submit_alert = shell_sidebar_submit_alert;
+}
+
+static void
e_shell_sidebar_init (EShellSidebar *shell_sidebar)
{
GtkStyle *style;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]