diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/Makefile.am | 4 | ||||
-rw-r--r-- | mail/e-mail-folder-pane.c | 804 | ||||
-rw-r--r-- | mail/e-mail-folder-pane.h | 16 | ||||
-rw-r--r-- | mail/e-mail-message-pane.c | 782 | ||||
-rw-r--r-- | mail/e-mail-message-pane.h | 16 | ||||
-rw-r--r-- | mail/e-mail-notebook-view.c | 220 | ||||
-rw-r--r-- | mail/e-mail-notebook-view.h | 17 | ||||
-rw-r--r-- | mail/e-mail-paned-view.c | 59 | ||||
-rw-r--r-- | mail/e-mail-paned-view.h | 10 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 16 | ||||
-rw-r--r-- | mail/e-mail-reader.h | 2 | ||||
-rw-r--r-- | mail/e-mail-view.c | 63 | ||||
-rw-r--r-- | mail/e-mail-view.h | 16 |
13 files changed, 468 insertions, 1557 deletions
diff --git a/mail/Makefile.am b/mail/Makefile.am index 4ddb9ccf89..daa6edaf6e 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -36,6 +36,8 @@ libevolution_mail_la_CPPFLAGS = \ mailinclude_HEADERS = \ e-mail-view.h \ + e-mail-folder-pane.h \ + e-mail-message-pane.h \ e-mail-paned-view.h \ e-mail-notebook-view.h \ e-mail-attachment-bar.h \ @@ -96,6 +98,8 @@ mailinclude_HEADERS = \ libevolution_mail_la_SOURCES = \ e-mail-view.c \ + e-mail-folder-pane.c \ + e-mail-message-pane.c \ e-mail-paned-view.c \ e-mail-notebook-view.c \ e-mail-attachment-bar.c \ diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c index 1b9632778e..be05cb3fca 100644 --- a/mail/e-mail-folder-pane.c +++ b/mail/e-mail-folder-pane.c @@ -43,366 +43,78 @@ ((obj), E_TYPE_MAIL_FOLDER_PANE, EMailFolderPanePrivate)) struct _EMailFolderPanePrivate { - GtkUIManager *ui_manager; - EFocusTracker *focus_tracker; - EShellBackend *shell_backend; - GtkActionGroup *action_group; - EMFormatHTMLDisplay *formatter; - - GtkWidget *main_menu; - GtkWidget *main_toolbar; - GtkWidget *message_list; - GtkWidget *search_bar; - GtkWidget *statusbar; - - guint show_deleted : 1; + int fo; }; enum { PROP_0, - PROP_FOCUS_TRACKER, - PROP_GROUP_BY_THREADS, - PROP_SHELL_BACKEND, - PROP_SHOW_DELETED, - PROP_UI_MANAGER + PROP_PREVIEW_VISIBLE, }; static gpointer parent_class; -/* This is too trivial to put in a file. - * It gets merged with the EMailReader UI. */ -static const gchar *ui = -"<ui>" -" <menubar name='main-menu'>" -" <menu action='file-menu'>" -" <placeholder name='file-actions'/>" -" <placeholder name='print-actions'/>" -" <separator/>" -" <menuitem action='close'/>" -" </menu>" -" <menu action='edit-menu'>" -" <placeholder name='selection-actions'>" -" <menuitem action='cut-clipboard'/>" -" <menuitem action='copy-clipboard'/>" -" <menuitem action='paste-clipboard'/>" -" <separator/>" -" <menuitem action='select-all'/>" -" </placeholder>" -" </menu>" -" </menubar>" -"</ui>"; static void -action_close_cb (GtkAction *action, - EMailFolderPane *browser) -{ - e_mail_folder_pane_close (browser); -} - -static GtkActionEntry mail_folder_pane_entries[] = { - - { "close", - GTK_STOCK_CLOSE, - NULL, - NULL, - N_("Close this window"), - G_CALLBACK (action_close_cb) }, - - { "copy-clipboard", - GTK_STOCK_COPY, - NULL, - NULL, - N_("Copy the selection"), - NULL }, /* Handled by EFocusTracker */ - - { "cut-clipboard", - GTK_STOCK_CUT, - NULL, - NULL, - N_("Cut the selection"), - NULL }, /* Handled by EFocusTracker */ - - { "paste-clipboard", - GTK_STOCK_PASTE, - NULL, - NULL, - N_("Paste the clipboard"), - NULL }, /* Handled by EFocusTracker */ - - { "select-all", - GTK_STOCK_SELECT_ALL, - NULL, - NULL, - N_("Select all text"), - NULL }, /* Handled by EFocusTracker */ - - /*** Menus ***/ - - { "file-menu", - NULL, - N_("_File"), - NULL, - NULL, - NULL }, - - { "edit-menu", - NULL, - N_("_Edit"), - NULL, - NULL, - NULL }, - - { "view-menu", - NULL, - N_("_View"), - NULL, - NULL, - NULL } -}; - -static EPopupActionEntry mail_folder_pane_popup_entries[] = { - - { "popup-copy-clipboard", - NULL, - "copy-clipboard" } -}; - -static void -mail_folder_pane_menu_item_select_cb (EMailFolderPane *browser, - GtkWidget *widget) -{ - GtkAction *action; - GtkActivatable *activatable; - GtkStatusbar *statusbar; - const gchar *tooltip; - guint context_id; - gpointer data; - - activatable = GTK_ACTIVATABLE (widget); - action = gtk_activatable_get_related_action (activatable); - tooltip = gtk_action_get_tooltip (action); - - data = g_object_get_data (G_OBJECT (widget), "context-id"); - context_id = GPOINTER_TO_UINT (data); - - if (tooltip == NULL) - return; - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - gtk_statusbar_push (statusbar, context_id, tooltip); -} - -static void -mail_folder_pane_menu_item_deselect_cb (EMailFolderPane *browser, - GtkWidget *menu_item) -{ - GtkStatusbar *statusbar; - guint context_id; - gpointer data; - - data = g_object_get_data (G_OBJECT (menu_item), "context-id"); - context_id = GPOINTER_TO_UINT (data); - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - gtk_statusbar_pop (statusbar, context_id); -} - -static void -mail_folder_pane_connect_proxy_cb (EMailFolderPane *browser, - GtkAction *action, - GtkWidget *proxy) +mail_folder_pane_dispose (GObject *object) { - GtkStatusbar *statusbar; - guint context_id; - - if (!GTK_IS_MENU_ITEM (proxy)) - return; - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - context_id = gtk_statusbar_get_context_id (statusbar, G_STRFUNC); - - g_object_set_data ( - G_OBJECT (proxy), "context-id", - GUINT_TO_POINTER (context_id)); + EMailFolderPanePrivate *priv; - g_signal_connect_swapped ( - proxy, "select", - G_CALLBACK (mail_folder_pane_menu_item_select_cb), browser); + priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (object); - g_signal_connect_swapped ( - proxy, "deselect", - G_CALLBACK (mail_folder_pane_menu_item_deselect_cb), browser); + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); } static void -mail_folder_pane_message_selected_cb (EMailFolderPane *browser, - const gchar *uid) +mail_folder_pane_constructed (GObject *object) { - EMFormatHTML *formatter; - CamelMessageInfo *info; - CamelFolder *folder; - EMailReader *reader; - EWebView *web_view; - const gchar *title; - - if (uid == NULL) - return; - - reader = E_MAIL_READER (browser); - folder = e_mail_reader_get_folder (reader); - formatter = e_mail_reader_get_formatter (reader); - web_view = em_format_html_get_web_view (formatter); - - info = camel_folder_get_message_info (folder, uid); - - if (info == NULL) - return; - - title = camel_message_info_subject (info); - if (title == NULL || *title == '\0') - title = _("(No Subject)"); - - gtk_widget_grab_focus (GTK_WIDGET (web_view)); - - camel_folder_free_message_info (folder, info); -} + /* Chain up to parent's constructed() method. */ + if (G_OBJECT_CLASS (parent_class)->constructed) + G_OBJECT_CLASS (parent_class)->constructed (object); -static gboolean -close_on_idle_cb (gpointer browser) -{ - e_mail_folder_pane_close (browser); - return FALSE; } static void -mail_folder_pane_message_list_built_cb (EMailFolderPane *browser, - MessageList *message_list) +folder_pane_set_preview_visible (EMailPanedView *view, + gboolean preview_visible) { - g_return_if_fail (E_IS_MAIL_FOLDER_PANE (browser)); - g_return_if_fail (IS_MESSAGE_LIST (message_list)); - - if (!message_list_count (message_list)) - g_idle_add (close_on_idle_cb, browser); + return; } static gboolean -mail_folder_pane_popup_event_cb (EMailFolderPane *browser, - GdkEventButton *event, - const gchar *uri) +folder_pane_get_preview_visible (EMailPanedView *view) { - EMailReader *reader; - GtkMenu *menu; - if (uri != NULL) - return FALSE; - - reader = E_MAIL_READER (browser); - menu = e_mail_reader_get_popup_menu (reader); - - e_mail_reader_update_actions (reader); - - if (event == NULL) - gtk_menu_popup ( - menu, NULL, NULL, NULL, NULL, - 0, gtk_get_current_event_time ()); - else - gtk_menu_popup ( - menu, NULL, NULL, NULL, NULL, - event->button, event->time); - - return TRUE; -} - -static void -mail_folder_pane_status_message_cb (EMailFolderPane *browser, - const gchar *status_message) -{ - GtkStatusbar *statusbar; - guint context_id; - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - context_id = gtk_statusbar_get_context_id (statusbar, G_STRFUNC); - - /* Always pop first. This prevents messages from piling up. */ - gtk_statusbar_pop (statusbar, context_id); - - if (status_message != NULL && *status_message != '\0') - gtk_statusbar_push (statusbar, context_id, status_message); -} - -static void -mail_folder_pane_set_shell_backend (EMailFolderPane *browser, - EShellBackend *shell_backend) -{ - g_return_if_fail (browser->priv->shell_backend == NULL); - - browser->priv->shell_backend = g_object_ref (shell_backend); + return FALSE; } static void -mail_folder_pane_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +mail_folder_pane_get_property (GObject *object, + guint property_id, + 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)); + case PROP_PREVIEW_VISIBLE: + g_value_set_boolean ( + value, + FALSE); return; - case PROP_SHELL_BACKEND: - mail_folder_pane_set_shell_backend ( - E_MAIL_FOLDER_PANE (object), - g_value_get_object (value)); - return; - case PROP_SHOW_DELETED: - e_mail_folder_pane_set_show_deleted ( - E_MAIL_FOLDER_PANE (object), - g_value_get_boolean (value)); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -mail_folder_pane_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +mail_folder_pane_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { - case PROP_FOCUS_TRACKER: - g_value_set_object ( - value, e_mail_folder_pane_get_focus_tracker ( - E_MAIL_FOLDER_PANE (object))); - return; - - case PROP_GROUP_BY_THREADS: - g_value_set_boolean ( - value, e_mail_reader_get_group_by_threads ( - E_MAIL_READER (object))); - return; - - case PROP_SHELL_BACKEND: - g_value_set_object ( - value, e_mail_reader_get_shell_backend ( - E_MAIL_READER (object))); - return; - - case PROP_SHOW_DELETED: - g_value_set_boolean ( - value, e_mail_folder_pane_get_show_deleted ( - E_MAIL_FOLDER_PANE (object))); - return; - - case PROP_UI_MANAGER: - g_value_set_object ( - value, e_mail_folder_pane_get_ui_manager ( - E_MAIL_FOLDER_PANE (object))); + case PROP_PREVIEW_VISIBLE: return; } @@ -410,416 +122,52 @@ mail_folder_pane_get_property (GObject *object, } static void -mail_folder_pane_dispose (GObject *object) +mfp_open_selected_mail (EMailPanedView *view) { - EMailFolderPanePrivate *priv; - - priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (object); - - if (priv->ui_manager != NULL) { - g_object_unref (priv->ui_manager); - priv->ui_manager = NULL; - } - - if (priv->focus_tracker != NULL) { - g_object_unref (priv->focus_tracker); - priv->focus_tracker = NULL; - } - - if (priv->shell_backend != NULL) { - g_object_unref (priv->shell_backend); - priv->shell_backend = NULL; - } - - if (priv->action_group != NULL) { - g_object_unref (priv->action_group); - priv->action_group = NULL; - } + GPtrArray *uids; + int i; - if (priv->formatter != NULL) { - g_object_unref (priv->formatter); - priv->formatter = NULL; + uids = e_mail_reader_get_selected_uids (E_MAIL_READER(view)); + for (i=0; i<uids->len; i++) { + g_signal_emit_by_name (view, "open-mail", uids->pdata[i]); } - - if (priv->main_menu != NULL) { - g_object_unref (priv->main_menu); - priv->main_menu = NULL; - } - - if (priv->main_toolbar != NULL) { - g_object_unref (priv->main_toolbar); - priv->main_toolbar = NULL; - } - - if (priv->message_list != NULL) { - /* This will cancel a regen operation. */ - gtk_widget_destroy (priv->message_list); - priv->message_list = NULL; - } - - if (priv->search_bar != NULL) { - g_object_unref (priv->search_bar); - priv->search_bar = NULL; - } - - if (priv->statusbar != NULL) { - g_object_unref (priv->statusbar); - priv->statusbar = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + + printf("I WIN\n"); } static void -mail_folder_pane_constructed (GObject *object) -{ - EMailFolderPanePrivate *priv; - EMFormatHTML *formatter; - EMailReader *reader; - EShellBackend *shell_backend; - EShell *shell; - EFocusTracker *focus_tracker; - ESearchBar *search_bar; - GConfBridge *bridge; - GtkAccelGroup *accel_group; - GtkActionGroup *action_group; - GtkAction *action; - GtkUIManager *ui_manager; - GtkWidget *container; - GtkWidget *widget; - EWebView *web_view; - const gchar *domain; - const gchar *key; - const gchar *id; - guint merge_id; - - /* Chain up to parent's constructed() method. */ - if (G_OBJECT_CLASS (parent_class)->constructed) - G_OBJECT_CLASS (parent_class)->constructed (object); - - priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (object); - - reader = E_MAIL_READER (object); - - shell_backend = e_mail_reader_get_shell_backend (reader); - shell = e_shell_backend_get_shell (shell_backend); - - ui_manager = e_ui_manager_new (); - e_shell_configure_ui_manager (shell, E_UI_MANAGER (ui_manager)); - - priv->ui_manager = ui_manager; - domain = GETTEXT_PACKAGE; - - formatter = e_mail_reader_get_formatter (reader); - - web_view = em_format_html_get_web_view (formatter); - - /* The message list is a widget, but it is not shown in the browser. - * Unfortunately, the widget is inseparable from its model, and the - * model is all we need. */ - priv->message_list = message_list_new (shell_backend); - g_object_ref_sink (priv->message_list); - - g_signal_connect_swapped ( - priv->message_list, "message-selected", - G_CALLBACK (mail_folder_pane_message_selected_cb), object); - - g_signal_connect_swapped ( - priv->message_list, "message-list-built", - G_CALLBACK (mail_folder_pane_message_list_built_cb), object); - - g_signal_connect_swapped ( - web_view, "popup-event", - G_CALLBACK (mail_folder_pane_popup_event_cb), object); - - g_signal_connect_swapped ( - web_view, "status-message", - G_CALLBACK (mail_folder_pane_status_message_cb), object); - - e_mail_reader_init (reader); - - action_group = priv->action_group; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_action_group_add_actions ( - action_group, mail_folder_pane_entries, - G_N_ELEMENTS (mail_folder_pane_entries), object); - e_action_group_add_popup_actions ( - action_group, mail_folder_pane_popup_entries, - G_N_ELEMENTS (mail_folder_pane_popup_entries)); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - e_ui_manager_add_ui_from_file ( - E_UI_MANAGER (ui_manager), E_MAIL_READER_UI_DEFINITION); - e_ui_manager_add_ui_from_string ( - E_UI_MANAGER (ui_manager), ui, NULL); - - merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (ui_manager)); - e_mail_reader_create_charset_menu (reader, ui_manager, merge_id); - - accel_group = gtk_ui_manager_get_accel_group (ui_manager); - gtk_window_add_accel_group (GTK_WINDOW (object), accel_group); - - g_signal_connect_swapped ( - ui_manager, "connect-proxy", - G_CALLBACK (mail_folder_pane_connect_proxy_cb), object); - - /* Configure an EFocusTracker to manage selection actions. */ - - focus_tracker = e_focus_tracker_new (GTK_WINDOW (object)); - action = gtk_action_group_get_action (action_group, "cut-clipboard"); - e_focus_tracker_set_cut_clipboard_action (focus_tracker, action); - action = gtk_action_group_get_action (action_group, "copy-clipboard"); - e_focus_tracker_set_copy_clipboard_action (focus_tracker, action); - action = gtk_action_group_get_action (action_group, "paste-clipboard"); - e_focus_tracker_set_paste_clipboard_action (focus_tracker, action); - action = gtk_action_group_get_action (action_group, "select-all"); - e_focus_tracker_set_select_all_action (focus_tracker, action); - priv->focus_tracker = focus_tracker; - - /* Construct window widgets. */ - - widget = (GtkWidget *)object; - gtk_box_set_spacing (GTK_BOX (widget), 0); - - container = (GtkWidget *)object; - - gtk_widget_show (GTK_WIDGET (web_view)); - - widget = e_preview_pane_new (web_view); - gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); - gtk_widget_show (widget); - - 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); - - /* Bind GObject properties to GConf keys. */ - - bridge = gconf_bridge_get (); - - object = G_OBJECT (reader); - key = "/apps/evolution/mail/display/show_deleted"; - gconf_bridge_bind_property (bridge, key, object, "show-deleted"); - - id = "org.gnome.evolution.mail.folder.pane"; - e_plugin_ui_register_manager (ui_manager, id, object); - e_plugin_ui_enable_manager (ui_manager, id); - - e_mail_reader_connect_headers (E_MAIL_READER (reader)); -} - -static gboolean -mail_folder_pane_key_press_event (GtkWidget *widget, - GdkEventKey *event) -{ - if (event->keyval == GDK_Escape) { - e_mail_folder_pane_close (E_MAIL_FOLDER_PANE (widget)); - return TRUE; - } - - /* Chain up to parent's key_press_event() method. */ - return GTK_WIDGET_CLASS (parent_class)-> - key_press_event (widget, event); -} - -static GtkActionGroup * -mail_folder_pane_get_action_group (EMailReader *reader) -{ - EMailFolderPanePrivate *priv; - - priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (reader); - - return priv->action_group; -} - -static gboolean -mail_folder_pane_get_hide_deleted (EMailReader *reader) -{ - EMailFolderPane *browser; - - browser = E_MAIL_FOLDER_PANE (reader); - - return !e_mail_folder_pane_get_show_deleted (browser); -} - -static EMFormatHTML * -mail_folder_pane_get_formatter (EMailReader *reader) -{ - EMailFolderPanePrivate *priv; - - priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (reader); - - return EM_FORMAT_HTML (priv->formatter); -} - -static GtkWidget * -mail_folder_pane_get_message_list (EMailReader *reader) -{ - EMailFolderPanePrivate *priv; - - priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (reader); - - return priv->message_list; -} - -static GtkMenu * -mail_folder_pane_get_popup_menu (EMailReader *reader) -{ - EMailFolderPane *browser; - GtkUIManager *ui_manager; - GtkWidget *widget; - - browser = E_MAIL_FOLDER_PANE (reader); - ui_manager = e_mail_folder_pane_get_ui_manager (browser); - widget = gtk_ui_manager_get_widget (ui_manager, "/mail-preview-popup"); - - return GTK_MENU (widget); -} - -static EShellBackend * -mail_folder_pane_get_shell_backend (EMailReader *reader) -{ - EMailFolderPanePrivate *priv; - - priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (reader); - - return priv->shell_backend; -} - -static GtkWindow * -mail_folder_pane_get_window (EMailReader *reader) -{ - return NULL; -} - -static void -mail_folder_pane_set_message (EMailReader *reader, - const gchar *uid) -{ - EMailReaderIface *iface; - CamelMessageInfo *info; - CamelFolder *folder; - - /* Chain up to parent's set_message() method. */ - iface = g_type_default_interface_peek (E_TYPE_MAIL_READER); - iface->set_message (reader, uid); - - if (uid == NULL) { - e_mail_folder_pane_close (E_MAIL_FOLDER_PANE (reader)); - return; - } - - folder = e_mail_reader_get_folder (reader); - info = camel_folder_get_message_info (folder, uid); - - if (info != NULL) { - gtk_window_set_title ( - GTK_WINDOW (reader), - camel_message_info_subject (info)); - camel_folder_free_message_info (folder, info); - } -} - -static void -mail_folder_pane_show_search_bar (EMailReader *reader) -{ - EMailFolderPanePrivate *priv; - - priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (reader); - - gtk_widget_show (priv->search_bar); -} - -static void -mail_folder_pane_class_init (EMailFolderPaneClass *class) +mail_folder_pane_class_init (EMailPanedViewClass *class) { GObjectClass *object_class; - GtkWidgetClass *widget_class; parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailFolderPanePrivate)); object_class = G_OBJECT_CLASS (class); - object_class->set_property = mail_folder_pane_set_property; - object_class->get_property = mail_folder_pane_get_property; object_class->dispose = mail_folder_pane_dispose; object_class->constructed = mail_folder_pane_constructed; + object_class->set_property = mail_folder_pane_set_property; + object_class->get_property = mail_folder_pane_get_property; - widget_class = GTK_WIDGET_CLASS (class); - widget_class->key_press_event = mail_folder_pane_key_press_event; + class->open_selected_mail = mfp_open_selected_mail; + + E_MAIL_VIEW_CLASS(g_type_class_peek_parent(class))->set_preview_visible = folder_pane_set_preview_visible; + E_MAIL_VIEW_CLASS(g_type_class_peek_parent(class))->get_preview_visible = folder_pane_get_preview_visible; - g_object_class_install_property ( - object_class, - PROP_FOCUS_TRACKER, - g_param_spec_object ( - "focus-tracker", - "Focus Tracker", - NULL, - E_TYPE_FOCUS_TRACKER, - G_PARAM_READABLE)); - - /* Inherited from EMailReader */ g_object_class_override_property ( object_class, - PROP_GROUP_BY_THREADS, - "group-by-threads"); + PROP_PREVIEW_VISIBLE, + "preview-visible"); - g_object_class_install_property ( - object_class, - PROP_SHELL_BACKEND, - g_param_spec_object ( - "shell-backend", - "Shell Module", - "The mail shell backend", - E_TYPE_SHELL_BACKEND, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property ( - object_class, - PROP_SHOW_DELETED, - g_param_spec_boolean ( - "show-deleted", - "Show Deleted", - "Show deleted messages", - FALSE, - G_PARAM_READWRITE)); } -static void -mail_folder_pane_iface_init (EMailReaderIface *iface) -{ - iface->get_action_group = mail_folder_pane_get_action_group; - iface->get_formatter = mail_folder_pane_get_formatter; - iface->get_hide_deleted = mail_folder_pane_get_hide_deleted; - iface->get_message_list = mail_folder_pane_get_message_list; - iface->get_popup_menu = mail_folder_pane_get_popup_menu; - iface->get_shell_backend = mail_folder_pane_get_shell_backend; - iface->get_window = mail_folder_pane_get_window; - iface->set_message = mail_folder_pane_set_message; - iface->show_search_bar = mail_folder_pane_show_search_bar; -} static void mail_folder_pane_init (EMailFolderPane *browser) { - GConfBridge *bridge; - const gchar *prefix; browser->priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (browser); - browser->priv->action_group = gtk_action_group_new ("mail-browser"); - browser->priv->formatter = em_format_html_display_new (); - - bridge = gconf_bridge_get (); - prefix = "/apps/evolution/mail/mail_browser"; - gconf_bridge_bind_window_size (bridge, prefix, GTK_WINDOW (browser)); - - gtk_window_set_title (GTK_WINDOW (browser), _("Evolution")); } GType @@ -841,71 +189,23 @@ e_mail_folder_pane_get_type (void) NULL /* value_table */ }; - static const GInterfaceInfo iface_info = { - (GInterfaceInitFunc) mail_folder_pane_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - type = g_type_register_static ( - GTK_TYPE_WINDOW, "EMailFolderPane", &type_info, 0); + E_MAIL_PANED_VIEW_TYPE, "EMailFolderPane", &type_info, 0); - g_type_add_interface_static ( - type, E_TYPE_MAIL_READER, &iface_info); } return type; } GtkWidget * -e_mail_folder_pane_new (EShellBackend *shell_backend) +e_mail_folder_pane_new (EShellContent *content) { - g_return_val_if_fail (E_IS_SHELL_BACKEND (shell_backend), NULL); + g_return_val_if_fail (E_IS_SHELL_CONTENT (content), NULL); return g_object_new ( E_TYPE_MAIL_FOLDER_PANE, - "shell-backend", shell_backend, NULL); -} - -void -e_mail_folder_pane_close (EMailFolderPane *browser) -{ - g_return_if_fail (E_IS_MAIL_FOLDER_PANE (browser)); - - gtk_widget_destroy (GTK_WIDGET (browser)); -} - -gboolean -e_mail_folder_pane_get_show_deleted (EMailFolderPane *browser) -{ - g_return_val_if_fail (E_IS_MAIL_FOLDER_PANE (browser), FALSE); - - return browser->priv->show_deleted; -} - -void -e_mail_folder_pane_set_show_deleted (EMailFolderPane *browser, - gboolean show_deleted) -{ - g_return_if_fail (E_IS_MAIL_FOLDER_PANE (browser)); - - browser->priv->show_deleted = show_deleted; - - g_object_notify (G_OBJECT (browser), "show-deleted"); + "shell-content", content, + "preview-visible", FALSE, + NULL); } -EFocusTracker * -e_mail_folder_pane_get_focus_tracker (EMailFolderPane *browser) -{ - g_return_val_if_fail (E_IS_MAIL_FOLDER_PANE (browser), NULL); - - return browser->priv->focus_tracker; -} - -GtkUIManager * -e_mail_folder_pane_get_ui_manager (EMailFolderPane *browser) -{ - g_return_val_if_fail (E_IS_MAIL_FOLDER_PANE (browser), NULL); - - return browser->priv->ui_manager; -} diff --git a/mail/e-mail-folder-pane.h b/mail/e-mail-folder-pane.h index db5951bff2..6071ce6417 100644 --- a/mail/e-mail-folder-pane.h +++ b/mail/e-mail-folder-pane.h @@ -23,8 +23,8 @@ #define E_MAIL_FOLDER_PANE_H #include <gtk/gtk.h> -#include <misc/e-focus-tracker.h> -#include <shell/e-shell-backend.h> +#include <shell/e-shell-content.h> +#include "mail/e-mail-paned-view.h" /* Standard GObject macros */ #define E_TYPE_MAIL_FOLDER_PANE \ @@ -52,22 +52,16 @@ typedef struct _EMailFolderPaneClass EMailFolderPaneClass; typedef struct _EMailFolderPanePrivate EMailFolderPanePrivate; struct _EMailFolderPane { - GtkVBox parent; + EMailPanedView parent; EMailFolderPanePrivate *priv; }; struct _EMailFolderPaneClass { - GtkVBoxClass parent_class; + EMailPanedViewClass parent_class; }; GType e_mail_folder_pane_get_type (void); -GtkWidget * e_mail_folder_pane_new (EShellBackend *shell_backend); -void e_mail_folder_pane_close (EMailFolderPane *browser); -gboolean e_mail_folder_pane_get_show_deleted (EMailFolderPane *browser); -void e_mail_folder_pane_set_show_deleted (EMailFolderPane *browser, - gboolean show_deleted); -EFocusTracker * e_mail_folder_pane_get_focus_tracker(EMailFolderPane *browser); -GtkUIManager * e_mail_folder_pane_get_ui_manager (EMailFolderPane *browser); +GtkWidget * e_mail_folder_pane_new (EShellContent *content); G_END_DECLS diff --git a/mail/e-mail-message-pane.c b/mail/e-mail-message-pane.c index 85a3e9e30b..0f3488dccb 100644 --- a/mail/e-mail-message-pane.c +++ b/mail/e-mail-message-pane.c @@ -24,323 +24,28 @@ #include <string.h> #include <glib/gi18n.h> -#include "e-util/e-util.h" -#include "e-util/e-plugin-ui.h" #include "e-util/gconf-bridge.h" -#include "shell/e-shell.h" -#include "shell/e-shell-utils.h" -#include "widgets/misc/e-popup-action.h" -#include "widgets/misc/e-preview-pane.h" #include "mail/e-mail-reader.h" -#include "mail/e-mail-reader-utils.h" -#include "mail/em-folder-tree-model.h" -#include "mail/em-format-html-display.h" -#include "mail/message-list.h" #define e_mail_message_pane_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPe_mail_message_pane, EMailMessagePanePrivate)) + ((obj), E_TYPE_MAIL_MESSAGE_PANE, EMailMessagePanePrivate)) struct _EMailMessagePanePrivate { - GtkUIManager *ui_manager; - EFocusTracker *focus_tracker; - EShellBackend *shell_backend; - GtkActionGroup *action_group; - EMFormatHTMLDisplay *formatter; - - GtkWidget *main_menu; - GtkWidget *main_toolbar; - GtkWidget *message_list; - GtkWidget *search_bar; - GtkWidget *statusbar; - - guint show_deleted : 1; + int fo; }; enum { PROP_0, - PROP_FOCUS_TRACKER, - PROP_GROUP_BY_THREADS, - PROP_SHELL_BACKEND, - PROP_SHOW_DELETED, - PROP_UI_MANAGER + PROP_PREVIEW_VISIBLE }; static gpointer parent_class; /* This is too trivial to put in a file. * It gets merged with the EMailReader UI. */ -static const gchar *ui = -"<ui>" -" <menubar name='main-menu'>" -" <menu action='file-menu'>" -" <placeholder name='file-actions'/>" -" <placeholder name='print-actions'/>" -" <separator/>" -" <menuitem action='close'/>" -" </menu>" -" <menu action='edit-menu'>" -" <placeholder name='selection-actions'>" -" <menuitem action='cut-clipboard'/>" -" <menuitem action='copy-clipboard'/>" -" <menuitem action='paste-clipboard'/>" -" <separator/>" -" <menuitem action='select-all'/>" -" </placeholder>" -" </menu>" -" </menubar>" -"</ui>"; - -static void -action_close_cb (GtkAction *action, - EMailMessagePane *browser) -{ - e_mail_message_pane_close (browser); -} - -static GtkActionEntry mail_message_pane_entries[] = { - - { "close", - GTK_STOCK_CLOSE, - NULL, - NULL, - N_("Close this window"), - G_CALLBACK (action_close_cb) }, - - { "copy-clipboard", - GTK_STOCK_COPY, - NULL, - NULL, - N_("Copy the selection"), - NULL }, /* Handled by EFocusTracker */ - - { "cut-clipboard", - GTK_STOCK_CUT, - NULL, - NULL, - N_("Cut the selection"), - NULL }, /* Handled by EFocusTracker */ - - { "paste-clipboard", - GTK_STOCK_PASTE, - NULL, - NULL, - N_("Paste the clipboard"), - NULL }, /* Handled by EFocusTracker */ - - { "select-all", - GTK_STOCK_SELECT_ALL, - NULL, - NULL, - N_("Select all text"), - NULL }, /* Handled by EFocusTracker */ - - /*** Menus ***/ - - { "file-menu", - NULL, - N_("_File"), - NULL, - NULL, - NULL }, - - { "edit-menu", - NULL, - N_("_Edit"), - NULL, - NULL, - NULL }, - - { "view-menu", - NULL, - N_("_View"), - NULL, - NULL, - NULL } -}; - -static EPopupActionEntry mail_message_pane_popup_entries[] = { - - { "popup-copy-clipboard", - NULL, - "copy-clipboard" } -}; - -static void -mail_message_pane_menu_item_select_cb (EMailMessagePane *browser, - GtkWidget *widget) -{ - GtkAction *action; - GtkActivatable *activatable; - GtkStatusbar *statusbar; - const gchar *tooltip; - guint context_id; - gpointer data; - - activatable = GTK_ACTIVATABLE (widget); - action = gtk_activatable_get_related_action (activatable); - tooltip = gtk_action_get_tooltip (action); - - data = g_object_get_data (G_OBJECT (widget), "context-id"); - context_id = GPOINTER_TO_UINT (data); - - if (tooltip == NULL) - return; - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - gtk_statusbar_push (statusbar, context_id, tooltip); -} - -static void -mail_message_pane_menu_item_deselect_cb (EMailMessagePane *browser, - GtkWidget *menu_item) -{ - GtkStatusbar *statusbar; - guint context_id; - gpointer data; - - data = g_object_get_data (G_OBJECT (menu_item), "context-id"); - context_id = GPOINTER_TO_UINT (data); - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - gtk_statusbar_pop (statusbar, context_id); -} - -static void -mail_message_pane_connect_proxy_cb (EMailMessagePane *browser, - GtkAction *action, - GtkWidget *proxy) -{ - GtkStatusbar *statusbar; - guint context_id; - - if (!GTK_IS_MENU_ITEM (proxy)) - return; - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - context_id = gtk_statusbar_get_context_id (statusbar, G_STRFUNC); - - g_object_set_data ( - G_OBJECT (proxy), "context-id", - GUINT_TO_POINTER (context_id)); - - g_signal_connect_swapped ( - proxy, "select", - G_CALLBACK (mail_message_pane_menu_item_select_cb), browser); - - g_signal_connect_swapped ( - proxy, "deselect", - G_CALLBACK (mail_message_pane_menu_item_deselect_cb), browser); -} - -static void -mail_message_pane_message_selected_cb (EMailMessagePane *browser, - const gchar *uid) -{ - EMFormatHTML *formatter; - CamelMessageInfo *info; - CamelFolder *folder; - EMailReader *reader; - EWebView *web_view; - const gchar *title; - - if (uid == NULL) - return; - - reader = E_MAIL_READER (browser); - folder = e_mail_reader_get_folder (reader); - formatter = e_mail_reader_get_formatter (reader); - web_view = em_format_html_get_web_view (formatter); - - info = camel_folder_get_message_info (folder, uid); - - if (info == NULL) - return; - - title = camel_message_info_subject (info); - if (title == NULL || *title == '\0') - title = _("(No Subject)"); - - gtk_window_set_title (GTK_WINDOW (browser), title); - gtk_widget_grab_focus (GTK_WIDGET (web_view)); - - camel_folder_free_message_info (folder, info); -} - -static gboolean -close_on_idle_cb (gpointer browser) -{ - e_mail_message_pane_close (browser); - return FALSE; -} - -static void -mail_message_pane_message_list_built_cb (EMailMessagePane *browser, - MessageList *message_list) -{ - g_return_if_fail (E_IS_MAIL_MESSAGE_PANE (browser)); - g_return_if_fail (IS_MESSAGE_LIST (message_list)); - - if (!message_list_count (message_list)) - g_idle_add (close_on_idle_cb, browser); -} - -static gboolean -mail_message_pane_popup_event_cb (EMailMessagePane *browser, - GdkEventButton *event, - const gchar *uri) -{ - EMailReader *reader; - GtkMenu *menu; - - if (uri != NULL) - return FALSE; - - reader = E_MAIL_READER (browser); - menu = e_mail_reader_get_popup_menu (reader); - - e_mail_reader_update_actions (reader); - - if (event == NULL) - gtk_menu_popup ( - menu, NULL, NULL, NULL, NULL, - 0, gtk_get_current_event_time ()); - else - gtk_menu_popup ( - menu, NULL, NULL, NULL, NULL, - event->button, event->time); - - return TRUE; -} - -static void -mail_message_pane_status_message_cb (EMailMessagePane *browser, - const gchar *status_message) -{ - GtkStatusbar *statusbar; - guint context_id; - - statusbar = GTK_STATUSBAR (browser->priv->statusbar); - context_id = gtk_statusbar_get_context_id (statusbar, G_STRFUNC); - - /* Always pop first. This prevents messages from piling up. */ - gtk_statusbar_pop (statusbar, context_id); - - if (status_message != NULL && *status_message != '\0') - gtk_statusbar_push (statusbar, context_id, status_message); -} - -static void -mail_message_pane_set_shell_backend (EMailMessagePane *browser, - EShellBackend *shell_backend) -{ - g_return_if_fail (browser->priv->shell_backend == NULL); - - browser->priv->shell_backend = g_object_ref (shell_backend); -} - static void mail_message_pane_set_property (GObject *object, guint property_id, @@ -348,23 +53,9 @@ mail_message_pane_set_property (GObject *object, 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_SHELL_BACKEND: - mail_message_pane_set_shell_backend ( - e_mail_message_pane (object), - g_value_get_object (value)); - return; - - case PROP_SHOW_DELETED: - e_mail_message_pane_set_show_deleted ( - e_mail_message_pane (object), - g_value_get_boolean (value)); + case PROP_PREVIEW_VISIBLE: return; + } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -377,35 +68,11 @@ mail_message_pane_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_FOCUS_TRACKER: - g_value_set_object ( - value, e_mail_message_pane_get_focus_tracker ( - e_mail_message_pane (object))); - return; - - case PROP_GROUP_BY_THREADS: - g_value_set_boolean ( - value, e_mail_reader_get_group_by_threads ( - E_MAIL_READER (object))); - return; - - case PROP_SHELL_BACKEND: - g_value_set_object ( - value, e_mail_reader_get_shell_backend ( - E_MAIL_READER (object))); - return; - - case PROP_SHOW_DELETED: + case PROP_PREVIEW_VISIBLE: g_value_set_boolean ( - value, e_mail_message_pane_get_show_deleted ( - e_mail_message_pane (object))); - return; - - case PROP_UI_MANAGER: - g_value_set_object ( - value, e_mail_message_pane_get_ui_manager ( - e_mail_message_pane (object))); - return; + value, + TRUE); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -418,56 +85,6 @@ mail_message_pane_dispose (GObject *object) priv = e_mail_message_pane_GET_PRIVATE (object); - if (priv->ui_manager != NULL) { - g_object_unref (priv->ui_manager); - priv->ui_manager = NULL; - } - - if (priv->focus_tracker != NULL) { - g_object_unref (priv->focus_tracker); - priv->focus_tracker = NULL; - } - - if (priv->shell_backend != NULL) { - g_object_unref (priv->shell_backend); - priv->shell_backend = NULL; - } - - if (priv->action_group != NULL) { - g_object_unref (priv->action_group); - priv->action_group = NULL; - } - - if (priv->formatter != NULL) { - g_object_unref (priv->formatter); - priv->formatter = NULL; - } - - if (priv->main_menu != NULL) { - g_object_unref (priv->main_menu); - priv->main_menu = NULL; - } - - if (priv->main_toolbar != NULL) { - g_object_unref (priv->main_toolbar); - priv->main_toolbar = NULL; - } - - if (priv->message_list != NULL) { - /* This will cancel a regen operation. */ - gtk_widget_destroy (priv->message_list); - priv->message_list = NULL; - } - - if (priv->search_bar != NULL) { - g_object_unref (priv->search_bar); - priv->search_bar = NULL; - } - - if (priv->statusbar != NULL) { - g_object_unref (priv->statusbar); - priv->statusbar = NULL; - } /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); @@ -477,275 +94,37 @@ static void mail_message_pane_constructed (GObject *object) { EMailMessagePanePrivate *priv; - EMFormatHTML *formatter; - EMailReader *reader; - EShellBackend *shell_backend; - EShell *shell; - EFocusTracker *focus_tracker; - ESearchBar *search_bar; - GConfBridge *bridge; - GtkAccelGroup *accel_group; - GtkActionGroup *action_group; - GtkAction *action; - GtkUIManager *ui_manager; - GtkWidget *container; - GtkWidget *widget; - EWebView *web_view; - const gchar *domain; - const gchar *key; - const gchar *id; - guint merge_id; - + /* Chain up to parent's constructed() method. */ if (G_OBJECT_CLASS (parent_class)->constructed) G_OBJECT_CLASS (parent_class)->constructed (object); priv = e_mail_message_pane_GET_PRIVATE (object); - reader = E_MAIL_READER (object); - - shell_backend = e_mail_reader_get_shell_backend (reader); - shell = e_shell_backend_get_shell (shell_backend); - - ui_manager = e_ui_manager_new (); - e_shell_configure_ui_manager (shell, E_UI_MANAGER (ui_manager)); - - priv->ui_manager = ui_manager; - domain = GETTEXT_PACKAGE; - - formatter = e_mail_reader_get_formatter (reader); - - web_view = em_format_html_get_web_view (formatter); - - /* The message list is a widget, but it is not shown in the browser. - * Unfortunately, the widget is inseparable from its model, and the - * model is all we need. */ - priv->message_list = message_list_new (shell_backend); - g_object_ref_sink (priv->message_list); - - g_signal_connect_swapped ( - priv->message_list, "message-selected", - G_CALLBACK (mail_message_pane_message_selected_cb), object); - - g_signal_connect_swapped ( - priv->message_list, "message-list-built", - G_CALLBACK (mail_message_pane_message_list_built_cb), object); - - g_signal_connect_swapped ( - web_view, "popup-event", - G_CALLBACK (mail_message_pane_popup_event_cb), object); - - g_signal_connect_swapped ( - web_view, "status-message", - G_CALLBACK (mail_message_pane_status_message_cb), object); - - e_mail_reader_init (reader); - - action_group = priv->action_group; - gtk_action_group_set_translation_domain (action_group, domain); - gtk_action_group_add_actions ( - action_group, mail_message_pane_entries, - G_N_ELEMENTS (mail_message_pane_entries), object); - e_action_group_add_popup_actions ( - action_group, mail_message_pane_popup_entries, - G_N_ELEMENTS (mail_message_pane_popup_entries)); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - e_ui_manager_add_ui_from_file ( - E_UI_MANAGER (ui_manager), E_MAIL_READER_UI_DEFINITION); - e_ui_manager_add_ui_from_string ( - E_UI_MANAGER (ui_manager), ui, NULL); - - merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (ui_manager)); - e_mail_reader_create_charset_menu (reader, ui_manager, merge_id); - - accel_group = gtk_ui_manager_get_accel_group (ui_manager); - gtk_window_add_accel_group (GTK_WINDOW (object), accel_group); - - g_signal_connect_swapped ( - ui_manager, "connect-proxy", - G_CALLBACK (mail_message_pane_connect_proxy_cb), object); - - /* Configure an EFocusTracker to manage selection actions. */ - - focus_tracker = e_focus_tracker_new (GTK_WINDOW (object)); - action = gtk_action_group_get_action (action_group, "cut-clipboard"); - e_focus_tracker_set_cut_clipboard_action (focus_tracker, action); - action = gtk_action_group_get_action (action_group, "copy-clipboard"); - e_focus_tracker_set_copy_clipboard_action (focus_tracker, action); - action = gtk_action_group_get_action (action_group, "paste-clipboard"); - e_focus_tracker_set_paste_clipboard_action (focus_tracker, action); - action = gtk_action_group_get_action (action_group, "select-all"); - e_focus_tracker_set_select_all_action (focus_tracker, action); - priv->focus_tracker = focus_tracker; - - /* Construct base widgets widgets. */ - widget = (GtkWidget *)object; - gtk_box_set_spacing (GTK_BOX (widget), 0); - - container = (GtkWidget *)object; - - /* Create the status bar before connecting proxy widgets. */ - widget = gtk_statusbar_new (); - gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0); - priv->statusbar = g_object_ref (widget); - gtk_widget_show (widget); - - gtk_widget_show (GTK_WIDGET (web_view)); - - widget = e_preview_pane_new (web_view); - gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); - gtk_widget_show (widget); - - 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); - - /* Bind GObject properties to GConf keys. */ - - bridge = gconf_bridge_get (); - - object = G_OBJECT (reader); - key = "/apps/evolution/mail/display/show_deleted"; - gconf_bridge_bind_property (bridge, key, object, "show-deleted"); - - id = "org.gnome.evolution.mail.message.pane"; - e_plugin_ui_register_manager (ui_manager, id, object); - e_plugin_ui_enable_manager (ui_manager, id); - - e_mail_reader_connect_headers (E_MAIL_READER (reader)); -} - -static gboolean -mail_message_pane_key_press_event (GtkWidget *widget, - GdkEventKey *event) -{ - if (event->keyval == GDK_Escape) { - e_mail_message_pane_close (e_mail_message_pane (widget)); - return TRUE; - } - - /* Chain up to parent's key_press_event() method. */ - return GTK_WIDGET_CLASS (parent_class)-> - key_press_event (widget, event); -} - -static GtkActionGroup * -mail_message_pane_get_action_group (EMailReader *reader) -{ - EMailMessagePanePrivate *priv; - - priv = e_mail_message_pane_GET_PRIVATE (reader); - - return priv->action_group; -} - -static gboolean -mail_message_pane_get_hide_deleted (EMailReader *reader) -{ - EMailMessagePane *browser; - - browser = e_mail_message_pane (reader); - - return !e_mail_message_pane_get_show_deleted (browser); -} - -static EMFormatHTML * -mail_message_pane_get_formatter (EMailReader *reader) -{ - EMailMessagePanePrivate *priv; - - priv = e_mail_message_pane_GET_PRIVATE (reader); - - return EM_FORMAT_HTML (priv->formatter); -} - -static GtkWidget * -mail_message_pane_get_message_list (EMailReader *reader) -{ - EMailMessagePanePrivate *priv; - - priv = e_mail_message_pane_GET_PRIVATE (reader); - - return priv->message_list; -} - -static GtkMenu * -mail_message_pane_get_popup_menu (EMailReader *reader) -{ - EMailMessagePane *browser; - GtkUIManager *ui_manager; - GtkWidget *widget; - - browser = e_mail_message_pane (reader); - ui_manager = e_mail_message_pane_get_ui_manager (browser); - widget = gtk_ui_manager_get_widget (ui_manager, "/mail-preview-popup"); - - return GTK_MENU (widget); -} - -static EShellBackend * -mail_message_pane_get_shell_backend (EMailReader *reader) -{ - EMailMessagePanePrivate *priv; - - priv = e_mail_message_pane_GET_PRIVATE (reader); - - return priv->shell_backend; -} - -static GtkWindow * -mail_message_pane_get_window (EMailReader *reader) -{ - return NULL; + gtk_widget_hide (e_mail_reader_get_message_list (E_MAIL_READER(object))); + e_mail_paned_view_hide_message_list_pane (E_MAIL_PANED_VIEW(object), FALSE); } static void -mail_message_pane_set_message (EMailReader *reader, - const gchar *uid) +message_pane_set_preview_visible (EMailMessagePane *view, + gboolean preview_visible) { - EMailReaderIface *iface; - CamelMessageInfo *info; - CamelFolder *folder; - - /* Chain up to parent's set_message() method. */ - iface = g_type_default_interface_peek (E_TYPE_MAIL_READER); - iface->set_message (reader, uid); + e_mail_paned_view_set_preview_visible (E_MAIL_PANED_VIEW(view), TRUE); - if (uid == NULL) { - e_mail_message_pane_close (e_mail_message_pane (reader)); - return; - } - - folder = e_mail_reader_get_folder (reader); - info = camel_folder_get_message_info (folder, uid); - - if (info != NULL) { - gtk_window_set_title ( - GTK_WINDOW (reader), - camel_message_info_subject (info)); - camel_folder_free_message_info (folder, info); - } + return; } -static void -mail_message_pane_show_search_bar (EMailReader *reader) +static gboolean +message_pane_get_preview_visible (EMailMessagePane *view) { - EMailMessagePanePrivate *priv; - priv = e_mail_message_pane_GET_PRIVATE (reader); - - gtk_widget_show (priv->search_bar); + return TRUE; } static void mail_message_pane_class_init (EMailMessagePaneClass *class) { GObjectClass *object_class; - GtkWidgetClass *widget_class; parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailMessagePanePrivate)); @@ -756,72 +135,20 @@ mail_message_pane_class_init (EMailMessagePaneClass *class) object_class->dispose = mail_message_pane_dispose; object_class->constructed = mail_message_pane_constructed; - widget_class = GTK_WIDGET_CLASS (class); - widget_class->key_press_event = mail_message_pane_key_press_event; + E_MAIL_VIEW_CLASS(g_type_class_peek_parent(class))->set_preview_visible = message_pane_set_preview_visible; + E_MAIL_VIEW_CLASS(g_type_class_peek_parent(class))->get_preview_visible = message_pane_get_preview_visible; - g_object_class_install_property ( - object_class, - PROP_FOCUS_TRACKER, - g_param_spec_object ( - "focus-tracker", - "Focus Tracker", - NULL, - E_TYPE_FOCUS_TRACKER, - G_PARAM_READABLE)); - - /* 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_SHELL_BACKEND, - g_param_spec_object ( - "shell-backend", - "Shell Module", - "The mail shell backend", - E_TYPE_SHELL_BACKEND, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property ( - object_class, - PROP_SHOW_DELETED, - g_param_spec_boolean ( - "show-deleted", - "Show Deleted", - "Show deleted messages", - FALSE, - G_PARAM_READWRITE)); -} - -static void -mail_message_pane_iface_init (EMailReaderIface *iface) -{ - iface->get_action_group = mail_message_pane_get_action_group; - iface->get_formatter = mail_message_pane_get_formatter; - iface->get_hide_deleted = mail_message_pane_get_hide_deleted; - iface->get_message_list = mail_message_pane_get_message_list; - iface->get_popup_menu = mail_message_pane_get_popup_menu; - iface->get_shell_backend = mail_message_pane_get_shell_backend; - iface->get_window = mail_message_pane_get_window; - iface->set_message = mail_message_pane_set_message; - iface->show_search_bar = mail_message_pane_show_search_bar; + PROP_PREVIEW_VISIBLE, + "preview-visible"); } static void mail_message_pane_init (EMailMessagePane *browser) { - GConfBridge *bridge; - const gchar *prefix; browser->priv = e_mail_message_pane_GET_PRIVATE (browser); - - browser->priv->action_group = gtk_action_group_new ("mail-browser"); - browser->priv->formatter = em_format_html_display_new (); - } GType @@ -843,71 +170,22 @@ e_mail_message_pane_get_type (void) NULL /* value_table */ }; - static const GInterfaceInfo iface_info = { - (GInterfaceInitFunc) mail_message_pane_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - type = g_type_register_static ( - GTK_TYPE_WINDOW, "EMailMessagePane", &type_info, 0); + E_MAIL_PANED_VIEW_TYPE , "EMailMessagePane", &type_info, 0); - g_type_add_interface_static ( - type, E_TYPE_MAIL_READER, &iface_info); } return type; } GtkWidget * -e_mail_message_pane_new (EShellBackend *shell_backend) +e_mail_message_pane_new (EShellContent *content) { - g_return_val_if_fail (E_IS_SHELL_BACKEND (shell_backend), NULL); + g_return_val_if_fail (E_IS_SHELL_CONTENT (content), NULL); return g_object_new ( - E_TYPe_mail_message_pane, - "shell-backend", shell_backend, NULL); -} - -void -e_mail_message_pane_close (EMailMessagePane *browser) -{ - g_return_if_fail (E_IS_MAIL_MESSAGE_PANE (browser)); - - gtk_widget_destroy (GTK_WIDGET (browser)); -} - -gboolean -e_mail_message_pane_get_show_deleted (EMailMessagePane *browser) -{ - g_return_val_if_fail (E_IS_MAIL_MESSAGE_PANE (browser), FALSE); - - return browser->priv->show_deleted; -} - -void -e_mail_message_pane_set_show_deleted (EMailMessagePane *browser, - gboolean show_deleted) -{ - g_return_if_fail (E_IS_MAIL_MESSAGE_PANE (browser)); - - browser->priv->show_deleted = show_deleted; - - g_object_notify (G_OBJECT (browser), "show-deleted"); -} - -EFocusTracker * -e_mail_message_pane_get_focus_tracker (EMailMessagePane *browser) -{ - g_return_val_if_fail (E_IS_MAIL_MESSAGE_PANE (browser), NULL); - - return browser->priv->focus_tracker; -} - -GtkUIManager * -e_mail_message_pane_get_ui_manager (EMailMessagePane *browser) -{ - g_return_val_if_fail (E_IS_MAIL_MESSAGE_PANE (browser), NULL); - - return browser->priv->ui_manager; + E_TYPE_MAIL_MESSAGE_PANE, + "shell-content", content, + "preview-visible", TRUE, + NULL); } diff --git a/mail/e-mail-message-pane.h b/mail/e-mail-message-pane.h index b6f49df6f2..ce5ea85ab5 100644 --- a/mail/e-mail-message-pane.h +++ b/mail/e-mail-message-pane.h @@ -23,9 +23,7 @@ #define E_MAIL_MESSAGE_PANE_H #include <gtk/gtk.h> -#include "e-mail-pane.h" -#include <misc/e-focus-tracker.h> -#include <shell/e-shell-backend.h> +#include "e-mail-paned-view.h" /* Standard GObject macros */ #define E_TYPE_MAIL_MESSAGE_PANE \ @@ -53,22 +51,16 @@ typedef struct _EMailMessagePaneClass EMailMessagePaneClass; typedef struct _EMailMessagePanePrivate EMailMessagePanePrivate; struct _EMailMessagePane { - EMailPane parent; + EMailPanedView parent; EMailMessagePanePrivate *priv; }; struct _EMailMessagePaneClass { - EMailPaneClass parent_class; + EMailPanedViewClass parent_class; }; GType e_mail_message_pane_get_type (void); -GtkWidget * e_mail_message_pane_new (EShellBackend *shell_backend); -void e_mail_message_pane_close (EMailMessagePane *browser); -gboolean e_mail_message_pane_get_show_deleted (EMailMessagePane *browser); -void e_mail_message_pane_set_show_deleted (EMailMessagePane *browser, - gboolean show_deleted); -EFocusTracker * e_mail_message_pane_get_focus_tracker(EMailMessagePane *browser); -GtkUIManager * e_mail_message_pane_get_ui_manager (EMailMessagePane *browser); +GtkWidget * e_mail_message_pane_new (EShellContent *content); G_END_DECLS diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c index 5fa6c6844f..cdf21bc702 100644 --- a/mail/e-mail-notebook-view.c +++ b/mail/e-mail-notebook-view.c @@ -29,8 +29,10 @@ #include <glib/gi18n.h> #include "mail/e-mail-reader.h" +#include "mail/message-list.h" #include "e-mail-notebook-view.h" -#include "e-mail-paned-view.h" +#include "e-mail-folder-pane.h" +#include "e-mail-message-pane.h" #include <shell/e-shell-window-actions.h> @@ -40,6 +42,11 @@ struct _EMailNotebookViewPrivate { GHashTable *views; }; +enum { + PROP_0, + PROP_GROUP_BY_THREADS, +}; + #define E_SHELL_WINDOW_ACTION_GROUP_MAIL(window) \ E_SHELL_WINDOW_ACTION_GROUP ((window), "mail") @@ -66,10 +73,14 @@ static void mnv_page_changed (GtkNotebook *book, GtkNotebookPage *page, guint page_num, EMailNotebookView *view) { - EMailView *mview = gtk_notebook_get_nth_page (book, page_num); + EMailView *mview = (EMailView *)gtk_notebook_get_nth_page (book, page_num); view->priv->current_view = mview; + /* For EMailReader related changes to EShellView*/ g_signal_emit_by_name (view, "changed"); + /* For EMailShellContent related changes */ + g_signal_emit_by_name (view, "view-changed"); + } static void @@ -89,19 +100,58 @@ mail_notebook_view_constructed (GObject *object) g_signal_connect (widget, "switch-page", G_CALLBACK(mnv_page_changed), object); - 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")); + priv->current_view = (EMailView *)e_mail_folder_pane_new (E_MAIL_VIEW(object)->content); + e_mail_paned_view_set_preview_visible ((EMailPanedView *)priv->current_view, FALSE); + gtk_widget_show ((GtkWidget *)priv->current_view); + gtk_notebook_append_page (priv->book, (GtkWidget *)priv->current_view, gtk_label_new ("Please select a folder")); } static void +mail_notebook_view_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(E_MAIL_NOTEBOOK_VIEW(object)->priv->current_view), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_notebook_view_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(E_MAIL_NOTEBOOK_VIEW(object)->priv->current_view))); + return; + + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void mail_notebook_view_class_init (EMailViewClass *klass) { GObjectClass * object_class = G_OBJECT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); object_class->constructed = mail_notebook_view_constructed; + object_class->set_property = mail_notebook_view_set_property; + object_class->get_property = mail_notebook_view_get_property; object_class->finalize = e_mail_notebook_view_finalize; @@ -109,8 +159,41 @@ mail_notebook_view_class_init (EMailViewClass *klass) 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; - - + klass->set_orientation = e_mail_notebook_view_set_orientation; + klass->get_orientation = e_mail_notebook_view_get_orientation; + klass->set_show_deleted = e_mail_notebook_view_set_show_deleted; + klass->get_show_deleted = e_mail_notebook_view_get_show_deleted; + klass->set_preview_visible = e_mail_notebook_view_set_preview_visible; + klass->get_preview_visible = e_mail_notebook_view_get_preview_visible; + + /* 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)); + + 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"); */ } @@ -231,6 +314,8 @@ emnv_get_page_num (EMailNotebookView *view, } g_warn_if_reached (); + + return; } static void @@ -246,6 +331,38 @@ reconnect_folder_loaded_event (EMailReader *child, EMailReader *parent) } static void +mail_netbook_view_open_mail (EMailView *view, const char *uid, EMailNotebookView *nview) +{ + const gchar *folder_uri; + CamelFolder *folder; + EMailMessagePane *pane = e_mail_message_pane_new (E_MAIL_VIEW(nview)->content); + int page; + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (nview)->priv; + + + gtk_widget_show (pane); + folder = e_mail_reader_get_folder (E_MAIL_READER(view)); + folder_uri = e_mail_reader_get_folder_uri (E_MAIL_READER(view)); + + page = gtk_notebook_append_page (priv->book, pane, gtk_label_new (_("Mail"))); + gtk_notebook_set_current_page (priv->book, page); + + g_signal_connect ( E_MAIL_READER(pane), "changed", + G_CALLBACK (reconnect_changed_event), + nview); + g_signal_connect ( E_MAIL_READER (pane), "folder-loaded", + G_CALLBACK (reconnect_folder_loaded_event), + nview); + e_mail_reader_set_folder ( + E_MAIL_READER (pane), folder, folder_uri); + e_mail_reader_set_group_by_threads ( + E_MAIL_READER (pane), + e_mail_reader_get_group_by_threads (E_MAIL_READER(view))); + + e_mail_reader_set_message (E_MAIL_READER (pane), uid); +} + +static void mail_notebook_view_set_folder (EMailReader *reader, CamelFolder *folder, const gchar *folder_uri) @@ -266,20 +383,25 @@ mail_notebook_view_set_folder (EMailReader *reader, if (folder || folder_uri) { int page; - - new_view = e_mail_paned_view_new (E_MAIL_VIEW(reader)->content); - priv->current_view = (EMailView *)new_view; - gtk_widget_show (new_view); - page = 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); - gtk_notebook_set_current_page (priv->book, page); - g_hash_table_insert (priv->views, g_strdup(folder_uri), new_view); - g_signal_connect ( E_MAIL_READER(new_view), "changed", + + if (g_hash_table_size (priv->views) != 0) { + priv->current_view = e_mail_folder_pane_new (E_MAIL_VIEW(reader)->content); + gtk_widget_show (priv->current_view); + page = gtk_notebook_append_page (priv->book, priv->current_view, gtk_label_new (camel_folder_get_full_name(folder))); + gtk_notebook_set_current_page (priv->book, page); + } else + gtk_notebook_set_tab_label (priv->book, priv->current_view, gtk_label_new (camel_folder_get_full_name(folder))); + + e_mail_reader_set_folder (E_MAIL_READER(priv->current_view), folder, folder_uri); + g_hash_table_insert (priv->views, g_strdup(folder_uri), priv->current_view); + g_signal_connect ( E_MAIL_READER(priv->current_view), "changed", G_CALLBACK (reconnect_changed_event), reader); - g_signal_connect ( E_MAIL_READER (new_view), "folder-loaded", + g_signal_connect ( E_MAIL_READER (priv->current_view), "folder-loaded", G_CALLBACK (reconnect_folder_loaded_event), reader); + g_signal_connect ( priv->current_view, "open-mail", + G_CALLBACK (mail_netbook_view_open_mail), reader); } } @@ -312,6 +434,17 @@ e_mail_notebook_view_get_searchbar (EMailView *view) return e_mail_view_get_searchbar (E_MAIL_NOTEBOOK_VIEW(view)->priv->current_view); */ } +static void +mail_notebook_view_open_selected_mail (EMailReader *reader) +{ + EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + + if (!priv->current_view) + return ; + + return e_mail_reader_open_selected_mail (E_MAIL_READER(priv->current_view)); +} + void e_mail_notebook_view_set_search_strings (EMailView *view, GSList *search_strings) @@ -346,6 +479,7 @@ mail_notebook_view_reader_init (EMailReaderIface *iface) 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; + iface->open_selected_mail = mail_notebook_view_open_selected_mail; } GType @@ -384,3 +518,55 @@ e_mail_notebook_view_register_type (GTypeModule *type_module) type_module, mail_notebook_view_type, E_TYPE_MAIL_READER, &reader_info); } + +void +e_mail_notebook_view_set_show_deleted (EMailNotebookView *view, + gboolean show_deleted) +{ + if (!view->priv->current_view) + return; + + e_mail_view_set_show_deleted (view->priv->current_view, show_deleted); +} +gboolean +e_mail_notebook_view_get_show_deleted (EMailNotebookView *view) +{ + if (!view->priv->current_view) + return FALSE; + + return e_mail_view_get_show_deleted (view->priv->current_view); +} +void +e_mail_notebook_view_set_preview_visible (EMailNotebookView *view, + gboolean preview_visible) +{ + if (!view->priv->current_view) + return ; + + e_mail_view_set_preview_visible (view->priv->current_view, preview_visible); +} +gboolean +e_mail_notebook_view_get_preview_visible (EMailNotebookView *view) +{ + if (!view->priv->current_view) + return FALSE; + + return e_mail_view_get_preview_visible (view->priv->current_view); +} +void +e_mail_notebook_view_set_orientation (EMailNotebookView *view, + GtkOrientation orientation) +{ + if (!view->priv->current_view) + return; + + e_mail_view_set_orientation (view->priv->current_view, orientation); +} +GtkOrientation +e_mail_notebook_view_get_orientation (EMailNotebookView *view) +{ + if (!view->priv->current_view) + return GTK_ORIENTATION_VERTICAL; + + return e_mail_view_get_orientation (view->priv->current_view); +} diff --git a/mail/e-mail-notebook-view.h b/mail/e-mail-notebook-view.h index a335e15444..957737653b 100644 --- a/mail/e-mail-notebook-view.h +++ b/mail/e-mail-notebook-view.h @@ -58,4 +58,21 @@ void e_mail_notebook_view_set_search_strings (EMailView *view, GSList *search_st GalViewInstance * e_mail_notebook_view_get_view_instance (EMailView *view); void e_mail_notebook_view_update_view_instance (EMailView *view); +void +e_mail_notebook_view_set_show_deleted (EMailNotebookView *view, + gboolean show_deleted); +gboolean +e_mail_notebook_view_get_show_deleted (EMailNotebookView *view); + +void +e_mail_notebook_view_set_preview_visible (EMailNotebookView *view, + gboolean preview_visible); +gboolean +e_mail_notebook_view_get_preview_visible (EMailNotebookView *view); +void +e_mail_notebook_view_set_orientation (EMailNotebookView *view, + GtkOrientation orientation); +GtkOrientation +e_mail_notebook_view_get_orientation (EMailNotebookView *view); + #endif diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c index f2314e183e..67268df399 100644 --- a/mail/e-mail-paned-view.c +++ b/mail/e-mail-paned-view.c @@ -240,14 +240,14 @@ mail_paned_view_notify_group_by_threads_cb (EMailReader *reader) STATE_KEY_GROUP_BY_THREADS, group_by_threads); } -static GtkOrientation -mail_paned_view_get_orientation (EMailPanedView *view) +GtkOrientation +e_mail_paned_view_get_orientation (EMailPanedView *view) { return view->priv->orientation; } -static void -mail_paned_view_set_orientation (EMailPanedView *view, +void +e_mail_paned_view_set_orientation (EMailPanedView *view, GtkOrientation orientation) { view->priv->orientation = orientation; @@ -271,7 +271,7 @@ mail_paned_view_set_property (GObject *object, return; case PROP_ORIENTATION: - mail_paned_view_set_orientation ( + e_mail_paned_view_set_orientation ( E_MAIL_PANED_VIEW (object), g_value_get_enum (value)); return; @@ -309,7 +309,7 @@ mail_paned_view_get_property (GObject *object, case PROP_ORIENTATION: g_value_set_enum ( value, - mail_paned_view_get_orientation ( + e_mail_paned_view_get_orientation ( E_MAIL_PANED_VIEW (object))); return; @@ -558,6 +558,16 @@ mail_paned_view_show_search_bar (EMailReader *reader) } static void +mail_paned_view_open_selected_mail (EMailReader *reader) +{ + EMailPanedViewPrivate *priv; + + priv = E_MAIL_PANED_VIEW (reader)->priv; + + E_MAIL_PANED_VIEW_CLASS(G_OBJECT_GET_CLASS (reader))->open_selected_mail (E_MAIL_PANED_VIEW(reader)); +} + +static void mail_paned_view_constructed (GObject *object) { EMailPanedViewPrivate *priv; @@ -662,6 +672,12 @@ mail_paned_view_constructed (GObject *object) } static void +mpv_open_selected_mail (EMailPanedView *view) +{ + e_mail_reader_open_selected (E_MAIL_READER(view)); +} + +static void mail_paned_view_init (EMailPanedView *shell) { shell->priv = g_new0(EMailPanedViewPrivate, 1); @@ -691,6 +707,15 @@ mail_paned_view_class_init (EMailViewClass *klass) klass->get_view_instance = e_mail_paned_view_get_view_instance; klass->update_view_instance = e_mail_paned_view_update_view_instance; + klass->set_orientation = e_mail_paned_view_set_orientation; + klass->get_orientation = e_mail_paned_view_get_orientation; + klass->set_show_deleted = e_mail_paned_view_set_show_deleted; + klass->get_show_deleted = e_mail_paned_view_get_show_deleted; + klass->set_preview_visible = e_mail_paned_view_set_preview_visible; + klass->get_preview_visible = e_mail_paned_view_get_preview_visible; + + E_MAIL_PANED_VIEW_CLASS(klass)->open_selected_mail = mpv_open_selected_mail; + /* Inherited from EMailReader */ g_object_class_override_property ( object_class, @@ -733,6 +758,7 @@ mail_paned_view_reader_init (EMailReaderIface *iface) iface->get_window = mail_paned_view_get_window; iface->set_folder = mail_paned_view_set_folder; iface->show_search_bar = mail_paned_view_show_search_bar; + iface->open_selected_mail = mail_paned_view_open_selected_mail; } GType @@ -756,13 +782,13 @@ e_mail_paned_view_register_type (GTypeModule *type_module) (GInstanceInitFunc) mail_paned_view_init, NULL /* value_table */ }; - +#if 0 static const GInterfaceInfo orientable_info = { (GInterfaceInitFunc) NULL, (GInterfaceFinalizeFunc) NULL, NULL /* interface_data */ }; - +#endif static const GInterfaceInfo reader_info = { (GInterfaceInitFunc) mail_paned_view_reader_init, (GInterfaceFinalizeFunc) NULL, @@ -772,11 +798,11 @@ e_mail_paned_view_register_type (GTypeModule *type_module) mail_paned_view_type = g_type_module_register_type ( type_module, E_MAIL_VIEW_TYPE, "EMailPanedView", &type_info, 0); - +#if 0 g_type_module_add_interface ( type_module, mail_paned_view_type, GTK_TYPE_ORIENTABLE, &orientable_info); - +#endif g_type_module_add_interface ( type_module, mail_paned_view_type, E_TYPE_MAIL_READER, &reader_info); @@ -1075,3 +1101,16 @@ e_mail_paned_view_update_view_instance (EMailPanedView *view) view, gal_view_instance_get_current_view (view_instance)); } + +void +e_mail_paned_view_hide_message_list_pane (EMailPanedView *view, + gboolean visible) +{ + EMailPanedViewPrivate *priv = view->priv; + + if (visible) + gtk_widget_show (priv->scrolled_window); + else + gtk_widget_hide (priv->scrolled_window); + +} diff --git a/mail/e-mail-paned-view.h b/mail/e-mail-paned-view.h index 3a7da31635..4b3f3a1482 100644 --- a/mail/e-mail-paned-view.h +++ b/mail/e-mail-paned-view.h @@ -51,6 +51,8 @@ typedef struct _EMailPanedView { typedef struct _EMailPanedViewClass { EMailViewClass parent_class; + void (*open_selected_mail) (EMailPanedView *view); + } EMailPanedViewClass; GType e_mail_paned_view_get_type (void); @@ -78,5 +80,13 @@ e_mail_paned_view_set_preview_visible (EMailPanedView *view, gboolean preview_visible); gboolean e_mail_paned_view_get_preview_visible (EMailPanedView *view); +void +e_mail_paned_view_set_orientation (EMailPanedView *view, + GtkOrientation orientation); +GtkOrientation +e_mail_paned_view_get_orientation (EMailPanedView *view); +void +e_mail_paned_view_hide_message_list_pane (EMailPanedView *view, + gboolean visible); #endif diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index a9ff239dd4..849695da78 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -607,7 +607,7 @@ static void action_mail_message_open_cb (GtkAction *action, EMailReader *reader) { - e_mail_reader_open_selected (reader); + e_mail_reader_open_selected_mail (reader); } static void @@ -2722,6 +2722,7 @@ mail_reader_class_init (EMailReaderIface *iface) iface->get_folder_uri = mail_reader_get_folder_uri; iface->set_folder = mail_reader_set_folder; iface->set_message = mail_reader_set_message; + iface->open_selected_mail = e_mail_reader_open_selected; iface->update_actions = mail_reader_update_actions; g_object_interface_install_property ( @@ -3431,6 +3432,19 @@ e_mail_reader_set_message (EMailReader *reader, iface->set_message (reader, uid); } +void +e_mail_reader_open_selected_mail (EMailReader *reader) +{ + EMailReaderIface *iface; + + g_return_if_fail (E_IS_MAIL_READER (reader)); + + iface = E_MAIL_READER_GET_IFACE (reader); + g_return_if_fail (iface->open_selected_mail != NULL); + + iface->open_selected_mail (reader); +} + gboolean e_mail_reader_get_group_by_threads (EMailReader *reader) { diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h index c58666cd27..911c2bdef5 100644 --- a/mail/e-mail-reader.h +++ b/mail/e-mail-reader.h @@ -99,6 +99,7 @@ struct _EMailReaderIface { const gchar *folder_uri); void (*set_message) (EMailReader *reader, const gchar *uid); + void (*open_selected_mail) (EMailReader *reader); /* Signals */ void (*show_search_bar) (EMailReader *reader); @@ -120,6 +121,7 @@ GtkActionGroup * EMFormatHTML * e_mail_reader_get_formatter (EMailReader *reader); gboolean e_mail_reader_get_hide_deleted (EMailReader *reader); GtkWidget * e_mail_reader_get_message_list (EMailReader *reader); +void e_mail_reader_open_selected_mail(EMailReader *reader); GtkMenu * e_mail_reader_get_popup_menu (EMailReader *reader); GPtrArray * e_mail_reader_get_selected_uids (EMailReader *reader); EShellBackend * e_mail_reader_get_shell_backend (EMailReader *reader); diff --git a/mail/e-mail-view.c b/mail/e-mail-view.c index 976d223f33..98f741d76a 100644 --- a/mail/e-mail-view.c +++ b/mail/e-mail-view.c @@ -34,6 +34,8 @@ G_DEFINE_TYPE (EMailView, e_mail_view, GTK_TYPE_VBOX) enum { PANE_CLOSE, + VIEW_CHANGED, + OPEN_MAIL, LAST_SIGNAL }; @@ -108,7 +110,13 @@ e_mail_view_class_init (EMailViewClass *klass) klass->set_search_strings = NULL; klass->get_view_instance = NULL; klass->update_view_instance = NULL; - + klass->set_orientation = NULL; + klass->get_orientation = NULL; + klass->set_show_deleted = NULL; + klass->get_show_deleted = NULL; + klass->set_preview_visible = NULL; + klass->get_preview_visible = NULL; + signals[PANE_CLOSE] = g_signal_new ("pane-close", G_OBJECT_CLASS_TYPE (object_class), @@ -117,6 +125,24 @@ e_mail_view_class_init (EMailViewClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + signals[VIEW_CHANGED] = + g_signal_new ("view-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EMailViewClass , view_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[OPEN_MAIL] = + g_signal_new ("open-mail", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EMailViewClass , open_mail), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); /** * EMailView:shell-content * @@ -160,3 +186,38 @@ e_mail_view_get_searchbar (EMailView *view) return E_MAIL_VIEW_GET_CLASS (view)->get_searchbar (view); } +void +e_mail_view_set_orientation (EMailView *view, GtkOrientation orientation) +{ + E_MAIL_VIEW_GET_CLASS (view)->set_orientation (view, orientation); +} + +GtkOrientation +e_mail_view_get_orientation (EMailView *view) +{ + return E_MAIL_VIEW_GET_CLASS (view)->get_orientation (view); +} + +void +e_mail_view_set_preview_visible (EMailView *view, gboolean visible) +{ + E_MAIL_VIEW_GET_CLASS (view)->set_preview_visible (view, visible); +} + +gboolean +e_mail_view_get_preview_visible (EMailView *view) +{ + return E_MAIL_VIEW_GET_CLASS (view)->get_preview_visible (view); +} + +void +e_mail_view_set_show_deleted (EMailView *view, gboolean show_deleted) +{ + E_MAIL_VIEW_GET_CLASS (view)->set_show_deleted (view, show_deleted); +} + +gboolean +e_mail_view_get_show_deleted (EMailView *view) +{ + return E_MAIL_VIEW_GET_CLASS (view)->get_show_deleted (view); +} diff --git a/mail/e-mail-view.h b/mail/e-mail-view.h index 430535b500..b680b39f52 100644 --- a/mail/e-mail-view.h +++ b/mail/e-mail-view.h @@ -49,12 +49,19 @@ typedef struct _EMailViewClass { GtkVBoxClass parent_class; void (*pane_close) (EMailView *); + void (*view_changed) (EMailView *); + void (*open_mail) (EMailView *, const char *); EShellSearchbar * (*get_searchbar) (EMailView *view); void (*set_search_strings) (EMailView *view, GSList *search_strings); GalViewInstance * (*get_view_instance) (EMailView *view); void (*update_view_instance) (EMailView *view); - + void (*set_orientation) (EMailView *view, GtkOrientation orientation); + GtkOrientation (*get_orientation) (EMailView *); + void (*set_preview_visible) (EMailView *view, gboolean visible); + gboolean (*get_preview_visible) (EMailView *view); + void (*set_show_deleted) (EMailView *view, gboolean show_deleted); + gboolean (*get_show_deleted) (EMailView *view); } EMailViewClass; @@ -65,6 +72,13 @@ GalViewInstance * e_mail_view_get_view_instance (EMailView *view); void e_mail_view_set_search_strings (EMailView *view, GSList *search_strings); +void e_mail_view_set_orientation (EMailView *view, GtkOrientation orientation); +GtkOrientation e_mail_view_get_orientation (EMailView *); +void e_mail_view_set_preview_visible (EMailView *view, gboolean visible); +gboolean e_mail_view_get_preview_visible (EMailView *view); +void e_mail_view_set_show_deleted (EMailView *view, gboolean show_deleted); +gboolean e_mail_view_get_show_deleted (EMailView *view); + EShellSearchbar * e_mail_view_get_searchbar (EMailView *view); #endif |