diff options
author | Srinivasa Ragavan <sragavan@gnome.org> | 2010-07-09 17:11:34 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-07-26 09:29:59 +0800 |
commit | 909774170062bd74c6f3554b25f0d06054fb9c8b (patch) | |
tree | 87e4a6fb10296fc87b92165f79c3b7a6c4e45400 /modules | |
parent | 237abb86d580b7013b1c0b8286e197399d5ae430 (diff) | |
download | gsoc2013-evolution-909774170062bd74c6f3554b25f0d06054fb9c8b.tar.gz gsoc2013-evolution-909774170062bd74c6f3554b25f0d06054fb9c8b.tar.zst gsoc2013-evolution-909774170062bd74c6f3554b25f0d06054fb9c8b.zip |
Rewrite the content piece of evolution.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mail/e-mail-shell-content.c | 932 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-content.h | 3 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 26 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.c | 22 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view.c | 8 | ||||
-rw-r--r-- | modules/mail/evolution-module-mail.c | 3 |
6 files changed, 47 insertions, 947 deletions
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index 7cfa678aff..54441b4466 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -38,6 +38,8 @@ #include "mail-ops.h" #include "message-list.h" +#include "e-mail-view.h" +#include "e-mail-paned-view.h" #include "e-mail-reader.h" #include "e-mail-reader-utils.h" #include "e-mail-shell-backend.h" @@ -47,351 +49,21 @@ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_MAIL_SHELL_CONTENT, EMailShellContentPrivate)) -#define STATE_KEY_GROUP_BY_THREADS "GroupByThreads" -#define STATE_KEY_SELECTED_MESSAGE "SelectedMessage" -#define STATE_KEY_PREVIEW_VISIBLE "PreviewVisible" - struct _EMailShellContentPrivate { - GtkWidget *paned; - GtkWidget *scrolled_window; - GtkWidget *message_list; - GtkWidget *search_bar; - - EMFormatHTMLDisplay *formatter; - GalViewInstance *view_instance; - GtkOrientation orientation; - - /* ETable scrolling hack */ - gdouble default_scrollbar_position; - - guint paned_binding_id; - - /* Signal handler IDs */ - guint message_list_built_id; - - guint preview_visible : 1; - guint show_deleted : 1; + int temp; }; -enum { - PROP_0, - PROP_GROUP_BY_THREADS, - PROP_ORIENTATION, - PROP_PREVIEW_VISIBLE, - PROP_QUOTE_FROM_SELECTION, - PROP_SHOW_DELETED -}; static gpointer parent_class; static GType mail_shell_content_type; static void -mail_shell_content_save_boolean (EMailShellContent *mail_shell_content, - const gchar *key, - gboolean value) -{ - EShellView *shell_view; - EShellContent *shell_content; - EMailReader *reader; - GKeyFile *key_file; - const gchar *folder_uri; - gchar *group_name; - - shell_content = E_SHELL_CONTENT (mail_shell_content); - shell_view = e_shell_content_get_shell_view (shell_content); - key_file = e_shell_view_get_state_key_file (shell_view); - - reader = E_MAIL_READER (mail_shell_content); - folder_uri = e_mail_reader_get_folder_uri (reader); - - if (folder_uri == NULL) - return; - - group_name = g_strdup_printf ("Folder %s", folder_uri); - g_key_file_set_boolean (key_file, group_name, key, value); - g_free (group_name); - - e_shell_view_set_state_dirty (shell_view); -} - -static void -mail_shell_content_message_list_built_cb (EMailShellContent *mail_shell_content, - MessageList *message_list) -{ - EMailShellContentPrivate *priv = mail_shell_content->priv; - EShellView *shell_view; - EShellWindow *shell_window; - EShellContent *shell_content; - GKeyFile *key_file; - - g_signal_handler_disconnect ( - message_list, priv->message_list_built_id); - priv->message_list_built_id = 0; - - shell_content = E_SHELL_CONTENT (mail_shell_content); - shell_view = e_shell_content_get_shell_view (shell_content); - shell_window = e_shell_view_get_shell_window (shell_view); - - key_file = e_shell_view_get_state_key_file (shell_view); - - if (message_list->cursor_uid != NULL) - ; /* do nothing */ - - else if (message_list->folder_uri == NULL) - ; /* do nothing */ - - else if (e_shell_window_get_safe_mode (shell_window)) - e_shell_window_set_safe_mode (shell_window, FALSE); - - else { - const gchar *folder_uri; - const gchar *key; - gchar *group_name; - gchar *uid; - - key = STATE_KEY_SELECTED_MESSAGE; - folder_uri = message_list->folder_uri; - group_name = g_strdup_printf ("Folder %s", folder_uri); - uid = g_key_file_get_string (key_file, group_name, key, NULL); - g_free (group_name); - - /* Use selection fallbacks if UID is not found. */ - message_list_select_uid (message_list, uid, TRUE); - - g_free (uid); - } -} - -static void -mail_shell_content_display_view_cb (EMailShellContent *mail_shell_content, - GalView *gal_view) -{ - EMailReader *reader; - GtkWidget *message_list; - - reader = E_MAIL_READER (mail_shell_content); - message_list = e_mail_reader_get_message_list (reader); - - if (GAL_IS_VIEW_ETABLE (gal_view)) - gal_view_etable_attach_tree ( - GAL_VIEW_ETABLE (gal_view), - E_TREE (message_list)); -} - -static void -mail_shell_content_message_selected_cb (EMailShellContent *mail_shell_content, - const gchar *message_uid, - MessageList *message_list) -{ - EShellContent *shell_content; - EShellView *shell_view; - GKeyFile *key_file; - const gchar *folder_uri; - const gchar *key; - gchar *group_name; - - folder_uri = message_list->folder_uri; - - /* This also gets triggered when selecting a store name on - * the sidebar such as "On This Computer", in which case - * 'folder_uri' will be NULL. */ - if (folder_uri == NULL) - return; - - shell_content = E_SHELL_CONTENT (mail_shell_content); - shell_view = e_shell_content_get_shell_view (shell_content); - key_file = e_shell_view_get_state_key_file (shell_view); - - key = STATE_KEY_SELECTED_MESSAGE; - group_name = g_strdup_printf ("Folder %s", folder_uri); - - if (message_uid != NULL) - g_key_file_set_string (key_file, group_name, key, message_uid); - else - g_key_file_remove_key (key_file, group_name, key, NULL); - e_shell_view_set_state_dirty (shell_view); - - g_free (group_name); -} - -static void -mail_shell_content_restore_state_cb (EShellWindow *shell_window, - EShellView *shell_view, - EShellContent *shell_content) -{ - EMailShellContentPrivate *priv; - GConfBridge *bridge; - GObject *object; - const gchar *key; - - priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (shell_content); - - /* Bind GObject properties to GConf keys. */ - - bridge = gconf_bridge_get (); - - object = G_OBJECT (priv->paned); - key = "/apps/evolution/mail/display/hpaned_size"; - gconf_bridge_bind_property (bridge, key, object, "hposition"); - - object = G_OBJECT (priv->paned); - key = "/apps/evolution/mail/display/paned_size"; - gconf_bridge_bind_property (bridge, key, object, "vposition"); -} - -static void -mail_shell_content_notify_group_by_threads_cb (EMailReader *reader) -{ - gboolean group_by_threads; - - group_by_threads = e_mail_reader_get_group_by_threads (reader); - - mail_shell_content_save_boolean ( - E_MAIL_SHELL_CONTENT (reader), - STATE_KEY_GROUP_BY_THREADS, group_by_threads); -} - -static GtkOrientation -mail_shell_content_get_orientation (EMailShellContent *mail_shell_content) -{ - return mail_shell_content->priv->orientation; -} - -static void -mail_shell_content_set_orientation (EMailShellContent *mail_shell_content, - GtkOrientation orientation) -{ - mail_shell_content->priv->orientation = orientation; - - g_object_notify (G_OBJECT (mail_shell_content), "orientation"); - - e_mail_shell_content_update_view_instance (mail_shell_content); -} - -static void -mail_shell_content_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_GROUP_BY_THREADS: - e_mail_reader_set_group_by_threads ( - E_MAIL_READER (object), - g_value_get_boolean (value)); - return; - - case PROP_ORIENTATION: - mail_shell_content_set_orientation ( - E_MAIL_SHELL_CONTENT (object), - g_value_get_enum (value)); - return; - - case PROP_PREVIEW_VISIBLE: - e_mail_shell_content_set_preview_visible ( - E_MAIL_SHELL_CONTENT (object), - g_value_get_boolean (value)); - return; - - case PROP_QUOTE_FROM_SELECTION: - e_mail_reader_set_quote_from_selection ( - E_MAIL_READER (object), - g_value_get_boolean (value)); - return; - - case PROP_SHOW_DELETED: - e_mail_shell_content_set_show_deleted ( - E_MAIL_SHELL_CONTENT (object), - g_value_get_boolean (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -mail_shell_content_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_GROUP_BY_THREADS: - g_value_set_boolean ( - value, - e_mail_reader_get_group_by_threads ( - E_MAIL_READER (object))); - return; - - case PROP_ORIENTATION: - g_value_set_enum ( - value, - mail_shell_content_get_orientation ( - E_MAIL_SHELL_CONTENT (object))); - return; - - case PROP_PREVIEW_VISIBLE: - g_value_set_boolean ( - value, - e_mail_shell_content_get_preview_visible ( - E_MAIL_SHELL_CONTENT (object))); - return; - - case PROP_QUOTE_FROM_SELECTION: - g_value_set_boolean ( - value, - e_mail_reader_get_quote_from_selection ( - E_MAIL_READER (object))); - return; - - case PROP_SHOW_DELETED: - g_value_set_boolean ( - value, - e_mail_shell_content_get_show_deleted ( - E_MAIL_SHELL_CONTENT (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void mail_shell_content_dispose (GObject *object) { EMailShellContentPrivate *priv; priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (object); - if (priv->paned != NULL) { - g_object_unref (priv->paned); - priv->paned = NULL; - } - - if (priv->scrolled_window != NULL) { - g_object_unref (priv->scrolled_window); - priv->scrolled_window = NULL; - } - - if (priv->message_list != NULL) { - g_object_unref (priv->message_list); - priv->message_list = NULL; - } - - if (priv->search_bar != NULL) { - g_object_unref (priv->search_bar); - priv->search_bar = NULL; - } - - if (priv->formatter != NULL) { - g_object_unref (priv->formatter); - priv->formatter = NULL; - } - - if (priv->view_instance != NULL) { - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -404,15 +76,10 @@ mail_shell_content_constructed (GObject *object) EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; - ESearchBar *search_bar; - EMailReader *reader; - GtkWidget *message_list; GtkWidget *container; GtkWidget *widget; - EWebView *web_view; priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (object); - priv->formatter = em_format_html_display_new (); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (parent_class)->constructed (object); @@ -422,85 +89,21 @@ mail_shell_content_constructed (GObject *object) shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); - web_view = em_format_html_get_web_view ( - EM_FORMAT_HTML (priv->formatter)); - /* Build content widgets. */ container = GTK_WIDGET (object); - widget = e_paned_new (GTK_ORIENTATION_VERTICAL); + widget = e_mail_paned_view_new (E_SHELL_CONTENT(object)); + E_MAIL_SHELL_CONTENT(object)->view = (EMailView *)widget; gtk_container_add (GTK_CONTAINER (container), widget); - priv->paned = g_object_ref (widget); - gtk_widget_show (widget); - - e_binding_new (object, "orientation", widget, "orientation"); - - container = priv->paned; - - widget = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy ( - GTK_SCROLLED_WINDOW (widget), - GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); - gtk_scrolled_window_set_shadow_type ( - GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - priv->scrolled_window = g_object_ref (widget); - gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE); - gtk_widget_show (widget); - - container = widget; - - widget = message_list_new (shell_backend); - gtk_container_add (GTK_CONTAINER (container), widget); - priv->message_list = g_object_ref (widget); - gtk_widget_show (widget); - - container = priv->paned; - - gtk_widget_show (GTK_WIDGET (web_view)); - - widget = e_preview_pane_new (web_view); - gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE); gtk_widget_show (widget); - e_binding_new (object, "preview-visible", widget, "visible"); - - search_bar = e_preview_pane_get_search_bar (E_PREVIEW_PANE (widget)); - priv->search_bar = g_object_ref (search_bar); - - g_signal_connect_swapped ( - search_bar, "changed", - G_CALLBACK (em_format_redraw), priv->formatter); - - /* Load the view instance. */ - - e_mail_shell_content_update_view_instance ( - E_MAIL_SHELL_CONTENT (shell_content)); - - /* Message list customizations. */ - - reader = E_MAIL_READER (shell_content); - message_list = e_mail_reader_get_message_list (reader); - - g_signal_connect_swapped ( - message_list, "message-selected", - G_CALLBACK (mail_shell_content_message_selected_cb), - shell_content); - - /* Restore pane positions from the last session once - * the shell view is fully initialized and visible. */ - g_signal_connect ( - shell_window, "shell-view-created::mail", - G_CALLBACK (mail_shell_content_restore_state_cb), - shell_content); - - e_mail_reader_connect_headers (reader); } static guint32 mail_shell_content_check_state (EShellContent *shell_content) { - return e_mail_reader_check_state (E_MAIL_READER (shell_content)); + return e_mail_reader_check_state (E_MAIL_READER (E_MAIL_SHELL_CONTENT(shell_content)->view)); } static void @@ -510,196 +113,7 @@ mail_shell_content_focus_search_results (EShellContent *shell_content) priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (shell_content); - gtk_widget_grab_focus (priv->message_list); -} - -static GtkActionGroup * -mail_shell_content_get_action_group (EMailReader *reader) -{ - EShellContent *shell_content; - EShellWindow *shell_window; - EShellView *shell_view; - - shell_content = E_SHELL_CONTENT (reader); - 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); -} - -static EMFormatHTML * -mail_shell_content_get_formatter (EMailReader *reader) -{ - EMailShellContentPrivate *priv; - - priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (reader); - - return EM_FORMAT_HTML (priv->formatter); -} - -static gboolean -mail_shell_content_get_hide_deleted (EMailReader *reader) -{ - EMailShellContent *mail_shell_content; - - mail_shell_content = E_MAIL_SHELL_CONTENT (reader); - - return !e_mail_shell_content_get_show_deleted (mail_shell_content); -} - -static GtkWidget * -mail_shell_content_get_message_list (EMailReader *reader) -{ - EMailShellContentPrivate *priv; - - priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (reader); - - return priv->message_list; -} - -static GtkMenu * -mail_shell_content_get_popup_menu (EMailReader *reader) -{ - EShellView *shell_view; - EShellWindow *shell_window; - EShellContent *shell_content; - GtkUIManager *ui_manager; - GtkWidget *widget; - - shell_content = E_SHELL_CONTENT (reader); - shell_view = e_shell_content_get_shell_view (shell_content); - shell_window = e_shell_view_get_shell_window (shell_view); - - ui_manager = e_shell_window_get_ui_manager (shell_window); - widget = gtk_ui_manager_get_widget (ui_manager, "/mail-preview-popup"); - - return GTK_MENU (widget); -} - -static EShellBackend * -mail_shell_content_get_shell_backend (EMailReader *reader) -{ - EShellContent *shell_content; - EShellView *shell_view; - - shell_content = E_SHELL_CONTENT (reader); - shell_view = e_shell_content_get_shell_view (shell_content); - - return e_shell_view_get_shell_backend (shell_view); -} - -static GtkWindow * -mail_shell_content_get_window (EMailReader *reader) -{ - EShellContent *shell_content; - EShellWindow *shell_window; - EShellView *shell_view; - - shell_content = E_SHELL_CONTENT (reader); - 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_shell_content_set_folder (EMailReader *reader, - CamelFolder *folder, - const gchar *folder_uri) -{ - EShell *shell; - EShellView *shell_view; - EShellWindow *shell_window; - EShellContent *shell_content; - EShellSettings *shell_settings; - EMailShellContentPrivate *priv; - EMailReaderIface *default_iface; - GtkWidget *message_list; - GKeyFile *key_file; - gchar *group_name; - const gchar *key; - gboolean value; - GError *error = NULL; - - priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (reader); - - shell_content = E_SHELL_CONTENT (reader); - shell_view = e_shell_content_get_shell_view (shell_content); - shell_window = e_shell_view_get_shell_window (shell_view); - - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); - - message_list = e_mail_reader_get_message_list (reader); - - message_list_freeze (MESSAGE_LIST (message_list)); - - /* Chain up to interface's default set_folder() method. */ - default_iface = g_type_default_interface_peek (E_TYPE_MAIL_READER); - default_iface->set_folder (reader, folder, folder_uri); - - if (folder == NULL) - goto exit; - - mail_refresh_folder (folder, NULL, NULL); - - /* This is a one-time-only callback. */ - if (MESSAGE_LIST (message_list)->cursor_uid == NULL && - priv->message_list_built_id == 0) - priv->message_list_built_id = g_signal_connect_swapped ( - message_list, "message-list-built", - G_CALLBACK (mail_shell_content_message_list_built_cb), - reader); - - /* Restore the folder's preview and threaded state. */ - - key_file = e_shell_view_get_state_key_file (shell_view); - group_name = g_strdup_printf ("Folder %s", folder_uri); - - key = STATE_KEY_GROUP_BY_THREADS; - value = g_key_file_get_boolean (key_file, group_name, key, &error); - if (error != NULL) { - value = TRUE; - g_clear_error (&error); - } - - e_mail_reader_set_group_by_threads (reader, value); - - key = STATE_KEY_PREVIEW_VISIBLE; - value = g_key_file_get_boolean (key_file, group_name, key, &error); - if (error != NULL) { - value = TRUE; - g_clear_error (&error); - } - - /* XXX This is a little confusing and needs rethought. The - * EShellWindow:safe-mode property blocks automatic message - * selection, but the "mail-safe-list" shell setting blocks - * both the preview pane and automatic message selection. */ - if (e_shell_settings_get_boolean (shell_settings, "mail-safe-list")) { - e_shell_settings_set_boolean ( - shell_settings, "mail-safe-list", FALSE); - e_shell_window_set_safe_mode (shell_window, TRUE); - value = FALSE; - } - - e_mail_shell_content_set_preview_visible ( - E_MAIL_SHELL_CONTENT (shell_content), value); - - g_free (group_name); - -exit: - message_list_thaw (MESSAGE_LIST (message_list)); -} - -static void -mail_shell_content_show_search_bar (EMailReader *reader) -{ - EMailShellContentPrivate *priv; - - priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (reader); - - gtk_widget_show (priv->search_bar); + gtk_widget_grab_focus (e_mail_reader_get_message_list(E_MAIL_READER (E_MAIL_SHELL_CONTENT(shell_content)->view))); } static void @@ -712,8 +126,6 @@ mail_shell_content_class_init (EMailShellContentClass *class) g_type_class_add_private (class, sizeof (EMailShellContentPrivate)); object_class = G_OBJECT_CLASS (class); - object_class->set_property = mail_shell_content_set_property; - object_class->get_property = mail_shell_content_get_property; object_class->dispose = mail_shell_content_dispose; object_class->constructed = mail_shell_content_constructed; @@ -721,54 +133,7 @@ mail_shell_content_class_init (EMailShellContentClass *class) shell_content_class->check_state = mail_shell_content_check_state; shell_content_class->focus_search_results = mail_shell_content_focus_search_results; - /* Inherited from EMailReader */ - g_object_class_override_property ( - object_class, - PROP_GROUP_BY_THREADS, - "group-by-threads"); - - g_object_class_install_property ( - object_class, - PROP_PREVIEW_VISIBLE, - g_param_spec_boolean ( - "preview-visible", - "Preview is Visible", - "Whether the preview pane is visible", - TRUE, - G_PARAM_READWRITE)); - - /* Inherited from EMailReader */ - g_object_class_override_property ( - object_class, - PROP_QUOTE_FROM_SELECTION, - "quote-from-selection"); - g_object_class_install_property ( - object_class, - PROP_SHOW_DELETED, - g_param_spec_boolean ( - "show-deleted", - "Show Deleted", - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_override_property ( - object_class, PROP_ORIENTATION, "orientation"); -} - -static void -mail_shell_content_reader_init (EMailReaderIface *iface) -{ - iface->get_action_group = mail_shell_content_get_action_group; - iface->get_formatter = mail_shell_content_get_formatter; - iface->get_hide_deleted = mail_shell_content_get_hide_deleted; - iface->get_message_list = mail_shell_content_get_message_list; - iface->get_popup_menu = mail_shell_content_get_popup_menu; - iface->get_shell_backend = mail_shell_content_get_shell_backend; - iface->get_window = mail_shell_content_get_window; - iface->set_folder = mail_shell_content_set_folder; - iface->show_search_bar = mail_shell_content_show_search_bar; } static void @@ -777,13 +142,6 @@ mail_shell_content_init (EMailShellContent *mail_shell_content) mail_shell_content->priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (mail_shell_content); - mail_shell_content->priv->preview_visible = TRUE; - - g_signal_connect ( - mail_shell_content, "notify::group-by-threads", - G_CALLBACK (mail_shell_content_notify_group_by_threads_cb), - NULL); - /* Postpone widget construction until we have a shell view. */ } @@ -809,29 +167,10 @@ e_mail_shell_content_register_type (GTypeModule *type_module) NULL /* value_table */ }; - static const GInterfaceInfo orientable_info = { - (GInterfaceInitFunc) NULL, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - - static const GInterfaceInfo reader_info = { - (GInterfaceInitFunc) mail_shell_content_reader_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - mail_shell_content_type = g_type_module_register_type ( type_module, E_TYPE_SHELL_CONTENT, "EMailShellContent", &type_info, 0); - g_type_module_add_interface ( - type_module, mail_shell_content_type, - GTK_TYPE_ORIENTABLE, &orientable_info); - - g_type_module_add_interface ( - type_module, mail_shell_content_type, - E_TYPE_MAIL_READER, &reader_info); } GtkWidget * @@ -844,271 +183,28 @@ e_mail_shell_content_new (EShellView *shell_view) "shell-view", shell_view, NULL); } -gboolean -e_mail_shell_content_get_preview_visible (EMailShellContent *mail_shell_content) -{ - g_return_val_if_fail ( - E_IS_MAIL_SHELL_CONTENT (mail_shell_content), FALSE); - - return mail_shell_content->priv->preview_visible; -} - -void -e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content, - gboolean preview_visible) -{ - g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content)); - - if (preview_visible == mail_shell_content->priv->preview_visible) - return; - - /* If we're showing the preview, tell EMailReader to reload the - * selected message. This should force it to download the full - * message if necessary, so we don't get an empty preview. */ - if (preview_visible) { - EMailReader *reader; - GtkWidget *message_list; - const gchar *cursor_uid; - - reader = E_MAIL_READER (mail_shell_content); - message_list = e_mail_reader_get_message_list (reader); - cursor_uid = MESSAGE_LIST (message_list)->cursor_uid; - - if (cursor_uid != NULL) - e_mail_reader_set_message (reader, cursor_uid); - } - - mail_shell_content->priv->preview_visible = preview_visible; - - mail_shell_content_save_boolean ( - mail_shell_content, - STATE_KEY_PREVIEW_VISIBLE, preview_visible); - - g_object_notify (G_OBJECT (mail_shell_content), "preview-visible"); -} - EShellSearchbar * e_mail_shell_content_get_searchbar (EMailShellContent *mail_shell_content) { - EShellView *shell_view; - EShellContent *shell_content; - GtkWidget *widget; - - g_return_val_if_fail ( - E_IS_MAIL_SHELL_CONTENT (mail_shell_content), NULL); - - shell_content = E_SHELL_CONTENT (mail_shell_content); - shell_view = e_shell_content_get_shell_view (shell_content); - widget = e_shell_view_get_searchbar (shell_view); - - return E_SHELL_SEARCHBAR (widget); -} - -gboolean -e_mail_shell_content_get_show_deleted (EMailShellContent *mail_shell_content) -{ - g_return_val_if_fail ( - E_IS_MAIL_SHELL_CONTENT (mail_shell_content), FALSE); - - return mail_shell_content->priv->show_deleted; + return e_mail_view_get_searchbar (mail_shell_content->view); } void -e_mail_shell_content_set_show_deleted (EMailShellContent *mail_shell_content, - gboolean show_deleted) +e_mail_shell_content_set_search_strings (EMailShellContent *mail_shell_content, + GSList *search_strings) { - g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content)); - - mail_shell_content->priv->show_deleted = show_deleted; - - g_object_notify (G_OBJECT (mail_shell_content), "show-deleted"); + e_mail_view_set_search_strings (mail_shell_content->view, search_strings); } GalViewInstance * e_mail_shell_content_get_view_instance (EMailShellContent *mail_shell_content) { - g_return_val_if_fail ( - E_IS_MAIL_SHELL_CONTENT (mail_shell_content), NULL); - - return mail_shell_content->priv->view_instance; -} - -void -e_mail_shell_content_set_search_strings (EMailShellContent *mail_shell_content, - GSList *search_strings) -{ - ESearchBar *search_bar; - ESearchingTokenizer *tokenizer; - - g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content)); - - search_bar = E_SEARCH_BAR (mail_shell_content->priv->search_bar); - tokenizer = e_search_bar_get_tokenizer (search_bar); - - e_searching_tokenizer_set_secondary_case_sensitivity (tokenizer, FALSE); - e_searching_tokenizer_set_secondary_search_string (tokenizer, NULL); - - while (search_strings != NULL) { - e_searching_tokenizer_add_secondary_search_string ( - tokenizer, search_strings->data); - search_strings = g_slist_next (search_strings); - } - - e_search_bar_changed (search_bar); + return e_mail_view_get_view_instance (mail_shell_content->view); } void e_mail_shell_content_update_view_instance (EMailShellContent *mail_shell_content) { - EMailReader *reader; - EShell *shell; - EShellContent *shell_content; - EShellView *shell_view; - EShellWindow *shell_window; - EShellViewClass *shell_view_class; - EShellSettings *shell_settings; - GalViewCollection *view_collection; - GalViewInstance *view_instance; - CamelFolder *folder; - GtkOrientable *orientable; - GtkOrientation orientation; - gboolean outgoing_folder; - gboolean show_vertical_view; - const gchar *folder_uri; - gchar *view_id; - - g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content)); - - shell_content = E_SHELL_CONTENT (mail_shell_content); - shell_view = e_shell_content_get_shell_view (shell_content); - shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); - view_collection = shell_view_class->view_collection; - - shell_window = e_shell_view_get_shell_window (shell_view); - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); - - reader = E_MAIL_READER (mail_shell_content); - folder = e_mail_reader_get_folder (reader); - folder_uri = e_mail_reader_get_folder_uri (reader); - - /* If no folder is selected, return silently. */ - if (folder == NULL) - return; - - /* If we have a folder, we should also have a URI. */ - g_return_if_fail (folder_uri != NULL); - - if (mail_shell_content->priv->view_instance != NULL) { - g_object_unref (mail_shell_content->priv->view_instance); - mail_shell_content->priv->view_instance = NULL; - } - - view_id = mail_config_folder_to_safe_url (folder); - if (e_shell_settings_get_boolean (shell_settings, "mail-global-view-setting")) - view_instance = e_shell_view_new_view_instance (shell_view, "global_view_setting"); - else - view_instance = e_shell_view_new_view_instance (shell_view, view_id); - - mail_shell_content->priv->view_instance = view_instance; - - orientable = GTK_ORIENTABLE (mail_shell_content); - orientation = gtk_orientable_get_orientation (orientable); - show_vertical_view = (orientation == GTK_ORIENTATION_HORIZONTAL); - - if (show_vertical_view) { - gchar *filename; - gchar *safe_view_id; - - /* Force the view instance into vertical view. */ - - g_free (view_instance->custom_filename); - g_free (view_instance->current_view_filename); - - safe_view_id = g_strdup (view_id); - e_filename_make_safe (safe_view_id); - - filename = g_strdup_printf ( - "custom_wide_view-%s.xml", safe_view_id); - view_instance->custom_filename = g_build_filename ( - view_collection->local_dir, filename, NULL); - g_free (filename); - - filename = g_strdup_printf ( - "current_wide_view-%s.xml", safe_view_id); - view_instance->current_view_filename = g_build_filename ( - view_collection->local_dir, filename, NULL); - g_free (filename); - - g_free (safe_view_id); - } - - g_free (view_id); - - outgoing_folder = - em_utils_folder_is_drafts (folder, folder_uri) || - em_utils_folder_is_outbox (folder, folder_uri) || - em_utils_folder_is_sent (folder, folder_uri); - - if (outgoing_folder) { - if (show_vertical_view) - gal_view_instance_set_default_view ( - view_instance, "Wide_View_Sent"); - else - gal_view_instance_set_default_view ( - view_instance, "As_Sent_Folder"); - } else if (show_vertical_view) { - gal_view_instance_set_default_view ( - view_instance, "Wide_View_Normal"); - } - - gal_view_instance_load (view_instance); - - if (!gal_view_instance_exists (view_instance)) { - gchar *state_filename; - - state_filename = mail_config_folder_to_cachename ( - folder, "et-header-"); - - if (g_file_test (state_filename, G_FILE_TEST_IS_REGULAR)) { - ETableSpecification *spec; - ETableState *state; - GalView *view; - gchar *spec_filename; - - spec = e_table_specification_new (); - spec_filename = g_build_filename ( - EVOLUTION_ETSPECDIR, - "message-list.etspec", - NULL); - e_table_specification_load_from_file ( - spec, spec_filename); - g_free (spec_filename); - - state = e_table_state_new (); - view = gal_view_etable_new (spec, ""); - - e_table_state_load_from_file ( - state, state_filename); - gal_view_etable_set_state ( - GAL_VIEW_ETABLE (view), state); - gal_view_instance_set_custom_view ( - view_instance, view); - - g_object_unref (state); - g_object_unref (view); - g_object_unref (spec); - } - - g_free (state_filename); - } - - g_signal_connect_swapped ( - view_instance, "display-view", - G_CALLBACK (mail_shell_content_display_view_cb), - mail_shell_content); - - mail_shell_content_display_view_cb ( - mail_shell_content, - gal_view_instance_get_current_view (view_instance)); + e_mail_view_update_view_instance (mail_shell_content->view); } + diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h index a5263bc561..b0a89361cb 100644 --- a/modules/mail/e-mail-shell-content.h +++ b/modules/mail/e-mail-shell-content.h @@ -25,7 +25,7 @@ #include <shell/e-shell-content.h> #include <shell/e-shell-searchbar.h> #include <shell/e-shell-view.h> - +#include <mail/e-mail-view.h> #include <mail/em-format-html-display.h> /* Standard GObject macros */ @@ -55,6 +55,7 @@ typedef struct _EMailShellContentPrivate EMailShellContentPrivate; struct _EMailShellContent { EShellContent parent; + EMailView *view; EMailShellContentPrivate *priv; }; diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 720f2da87e..009b0c1bcd 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -104,7 +104,7 @@ action_mail_create_search_folder_cb (GtkAction *action, if (search_text == NULL || *search_text == '\0') search_text = "''"; - reader = E_MAIL_READER (mail_shell_content); + reader = E_MAIL_READER (mail_shell_content->view); folder_uri = e_mail_reader_get_folder_uri (reader); search_rule = vfolder_clone_rule (search_rule); @@ -228,7 +228,7 @@ action_mail_folder_mark_all_as_read_cb (GtkAction *action, shell_window = e_shell_view_get_shell_window (shell_view); parent = GTK_WINDOW (shell_window); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); folder = e_mail_reader_get_folder (reader); g_return_if_fail (folder != NULL); @@ -367,7 +367,7 @@ action_mail_folder_select_thread_cb (GtkAction *action, GtkWidget *message_list; EMailReader *reader; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); message_list_select_thread (MESSAGE_LIST (message_list)); @@ -380,7 +380,7 @@ action_mail_folder_select_subthread_cb (GtkAction *action, GtkWidget *message_list; EMailReader *reader; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); message_list_select_subthread (MESSAGE_LIST (message_list)); @@ -428,7 +428,7 @@ action_mail_label_cb (GtkToggleAction *action, tag = g_object_get_data (G_OBJECT (action), "tag"); g_return_if_fail (tag != NULL); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); folder = e_mail_reader_get_folder (reader); uids = e_mail_reader_get_selected_uids (reader); @@ -502,7 +502,7 @@ action_mail_label_new_cb (GtkAction *action, gtk_tree_model_iter_nth_child (model, &iter, NULL, n_children - 1); label_tag = e_mail_label_list_store_get_tag (store, &iter); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); folder = e_mail_reader_get_folder (reader); uids = e_mail_reader_get_selected_uids (reader); @@ -542,7 +542,7 @@ action_mail_label_none_cb (GtkAction *action, tree_model = e_shell_settings_get_object ( shell_settings, "mail-label-list-store"); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); folder = e_mail_reader_get_folder (reader); uids = e_mail_reader_get_selected_uids (reader); @@ -577,7 +577,7 @@ action_mail_show_deleted_cb (GtkToggleAction *action, EMailReader *reader; gboolean active; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); active = gtk_toggle_action_get_active (action); @@ -612,7 +612,7 @@ action_mail_smart_backward_cb (GtkAction *action, mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); formatter = e_mail_reader_get_formatter (reader); message_list = e_mail_reader_get_message_list (reader); @@ -678,7 +678,7 @@ action_mail_smart_forward_cb (GtkAction *action, mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); formatter = e_mail_reader_get_formatter (reader); message_list = e_mail_reader_get_message_list (reader); @@ -730,7 +730,7 @@ action_mail_threads_collapse_all_cb (GtkAction *action, GtkWidget *message_list; EMailReader *reader; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); message_list_set_threaded_collapse_all (MESSAGE_LIST (message_list)); @@ -743,7 +743,7 @@ action_mail_threads_expand_all_cb (GtkAction *action, GtkWidget *message_list; EMailReader *reader; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); message_list_set_threaded_expand_all (MESSAGE_LIST (message_list)); @@ -1498,7 +1498,7 @@ e_mail_shell_view_update_popup_labels (EMailShellView *mail_shell_view) gtk_ui_manager_remove_ui (ui_manager, merge_id); e_action_group_remove_all_actions (action_group); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); uids = e_mail_reader_get_selected_uids (reader); valid = gtk_tree_model_get_iter_first (tree_model, &iter); diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 50cad27444..688dcd8a78 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -37,7 +37,7 @@ mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view, gboolean folder_selected; shell_view = E_SHELL_VIEW (mail_shell_view); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); folder_selected = !(flags & CAMEL_FOLDER_NOSELECT) && @@ -89,7 +89,7 @@ ctrl: emit: /* Forward the key press to the EMailReader interface. */ - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); g_signal_emit_by_name (reader, "key-press-event", event, &handled); exit: @@ -107,7 +107,7 @@ mail_shell_view_folder_tree_selection_done_cb (EMailShellView *mail_shell_view, const gchar *list_uri; gchar *tree_uri; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; @@ -231,7 +231,7 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view, return FALSE; shell_view = E_SHELL_VIEW (mail_shell_view); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); menu = e_mail_reader_get_popup_menu (reader); e_shell_view_update_actions (shell_view); @@ -291,7 +291,7 @@ mail_shell_view_scroll_cb (EMailShellView *mail_shell_view, if (!magic_spacebar) return; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); if (scroll_type == GTK_SCROLL_PAGE_FORWARD) @@ -325,7 +325,7 @@ mail_shell_view_prepare_for_quit_cb (EMailShellView *mail_shell_view, * and this is the last EMailShellView instance. Synchronize * the currently selected folder before we terminate. */ - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); folder = e_mail_reader_get_folder (reader); @@ -458,7 +458,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) priv->mail_shell_content = g_object_ref (shell_content); priv->mail_shell_sidebar = g_object_ref (shell_sidebar); - reader = E_MAIL_READER (shell_content); + reader = E_MAIL_READER (E_MAIL_SHELL_CONTENT(shell_content)->view); formatter = e_mail_reader_get_formatter (reader); message_list = e_mail_reader_get_message_list (reader); @@ -671,7 +671,7 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view) mail_shell_content = mail_shell_view->priv->mail_shell_content; searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); - reader = E_MAIL_READER (mail_shell_content); + reader = E_MAIL_READER (mail_shell_content->view); folder = e_mail_reader_get_folder (reader); folder_uri = e_mail_reader_get_folder_uri (reader); @@ -738,7 +738,7 @@ e_mail_shell_view_create_filter_from_selected (EMailShellView *mail_shell_view, g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); folder = e_mail_reader_get_folder (reader); folder_uri = e_mail_reader_get_folder_uri (reader); uids = e_mail_reader_get_selected_uids (reader); @@ -800,7 +800,7 @@ e_mail_shell_view_create_vfolder_from_selected (EMailShellView *mail_shell_view, g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); folder = e_mail_reader_get_folder (reader); folder_uri = e_mail_reader_get_folder_uri (reader); uids = e_mail_reader_get_selected_uids (reader); @@ -848,7 +848,7 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view) shell_view = E_SHELL_VIEW (mail_shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); - reader = E_MAIL_READER (mail_shell_content); + reader = E_MAIL_READER (mail_shell_content->view); folder = e_mail_reader_get_folder (reader); folder_uri = e_mail_reader_get_folder_uri (reader); diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index f3b70433bf..5a469d8379 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -122,7 +122,7 @@ mail_shell_view_show_search_results_folder (EMailShellView *mail_shell_view, GtkWidget *message_list; EMailReader *reader; - reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content); + reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content->view); message_list = e_mail_reader_get_message_list (reader); message_list_freeze (MESSAGE_LIST (message_list)); @@ -180,7 +180,7 @@ mail_shell_view_toggled (EShellView *shell_view) priv->merge_id = e_ui_manager_add_ui_from_file ( E_UI_MANAGER (ui_manager), basename); e_mail_reader_create_charset_menu ( - E_MAIL_READER (priv->mail_shell_content), + E_MAIL_READER (priv->mail_shell_content->view), ui_manager, priv->merge_id); } else if (!view_is_active && priv->merge_id != 0) { gtk_ui_manager_remove_ui (ui_manager, priv->merge_id); @@ -248,7 +248,7 @@ mail_shell_view_execute_search (EShellView *shell_view) folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_tree)); - reader = E_MAIL_READER (shell_content); + reader = E_MAIL_READER (E_MAIL_SHELL_CONTENT (shell_content)->view); folder = e_mail_reader_get_folder (reader); folder_uri = e_mail_reader_get_folder_uri (reader); message_list = e_mail_reader_get_message_list (reader); @@ -795,7 +795,7 @@ mail_shell_view_update_actions (EShellView *shell_view) shell_window = e_shell_view_get_shell_window (shell_view); mail_shell_content = mail_shell_view->priv->mail_shell_content; - reader = E_MAIL_READER (mail_shell_content); + reader = E_MAIL_READER (mail_shell_content->view); state = e_mail_reader_check_state (reader); e_mail_reader_update_actions (reader, state); diff --git a/modules/mail/evolution-module-mail.c b/modules/mail/evolution-module-mail.c index 9e9744569b..24adc5729f 100644 --- a/modules/mail/evolution-module-mail.c +++ b/modules/mail/evolution-module-mail.c @@ -33,6 +33,8 @@ #include "e-mail-config-format-html.h" #include "e-mail-config-web-view.h" +#include "mail/e-mail-paned-view.h" + /* Module Entry Points */ void e_module_load (GTypeModule *type_module); void e_module_unload (GTypeModule *type_module); @@ -51,6 +53,7 @@ e_module_load (GTypeModule *type_module) e_mail_shell_backend_register_type (type_module); e_mail_shell_content_register_type (type_module); + e_mail_paned_view_register_type (type_module); e_mail_shell_sidebar_register_type (type_module); e_mail_shell_view_register_type (type_module); |