diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 24 | ||||
-rw-r--r-- | mail/Makefile.am | 2 | ||||
-rw-r--r-- | mail/folder-browser-factory.c | 249 | ||||
-rw-r--r-- | mail/folder-browser-ui.c | 390 | ||||
-rw-r--r-- | mail/folder-browser-ui.h | 25 | ||||
-rw-r--r-- | mail/message-browser.c | 212 | ||||
-rw-r--r-- | mail/message-browser.h | 7 |
7 files changed, 531 insertions, 378 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index bc372e151c..8230f423d4 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,27 @@ +2001-06-26 Peter Williams <peterw@ximian.com> + + * folder-browser-ui.c: New file derived from folder-browser-factory.c. + Contains the Bonobo UI code, split into three groups as described in + ui/ChangeLog. Also contains the GalView stuff and the hookups into + the Bonobo UI stuff. + + * folder-browser-factory.c: Move most of the UI stuff to folder-browser-ui.c. + (control_activate): Add all three kinds of UI element to this folderbrowser. + (control_deactivate): Remove all three kinds. + + * folder-browser-ui.h: New file. Prototypes functions to add UI elements + to a FolderBrowser. + + * Makefile.am: Add folder-browser-ui.{c,h} + + * message-browser.c (PARENT_TYPE): Change to BONOBO_TYPE_WINDOW + (message_browser_destroy): Chain to parent destroy function. + (set_bonobo_ui): New function. Add the 'message' functions from the folder + browser to our UI. + (message_browser_close): BonoboVerbify this. + + * message-browser.h: Convert to BonoboWindow. + 2001-06-26 Jeffrey Stedfast <fejj@ximian.com> * folder-browser.c (my_folder_browser_init): Helps if I spell diff --git a/mail/Makefile.am b/mail/Makefile.am index 8d075b531c..1c31e5c080 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -45,6 +45,8 @@ evolution_mail_SOURCES = \ folder-browser.h \ folder-browser-factory.c \ folder-browser-factory.h \ + folder-browser-ui.c \ + folder-browser-ui.h \ folder-info.c \ mail-accounts.c \ mail-accounts.h \ diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 70e149a6bd..9b2a198478 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -43,192 +43,6 @@ /* The FolderBrowser BonoboControls we have. */ static EList *control_list = NULL; -/* - * Add with 'folder_browser' - */ -BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("EditCut", folder_browser_cut), - BONOBO_UI_UNSAFE_VERB ("EditCopy", folder_browser_copy), - BONOBO_UI_UNSAFE_VERB ("EditPaste", folder_browser_paste), - BONOBO_UI_UNSAFE_VERB ("EditInvertSelection", invert_selection), - BONOBO_UI_UNSAFE_VERB ("EditSelectAll", select_all), -/* BONOBO_UI_UNSAFE_VERB ("EditSelectThread", select_thread), */ - BONOBO_UI_UNSAFE_VERB ("EmptyTrash", empty_trash), - BONOBO_UI_UNSAFE_VERB ("FolderConfig", configure_folder), - BONOBO_UI_UNSAFE_VERB ("FolderExpunge", expunge_folder), - BONOBO_UI_UNSAFE_VERB ("ForgetPasswords", mail_session_forget_passwords), - BONOBO_UI_UNSAFE_VERB ("MailCompose", compose_msg), - BONOBO_UI_UNSAFE_VERB ("MailGetSend", send_receive_mail), - BONOBO_UI_UNSAFE_VERB ("MailNext", next_msg), - BONOBO_UI_UNSAFE_VERB ("MailNextUnread", next_unread_msg), - BONOBO_UI_UNSAFE_VERB ("MailNextFlagged", next_flagged_msg), - BONOBO_UI_UNSAFE_VERB ("MailPrevious", previous_msg), - BONOBO_UI_UNSAFE_VERB ("MailPreviousUnread", previous_unread_msg), - BONOBO_UI_UNSAFE_VERB ("MailPreviousFlagged", previous_flagged_msg), - BONOBO_UI_UNSAFE_VERB ("MailStop", stop_threads), - BONOBO_UI_UNSAFE_VERB ("MessageApplyFilters", apply_filters), - BONOBO_UI_UNSAFE_VERB ("MessageCopy", copy_msg), - BONOBO_UI_UNSAFE_VERB ("MessageDelete", delete_msg), - BONOBO_UI_UNSAFE_VERB ("MessageForward", forward), - BONOBO_UI_UNSAFE_VERB ("MessageForwardAttached", forward_attached), - BONOBO_UI_UNSAFE_VERB ("MessageForwardInline", forward_inline), - BONOBO_UI_UNSAFE_VERB ("MessageForwardQuoted", forward_quoted), - BONOBO_UI_UNSAFE_VERB ("MessageMarkAllAsRead", mark_all_as_seen), - BONOBO_UI_UNSAFE_VERB ("MessageMarkAsRead", mark_as_seen), - BONOBO_UI_UNSAFE_VERB ("MessageMarkAsUnRead", mark_as_unseen), - BONOBO_UI_UNSAFE_VERB ("MessageMarkAsImportant", mark_as_important), - BONOBO_UI_UNSAFE_VERB ("MessageMove", move_msg), - BONOBO_UI_UNSAFE_VERB ("MessageOpen", open_message), - BONOBO_UI_UNSAFE_VERB ("MessageReplyAll", reply_to_all), - BONOBO_UI_UNSAFE_VERB ("MessageReplySender", reply_to_sender), - BONOBO_UI_UNSAFE_VERB ("MessageReplyList", reply_to_list), - BONOBO_UI_UNSAFE_VERB ("MessageResend", resend_msg), - BONOBO_UI_UNSAFE_VERB ("MessageSaveAs", save_msg), - BONOBO_UI_UNSAFE_VERB ("MessageSearch", search_msg), - BONOBO_UI_UNSAFE_VERB ("MessageUndelete", undelete_msg), - BONOBO_UI_UNSAFE_VERB ("PrintMessage", print_msg), - BONOBO_UI_UNSAFE_VERB ("PrintPreviewMessage", print_preview_msg), - BONOBO_UI_UNSAFE_VERB ("ToolsFilterMailingList", filter_mlist), - BONOBO_UI_UNSAFE_VERB ("ToolsFilterRecipient", filter_recipient), - BONOBO_UI_UNSAFE_VERB ("ToolsFilters", filter_edit), - BONOBO_UI_UNSAFE_VERB ("ToolsFilterSender", filter_sender), - BONOBO_UI_UNSAFE_VERB ("ToolsFilterSubject", filter_subject), - BONOBO_UI_UNSAFE_VERB ("ToolsSettings", providers_config), - BONOBO_UI_UNSAFE_VERB ("ToolsSubscriptions", manage_subscriptions), - BONOBO_UI_UNSAFE_VERB ("ToolsVFolderMailingList", vfolder_mlist), - BONOBO_UI_UNSAFE_VERB ("ToolsVFolderRecipient", vfolder_recipient), - BONOBO_UI_UNSAFE_VERB ("ToolsVFolders", vfolder_edit_vfolders), - BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSender", vfolder_sender), - BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSubject", vfolder_subject), - BONOBO_UI_UNSAFE_VERB ("ViewHideRead", hide_read), - BONOBO_UI_UNSAFE_VERB ("ViewHideSelected", hide_selected), - BONOBO_UI_UNSAFE_VERB ("ViewLoadImages", load_images), - BONOBO_UI_UNSAFE_VERB ("ViewShowAll", hide_none), - - BONOBO_UI_VERB_END -}; - -static EPixmap pixcache [] = { - E_PIXMAP ("/commands/MailCompose", "new-message.xpm"), - E_PIXMAP ("/commands/FolderConfig", "configure_16_folder.xpm"), - E_PIXMAP ("/commands/PrintMessage", "print.xpm"), - E_PIXMAP ("/commands/PrintPreviewMessage", "print-preview.xpm"), - - E_PIXMAP ("/commands/MessageDelete", "delete_message.xpm"), - E_PIXMAP ("/commands/MessageUndelete", "undelete_message.xpm"), - - E_PIXMAP ("/commands/ViewHideRead", "hide_read_messages.xpm"), - E_PIXMAP ("/commands/ViewHideSelected", "hide_selected_messages.xpm"), - E_PIXMAP ("/commands/ViewShowAll", "show_all_messages.xpm"), - - E_PIXMAP ("/commands/MailGetSend", "send-receive.xpm"), - E_PIXMAP ("/commands/MessageCopy", "copy_16_message.xpm"), - E_PIXMAP ("/commands/MessageMove", "move_message.xpm"), - E_PIXMAP ("/commands/MessageReplyAll", "reply_to_all.xpm"), - E_PIXMAP ("/commands/MessageReplySender", "reply.xpm"), - E_PIXMAP ("/commands/MessageForward", "forward.xpm"), - - E_PIXMAP ("/commands/ToolsSettings", "configure_16_mail.xpm"), - - E_PIXMAP ("/Toolbar/MailGetSend", "buttons/send-24-receive.png"), - E_PIXMAP ("/Toolbar/MailCompose", "buttons/compose-message.png"), - E_PIXMAP ("/Toolbar/MessageReplySender", "buttons/reply.png"), - E_PIXMAP ("/Toolbar/MessageReplyAll", "buttons/reply-to-all.png"), - E_PIXMAP ("/Toolbar/MessageForward", "buttons/forward.png"), - E_PIXMAP ("/Toolbar/MessageMove", "buttons/move-message.png"), - E_PIXMAP ("/Toolbar/MessageCopy", "buttons/copy-message.png"), - - E_PIXMAP_END -}; - -static void -display_view(GalViewCollection *collection, - GalView *view, - gpointer data) -{ - FolderBrowser *fb = data; - if (GAL_IS_VIEW_ETABLE(view)) { - e_tree_set_state_object(fb->message_list->tree, GAL_VIEW_ETABLE(view)->state); - } -} - -static void -folder_browser_setup_view_menus (FolderBrowser *fb, - BonoboUIComponent *uic) -{ - GalViewFactory *factory; - ETableSpecification *spec; - char *local_dir; - - g_assert (fb->view_collection == NULL); - g_assert (fb->view_menus == NULL); - - fb->view_collection = gal_view_collection_new(); - - local_dir = gnome_util_prepend_user_home ("/evolution/views/mail/"); - gal_view_collection_set_storage_directories( - fb->view_collection, - EVOLUTION_DATADIR "/evolution/views/mail/", - local_dir); - g_free (local_dir); - - spec = e_table_specification_new(); - e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec"); - - factory = gal_view_factory_etable_new (spec); - gtk_object_unref (GTK_OBJECT (spec)); - gal_view_collection_add_factory (fb->view_collection, factory); - gtk_object_unref (GTK_OBJECT (factory)); - - gal_view_collection_load(fb->view_collection); - - fb->view_menus = gal_view_menus_new(fb->view_collection); - gal_view_menus_apply(fb->view_menus, uic, NULL); - gtk_signal_connect(GTK_OBJECT(fb->view_collection), "display_view", - display_view, fb); -} - -/* Gets rid of the view collection and view menus objects */ -static void -folder_browser_discard_view_menus (FolderBrowser *fb) -{ - g_assert (fb->view_collection != NULL); - g_assert (fb->view_menus != NULL); - - gtk_object_unref (GTK_OBJECT (fb->view_collection)); - fb->view_collection = NULL; - - gtk_object_unref (GTK_OBJECT (fb->view_menus)); - fb->view_menus = NULL; -} - -static void -folder_browser_setup_property_menu (FolderBrowser *fb, - BonoboUIComponent *uic) -{ - char *name, *base = NULL; - - if (fb->uri) - base = g_basename (fb->uri); - - if (base && base [0] != 0) - name = g_strdup_printf (_("Properties for \"%s\""), base); - else - name = g_strdup (_("Properties")); - - bonobo_ui_component_set_prop ( - uic, "/menu/File/Folder/FolderConfig", - "label", name, NULL); - g_free (name); -} - -/* Must be in the same order as MailConfigDisplayStyle */ -char *message_display_styles[] = { - "/commands/ViewNormal", - "/commands/ViewFullHeaders", - "/commands/ViewSource" -}; - static void control_activate (BonoboControl *control, BonoboUIComponent *uic, @@ -248,60 +62,9 @@ control_activate (BonoboControl *control, folder_browser = bonobo_control_get_widget (control); folder_browser_set_ui_component (FOLDER_BROWSER (folder_browser), uic); - bonobo_ui_component_add_verb_list_with_data ( - uic, verbs, folder_browser); - - bonobo_ui_component_freeze (uic, NULL); - - bonobo_ui_util_set_ui ( - uic, EVOLUTION_DATADIR, - "evolution-mail.xml", "evolution-mail"); - - state = mail_config_get_show_preview (FOLDER_BROWSER (folder_browser)->uri); - bonobo_ui_component_set_prop (uic, "/commands/ViewPreview", "state", state ? "1" : "0", NULL); - bonobo_ui_component_add_listener (uic, "ViewPreview", folder_browser_toggle_preview, folder_browser); - /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ - folder_browser_toggle_preview (uic, "", Bonobo_UIComponent_STATE_CHANGED, state ? "1" : "0", folder_browser); - - state = mail_config_get_thread_list (FOLDER_BROWSER (folder_browser)->uri); - bonobo_ui_component_set_prop (uic, "/commands/ViewThreaded", "state", state ? "1" : "0", NULL); - bonobo_ui_component_add_listener (uic, "ViewThreaded", folder_browser_toggle_threads, folder_browser); - /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ - folder_browser_toggle_threads (uic, "", Bonobo_UIComponent_STATE_CHANGED, state ? "1" : "0", folder_browser); - - state = mail_config_get_message_display_style (); - bonobo_ui_component_set_prop (uic, message_display_styles[state], - "state", "1", NULL); - bonobo_ui_component_add_listener (uic, "ViewNormal", folder_browser_set_message_display_style, folder_browser); - bonobo_ui_component_add_listener (uic, "ViewFullHeaders", folder_browser_set_message_display_style, folder_browser); - bonobo_ui_component_add_listener (uic, "ViewSource", folder_browser_set_message_display_style, folder_browser); - /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ - folder_browser_set_message_display_style (uic, strrchr (message_display_styles[state], '/') + 1, - Bonobo_UIComponent_STATE_CHANGED, "1", folder_browser); - - if (fb->folder && CAMEL_IS_VTRASH_FOLDER(fb->folder)) { - bonobo_ui_component_set_prop(uic, "/commands/HideDeleted", "sensitive", "0", NULL); - state = FALSE; - } else { - state = mail_config_get_hide_deleted(); - } - bonobo_ui_component_set_prop (uic, "/commands/HideDeleted", "state", state ? "1" : "0", NULL); - bonobo_ui_component_add_listener (uic, "HideDeleted", folder_browser_toggle_hide_deleted, - folder_browser); - /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ - folder_browser_toggle_hide_deleted (uic, "", Bonobo_UIComponent_STATE_CHANGED, - state ? "1" : "0", folder_browser); - if (fb->folder && !folder_browser_is_sent (fb)) - bonobo_ui_component_set_prop (uic, "/commands/MessageResend", "sensitive", "0", NULL); - - folder_browser_setup_view_menus (fb, uic); - folder_browser_setup_property_menu (fb, uic); - - e_pixmaps_update (uic, pixcache); - - bonobo_ui_component_set_prop(uic, "/commands/MailStop", "sensitive", "0", NULL); - - bonobo_ui_component_thaw (uic, NULL); + folder_browser_ui_add_global (fb); + folder_browser_ui_add_list (fb); + folder_browser_ui_add_message (fb); if (fb->folder) mail_refresh_folder (fb->folder, NULL, NULL); @@ -312,8 +75,9 @@ control_deactivate (BonoboControl *control, BonoboUIComponent *uic, FolderBrowser *fb) { - bonobo_ui_component_rm (uic, "/", NULL); - bonobo_ui_component_unset_container (uic); + folder_browser_ui_rm_message (fb); + folder_browser_ui_rm_list (fb); + folder_browser_ui_rm_global (fb); /* turn this back on to get the old (broken) behaviour of * synching when leaving a folder @@ -324,7 +88,6 @@ control_deactivate (BonoboControl *control, #endif folder_browser_set_ui_component (fb, NULL); - folder_browser_discard_view_menus (fb); } static void diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c new file mode 100644 index 0000000000..f856c34617 --- /dev/null +++ b/mail/folder-browser-ui.c @@ -0,0 +1,390 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * folder-browser-ui.c: Sets up the Bonobo UI for FolderBrowsers + * + * Author: + * Peter Williams <peterw@ximian.com> + * + * (C) 2001 Ximian, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-util.h> /* gnome_util_prepend_user_home */ + +#include <bonobo/bonobo-ui-component.h> +#include <bonobo/bonobo-ui-util.h> + +#include "widgets/menus/gal-view-menus.h" /* GalView stuff */ +#include <gal/menus/gal-view-factory-etable.h> +#include <gal/menus/gal-view-etable.h> + +#include "mail-callbacks.h" /* almost all the verbs */ +#include "mail-session.h" /* mail_session_forget_passwords */ + +#include "folder-browser-ui.h" + +#include "evolution-shell-component-utils.h" /* Pixmap stuff */ +#include "camel/camel-vtrash-folder.h" /* vtrash checking */ + +/* + * Add with 'folder_browser' + */ + +static BonoboUIVerb message_verbs [] = { + BONOBO_UI_UNSAFE_VERB ("MailNext", next_msg), + BONOBO_UI_UNSAFE_VERB ("MailNextFlagged", next_flagged_msg), + BONOBO_UI_UNSAFE_VERB ("MailNextUnread", next_unread_msg), +/* BONOBO_UI_UNSAFE_VERB ("MailNextThread", next_thread),*/ + BONOBO_UI_UNSAFE_VERB ("MailPrevious", previous_msg), + BONOBO_UI_UNSAFE_VERB ("MailPreviousFlagged", previous_flagged_msg), + BONOBO_UI_UNSAFE_VERB ("MailPreviousUnread", previous_unread_msg), + BONOBO_UI_UNSAFE_VERB ("MessageApplyFilters", apply_filters), + BONOBO_UI_UNSAFE_VERB ("MessageCopy", copy_msg), + BONOBO_UI_UNSAFE_VERB ("MessageDelete", delete_msg), + BONOBO_UI_UNSAFE_VERB ("MessageForward", forward), + BONOBO_UI_UNSAFE_VERB ("MessageForwardAttached", forward_attached), + BONOBO_UI_UNSAFE_VERB ("MessageForwardInline", forward_inline), + BONOBO_UI_UNSAFE_VERB ("MessageForwardQuoted", forward_quoted), +/* BONOBO_UI_UNSAFE_VERB ("MessageMarkAsImportant", mark_as_important),*/ + BONOBO_UI_UNSAFE_VERB ("MessageMarkAsRead", mark_as_seen), + BONOBO_UI_UNSAFE_VERB ("MessageMarkAsUnRead", mark_as_unseen), + BONOBO_UI_UNSAFE_VERB ("MessageMove", move_msg), + BONOBO_UI_UNSAFE_VERB ("MessageOpen", open_message), + BONOBO_UI_UNSAFE_VERB ("MessageReplyAll", reply_to_all), + BONOBO_UI_UNSAFE_VERB ("MessageReplyList", reply_to_list), + BONOBO_UI_UNSAFE_VERB ("MessageReplySender", reply_to_sender), + BONOBO_UI_UNSAFE_VERB ("MessageResend", resend_msg), + BONOBO_UI_UNSAFE_VERB ("MessageSaveAs", save_msg), + BONOBO_UI_UNSAFE_VERB ("MessageSearch", search_msg), + BONOBO_UI_UNSAFE_VERB ("MessageUndelete", undelete_msg), + BONOBO_UI_UNSAFE_VERB ("PrintMessage", print_msg), + BONOBO_UI_UNSAFE_VERB ("PrintPreviewMessage", print_preview_msg), + BONOBO_UI_UNSAFE_VERB ("ToolsFilterMailingList", filter_mlist), + BONOBO_UI_UNSAFE_VERB ("ToolsFilterRecipient", filter_recipient), + BONOBO_UI_UNSAFE_VERB ("ToolsFilterSender", filter_sender), + BONOBO_UI_UNSAFE_VERB ("ToolsFilterSubject", filter_subject), + BONOBO_UI_UNSAFE_VERB ("ToolsVFolderMailingList", vfolder_mlist), + BONOBO_UI_UNSAFE_VERB ("ToolsVFolderRecipient", vfolder_recipient), + BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSender", vfolder_sender), + BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSubject", vfolder_subject), + BONOBO_UI_UNSAFE_VERB ("ViewLoadImages", load_images), + /* ViewHeaders stuff is a radio */ + + BONOBO_UI_VERB_END +}; + +static BonoboUIVerb list_verbs [] = { + BONOBO_UI_UNSAFE_VERB ("EditCut", folder_browser_cut), + BONOBO_UI_UNSAFE_VERB ("EditCopy", folder_browser_copy), + BONOBO_UI_UNSAFE_VERB ("EditPaste", folder_browser_paste), + BONOBO_UI_UNSAFE_VERB ("EditInvertSelection", invert_selection), + BONOBO_UI_UNSAFE_VERB ("EditSelectAll", select_all), +/* BONOBO_UI_UNSAFE_VERB ("EditSelectThread", select_thread),*/ + BONOBO_UI_UNSAFE_VERB ("ChangeFolderProperties", configure_folder), + BONOBO_UI_UNSAFE_VERB ("FolderExpunge", expunge_folder), + /* HideDeleted is a toggle */ + BONOBO_UI_UNSAFE_VERB ("MessageMarkAllAsRead", mark_all_as_seen), + BONOBO_UI_UNSAFE_VERB ("ViewHideRead", hide_read), + BONOBO_UI_UNSAFE_VERB ("ViewHideSelected", hide_selected), + BONOBO_UI_UNSAFE_VERB ("ViewShowAll", hide_none), + /* ViewThreaded is a toggle */ + + BONOBO_UI_VERB_END +}; + +static BonoboUIVerb global_verbs [] = { + BONOBO_UI_UNSAFE_VERB ("EmptyTrash", empty_trash), + BONOBO_UI_UNSAFE_VERB ("ForgetPasswords", mail_session_forget_passwords), + BONOBO_UI_UNSAFE_VERB ("MailCompose", compose_msg), + BONOBO_UI_UNSAFE_VERB ("MailGetSend", send_receive_mail), + BONOBO_UI_UNSAFE_VERB ("MailStop", stop_threads), + BONOBO_UI_UNSAFE_VERB ("ToolsFilters", filter_edit), + BONOBO_UI_UNSAFE_VERB ("ToolsSettings", providers_config), + BONOBO_UI_UNSAFE_VERB ("ToolsSubscriptions", manage_subscriptions), + BONOBO_UI_UNSAFE_VERB ("ToolsVFolders", vfolder_edit_vfolders), + /* ViewPreview is a toggle */ + + BONOBO_UI_VERB_END +}; + +static EPixmap message_pixcache [] = { + E_PIXMAP ("/commands/PrintMessage", "print.xpm"), + E_PIXMAP ("/commands/PrintPreviewMessage", "print-preview.xpm"), + E_PIXMAP ("/commands/MessageDelete", "delete_message.xpm"), + E_PIXMAP ("/commands/MessageUndelete", "undelete_message.xpm"), + E_PIXMAP ("/commands/MessageCopy", "copy_16_message.xpm"), + E_PIXMAP ("/commands/MessageMove", "move_message.xpm"), + E_PIXMAP ("/commands/MessageReplyAll", "reply_to_all.xpm"), + E_PIXMAP ("/commands/MessageReplySender", "reply.xpm"), + E_PIXMAP ("/commands/MessageForward", "forward.xpm"), + + E_PIXMAP ("/Toolbar/MailMessageToolbar/MessageReplySender", "buttons/reply.png"), + E_PIXMAP ("/Toolbar/MailMessageToolbar/MessageReplyAll", "buttons/reply-to-all.png"), + E_PIXMAP ("/Toolbar/MailMessageToolbar/MessageForward", "buttons/forward.png"), + E_PIXMAP ("/Toolbar/MailMessageToolbar/MessageMove", "buttons/move-message.png"), + E_PIXMAP ("/Toolbar/MailMessageToolbar/MessageCopy", "buttons/copy-message.png"), + + E_PIXMAP_END +}; + +static EPixmap list_pixcache [] = { + E_PIXMAP ("/commands/ChangeFolderProperties", "configure_16_folder.xpm"), + E_PIXMAP ("/commands/ViewHideRead", "hide_read_messages.xpm"), + E_PIXMAP ("/commands/ViewHideSelected", "hide_selected_messages.xpm"), + E_PIXMAP ("/commands/ViewShowAll", "show_all_messages.xpm"), + + E_PIXMAP_END +}; + +static EPixmap global_pixcache [] = { + E_PIXMAP ("/commands/MailCompose", "new-message.xpm"), + E_PIXMAP ("/commands/MailGetSend", "send-receive.xpm"), + E_PIXMAP ("/commands/ToolsSettings", "configure_16_mail.xpm"), + + E_PIXMAP ("/Toolbar/MailGetSend", "buttons/send-24-receive.png"), + E_PIXMAP ("/Toolbar/MailCompose", "buttons/compose-message.png"), + + E_PIXMAP_END +}; + +static void ui_add (FolderBrowser *fb, + const gchar *name, + BonoboUIVerb verb[], + EPixmap pixcache[]) +{ + BonoboUIComponent *uic = fb->uicomp; + gchar *file; + + bonobo_ui_component_add_verb_list_with_data (uic, verb, fb); + + bonobo_ui_component_freeze (uic, NULL); + + file = g_strconcat ("evolution-mail-", name, ".xml", NULL); + bonobo_ui_util_set_ui (uic, EVOLUTION_DATADIR, file, "evolution-mail"); + g_free (file); + + e_pixmaps_update (uic, pixcache); + + bonobo_ui_component_thaw (uic, NULL); +} + +/* unused args, for now... */ + +static void ui_rm (FolderBrowser *fb, + const gchar *name, + BonoboUIVerb verb[], + EPixmap pixcache[]) +{ + BonoboUIComponent *uic = fb->uicomp; + + bonobo_ui_component_rm (uic, "/", NULL); + bonobo_ui_component_unset_container (uic); +} + +/* more complex stuff */ + +static void +display_view(GalViewCollection *collection, + GalView *view, + gpointer data) +{ + FolderBrowser *fb = data; + if (GAL_IS_VIEW_ETABLE(view)) { + e_tree_set_state_object(fb->message_list->tree, GAL_VIEW_ETABLE(view)->state); + } +} + +static void +folder_browser_setup_view_menus (FolderBrowser *fb, + BonoboUIComponent *uic) +{ + GalViewFactory *factory; + ETableSpecification *spec; + char *local_dir; + + g_assert (fb->view_collection == NULL); + g_assert (fb->view_menus == NULL); + + fb->view_collection = gal_view_collection_new(); + + local_dir = gnome_util_prepend_user_home ("/evolution/views/mail/"); + gal_view_collection_set_storage_directories( + fb->view_collection, + EVOLUTION_DATADIR "/evolution/views/mail/", + local_dir); + g_free (local_dir); + + spec = e_table_specification_new(); + e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec"); + + factory = gal_view_factory_etable_new (spec); + gtk_object_unref (GTK_OBJECT (spec)); + gal_view_collection_add_factory (fb->view_collection, factory); + gtk_object_unref (GTK_OBJECT (factory)); + + gal_view_collection_load(fb->view_collection); + + fb->view_menus = gal_view_menus_new(fb->view_collection); + gal_view_menus_apply(fb->view_menus, uic, NULL); + gtk_signal_connect(GTK_OBJECT(fb->view_collection), "display_view", + display_view, fb); +} + +/* Gets rid of the view collection and view menus objects */ +static void +folder_browser_discard_view_menus (FolderBrowser *fb) +{ + g_assert (fb->view_collection != NULL); + g_assert (fb->view_menus != NULL); + + gtk_object_unref (GTK_OBJECT (fb->view_collection)); + fb->view_collection = NULL; + + gtk_object_unref (GTK_OBJECT (fb->view_menus)); + fb->view_menus = NULL; +} + +static void +folder_browser_setup_property_menu (FolderBrowser *fb, + BonoboUIComponent *uic) +{ + char *name, *base = NULL; + + if (fb->uri) + base = g_basename (fb->uri); + + if (base && base [0] != 0) + name = g_strdup_printf (_("Properties for \"%s\""), base); + else + name = g_strdup (_("Properties")); + + bonobo_ui_component_set_prop ( + uic, "/menu/File/Folder/ChangeFolderProperties", + "label", name, NULL); + g_free (name); +} + +/* Must be in the same order as MailConfigDisplayStyle */ +/* used in folder-browser.c as well (therefore not static) */ +char *message_display_styles[] = { + "/commands/ViewNormal", + "/commands/ViewFullHeaders", + "/commands/ViewSource" +}; + +/* public */ + +void +folder_browser_ui_add_message (FolderBrowser *fb) +{ + int state; + BonoboUIComponent *uic = fb->uicomp; + + ui_add (fb, "message", message_verbs, message_pixcache); + + /* Display Style */ + + state = mail_config_get_message_display_style (); + bonobo_ui_component_set_prop (uic, message_display_styles[state], + "state", "1", NULL); + bonobo_ui_component_add_listener (uic, "ViewNormal", folder_browser_set_message_display_style, fb); + bonobo_ui_component_add_listener (uic, "ViewFullHeaders", folder_browser_set_message_display_style, fb); + bonobo_ui_component_add_listener (uic, "ViewSource", folder_browser_set_message_display_style, fb); + /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ + folder_browser_set_message_display_style (uic, strrchr (message_display_styles[state], '/') + 1, + Bonobo_UIComponent_STATE_CHANGED, "1", fb); + + /* Resend Message */ + + if (fb->folder && !folder_browser_is_sent (fb)) + bonobo_ui_component_set_prop (uic, "/commands/MessageResend", "sensitive", "0", NULL); +} + +void +folder_browser_ui_rm_message (FolderBrowser *fb) +{ + ui_rm (fb, "message", message_verbs, message_pixcache); +} + +void +folder_browser_ui_add_list (FolderBrowser *fb) +{ + int state; + BonoboUIComponent *uic = fb->uicomp; + + ui_add (fb, "list", list_verbs, list_pixcache); + + /* Hide Deleted */ + + if (fb->folder && CAMEL_IS_VTRASH_FOLDER(fb->folder)) { + bonobo_ui_component_set_prop(uic, "/commands/HideDeleted", "sensitive", "0", NULL); + state = FALSE; + } else { + state = mail_config_get_hide_deleted(); + } + bonobo_ui_component_set_prop (uic, "/commands/HideDeleted", "state", state ? "1" : "0", NULL); + bonobo_ui_component_add_listener (uic, "HideDeleted", folder_browser_toggle_hide_deleted, + fb); + /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ + folder_browser_toggle_hide_deleted (uic, "", Bonobo_UIComponent_STATE_CHANGED, + state ? "1" : "0", fb); + + /* Threaded toggle */ + + state = mail_config_get_thread_list (FOLDER_BROWSER (fb)->uri); + bonobo_ui_component_set_prop (uic, "/commands/ViewThreaded", "state", state ? "1" : "0", NULL); + bonobo_ui_component_add_listener (uic, "ViewThreaded", folder_browser_toggle_threads, fb); + /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ + folder_browser_toggle_threads (uic, "", Bonobo_UIComponent_STATE_CHANGED, state ? "1" : "0", fb); + + /* Property menu */ + + folder_browser_setup_property_menu (fb, fb->uicomp); +} + +void +folder_browser_ui_rm_list (FolderBrowser *fb) +{ + ui_rm (fb, "list", list_verbs, list_pixcache); +} + +void +folder_browser_ui_add_global (FolderBrowser *fb) +{ + int state; + BonoboUIComponent *uic = fb->uicomp; + + ui_add (fb, "global", global_verbs, global_pixcache); + + /* (Pre)view toggle */ + + state = mail_config_get_show_preview (FOLDER_BROWSER (fb)->uri); + bonobo_ui_component_set_prop (uic, "/commands/ViewPreview", "state", state ? "1" : "0", NULL); + bonobo_ui_component_add_listener (uic, "ViewPreview", folder_browser_toggle_preview, fb); + /* FIXME: this kind of bypasses bonobo but seems the only way when we change components */ + folder_browser_toggle_preview (uic, "", Bonobo_UIComponent_STATE_CHANGED, state ? "1" : "0", fb); + + /* Stop button */ + + bonobo_ui_component_set_prop(uic, "/commands/MailStop", "sensitive", "0", NULL); + + /* View menu */ + + folder_browser_setup_view_menus (fb, fb->uicomp); + +} + +void +folder_browser_ui_rm_global (FolderBrowser *fb) +{ + ui_rm (fb, "global", global_verbs, global_pixcache); + + /* View menu */ + + folder_browser_discard_view_menus (fb); +} + diff --git a/mail/folder-browser-ui.h b/mail/folder-browser-ui.h new file mode 100644 index 0000000000..75060aeeef --- /dev/null +++ b/mail/folder-browser-ui.h @@ -0,0 +1,25 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * folder-browser-ui.c: Sets up the Bonobo UI for FolderBrowsers + * + * Author: + * Peter Williams <peterw@ximian.com> + * + * (C) 2001 Ximian, Inc. + */ + +#ifndef _FOLDER_BROWSER_UI_H +#define _FOLDER_BROWSER_UI_H + +#include "folder-browser.h" + +void folder_browser_ui_add_message (FolderBrowser *fb); +void folder_browser_ui_rm_message (FolderBrowser *fb); + +void folder_browser_ui_add_list (FolderBrowser *fb); +void folder_browser_ui_rm_list (FolderBrowser *fb); + +void folder_browser_ui_add_global (FolderBrowser *fb); +void folder_browser_ui_rm_global (FolderBrowser *fb); + +#endif /* _FOLDER_BROWSER_FACTORY_H */ diff --git a/mail/message-browser.c b/mail/message-browser.c index f3de72806a..39ff1249cc 100644 --- a/mail/message-browser.c +++ b/mail/message-browser.c @@ -25,6 +25,10 @@ #endif #include <gal/util/e-util.h> +#include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-ui-component.h> +#include <bonobo/bonobo-ui-container.h> +#include <bonobo/bonobo-ui-util.h> #include "message-browser.h" @@ -40,17 +44,19 @@ #include "mail-local.h" #include "mail-config.h" +#include "folder-browser-ui.h" + #define d(x) x #define MINIMUM_WIDTH 600 #define MINIMUM_HEIGHT 400 -#define PARENT_TYPE (gnome_app_get_type ()) +#define PARENT_TYPE BONOBO_TYPE_WINDOW /* Size of the window last time it was changed. */ static GtkAllocation last_allocation = { 0, 0 }; -static GnomeAppClass *message_browser_parent_class; +static BonoboWindowClass *message_browser_parent_class; static void message_browser_destroy (GtkObject *object) @@ -62,6 +68,9 @@ message_browser_destroy (GtkObject *object) gtk_object_unref (GTK_OBJECT (message_browser->fb)); gtk_widget_destroy (GTK_WIDGET (message_browser)); + + if (GTK_OBJECT_CLASS (message_browser_parent_class)->destroy) + (GTK_OBJECT_CLASS (message_browser_parent_class)->destroy) (object); } static void @@ -78,81 +87,21 @@ message_browser_init (GtkObject *object) } -static void -message_browser_close (GtkWidget *menuitem, gpointer user_data) -{ - gtk_widget_destroy (GTK_WIDGET (user_data)); -} - -static void -message_browser_reply_to_sender (GtkWidget *widget, gpointer user_data) -{ - MessageBrowser *mb = MESSAGE_BROWSER (user_data); - - reply_to_sender (NULL, mb->fb); -} - -static void -message_browser_reply_to_all (GtkWidget *widget, gpointer user_data) -{ - MessageBrowser *mb = MESSAGE_BROWSER (user_data); - - reply_to_all (NULL, mb->fb); -} +/* UI callbacks */ static void -message_browser_forward_msg (GtkWidget *widget, gpointer user_data) +message_browser_close (BonoboUIComponent *uih, void *user_data, const char *path) { - MessageBrowser *mb = MESSAGE_BROWSER (user_data); - - forward (NULL, mb->fb); -} - -static void -message_browser_print_msg (GtkWidget *widget, gpointer user_data) -{ - MessageBrowser *mb = MESSAGE_BROWSER (user_data); - - mail_print_msg (mb->fb->mail_display); -} - -static void -message_browser_delete_msg (GtkWidget *button, gpointer user_data) -{ - MessageBrowser *mb = MESSAGE_BROWSER (user_data); - - delete_msg (NULL, mb->fb); + gtk_widget_destroy (GTK_WIDGET (user_data)); } -static void -message_browser_next_msg (GtkWidget *button, gpointer user_data) -{ - MessageBrowser *mb = MESSAGE_BROWSER (user_data); - int row; - - row = e_tree_row_of_node (mb->fb->message_list->tree, - e_tree_get_cursor (mb->fb->message_list->tree)); - - message_list_select (mb->fb->message_list, row, - MESSAGE_LIST_SELECT_NEXT, - 0, 0); - -} +static BonoboUIVerb +browser_verbs [] = { + BONOBO_UI_UNSAFE_VERB ("MessageBrowserClose", message_browser_close), + BONOBO_UI_VERB_END +}; -static void -message_browser_prev_msg (GtkWidget *button, gpointer user_data) -{ - MessageBrowser *mb = MESSAGE_BROWSER (user_data); - int row; - - row = e_tree_row_of_node (mb->fb->message_list->tree, - e_tree_get_cursor (mb->fb->message_list->tree)); - - message_list_select (mb->fb->message_list, row, - MESSAGE_LIST_SELECT_PREVIOUS, - 0, 0); - -} +/* FB message loading hookups */ static void message_browser_message_loaded (FolderBrowser *fb, const char *uid, MessageBrowser *mb) @@ -189,58 +138,7 @@ message_browser_folder_loaded (FolderBrowser *fb, const char *uri, MessageBrowse message_browser_message_list_built, mb); } -static GnomeUIInfo message_browser_toolbar [] = { - - /*GNOMEUIINFO_ITEM_STOCK (N_("Save"), N_("Save this message"), - save_msg, GNOME_STOCK_PIXMAP_SAVE),*/ - - GNOMEUIINFO_ITEM_STOCK (N_("Reply"), N_("Reply to the sender of this message"), - message_browser_reply_to_sender, GNOME_STOCK_PIXMAP_MAIL_RPL), - - GNOMEUIINFO_ITEM_STOCK (N_("Reply to All"), N_("Reply to all recipients of this message"), - message_browser_reply_to_all, GNOME_STOCK_PIXMAP_MAIL_RPL), - - GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Forward this message"), - message_browser_forward_msg, GNOME_STOCK_PIXMAP_MAIL_FWD), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), - message_browser_print_msg, GNOME_STOCK_PIXMAP_PRINT), - - GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete this message"), - message_browser_delete_msg, GNOME_STOCK_PIXMAP_TRASH), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Previous"), N_("Previous message"), - message_browser_prev_msg, GNOME_STOCK_PIXMAP_BACK), - - GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Next message"), - message_browser_next_msg, GNOME_STOCK_PIXMAP_FORWARD), - - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_menu[] = { - /*GNOMEUIINFO_MENU_SAVE_ITEM (save, NULL),*/ - /*GNOMEUIINFO_MENU_SAVE_AS_ITEM (save_as, NULL),*/ - /*GNOMEUIINFO_SEPARATOR,*/ - GNOMEUIINFO_MENU_CLOSE_ITEM (message_browser_close, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_menu[] = -{ - GNOMEUIINFO_END -}; - -static GnomeUIInfo message_browser_menubar[] = -{ - GNOMEUIINFO_MENU_FILE_TREE (file_menu), - GNOMEUIINFO_MENU_VIEW_TREE (view_menu), - GNOMEUIINFO_END -}; +/* Construction */ static void set_default_size (GtkWidget *widget) @@ -253,6 +151,53 @@ set_default_size (GtkWidget *widget) gtk_window_set_default_size (GTK_WINDOW (widget), width, height); } +static void +set_bonobo_ui (GtkWidget *widget, FolderBrowser *fb) +{ + BonoboUIContainer *uicont; + BonoboUIComponent *uic; + CORBA_Environment ev; + + uicont = bonobo_ui_container_new (); + bonobo_ui_container_set_win (uicont, BONOBO_WINDOW (widget)); + + uic = bonobo_ui_component_new_default (); + bonobo_ui_component_set_container (uic, BONOBO_OBJREF (uicont)); + folder_browser_set_ui_component (fb, uic); + + /* Load our UI */ + + bonobo_ui_component_freeze (uic, NULL); + bonobo_ui_util_set_ui (uic, EVOLUTION_DATADIR, "evolution-mail-messagedisplay.xml", "evolution-mail"); + + /* Load the appropriate UI stuff from the folder browser */ + + folder_browser_ui_add_message (fb); + + /* We just opened the message! We don't need to open it again. */ + + CORBA_exception_init (&ev); + bonobo_ui_component_rm (uic, "/menu/File/FileOps/MessageOpen", &ev); + if (BONOBO_EX (&ev)) + g_warning ("Couldn't remove message open item. Weird. Error: %s", + bonobo_exception_get_text (&ev)); + CORBA_exception_free (&ev); + + /* Customize Toolbar thingie */ + + bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (BONOBO_WINDOW (widget)), + "/evolution/UIConf/messagebrowser"); + + /* Add the Close item */ + + bonobo_ui_component_add_verb_list_with_data (uic, browser_verbs, widget); + + /* Done */ + + bonobo_ui_component_thaw (uic, NULL); + +} + GtkWidget * message_browser_new (const GNOME_Evolution_Shell shell, const char *uri, const char *uid) { @@ -260,18 +205,20 @@ message_browser_new (const GNOME_Evolution_Shell shell, const char *uri, const c MessageBrowser *new; FolderBrowser *fb; - new = gtk_type_new (message_browser_get_type ()); - - gnome_app_construct (GNOME_APP (new), "Evolution", ""); - + new = gtk_type_new (MESSAGE_BROWSER_TYPE); + new = (MessageBrowser *) bonobo_window_construct (BONOBO_WINDOW (new), "Evolution", ""); + if (!new) { + g_warning ("Failed to construct Bonobo window!"); + return NULL; + } + gtk_object_set_data_full (GTK_OBJECT (new), "uid", g_strdup (uid), g_free); - gnome_app_create_toolbar_with_data (GNOME_APP (new), message_browser_toolbar, new); - gnome_app_create_menus_with_data (GNOME_APP (new), message_browser_menubar, new); - fb = FOLDER_BROWSER (folder_browser_new (shell)); new->fb = fb; - + + set_bonobo_ui (GTK_WIDGET (new), fb); + /* some evil hackery action... */ vbox = gtk_vbox_new (TRUE, 0); gtk_widget_ref (GTK_WIDGET (fb->mail_display)); @@ -279,7 +226,7 @@ message_browser_new (const GNOME_Evolution_Shell shell, const char *uri, const c gtk_widget_show (GTK_WIDGET (fb->mail_display)); gtk_widget_show (vbox); - gnome_app_set_contents (GNOME_APP (new), vbox); + bonobo_window_set_contents (BONOBO_WINDOW (new), vbox); gtk_widget_grab_focus (GTK_WIDGET (MAIL_DISPLAY (fb->mail_display)->html)); set_default_size (GTK_WIDGET (new)); @@ -296,6 +243,7 @@ message_browser_new (const GNOME_Evolution_Shell shell, const char *uri, const c return GTK_WIDGET (new); } +/* Fin */ E_MAKE_TYPE (message_browser, "MessageBrowser", MessageBrowser, message_browser_class_init, message_browser_init, PARENT_TYPE); diff --git a/mail/message-browser.h b/mail/message-browser.h index 365a2cd6da..208396bff4 100644 --- a/mail/message-browser.h +++ b/mail/message-browser.h @@ -24,6 +24,8 @@ #define _MESSAGE_BROWSER_H_ #include <gnome.h> +#include <bonobo/bonobo-win.h> + #include <camel/camel-folder.h> #include "folder-browser.h" #include "mail-display.h" @@ -35,9 +37,8 @@ #define IS_MESSAGE_BROWSER(o) (GTK_CHECK_TYPE ((o), MESSAGE_BROWSER_TYPE)) #define IS_MESSAGE_BROWSER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), MESSAGE_BROWSER_TYPE)) - struct _MessageBrowser { - GnomeApp parent; + BonoboWindow parent; /* * The current URI being displayed by the MessageBrowser @@ -47,7 +48,7 @@ struct _MessageBrowser { typedef struct { - GnomeAppClass parent_class; + BonoboWindowClass parent_class; } MessageBrowserClass; |