diff options
author | Srinivasa Ragavan <sragavan@gnome.org> | 2010-07-12 18:32:25 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-07-26 09:29:59 +0800 |
commit | b1f4b085656a2520d807eb8ebca3d64b568ff037 (patch) | |
tree | 46a9d3312afe4a390ed85b465d7cd576757f9e37 /mail | |
parent | 10df2a43b866eb6a5e73d652d89db3d1010fe7f9 (diff) | |
download | gsoc2013-evolution-b1f4b085656a2520d807eb8ebca3d64b568ff037.tar gsoc2013-evolution-b1f4b085656a2520d807eb8ebca3d64b568ff037.tar.gz gsoc2013-evolution-b1f4b085656a2520d807eb8ebca3d64b568ff037.tar.bz2 gsoc2013-evolution-b1f4b085656a2520d807eb8ebca3d64b568ff037.tar.lz gsoc2013-evolution-b1f4b085656a2520d807eb8ebca3d64b568ff037.tar.xz gsoc2013-evolution-b1f4b085656a2520d807eb8ebca3d64b568ff037.tar.zst gsoc2013-evolution-b1f4b085656a2520d807eb8ebca3d64b568ff037.zip |
Add EMailNotebook View
Diffstat (limited to 'mail')
-rw-r--r-- | mail/Makefile.am | 2 | ||||
-rw-r--r-- | mail/e-mail-notebook-view.c | 292 | ||||
-rw-r--r-- | mail/e-mail-notebook-view.h | 19 | ||||
-rw-r--r-- | mail/e-mail-paned-view.c | 2 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 2 |
5 files changed, 295 insertions, 22 deletions
diff --git a/mail/Makefile.am b/mail/Makefile.am index 0ec87b1b5f..4ddb9ccf89 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -37,6 +37,7 @@ libevolution_mail_la_CPPFLAGS = \ mailinclude_HEADERS = \ e-mail-view.h \ e-mail-paned-view.h \ + e-mail-notebook-view.h \ e-mail-attachment-bar.h \ e-mail-backend.h \ e-mail-browser.h \ @@ -96,6 +97,7 @@ mailinclude_HEADERS = \ libevolution_mail_la_SOURCES = \ e-mail-view.c \ e-mail-paned-view.c \ + e-mail-notebook-view.c \ e-mail-attachment-bar.c \ e-mail-backend.c \ e-mail-browser.c \ diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c index 1850bbedbc..c15ca90fb8 100644 --- a/mail/e-mail-notebook-view.c +++ b/mail/e-mail-notebook-view.c @@ -27,22 +27,31 @@ #include <glib.h> #include <glib/gi18n.h> -#include "e-mail-notebook-view.h" +#include "mail/e-mail-reader.h" +#include "e-mail-notebook-view.h" +#include "e-mail-paned-view.h" -G_DEFINE_TYPE (EMailNotebookView, e_mail_notebook_view, GTK_TYPE_VBOX) +#include <shell/e-shell-window-actions.h> -enum { - PANE_CLOSE, - LAST_SIGNAL +struct _EMailNotebookViewPrivate { + GtkNotebook *book; + EMailView *current_view; + GHashTable *views; }; -static guint signals[LAST_SIGNAL] = { 0 }; +#define E_SHELL_WINDOW_ACTION_GROUP_MAIL(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "mail") + +static EMailViewClass *parent_class; +static GType mail_notebook_view_type; static void -e_mail_notebook_view_init (EMailNotebookView *shell) +mail_notebook_view_init (EMailNotebookView *shell) { shell->priv = g_new0(EMailNotebookViewPrivate, 1); + + shell->priv->views = g_hash_table_new (g_str_hash, g_str_equal); } static void @@ -50,26 +59,273 @@ e_mail_notebook_view_finalize (GObject *object) { /* EMailNotebookView *shell = (EMailNotebookView *)object; */ - G_OBJECT_CLASS (e_mail_notebook_view_parent_class)->finalize (object); + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +mail_notebook_view_constructed (GObject *object) +{ + GtkWidget *widget, *container; + EMailNotebookViewPrivate *priv; + + priv = E_MAIL_NOTEBOOK_VIEW (object)->priv; + + container = GTK_WIDGET(object); + + widget = gtk_notebook_new (); + priv->book = (GtkNotebook *)widget; + gtk_widget_show (widget); + gtk_box_pack_start (GTK_BOX(container), widget, TRUE, TRUE, 0); + + priv->current_view = e_mail_paned_view_new (E_MAIL_VIEW(object)->content); + gtk_widget_show (priv->current_view); + gtk_notebook_append_page (priv->book, priv->current_view, gtk_label_new ("Please select a folder")); + } static void -e_mail_notebook_view_class_init (EMailNotebookViewClass *klass) +mail_notebook_view_class_init (EMailViewClass *klass) { GObjectClass * object_class = G_OBJECT_CLASS (klass); - e_mail_notebook_view_parent_class = g_type_class_peek_parent (klass); + parent_class = g_type_class_peek_parent (klass); + object_class->constructed = mail_notebook_view_constructed; + object_class->finalize = e_mail_notebook_view_finalize; - signals[PANE_CLOSE] = - g_signal_new ("pane-close", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EMailNotebookViewClass , view_close), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + klass->get_searchbar = e_mail_notebook_view_get_searchbar; + klass->set_search_strings = e_mail_notebook_view_set_search_strings; + klass->get_view_instance = e_mail_notebook_view_get_view_instance; + klass->update_view_instance = e_mail_notebook_view_update_view_instance; + } + +GtkWidget * +e_mail_notebook_view_new (EShellContent *content) +{ + g_return_val_if_fail (E_IS_SHELL_CONTENT (content), NULL); + + return g_object_new ( + E_MAIL_NOTEBOOK_VIEW_TYPE, + "shell-content", content, NULL); +} + +static GtkActionGroup * +mail_notebook_view_get_action_group (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + EShellContent *shell_content; + EShellWindow *shell_window; + EShellView *shell_view; + + shell_content = E_MAIL_VIEW (reader)->content; + shell_view = e_shell_content_get_shell_view (shell_content); + shell_window = e_shell_view_get_shell_window (shell_view); + + return E_SHELL_WINDOW_ACTION_GROUP_MAIL (shell_window); +/* + if (!priv->current_view) + return NULL; + + return e_mail_reader_get_action_group (E_MAIL_READER(priv->current_view));*/ +} + +static EMFormatHTML * +mail_notebook_view_get_formatter (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + + if (!priv->current_view) + return NULL; + + return e_mail_reader_get_formatter (E_MAIL_READER(priv->current_view)); +} + +static gboolean +mail_notebook_view_get_hide_deleted (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + + if (!priv->current_view) + return FALSE; + + return e_mail_reader_get_hide_deleted (E_MAIL_READER(priv->current_view)); +} + +static GtkWidget * +mail_notebook_view_get_message_list (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + + if (!priv->current_view) + return NULL; + + return e_mail_reader_get_message_list (E_MAIL_READER(priv->current_view)); +} + +static GtkMenu * +mail_notebook_view_get_popup_menu (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + + if (!priv->current_view) + return NULL; + + return e_mail_reader_get_popup_menu (E_MAIL_READER(priv->current_view)); +} + +static EShellBackend * +mail_notebook_view_get_shell_backend (EMailReader *reader) +{ + EShellContent *shell_content; + EShellView *shell_view; + + shell_content = E_MAIL_VIEW (reader)->content; + shell_view = e_shell_content_get_shell_view (shell_content); + + return e_shell_view_get_shell_backend (shell_view); +} + +static GtkWindow * +mail_notebook_view_get_window (EMailReader *reader) +{ + EShellContent *shell_content; + EShellWindow *shell_window; + EShellView *shell_view; + + shell_content = E_MAIL_VIEW (reader)->content; + shell_view = e_shell_content_get_shell_view (shell_content); + shell_window = e_shell_view_get_shell_window (shell_view); + + return GTK_WINDOW (shell_window); +} + +static void +mail_notebook_view_set_folder (EMailReader *reader, + CamelFolder *folder, + const gchar *folder_uri) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + GtkWidget *new_view; + + if (!folder_uri) + return; + + new_view = g_hash_table_lookup (priv->views, folder_uri); + if (new_view) { + priv->current_view = (EMailView *)new_view; + return; + } + + if (folder || folder_uri) { + new_view = e_mail_paned_view_new (E_MAIL_VIEW(reader)->content); + gtk_widget_show (new_view); + gtk_notebook_append_page (priv->book, new_view, gtk_label_new (camel_folder_get_full_name(folder))); + e_mail_reader_set_folder (E_MAIL_READER(new_view), folder, folder_uri); + } +} + +static void +mail_notebook_view_show_search_bar (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + + e_mail_reader_show_search_bar (E_MAIL_READER(priv->current_view)); +} + +EShellSearchbar * +e_mail_notebook_view_get_searchbar (EMailView *view) +{ + EShellView *shell_view; + EShellContent *shell_content; + GtkWidget *widget; + + g_return_val_if_fail ( + E_IS_MAIL_NOTEBOOK_VIEW (view), NULL); + + shell_content = E_MAIL_VIEW (view)->content; + shell_view = e_shell_content_get_shell_view (shell_content); + widget = e_shell_view_get_searchbar (shell_view); + + return E_SHELL_SEARCHBAR (widget); +/* + if (!E_MAIL_NOTEBOOK_VIEW(view)->priv->current_view) + return NULL; + return e_mail_view_get_searchbar (E_MAIL_NOTEBOOK_VIEW(view)->priv->current_view); */ +} + +void +e_mail_notebook_view_set_search_strings (EMailView *view, + GSList *search_strings) +{ + e_mail_view_set_search_strings (E_MAIL_NOTEBOOK_VIEW (view)->priv->current_view, search_strings); +} + +GalViewInstance * +e_mail_notebook_view_get_view_instance (EMailView *view) +{ + if (!E_MAIL_NOTEBOOK_VIEW(view)->priv->current_view) + return NULL; + + return e_mail_view_get_view_instance (E_MAIL_NOTEBOOK_VIEW (view)->priv->current_view); +} + +void +e_mail_notebook_view_update_view_instance (EMailView *view) +{ + e_mail_view_update_view_instance (E_MAIL_NOTEBOOK_VIEW (view)->priv->current_view); +} + +static void +mail_notebook_view_reader_init (EMailReaderIface *iface) +{ + iface->get_action_group = mail_notebook_view_get_action_group; + iface->get_formatter = mail_notebook_view_get_formatter; + iface->get_hide_deleted = mail_notebook_view_get_hide_deleted; + iface->get_message_list = mail_notebook_view_get_message_list; + iface->get_popup_menu = mail_notebook_view_get_popup_menu; + iface->get_shell_backend = mail_notebook_view_get_shell_backend; + iface->get_window = mail_notebook_view_get_window; + iface->set_folder = mail_notebook_view_set_folder; + iface->show_search_bar = mail_notebook_view_show_search_bar; +} + +GType +e_mail_notebook_view_get_type (void) +{ + return mail_notebook_view_type; +} + +void +e_mail_notebook_view_register_type (GTypeModule *type_module) +{ + static const GTypeInfo type_info = { + sizeof (EMailNotebookViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_notebook_view_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailNotebookView), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_notebook_view_init, + NULL /* value_table */ + }; + + static const GInterfaceInfo reader_info = { + (GInterfaceInitFunc) mail_notebook_view_reader_init, + (GInterfaceFinalizeFunc) NULL, + NULL /* interface_data */ + }; + + mail_notebook_view_type = g_type_module_register_type ( + type_module, E_MAIL_VIEW_TYPE, + "EMailNotebookView", &type_info, 0); + + g_type_module_add_interface ( + type_module, mail_notebook_view_type, + E_TYPE_MAIL_READER, &reader_info); +} diff --git a/mail/e-mail-notebook-view.h b/mail/e-mail-notebook-view.h index 6dfd3c68db..a335e15444 100644 --- a/mail/e-mail-notebook-view.h +++ b/mail/e-mail-notebook-view.h @@ -25,12 +25,14 @@ #include <gtk/gtk.h> #include "e-mail-view.h" +#include <shell/e-shell-searchbar.h> +#include "widgets/menus/gal-view-instance.h" #define E_MAIL_NOTEBOOK_VIEW_TYPE (e_mail_notebook_view_get_type ()) -#define E_MAIL_NOTEBOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_MAIL_NOTEBOOK_VIEW_TYPE, MailFolderView)) -#define E_MAIL_NOTEBOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_MAIL_NOTEBOOK_VIEW_TYPE, MailFolderViewClass)) -#define IS_E_MAIL_NOTEBOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_MAIL_NOTEBOOK_VIEW_TYPE)) -#define IS_E_MAIL_NOTEBOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_MAIL_NOTEBOOK_VIEW_TYPE)) +#define E_MAIL_NOTEBOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_MAIL_NOTEBOOK_VIEW_TYPE, EMailNotebookView)) +#define E_MAIL_NOTEBOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_MAIL_NOTEBOOK_VIEW_TYPE, EMailNotebookViewClass)) +#define E_IS_MAIL_NOTEBOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_MAIL_NOTEBOOK_VIEW_TYPE)) +#define E_IS_MAIL_NOTEBOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_MAIL_NOTEBOOK_VIEW_TYPE)) #define E_MAIL_NOTEBOOK_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), E_MAIL_NOTEBOOK_VIEW_TYPE, EMailNotebookViewClass)) @@ -47,4 +49,13 @@ typedef struct _EMailNotebookViewClass { } EMailNotebookViewClass; +GType e_mail_notebook_view_get_type (void); +void e_mail_notebook_view_register_type (GTypeModule *type_module); +GtkWidget * e_mail_notebook_view_new (EShellContent *content); + +EShellSearchbar * e_mail_notebook_view_get_searchbar (EMailView *view); +void e_mail_notebook_view_set_search_strings (EMailView *view, GSList *search_strings); +GalViewInstance * e_mail_notebook_view_get_view_instance (EMailView *view); +void e_mail_notebook_view_update_view_instance (EMailView *view); + #endif diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c index a1688d6232..365f6c99e3 100644 --- a/mail/e-mail-paned-view.c +++ b/mail/e-mail-paned-view.c @@ -586,6 +586,8 @@ mail_paned_view_constructed (GObject *object) web_view = em_format_html_get_web_view ( EM_FORMAT_HTML (priv->formatter)); + e_mail_reader_init (E_MAIL_READER(object)); + /* Build content widgets. */ container = GTK_WIDGET (object); diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 43f41c93c5..4e1238bd73 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -2304,6 +2304,7 @@ mail_reader_set_folder (EMailReader *reader, priv = E_MAIL_READER_GET_PRIVATE (reader); + printf("PRIV %p\n", priv); formatter = e_mail_reader_get_formatter (reader); message_list = e_mail_reader_get_message_list (reader); @@ -2848,6 +2849,7 @@ e_mail_reader_init (EMailReader *reader) menu_tool_action, "activate", G_CALLBACK (action_mail_forward_cb), reader); + if (action_group) { gtk_action_group_add_action_with_accel ( action_group, GTK_ACTION (menu_tool_action), "<Control>f"); |