From 7c4ce285d03821cbb13cadd74ae491abed3c3bdf Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 5 May 2009 22:40:51 -0400 Subject: Convert the vCard Bonobo control to an EMFormatHook plugin. --- mail/em-format-html-display.c | 208 ++---------------------------------------- 1 file changed, 6 insertions(+), 202 deletions(-) (limited to 'mail') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index f20af59683..bc2f4e25bf 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -46,11 +46,6 @@ #include -#include -#include -#include -#include - #include #include #include @@ -174,8 +169,6 @@ static void efhd_format_optional(EMFormat *, CamelStream *, CamelMimePart *, Cam static void efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid); static void efhd_complete(EMFormat *); -static gboolean efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); -static gboolean efhd_use_component(const char *mime_type); static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); enum { @@ -187,8 +180,6 @@ enum { static guint efhd_signals[EFHD_LAST_SIGNAL] = { 0 }; -/* EMFormatHandler's for bonobo objects */ -static GHashTable *efhd_bonobo_handlers; static EMFormatHTMLClass *efhd_parent; static EMFormatClass *efhd_format_class; @@ -338,7 +329,7 @@ efhd_class_init(GObjectClass *klass) } GType -em_format_html_display_get_type(void) +em_format_html_display_get_type (void) { static GType type = 0; @@ -354,8 +345,6 @@ em_format_html_display_get_type(void) efhd_parent = g_type_class_ref(em_format_html_get_type()); efhd_format_class = g_type_class_ref(em_format_get_type()); type = g_type_register_static(em_format_html_get_type(), "EMFormatHTMLDisplay", &info, 0); - - efhd_bonobo_handlers = g_hash_table_new(g_str_hash, g_str_equal); } return type; @@ -1274,38 +1263,10 @@ efhd_builtin_init(EMFormatHTMLDisplayClass *efhc) em_format_class_add_handler((EMFormatClass *)efhc, &type_builtin_table[i]); } -/* ********************************************************************** */ -static void -efhd_bonobo_unknown(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) -{ - char *classid; - - classid = g_strdup_printf("bonobo-unknown:///em-format-html-display/%s", emf->part_id->str); - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_bonobo_object); - camel_stream_printf(stream, "
\n", classid, info->mime_type); - g_free(classid); -} - - /* ********************************************************************** */ -static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_type) +static const EMFormatHandler * +efhd_find_handler(EMFormat *emf, const char *mime_type) { - const EMFormatHandler *handle; - - if ( (handle = ((EMFormatClass *)efhd_parent)->find_handler(emf, mime_type)) == NULL - && efhd_use_component(mime_type) - && (handle = g_hash_table_lookup(efhd_bonobo_handlers, mime_type)) == NULL) { - - EMFormatHandler *h = g_malloc0(sizeof(*h)); - - h->mime_type = g_strdup(mime_type); - h->handler = efhd_bonobo_unknown; - h->flags = EM_FORMAT_HANDLER_INLINE_DISPOSITION; - g_hash_table_insert(efhd_bonobo_handlers, h->mime_type, h); - - handle = h; - } - - return handle; + return ((EMFormatClass *) efhd_parent)->find_handler (emf, mime_type); } static void efhd_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *src) @@ -1843,155 +1804,6 @@ efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) } } -static gboolean -efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) -{ - CamelDataWrapper *wrapper; - Bonobo_ServerInfo *component; - GtkWidget *embedded; - Bonobo_PersistStream persist; - CORBA_Environment ev; - CamelStreamMem *cstream; - BonoboStream *bstream; - BonoboControlFrame *control_frame; - Bonobo_PropertyBag prop_bag; - - component = bonobo_activation_get_default_component_for_mime_type (eb->type); - if (component == NULL) - return FALSE; - - embedded = bonobo_widget_new_control(component->iid, NULL); - CORBA_free(component); - if (embedded == NULL) - return FALSE; - - CORBA_exception_init(&ev); - - control_frame = bonobo_widget_get_control_frame((BonoboWidget *)embedded); - prop_bag = bonobo_control_frame_get_control_property_bag(control_frame, NULL); - if (prop_bag != CORBA_OBJECT_NIL) { - /* - * Now we can take care of business. Currently, the only control - * that needs something passed to it through a property bag is - * the iTip control, and it needs only the From email address, - * but perhaps in the future we can generalize this section of code - * to pass a bunch of useful things to all embedded controls. - */ - const CamelInternetAddress *from; - char *from_address; - - from = camel_mime_message_get_from((CamelMimeMessage *)((EMFormat *)efh)->message); - from_address = camel_address_encode((CamelAddress *)from); - bonobo_property_bag_client_set_value_string(prop_bag, "from_address", from_address, &ev); - g_free(from_address); - - Bonobo_Unknown_unref(prop_bag, &ev); - } - - persist = (Bonobo_PersistStream)Bonobo_Unknown_queryInterface(bonobo_widget_get_objref((BonoboWidget *)embedded), - "IDL:Bonobo/PersistStream:1.0", &ev); - if (persist == CORBA_OBJECT_NIL) { - g_object_ref_sink(embedded); - CORBA_exception_free(&ev); - return FALSE; - } - - /* Write the data to a CamelStreamMem... */ - cstream = (CamelStreamMem *)camel_stream_mem_new(); - wrapper = camel_medium_get_content_object((CamelMedium *)pobject->part); - if (FALSE && !g_ascii_strncasecmp (eb->type, "text/", 5)) { - /* do charset conversion, etc */ - d(printf("performing charset conversion for %s component\n", eb->type)); - em_format_format_text((EMFormat *)efh, (CamelStream *)cstream, wrapper); - } else { - camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) cstream); - } - - /* ...convert the CamelStreamMem to a BonoboStreamMem... */ - bstream = bonobo_stream_mem_create((char *)cstream->buffer->data, cstream->buffer->len, TRUE, FALSE); - camel_object_unref(cstream); - - /* ...and hydrate the PersistStream from the BonoboStream. */ - Bonobo_PersistStream_load(persist, - bonobo_object_corba_objref(BONOBO_OBJECT (bstream)), - eb->type, &ev); - bonobo_object_unref(BONOBO_OBJECT (bstream)); - Bonobo_Unknown_unref(persist, &ev); - CORBA_Object_release(persist, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_object_ref_sink(embedded); - CORBA_exception_free(&ev); - return FALSE; - } - CORBA_exception_free(&ev); - - gtk_widget_show(embedded); - gtk_container_add(GTK_CONTAINER (eb), embedded); - - return TRUE; -} - -static gboolean -efhd_check_server_prop(Bonobo_ServerInfo *component, const char *propname, const char *value) -{ - CORBA_sequence_CORBA_string stringv; - Bonobo_ActivationProperty *prop; - int i; - - prop = bonobo_server_info_prop_find(component, propname); - if (!prop || prop->v._d != Bonobo_ACTIVATION_P_STRINGV) - return FALSE; - - stringv = prop->v._u.value_stringv; - for (i = 0; i < stringv._length; i++) { - if (!g_ascii_strcasecmp(value, stringv._buffer[i])) - return TRUE; - } - - return FALSE; -} - -static gboolean -efhd_use_component(const char *mime_type) -{ - GList *components, *iter; - Bonobo_ServerInfo *component = NULL; - - /* should this cache it? */ - - if (g_ascii_strcasecmp(mime_type, "text/x-vcard") != 0 - && g_ascii_strcasecmp(mime_type, "text/calendar") != 0) { - const char **mime_types; - int i; - - mime_types = mail_config_get_allowable_mime_types(); - for (i = 0; mime_types[i]; i++) { - if (!g_ascii_strcasecmp(mime_types[i], mime_type)) - goto type_ok; - } - return FALSE; - } -type_ok: - components = bonobo_activation_get_all_components_for_mime_type (mime_type); - for (iter = components; iter; iter = iter->next) { - Bonobo_ServerInfo *comp = iter->data; - - comp = iter->data; - if (efhd_check_server_prop(comp, "repo_ids", "IDL:Bonobo/PersistStream:1.0") - && efhd_check_server_prop(comp, "bonobo:supported_mime_types", mime_type)) { - component = comp; - break; - } - } - - /* FIXME: How should I free the Bonobo_ServerInfo's ? */ - g_list_foreach (components, (GFunc)CORBA_free, NULL); - g_list_free (components); - - return component != NULL; -} - static void efhd_bar_resize (EMFormatHTML *efh, GtkAllocation *event) @@ -2097,16 +1909,8 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, stream, "\n" EM_FORMAT_HTML_VPAD); - if (handle) { - if (info->shown) - handle->handler(emf, stream, part, handle); - } else if (efhd_use_component(mime_type)) { - g_free(classid); /* messy */ - - classid = g_strdup_printf("bonobo-unknown:///em-format-html-display/%s", emf->part_id->str); - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_bonobo_object); - camel_stream_printf(stream, "
>\n", classid, mime_type); - } + if (handle && info->shown) + handle->handler(emf, stream, part, handle); g_free(classid); } -- cgit From fee1642fc78d80a382c5c96cb294f4bd3d00be77 Mon Sep 17 00:00:00 2001 From: Johnny Jacob Date: Wed, 13 May 2009 12:30:35 +0530 Subject: Bug 581424 - Personal folder tree appears besides Public folder in subscription editor. mail/em-subscribe-editor.c (sub_folderinfo_exec): Use CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST for requesting list of subscribable folders. --- mail/em-subscribe-editor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mail') diff --git a/mail/em-subscribe-editor.c b/mail/em-subscribe-editor.c index 724b9b4874..9842e32d0e 100644 --- a/mail/em-subscribe-editor.c +++ b/mail/em-subscribe-editor.c @@ -356,7 +356,8 @@ sub_folderinfo_exec (struct _emse_folderinfo_msg *m) if (m->seq == m->sub->seq) { camel_operation_register(m->base.cancel); - m->info = camel_store_get_folder_info(m->sub->store, m->node?m->node->info->full_name:pub_full_name, CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL, &m->base.ex); + m->info = camel_store_get_folder_info(m->sub->store, m->node?m->node->info->full_name:pub_full_name, + CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL | CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST, &m->base.ex); camel_operation_unregister(m->base.cancel); } } -- cgit From ea3e4f239a529716452159d5deac20cd9a38c832 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 14 May 2009 21:20:55 -0400 Subject: Bug 458491 – Remove useless "Call To..." popup menu option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mail/em-folder-view.c | 1 - mail/em-popup.c | 5 ----- mail/em-popup.h | 4 +--- 3 files changed, 1 insertion(+), 9 deletions(-) (limited to 'mail') diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 8e220955fa..2fa04b5990 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -2752,7 +2752,6 @@ emp_uri_popup_link_copy(EPopup *ep, EPopupItem *pitem, void *data) } static EPopupItem emfv_uri_popups[] = { - { E_POPUP_ITEM, "00.uri.11", N_("C_all To..."), emp_uri_popup_link_copy, NULL, NULL, EM_POPUP_URI_CALLTO }, { E_POPUP_ITEM, "00.uri.15", N_("_Copy Link Location"), emp_uri_popup_link_copy, NULL, "edit-copy", EM_POPUP_URI_NOT_MAILTO }, { E_POPUP_SUBMENU, "99.uri.00", N_("Create _Search Folder"), NULL, NULL, NULL, EM_POPUP_URI_MAILTO }, diff --git a/mail/em-popup.c b/mail/em-popup.c index debad8cb56..192ab7ac7b 100644 --- a/mail/em-popup.c +++ b/mail/em-popup.c @@ -261,10 +261,6 @@ em_popup_target_new_uri(EMPopup *emp, const char *uri) if (g_ascii_strncasecmp(uri, "http:", 5) == 0 || g_ascii_strncasecmp(uri, "https:", 6) == 0) mask &= ~EM_POPUP_URI_HTTP; - else if (g_ascii_strncasecmp(uri, "sip:", 3) == 0 - || g_ascii_strncasecmp(uri, "h323:", 5) == 0 - || g_ascii_strncasecmp(uri, "callto:", 7) == 0) - mask &= ~EM_POPUP_URI_CALLTO; if (g_ascii_strncasecmp(uri, "mailto:", 7) == 0) mask &= ~EM_POPUP_URI_MAILTO; @@ -824,7 +820,6 @@ static const EPopupHookTargetMask emph_uri_masks[] = { { "http", EM_POPUP_URI_HTTP }, { "mailto", EM_POPUP_URI_MAILTO }, { "notmailto", EM_POPUP_URI_NOT_MAILTO }, - { "callto", EM_POPUP_URI_CALLTO }, { NULL } }; diff --git a/mail/em-popup.h b/mail/em-popup.h index 77f80e5599..8df98a6488 100644 --- a/mail/em-popup.h +++ b/mail/em-popup.h @@ -113,14 +113,12 @@ enum _em_popup_target_select_t { * @EM_POPUP_URI_HTTP: This is a HTTP or HTTPS url. * @EM_POPUP_URI_MAILTO: This is a MAILTO url. * @EM_POPUP_URI_NOT_MAILTO: This is not a MAILTO url. - * @EM_POPUP_URI_CALLTO: This is a CALLTO url. * **/ enum _em_popup_target_uri_t { EM_POPUP_URI_HTTP = 1<<0, EM_POPUP_URI_MAILTO = 1<<1, - EM_POPUP_URI_NOT_MAILTO = 1<<2, - EM_POPUP_URI_CALLTO = 1<<3, + EM_POPUP_URI_NOT_MAILTO = 1<<2 }; /** -- cgit From e4fa8fe10408c4c370e1e11e4bb2d7745f50aceb Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 16 May 2009 12:11:55 -0400 Subject: Fix several types of pedantic compiler warnings. --- mail/em-account-editor.h | 2 +- mail/em-composer-utils.c | 2 +- mail/em-config.h | 2 +- mail/em-event.h | 14 +++++++------- mail/em-folder-browser.c | 4 ++-- mail/em-folder-selector.h | 4 ++-- mail/em-folder-tree-model.c | 2 +- mail/em-folder-view.c | 2 +- mail/em-folder-view.h | 2 +- mail/em-format-html-display.c | 6 +++--- mail/em-format-html.h | 2 +- mail/em-format.c | 4 ++-- mail/em-format.h | 4 ++-- mail/em-inline-filter.c | 2 +- mail/em-mailer-prefs.c | 18 +++--------------- mail/em-menu.h | 2 +- mail/em-migrate.c | 4 ++-- mail/em-popup.h | 6 +++--- mail/em-sync-stream.c | 2 +- mail/em-vfolder-rule.c | 2 +- mail/em-vfolder-rule.h | 2 +- mail/mail-autofilter.h | 2 +- mail/mail-component.h | 2 +- mail/mail-mt.c | 2 +- mail/mail-mt.h | 4 ++-- mail/mail-ops.c | 4 ++-- mail/message-list.c | 6 +++--- mail/message-list.h | 4 ++-- 28 files changed, 50 insertions(+), 62 deletions(-) (limited to 'mail') diff --git a/mail/em-account-editor.h b/mail/em-account-editor.h index 9a5b09afe3..43e5c0652c 100644 --- a/mail/em-account-editor.h +++ b/mail/em-account-editor.h @@ -38,7 +38,7 @@ typedef struct _EMAccountEditorClass EMAccountEditorClass; typedef enum { EMAE_NOTEBOOK, - EMAE_DRUID, + EMAE_DRUID } em_account_editor_t; struct _EMAccountEditor { diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 0425645abe..2336f3c798 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -2047,7 +2047,7 @@ enum { ATTRIB_TM_YEAR, ATTRIB_TM_2YEAR, ATTRIB_TM_WDAY, /* not actually used */ - ATTRIB_TM_YDAY, + ATTRIB_TM_YDAY }; typedef void (* AttribFormatter) (GString *str, const char *attr, CamelMimeMessage *message); diff --git a/mail/em-config.h b/mail/em-config.h index 5530d27d00..ba19bb1c37 100644 --- a/mail/em-config.h +++ b/mail/em-config.h @@ -42,7 +42,7 @@ typedef struct _EMConfigClass EMConfigClass; enum _em_config_target_t { EM_CONFIG_TARGET_FOLDER, EM_CONFIG_TARGET_PREFS, - EM_CONFIG_TARGET_ACCOUNT, + EM_CONFIG_TARGET_ACCOUNT }; typedef struct _EMConfigTargetFolder EMConfigTargetFolder; diff --git a/mail/em-event.h b/mail/em-event.h index eb45050a27..21df1df42d 100644 --- a/mail/em-event.h +++ b/mail/em-event.h @@ -49,37 +49,37 @@ enum _em_event_target_t { EM_EVENT_TARGET_MESSAGE, EM_EVENT_TARGET_COMPOSER, EM_EVENT_TARGET_SEND_RECEIVE, - EM_EVENT_TARGET_CUSTOM_ICON, + EM_EVENT_TARGET_CUSTOM_ICON }; /* Flags for FOLDER BROWSER Events*/ enum { - EM_EVENT_FOLDER_BROWSER = 1<< 0, + EM_EVENT_FOLDER_BROWSER = 1<< 0 }; /* Flags that describe TARGET_FOLDER */ enum { - EM_EVENT_FOLDER_NEWMAIL = 1<< 0, + EM_EVENT_FOLDER_NEWMAIL = 1<< 0 }; /* Flags that describe TARGET_MESSAGE */ enum { - EM_EVENT_MESSAGE_REPLY_ALL = 1<< 0, + EM_EVENT_MESSAGE_REPLY_ALL = 1<< 0 }; /* Flags that describe TARGET_COMPOSER */ enum { - EM_EVENT_COMPOSER_SEND_OPTION = 1<< 0, + EM_EVENT_COMPOSER_SEND_OPTION = 1<< 0 }; /* Flags that describe TARGET_SEND_RECEIVE*/ enum { - EM_EVENT_SEND_RECEIVE = 1<< 0, + EM_EVENT_SEND_RECEIVE = 1<< 0 }; /* Flags that describe TARGET_CUSTOM_ICON*/ enum { - EM_EVENT_CUSTOM_ICON = 1<< 0, + EM_EVENT_CUSTOM_ICON = 1<< 0 }; typedef struct _EMEventTargetFolder EMEventTargetFolder; diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c index 58e42a5834..7a3e690e2b 100644 --- a/mail/em-folder-browser.c +++ b/mail/em-folder-browser.c @@ -181,7 +181,7 @@ enum { static guint folder_browser_signals [LAST_SIGNAL] = {0, }; enum { - ESB_SAVE, + ESB_SAVE }; static ESearchBarItem emfb_search_items[] = { @@ -1363,7 +1363,7 @@ emfb_list_key_press(ETree *tree, int row, ETreePath path, int col, GdkEvent *ev, } if (!folder_choose && !emfb->view.preview->caret_mode && mail_config_get_enable_magic_spacebar ()) { - //check for unread messages. if yes .. rewindback to the folder + /* check for unread messages. if yes .. rewindback to the folder */ EMFolderTree *emft = g_object_get_data((GObject*)emfb, "foldertree"); switch (ev->key.keyval) { case GDK_space: diff --git a/mail/em-folder-selector.h b/mail/em-folder-selector.h index 06b1bc4520..7b011f588c 100644 --- a/mail/em-folder-selector.h +++ b/mail/em-folder-selector.h @@ -61,11 +61,11 @@ struct _EMFolderSelectorClass { }; enum { - EM_FOLDER_SELECTOR_CAN_CREATE = 1, + EM_FOLDER_SELECTOR_CAN_CREATE = 1 }; enum { - EM_FOLDER_SELECTOR_RESPONSE_NEW = 1, + EM_FOLDER_SELECTOR_RESPONSE_NEW = 1 }; GType em_folder_selector_get_type (void); diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 8687b1cbd2..04e66e2c86 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -295,7 +295,7 @@ em_folder_tree_model_init (EMFolderTreeModel *model) model->account_hash = g_hash_table_new (g_direct_hash, g_direct_equal); model->account_changed_id = g_signal_connect (model->accounts, "account-changed", G_CALLBACK (account_changed), model); model->account_removed_id = g_signal_connect (model->accounts, "account-removed", G_CALLBACK (account_removed), model); - //g_signal_connect (model, "row-changed", G_CALLBACK (emft_model_unread_count_changed), NULL); + /* g_signal_connect (model, "row-changed", G_CALLBACK (emft_model_unread_count_changed), NULL); */ } static void diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 2fa04b5990..42037b5a33 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -2821,7 +2821,7 @@ emfv_append_menu (EMPopup *des_emp, GtkMenu *des_menu, EMPopup *src_emp, GtkMenu gtk_widget_destroy (GTK_WIDGET (src_menu)); /* free src_emp together with des_emp; name contains unique identifier */ - name = g_strdup_printf ("emp_%p", src_emp); + name = g_strdup_printf ("emp_%p", (gpointer) src_emp); g_object_set_data_full (G_OBJECT (des_emp), name, src_emp, emfv_free_em_popup); g_free (name); diff --git a/mail/em-folder-view.h b/mail/em-folder-view.h index 42ef20d296..4af4760cac 100644 --- a/mail/em-folder-view.h +++ b/mail/em-folder-view.h @@ -67,7 +67,7 @@ enum { EM_FOLDER_VIEW_SELECT_SELECTION = EM_POPUP_SELECT_LAST<<6, EM_FOLDER_VIEW_SELECT_NOSELECTION = EM_POPUP_SELECT_LAST<<7, EM_FOLDER_VIEW_PREVIEW_PRESENT = EM_POPUP_SELECT_LAST<<8, - EM_FOLDER_VIEW_SELECT_LAST = EM_POPUP_SELECT_LAST<<9, + EM_FOLDER_VIEW_SELECT_LAST = EM_POPUP_SELECT_LAST<<9 }; struct _EMFolderViewEnable { diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index f20af59683..68a28ea7cd 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -182,7 +182,7 @@ enum { EFHD_LINK_CLICKED, EFHD_POPUP_EVENT, EFHD_ON_URL, - EFHD_LAST_SIGNAL, + EFHD_LAST_SIGNAL }; static guint efhd_signals[EFHD_LAST_SIGNAL] = { 0 }; @@ -606,11 +606,11 @@ em_format_html_get_search_dialog (EMFormatHTMLDisplay *efhd) g_signal_connect (G_OBJECT (p->search_entry), "changed", (GCallback) icon_entry_changed_cb, clear_button); gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, FALSE, FALSE, 0); -// gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, TRUE, TRUE, 0); + /* gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, TRUE, TRUE, 0); */ hbox2 = gtk_hbox_new (FALSE, 0); gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, FALSE, FALSE, 5); -// gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, TRUE, TRUE, 5); + /* gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, TRUE, TRUE, 5); */ button3 = gtk_button_new_with_mnemonic (_("_Previous")); gtk_button_set_image (GTK_BUTTON (button3), GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON))); diff --git a/mail/em-format-html.h b/mail/em-format-html.h index a34f7b6915..7cadd5e282 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -65,7 +65,7 @@ typedef struct _EMFormatHTMLPrivate EMFormatHTMLPrivate; enum _em_format_html_header_flags { EM_FORMAT_HTML_HEADER_TO = 1<<0, EM_FORMAT_HTML_HEADER_CC = 1<<1, - EM_FORMAT_HTML_HEADER_BCC = 1<<2, + EM_FORMAT_HTML_HEADER_BCC = 1<<2 }; typedef enum { diff --git a/mail/em-format.c b/mail/em-format.c index 89445ab35a..1d5570be96 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -82,7 +82,7 @@ static void emf_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart static gboolean emf_busy(EMFormat *emf); enum { EMF_COMPLETE, - EMF_LAST_SIGNAL, + EMF_LAST_SIGNAL }; static guint emf_signals[EMF_LAST_SIGNAL]; @@ -718,7 +718,7 @@ emf_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeM g_string_truncate(emf->part_id, 0); if (folder != NULL) /* TODO build some string based on the folder name/location? */ - g_string_append_printf(emf->part_id, ".%p", folder); + g_string_append_printf(emf->part_id, ".%p", (gpointer) folder); if (uid != NULL) g_string_append_printf(emf->part_id, ".%s", uid); } diff --git a/mail/em-format.h b/mail/em-format.h index 004d9c2e96..92c6b3dddf 100644 --- a/mail/em-format.h +++ b/mail/em-format.h @@ -71,7 +71,7 @@ typedef void (*EMFormatFunc) (EMFormat *md, CamelStream *stream, CamelMimePart * typedef enum _em_format_mode_t { EM_FORMAT_NORMAL, EM_FORMAT_ALLHEADERS, - EM_FORMAT_SOURCE, + EM_FORMAT_SOURCE } em_format_mode_t; /** @@ -103,7 +103,7 @@ struct _EMFormatHandler { **/ enum _em_format_handler_t { EM_FORMAT_HANDLER_INLINE = 1<<0, - EM_FORMAT_HANDLER_INLINE_DISPOSITION = 1<<1, + EM_FORMAT_HANDLER_INLINE_DISPOSITION = 1<<1 }; diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c index 07c7afa192..f671159369 100644 --- a/mail/em-inline-filter.c +++ b/mail/em-inline-filter.c @@ -102,7 +102,7 @@ enum { EMIF_BINHEX, EMIF_POSTSCRIPT, EMIF_PGPSIGNED, - EMIF_PGPENCRYPTED, + EMIF_PGPENCRYPTED }; static const struct { diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index e489e16826..9784f480b8 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -60,7 +60,7 @@ enum { HEADER_LIST_ENABLED_COLUMN, /* is the header enabled? */ HEADER_LIST_IS_DEFAULT_COLUMN, /* is this header a default header, eg From: */ HEADER_LIST_HEADER_COLUMN, /* the real name of this header */ - HEADER_LIST_N_COLUMNS, + HEADER_LIST_N_COLUMNS }; static GType col_types[] = { @@ -190,7 +190,7 @@ enum { enum { JH_LIST_COLUMN_NAME, - JH_LIST_COLUMN_VALUE, + JH_LIST_COLUMN_VALUE }; static void label_sensitive_buttons (EMMailerPrefs *prefs) @@ -356,7 +356,7 @@ jh_add_cb (GtkWidget *widget, gpointer user_data) char *tok; GSList *list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL); - //FIXME: Validate the values + /* FIXME: Validate the values */ tok = g_strdup_printf ("%s=%s", name, value); list = g_slist_append (list, tok); @@ -842,18 +842,6 @@ custom_junk_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs) } -#if 0 -// not used at the moment, commenting out -static void -toggle_button_toggled_not (GtkToggleButton *toggle, EMMailerPrefs *prefs) -{ - const char *key; - - key = g_object_get_data ((GObject *) toggle, "key"); - gconf_client_set_bool (prefs->gconf, key, !gtk_toggle_button_get_active (toggle), NULL); -} -#endif - static void custom_font_changed (GtkToggleButton *toggle, EMMailerPrefs *prefs) { diff --git a/mail/em-menu.h b/mail/em-menu.h index 48fc96b7fc..08467fefd8 100644 --- a/mail/em-menu.h +++ b/mail/em-menu.h @@ -40,7 +40,7 @@ typedef struct _EMMenuClass EMMenuClass; /* Types of popup tagets */ enum _em_menu_target_t { EM_MENU_TARGET_SELECT, - EM_MENU_TARGET_WIDGET, + EM_MENU_TARGET_WIDGET }; /* Flags that describe a TARGET_SELECT */ diff --git a/mail/em-migrate.c b/mail/em-migrate.c index 8338bf56dc..1c58b6ca99 100644 --- a/mail/em-migrate.c +++ b/mail/em-migrate.c @@ -1347,7 +1347,7 @@ nofile: enum { CP_UNIQUE = 0, CP_OVERWRITE, - CP_APPEND, + CP_APPEND }; static int open_flags[3] = { @@ -2936,7 +2936,7 @@ migrate_to_db() i++; e_iterator_next (iter); } - //camel_session_set_online ((CamelSession *) session, TRUE); + /* camel_session_set_online ((CamelSession *) session, TRUE); */ g_object_unref (iter); em_migrate_close_progress_dialog (); } diff --git a/mail/em-popup.h b/mail/em-popup.h index 8df98a6488..870055140b 100644 --- a/mail/em-popup.h +++ b/mail/em-popup.h @@ -104,7 +104,7 @@ enum _em_popup_target_select_t { EM_POPUP_SELECT_FOLDER = 1<<15, /* do we have any folder at all? */ EM_POPUP_SELECT_JUNK = 1<<16, EM_POPUP_SELECT_NOT_JUNK = 1<<17, - EM_POPUP_SELECT_LAST = 1<<18, + EM_POPUP_SELECT_LAST = 1<<18 }; /** @@ -130,7 +130,7 @@ enum _em_popup_target_uri_t { **/ enum _em_popup_target_part_t { EM_POPUP_PART_MESSAGE = 1<<0, - EM_POPUP_PART_IMAGE = 1<<1, + EM_POPUP_PART_IMAGE = 1<<1 }; /** @@ -151,7 +151,7 @@ enum _em_popup_target_folder_t { EM_POPUP_FOLDER_DELETE = 1<<3, /* folder can be deleted/renamed */ EM_POPUP_FOLDER_SELECT = 1<<4, /* folder can be selected/opened */ EM_POPUP_FOLDER_OUTBOX = 1<<5, /* Outbox folder */ - EM_POPUP_FOLDER_NONSTATIC = 1<<6, /* Except static folders like Outbox.*/ + EM_POPUP_FOLDER_NONSTATIC = 1<<6 /* Except static folders like Outbox.*/ }; typedef struct _EMPopupTargetSelect EMPopupTargetSelect; diff --git a/mail/em-sync-stream.c b/mail/em-sync-stream.c index ce388eea42..311c2e1b7a 100644 --- a/mail/em-sync-stream.c +++ b/mail/em-sync-stream.c @@ -39,7 +39,7 @@ enum _write_msg_t { EMSS_WRITE, EMSS_FLUSH, - EMSS_CLOSE, + EMSS_CLOSE }; struct _write_msg { diff --git a/mail/em-vfolder-rule.c b/mail/em-vfolder-rule.c index 6e12a0456d..a777faaefe 100644 --- a/mail/em-vfolder-rule.c +++ b/mail/em-vfolder-rule.c @@ -366,7 +366,7 @@ rule_copy(FilterRule *dest, FilterRule *src) enum { BUTTON_ADD, BUTTON_REMOVE, - BUTTON_LAST, + BUTTON_LAST }; struct _source_data { diff --git a/mail/em-vfolder-rule.h b/mail/em-vfolder-rule.h index 18f8c3156b..bc6a330c4b 100644 --- a/mail/em-vfolder-rule.h +++ b/mail/em-vfolder-rule.h @@ -37,7 +37,7 @@ enum _em_vfolder_rule_with_t { EM_VFOLDER_RULE_WITH_SPECIFIC, EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE, EM_VFOLDER_RULE_WITH_REMOTE_ACTIVE, - EM_VFOLDER_RULE_WITH_LOCAL, + EM_VFOLDER_RULE_WITH_LOCAL }; typedef struct _EMVFolderRule EMVFolderRule; diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h index 9f2f66674a..bae8bd8313 100644 --- a/mail/mail-autofilter.h +++ b/mail/mail-autofilter.h @@ -35,7 +35,7 @@ enum { AUTO_SUBJECT = 1, AUTO_FROM = 2, AUTO_TO = 4, - AUTO_MLIST = 8, + AUTO_MLIST = 8 }; struct _FilterRule *em_vfolder_rule_from_message(struct _EMVFolderContext *context, struct _CamelMimeMessage *msg, int flags, const char *source); diff --git a/mail/mail-component.h b/mail/mail-component.h index 3aa088c890..c1215c61c4 100644 --- a/mail/mail-component.h +++ b/mail/mail-component.h @@ -47,7 +47,7 @@ enum _mail_component_folder_t { MAIL_COMPONENT_FOLDER_OUTBOX, MAIL_COMPONENT_FOLDER_SENT, MAIL_COMPONENT_FOLDER_TEMPLATES, - MAIL_COMPONENT_FOLDER_LOCAL_INBOX, + MAIL_COMPONENT_FOLDER_LOCAL_INBOX }; struct _MailComponent { diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 5d26c13b3f..6388a56938 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -132,7 +132,7 @@ mail_msg_new (MailMsgInfo *info) #ifdef LOG_OPS if (log_ops) - fprintf(log, "%p: New\n", msg); + fprintf(log, "%p: New\n", (gpointer) msg); #endif MAIL_MT_UNLOCK(mail_msg_lock); diff --git a/mail/mail-mt.h b/mail/mail-mt.h index dba4adee16..b95620a000 100644 --- a/mail/mail-mt.h +++ b/mail/mail-mt.h @@ -100,7 +100,7 @@ typedef struct _MailAsyncEvent { typedef enum _mail_async_event_t { MAIL_ASYNC_GUI, - MAIL_ASYNC_THREAD, + MAIL_ASYNC_THREAD } mail_async_event_t; typedef void (*MailAsyncFunc)(void *, void *, void *); @@ -119,7 +119,7 @@ typedef enum { MAIL_CALL_p_ppp, MAIL_CALL_p_pppp, MAIL_CALL_p_ppppp, - MAIL_CALL_p_ppippp, + MAIL_CALL_p_ppippp } mail_call_t; typedef void *(*MailMainFunc)(); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 896ec73aec..6feadd5b9c 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1657,9 +1657,9 @@ refresh_folder_desc (struct _sync_folder_msg *m) static void refresh_folder_exec (struct _sync_folder_msg *m) { - //camel_folder_sync (m->folder, FALSE, &m->base.ex); + /* camel_folder_sync (m->folder, FALSE, &m->base.ex); */ - //if (!camel_exception_is_set (&m->base.ex)) + /* if (!camel_exception_is_set (&m->base.ex)) */ camel_folder_refresh_info(m->folder, &m->base.ex); } diff --git a/mail/message-list.c b/mail/message-list.c index 68177535e2..e2c23db51a 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -126,7 +126,7 @@ static struct { enum { DND_X_UID_LIST, /* x-uid-list */ DND_MESSAGE_RFC822, /* message/rfc822 */ - DND_TEXT_URI_LIST, /* text/uri-list */ + DND_TEXT_URI_LIST /* text/uri-list */ }; /* What we send */ @@ -170,7 +170,7 @@ enum { NORMALISED_SUBJECT, NORMALISED_FROM, NORMALISED_TO, - NORMALISED_LAST, + NORMALISED_LAST }; /* #define SMART_ADDRESS_COMPARE */ @@ -4169,7 +4169,7 @@ regen_list_exec (struct _regen_list_msg *m) e_profile_event_emit("list.threaduids", m->folder->full_name, 0); - //camel_folder_summary_reload_from_db (m->folder->summary, NULL); + /* camel_folder_summary_reload_from_db (m->folder->summary, NULL); */ if (!camel_operation_cancel_check(m->base.cancel)) { camel_folder_sort_uids (m->folder, showuids); diff --git a/mail/message-list.h b/mail/message-list.h index 47be897fd2..15dae0fcb7 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -73,7 +73,7 @@ enum { /* Invisible columns */ COL_DELETED, COL_UNREAD, - COL_COLOUR, + COL_COLOUR }; #define MESSAGE_LIST_COLUMN_IS_ACTIVE(col) (col == COL_MESSAGE_STATUS || \ @@ -178,7 +178,7 @@ typedef enum { MESSAGE_LIST_SELECT_NEXT = 0, MESSAGE_LIST_SELECT_PREVIOUS = 1, MESSAGE_LIST_SELECT_DIRECTION = 1, /* direction mask */ - MESSAGE_LIST_SELECT_WRAP = 1<<1, /* option bit */ + MESSAGE_LIST_SELECT_WRAP = 1<<1 /* option bit */ } MessageListSelectDirection; GType message_list_get_type (void); -- cgit From 152d43ec92989b4a416c1fedf3ec133b48bee6ae Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 16 May 2009 17:19:51 -0400 Subject: Bug 582744 – CC field autofill doesn't work for replies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mail/em-composer-utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mail') diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 2336f3c798..0f9945b7d7 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -1789,7 +1789,10 @@ reply_get_composer (CamelMimeMessage *message, EAccount *account, e_composer_header_table_set_account (table, account); e_composer_header_table_set_subject (table, subject); e_composer_header_table_set_destinations_to (table, tov); - e_composer_header_table_set_destinations_cc (table, ccv); + + /* Add destinations instead of setting, so we don't remove + * automatic CC addresses that have already been added. */ + e_composer_header_table_add_destinations_cc (table, ccv); g_free (subject); -- cgit From 39024ea8d22d39ddb193fc6839f546d9f56e787d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 16 May 2009 23:12:43 -0400 Subject: Fix compiler warnings. --- mail/mail-folder-cache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'mail') diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index a1589cec79..ed3d583927 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -1048,10 +1048,7 @@ int mail_note_get_folder_from_uri(const char *uri, CamelFolder **folderp) gboolean mail_folder_cache_get_folder_info_flags (CamelFolder *folder, int *flags) { - char *uri; - - uri = mail_tools_folder_to_url (folder); - + char *uri = mail_tools_folder_to_url (folder); struct _find_info fi = { uri, NULL, NULL }; if (stores == NULL) -- cgit From a1f287ca6bf35d27e5dcb9b89a10f76e9abbd057 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 20 May 2009 12:02:30 -0400 Subject: Bug 274117 – Difficult to post a new message to newsgroups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completely rewrite how composer headers are managed. There's now two sets of headers (with some overlap): one set is for sending an email message, the other is for posting to a newsgroup. The correct set of headers is chosen on-the-fly based on the currently selected account type. The user's "view" preferences for these two sets are stored separately, so that switching between an email account and a news account will no longer stomp on your preferences. This also eliminates the need for the "Post New Message to Folder" and "Post a Reply" actions, so they've been removed. Usenet users can now just highlight a newsgroup in the folder tree and click New or Reply, and the composer window will show the correct set of headers with the Post-To field filled in automatically. Comment #6 in the bug discusses other standard news reader behaviors we still don't get right, particularly the missing "Followup To" header. These will be dealt with separately. --- mail/em-composer-utils.c | 220 +++-------------------------------------- mail/em-composer-utils.h | 4 - mail/em-folder-browser.c | 9 -- mail/em-folder-view.c | 16 --- mail/evolution-mail.schemas.in | 62 ++++++++---- 5 files changed, 52 insertions(+), 259 deletions(-) (limited to 'mail') diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 0f9945b7d7..f427feca6d 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -660,13 +660,18 @@ create_new_composer (const char *subject, const char *fromuri, gboolean use_defa EAccount *account = NULL; composer = e_msg_composer_new (); - if (composer == NULL) - return NULL; + table = e_msg_composer_get_header_table (composer); + + if (fromuri != NULL) { + GList *list; - if (fromuri) account = mail_config_get_account_by_source_url(fromuri); - table = e_msg_composer_get_header_table (composer); + list = g_list_prepend (NULL, (gpointer) fromuri); + e_composer_header_table_set_post_to_list (table, list); + g_list_free (list); + } + e_composer_header_table_set_account (table, account); e_composer_header_table_set_subject (table, subject); @@ -729,82 +734,6 @@ em_utils_compose_new_message_with_mailto (const char *url, const char *fromuri) gdk_window_raise (((GtkWidget *) composer)->window); } -/** - * em_utils_post_to_folder: - * @folder: folder - * - * Opens a new composer window as a child window of @parent's toplevel - * window. If @folder is non-NULL, the composer will default to posting - * mail to the folder specified by @folder. - **/ -void -em_utils_post_to_folder (CamelFolder *folder) -{ - EMsgComposer *composer; - EComposerHeaderTable *table; - EAccount *account; - - composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_POST); - table = e_msg_composer_get_header_table (composer); - - if (folder != NULL) { - char *url = mail_tools_folder_to_url (folder); - GList *list = g_list_prepend (NULL, url); - - e_composer_header_table_set_post_to_list (table, list); - - g_list_free (list); - g_free (url); - - url = camel_url_to_string (CAMEL_SERVICE (folder->parent_store)->url, CAMEL_URL_HIDE_ALL); - account = mail_config_get_account_by_source_url (url); - g_free (url); - - if (account) - e_composer_header_table_set_account_name ( - table, account->name); - } - - em_composer_utils_setup_default_callbacks (composer); - - composer_set_no_change (composer, TRUE, TRUE); - - gtk_widget_show ((GtkWidget *) composer); - gdk_window_raise (((GtkWidget *) composer)->window); -} - -/** - * em_utils_post_to_url: - * @url: mailto url - * - * Opens a new composer window as a child window of @parent's toplevel - * window. If @url is non-NULL, the composer will default to posting - * mail to the folder specified by @url. - **/ -void -em_utils_post_to_url (const char *url) -{ - EMsgComposer *composer; - EComposerHeaderTable *table; - - composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_POST); - table = e_msg_composer_get_header_table (composer); - - if (url != NULL) { - GList *list = NULL; - - list = g_list_prepend (list, (gpointer) url); - e_composer_header_table_set_post_to_list (table, list); - g_list_free (list); - } - - em_composer_utils_setup_default_callbacks (composer); - - composer_set_no_change (composer, TRUE, TRUE); - - gtk_widget_show ((GtkWidget *) composer); -} - /* Editing messages... */ static void @@ -1763,18 +1692,12 @@ reply_get_composer (CamelMimeMessage *message, EAccount *account, g_return_val_if_fail (to == NULL || CAMEL_IS_INTERNET_ADDRESS (to), NULL); g_return_val_if_fail (cc == NULL || CAMEL_IS_INTERNET_ADDRESS (cc), NULL); + composer = e_msg_composer_new (); + /* construct the tov/ccv */ tov = em_utils_camel_address_to_destination (to); ccv = em_utils_camel_address_to_destination (cc); - if (tov || ccv) { - if (postto && camel_address_length((CamelAddress *)postto)) - composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL_POST); - else - composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL); - } else - composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_POST); - /* Set the subject of the new message. */ if ((subject = (char *) camel_mime_message_get_subject (message))) { if (g_ascii_strncasecmp (subject, "Re: ", 4) != 0) @@ -2403,124 +2326,3 @@ em_utils_reply_to_message(CamelFolder *folder, const char *uid, CamelMimeMessage gtk_widget_show (GTK_WIDGET (composer)); } - -/* Posting replies... */ - -static void -post_reply_to_message (CamelFolder *folder, const char *uid, CamelMimeMessage *message, void *user_data) -{ - /* FIXME: would be nice if this shared more code with reply_get_composer() */ - const char *message_id, *references; - CamelInternetAddress *to; - EDestination **tov = NULL; - CamelFolder *real_folder; - EMsgComposer *composer; - EComposerHeaderTable *table; - char *subject, *url; - EAccount *account; - char *real_uid; - guint32 flags; - GList *list = NULL; - - if (message == NULL) - return; - - if (CAMEL_IS_VEE_FOLDER (folder)) { - CamelMessageInfo *info; - - info = camel_folder_get_message_info (folder, uid); - real_folder = camel_vee_folder_get_location ((CamelVeeFolder *) folder, (struct _CamelVeeMessageInfo *) info, &real_uid); - camel_folder_free_message_info (folder, info); - } else { - real_folder = folder; - camel_object_ref (folder); - real_uid = g_strdup (uid); - } - - account = guess_account (message, real_folder); - flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_SEEN; - - to = camel_internet_address_new(); - get_reply_sender (message, to, NULL); - - composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL_POST); - - /* construct the tov/ccv */ - tov = em_utils_camel_address_to_destination (to); - - /* Set the subject of the new message. */ - if ((subject = (char *) camel_mime_message_get_subject (message))) { - if (g_ascii_strncasecmp (subject, "Re: ", 4) != 0) - subject = g_strdup_printf ("Re: %s", subject); - else - subject = g_strdup (subject); - } else { - subject = g_strdup (""); - } - - table = e_msg_composer_get_header_table (composer); - e_composer_header_table_set_account (table, account); - e_composer_header_table_set_subject (table, subject); - e_composer_header_table_set_destinations_to (table, tov); - - g_free (subject); - - url = mail_tools_folder_to_url (real_folder); - list = g_list_prepend (list, url); - - e_composer_header_table_set_post_to_list (table, list); - - g_list_free (list); - g_free (url); - - /* Add In-Reply-To and References. */ - message_id = camel_medium_get_header (CAMEL_MEDIUM (message), "Message-Id"); - references = camel_medium_get_header (CAMEL_MEDIUM (message), "References"); - if (message_id) { - char *reply_refs; - - e_msg_composer_add_header (composer, "In-Reply-To", message_id); - - if (references) - reply_refs = g_strdup_printf ("%s %s", references, message_id); - else - reply_refs = g_strdup (message_id); - - e_msg_composer_add_header (composer, "References", reply_refs); - g_free (reply_refs); - } else if (references) { - e_msg_composer_add_header (composer, "References", references); - } - - e_msg_composer_add_message_attachments (composer, message, TRUE); - - composer_set_body (composer, message, NULL); - - em_composer_utils_setup_callbacks (composer, real_folder, real_uid, flags, flags, NULL, NULL); - - composer_set_no_change (composer, TRUE, FALSE); - - gtk_widget_show (GTK_WIDGET (composer)); - - camel_object_unref (real_folder); - camel_object_unref(to); - g_free (real_uid); -} - -/** - * em_utils_post_reply_to_message_by_uid: - * @folder: folder containing message to reply to - * @uid: message uid - * @mode: reply mode - * - * Creates a new composer (post mode) ready to reply to the message - * referenced by @folder and @uid. - **/ -void -em_utils_post_reply_to_message_by_uid (CamelFolder *folder, const char *uid) -{ - g_return_if_fail (CAMEL_IS_FOLDER (folder)); - g_return_if_fail (uid != NULL); - - mail_get_message (folder, uid, post_reply_to_message, NULL, mail_msg_unordered_push); -} diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h index d17a98caa3..c46f808879 100644 --- a/mail/em-composer-utils.h +++ b/mail/em-composer-utils.h @@ -50,8 +50,6 @@ void em_utils_compose_new_message (const char *fromuri); /* FIXME: mailto? url? should make up its mind what its called. imho use 'uri' */ void em_utils_compose_new_message_with_mailto (const char *url, const char *fromuri); -void em_utils_post_to_folder (struct _CamelFolder *folder); -void em_utils_post_to_url (const char *url); void em_utils_edit_message (struct _CamelMimeMessage *message, struct _CamelFolder *folder); void em_utils_edit_messages (struct _CamelFolder *folder, GPtrArray *uids, gboolean replace); @@ -79,8 +77,6 @@ enum { void em_utils_reply_to_message (struct _CamelFolder *, const char *uid, struct _CamelMimeMessage *message, int mode, struct _EMFormat *source); -void em_utils_post_reply_to_message_by_uid (struct _CamelFolder *folder, const char *uid); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c index 7a3e690e2b..9a80a0c254 100644 --- a/mail/em-folder-browser.c +++ b/mail/em-folder-browser.c @@ -164,7 +164,6 @@ static const EMFolderViewEnable emfb_enable_map[] = { { "FolderRename", EM_POPUP_SELECT_FOLDER }, { "FolderRefresh", EM_POPUP_SELECT_FOLDER }, { "ChangeFolderProperties", EM_POPUP_SELECT_FOLDER }, - { "MailPost", EM_POPUP_SELECT_FOLDER }, { "MessageMarkAllAsRead", EM_POPUP_SELECT_FOLDER }, { "ViewHideSelected", EM_POPUP_SELECT_MANY }, { "ViewThreadsCollapseAll", EM_FOLDER_VIEW_SELECT_THREADED}, @@ -1693,13 +1692,6 @@ emfb_mail_stop(BonoboUIComponent *uid, void *data, const char *path) mail_cancel_all(); } -static void -emfb_mail_post(BonoboUIComponent *uid, void *data, const char *path) -{ - EMFolderView *emfv = data; - em_utils_post_to_folder (emfv->folder); -} - static void emfb_tools_filters(BonoboUIComponent *uid, void *data, const char *path) { @@ -1779,7 +1771,6 @@ static BonoboUIVerb emfb_verbs[] = { BONOBO_UI_UNSAFE_VERB ("FolderCreate", emfb_folder_create), BONOBO_UI_UNSAFE_VERB ("HelpDebug", emfb_help_debug), - BONOBO_UI_UNSAFE_VERB ("MailPost", emfb_mail_post), BONOBO_UI_UNSAFE_VERB ("MailStop", emfb_mail_stop), BONOBO_UI_UNSAFE_VERB ("ToolsFilters", emfb_tools_filters), BONOBO_UI_UNSAFE_VERB ("ToolsSubscriptions", emfb_tools_subscriptions), diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 42037b5a33..e31d8d727c 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -185,7 +185,6 @@ static const EMFolderViewEnable emfv_enable_map[] = { { "MessageFollowUpClear", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_FLAG_CLEAR }, { "MessageMove", EM_POPUP_SELECT_MANY }, { "MessageOpen", EM_POPUP_SELECT_MANY }, - { "MessagePostReply", EM_POPUP_SELECT_ONE }, { "MessageReplyAll", EM_POPUP_SELECT_ONE }, { "MessageReplyList", EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST }, { "MessageReplySender", EM_POPUP_SELECT_ONE }, @@ -1726,20 +1725,6 @@ emfv_message_redirect (BonoboUIComponent *uic, void *data, const char *path) em_utils_redirect_message_by_uid (emfv->folder, emfv->list->cursor_uid); } -static void -emfv_message_post_reply (BonoboUIComponent *uic, void *data, const char *path) -{ - EMFolderView *emfv = data; - - if (emfv->list->cursor_uid == NULL) - return; - - if (!em_utils_check_user_can_send_mail ((GtkWidget *) emfv)) - return; - - em_utils_post_reply_to_message_by_uid (emfv->folder, emfv->list->cursor_uid); -} - static gboolean html_contains_nonwhitespace (const char *html, gint len) { @@ -2073,7 +2058,6 @@ static BonoboUIVerb emfv_message_verbs[] = { BONOBO_UI_UNSAFE_VERB ("MessageFollowUpClear", emfv_message_followup_clear), BONOBO_UI_UNSAFE_VERB ("MessageMove", emfv_message_move), BONOBO_UI_UNSAFE_VERB ("MessageOpen", emfv_message_open), - BONOBO_UI_UNSAFE_VERB ("MessagePostReply", emfv_message_post_reply), BONOBO_UI_UNSAFE_VERB ("MessageReplyAll", emfv_message_reply_all), BONOBO_UI_UNSAFE_VERB ("MessageReplyList", emfv_message_reply_list), BONOBO_UI_UNSAFE_VERB ("MessageReplySender", emfv_message_reply_sender), diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index e63d9eec4a..fbc23eb746 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -116,71 +116,91 @@ - /schemas/apps/evolution/mail/composer/view/From - /apps/evolution/mail/composer/view/From + /schemas/apps/evolution/mail/composer/show_mail_bcc + /apps/evolution/mail/composer/show_mail_bcc + evolution-mail + bool + false + + Show "Bcc" field when sending a mail message + + Show the "Bcc" field when sending a mail message. This is + controlled from the View menu when a mail account is chosen. + + + + + + /schemas/apps/evolution/mail/composer/show_mail_cc + /apps/evolution/mail/composer/show_mail_cc evolution-mail bool true - View/From menu item is checked + Show "Cc" field when sending a mail message - View/From menu item is checked. + Show the "Cc" field when sending a mail message. This is + controlled from the View menu when a mail account is chosen. - /schemas/apps/evolution/mail/composer/view/PostTo - /apps/evolution/mail/composer/view/PostTo + /schemas/apps/evolution/mail/composer/show_mail_from + /apps/evolution/mail/composer/show_mail_from evolution-mail bool true - View/PostTo menu item is checked + Show "From" field when sending a mail message - View/PostTo menu item is checked. + Show the "From" field when sending a mail message. This is + controlled from the View menu when a mail account is chosen. - /schemas/apps/evolution/mail/composer/view/ReplyTo - /apps/evolution/mail/composer/view/ReplyTo + /schemas/apps/evolution/mail/composer/show_mail_reply_to + /apps/evolution/mail/composer/show_mail_reply_to evolution-mail bool false - View/ReplyTo menu item is checked + Show "Reply To" field when sending a mail message - View/ReplyTo menu item is checked. + Show the "Reply To" field when sending a mail message. This + is controlled from the View menu when a mail account is chosen. - /schemas/apps/evolution/mail/composer/view/Cc - /apps/evolution/mail/composer/view/Cc + /schemas/apps/evolution/mail/composer/show_post_from + /apps/evolution/mail/composer/show_post_from evolution-mail bool - false + true - View/Cc menu item is checked + Show "From" field when posting to a newsgroup - View/Cc menu item is checked. + Show the "From" field when posting to a newsgroup. This is + controlled from the View menu when a news account is chosen. - /schemas/apps/evolution/mail/composer/view/Bcc - /apps/evolution/mail/composer/view/Bcc + /schemas/apps/evolution/mail/composer/show_post_reply_to + /apps/evolution/mail/composer/show_post_reply_to evolution-mail bool false - View/Bcc menu item is checked + Show "Reply To" field when posting to a newsgroup - View/Bcc menu item is checked. + Show the "Reply To" field when posting to a newsgroup. This + is controlled from the View menu when a news account is chosen. -- cgit From 5d12f06367a0939387381f66cea77766a873aea6 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 20 May 2009 18:09:34 -0400 Subject: Bug 580925 – Better search bar for word searches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the word search bar more like Firefox and get rid of the "Current Message" search scope in the folder search bar. Shift+Ctrl+F now activates the word search bar. --- mail/Makefile.am | 2 + mail/e-mail-search-bar.c | 774 ++++++++++++++++++++++++++++++++++++++++++ mail/e-mail-search-bar.h | 85 +++++ mail/e-searching-tokenizer.c | 4 +- mail/e-searching-tokenizer.h | 2 +- mail/em-folder-browser.c | 75 ++-- mail/em-folder-view.c | 24 +- mail/em-folder-view.h | 3 + mail/em-format-html-display.c | 338 ------------------ mail/em-format-html-display.h | 2 - mail/em-format.c | 38 ++- mail/em-format.h | 10 +- mail/em-message-browser.c | 38 ++- mail/em-utils.c | 2 +- 14 files changed, 997 insertions(+), 400 deletions(-) create mode 100644 mail/e-mail-search-bar.c create mode 100644 mail/e-mail-search-bar.h (limited to 'mail') diff --git a/mail/Makefile.am b/mail/Makefile.am index 96ed893007..793d5c3a1e 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -55,6 +55,7 @@ idl_DATA = $(MAIL_IDL) mailinclude_HEADERS = \ $(MAIL_IDL_GENERATED_H) \ e-mail-attachment-bar.h \ + e-mail-search-bar.h \ em-composer-utils.h \ em-config.h \ em-event.h \ @@ -97,6 +98,7 @@ libevolution_mail_la_SOURCES = \ e-attachment-handler-mail.c \ e-attachment-handler-mail.h \ e-mail-attachment-bar.c \ + e-mail-search-bar.c \ e-searching-tokenizer.c \ e-searching-tokenizer.h \ em-account-editor.c \ diff --git a/mail/e-mail-search-bar.c b/mail/e-mail-search-bar.c new file mode 100644 index 0000000000..4d555857ca --- /dev/null +++ b/mail/e-mail-search-bar.c @@ -0,0 +1,774 @@ +/* + * e-mail-search-bar.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-search-bar.h" + +#include +#include +#include + +#include "e-util/e-binding.h" + +#define E_MAIL_SEARCH_BAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SEARCH_BAR, EMailSearchBarPrivate)) + +struct _EMailSearchBarPrivate { + GtkHTML *html; + GtkWidget *entry; + GtkWidget *case_sensitive_button; + GtkWidget *wrapped_next_box; + GtkWidget *wrapped_prev_box; + GtkWidget *matches_label; + + ESearchingTokenizer *tokenizer; + gchar *active_search; + + guint rerun_search : 1; +}; + +enum { + PROP_0, + PROP_CASE_SENSITIVE, + PROP_HTML, + PROP_TEXT +}; + +enum { + CHANGED, + CLEAR, + LAST_SIGNAL +}; + +static gpointer parent_class; +static guint signals[LAST_SIGNAL]; + +static void +mail_search_bar_update_matches (EMailSearchBar *search_bar) +{ + ESearchingTokenizer *tokenizer; + GtkWidget *matches_label; + gint matches; + gchar *text; + + tokenizer = e_mail_search_bar_get_tokenizer (search_bar); + matches_label = search_bar->priv->matches_label; + + matches = e_searching_tokenizer_match_count (tokenizer); + text = g_strdup_printf (_("Matches: %d"), matches); + + gtk_label_set_text (GTK_LABEL (matches_label), text); + gtk_widget_show (matches_label); + + g_free (text); +} + +static void +mail_search_bar_update_tokenizer (EMailSearchBar *search_bar) +{ + ESearchingTokenizer *tokenizer; + gboolean case_sensitive; + gchar *active_search; + + tokenizer = e_mail_search_bar_get_tokenizer (search_bar); + case_sensitive = e_mail_search_bar_get_case_sensitive (search_bar); + + if (GTK_WIDGET_VISIBLE (search_bar)) + active_search = search_bar->priv->active_search; + else + active_search = NULL; + + e_searching_tokenizer_set_primary_case_sensitivity ( + tokenizer, case_sensitive); + e_searching_tokenizer_set_primary_search_string ( + tokenizer, active_search); + + e_mail_search_bar_changed (search_bar); +} + +static void +mail_search_bar_find (EMailSearchBar *search_bar, + gboolean search_forward) +{ + GtkHTML *html; + GtkWidget *widget; + gboolean case_sensitive; + gboolean new_search; + gboolean wrapped = FALSE; + gchar *text; + + html = e_mail_search_bar_get_html (search_bar); + case_sensitive = e_mail_search_bar_get_case_sensitive (search_bar); + text = e_mail_search_bar_get_text (search_bar); + + if (text == NULL || *text == '\0') + gtk_widget_hide (search_bar->priv->matches_label); + + new_search = + (search_bar->priv->active_search == NULL) || + (g_strcmp0 (text, search_bar->priv->active_search) != 0); + + /* XXX On a new search, the HTMLEngine's search state gets + * destroyed when we redraw the message with highlighted + * matches (EMHTMLStream's write() method triggers this, + * but it's really GtkHtml's fault). That's why the first + * match isn't selected automatically. It also causes + * gtk_html_engine_search_next() to return FALSE, which we + * assume to mean the search wrapped. + * + * So to avoid mistakenly thinking the search wrapped when + * it hasn't, we have to trap the first button click after a + * search and re-run the search to recreate the HTMLEngine's + * search state, so that gtk_html_engine_search_next() will + * succeed. */ + if (new_search) { + g_free (search_bar->priv->active_search); + search_bar->priv->active_search = text; + search_bar->priv->rerun_search = TRUE; + mail_search_bar_update_tokenizer (search_bar); + } else if (search_bar->priv->rerun_search) { + gtk_html_engine_search ( + html, search_bar->priv->active_search, + case_sensitive, search_forward, FALSE); + search_bar->priv->rerun_search = FALSE; + g_free (text); + } else { + gtk_html_engine_search_set_forward (html, search_forward); + if (!gtk_html_engine_search_next (html)) + wrapped = TRUE; + g_free (text); + } + + if (new_search || wrapped) + gtk_html_engine_search ( + html, search_bar->priv->active_search, + case_sensitive, search_forward, FALSE); + + /* Update wrapped label visibility. */ + + widget = search_bar->priv->wrapped_next_box; + + if (wrapped && search_forward) + gtk_widget_show (widget); + else + gtk_widget_hide (widget); + + widget = search_bar->priv->wrapped_prev_box; + + if (wrapped && !search_forward) + gtk_widget_show (widget); + else + gtk_widget_hide (widget); +} + +static void +mail_search_bar_changed_cb (EMailSearchBar *search_bar) +{ + g_object_notify (G_OBJECT (search_bar), "text"); +} + +static void +mail_search_bar_find_next_cb (EMailSearchBar *search_bar) +{ + mail_search_bar_find (search_bar, TRUE); +} + +static void +mail_search_bar_find_previous_cb (EMailSearchBar *search_bar) +{ + mail_search_bar_find (search_bar, FALSE); +} + +static void +mail_search_bar_icon_release_cb (EMailSearchBar *search_bar, + GtkEntryIconPosition icon_pos, + GdkEvent *event) +{ + g_return_if_fail (icon_pos == GTK_ENTRY_ICON_SECONDARY); + + e_mail_search_bar_clear (search_bar); + gtk_widget_grab_focus (search_bar->priv->entry); +} + +static void +mail_search_bar_toggled_cb (EMailSearchBar *search_bar) +{ + g_free (search_bar->priv->active_search); + search_bar->priv->active_search = NULL; + + g_object_notify (G_OBJECT (search_bar), "case-sensitive"); +} + +static void +mail_search_bar_set_html (EMailSearchBar *search_bar, + GtkHTML *html) +{ + ESearchingTokenizer *tokenizer; + + g_return_if_fail (search_bar->priv->html == NULL); + + search_bar->priv->html = g_object_ref (html); + + tokenizer = e_mail_search_bar_get_tokenizer (search_bar); + gtk_html_set_tokenizer (html, HTML_TOKENIZER (tokenizer)); +} + +static void +mail_search_bar_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_CASE_SENSITIVE: + e_mail_search_bar_set_case_sensitive ( + E_MAIL_SEARCH_BAR (object), + g_value_get_boolean (value)); + return; + + case PROP_HTML: + mail_search_bar_set_html ( + E_MAIL_SEARCH_BAR (object), + g_value_get_object (value)); + return; + + case PROP_TEXT: + e_mail_search_bar_set_text ( + E_MAIL_SEARCH_BAR (object), + g_value_get_string (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_search_bar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_CASE_SENSITIVE: + g_value_set_boolean ( + value, e_mail_search_bar_get_case_sensitive ( + E_MAIL_SEARCH_BAR (object))); + return; + + case PROP_HTML: + g_value_set_object ( + value, e_mail_search_bar_get_html ( + E_MAIL_SEARCH_BAR (object))); + return; + + case PROP_TEXT: + g_value_take_string ( + value, e_mail_search_bar_get_text ( + E_MAIL_SEARCH_BAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_search_bar_dispose (GObject *object) +{ + EMailSearchBarPrivate *priv; + + priv = E_MAIL_SEARCH_BAR_GET_PRIVATE (object); + + if (priv->html != NULL) { + g_object_unref (priv->html); + priv->html = NULL; + } + + if (priv->entry != NULL) { + g_object_unref (priv->entry); + priv->entry = NULL; + } + + if (priv->case_sensitive_button != NULL) { + g_object_unref (priv->case_sensitive_button); + priv->case_sensitive_button = NULL; + } + + if (priv->wrapped_next_box != NULL) { + g_object_unref (priv->wrapped_next_box); + priv->wrapped_next_box = NULL; + } + + if (priv->wrapped_prev_box != NULL) { + g_object_unref (priv->wrapped_prev_box); + priv->wrapped_prev_box = NULL; + } + + if (priv->matches_label != NULL) { + g_object_unref (priv->matches_label); + priv->matches_label = NULL; + } + + if (priv->tokenizer != NULL) { + g_object_unref (priv->tokenizer); + priv->tokenizer = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +mail_search_bar_finalize (GObject *object) +{ + EMailSearchBarPrivate *priv; + + priv = E_MAIL_SEARCH_BAR_GET_PRIVATE (object); + + g_free (priv->active_search); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +mail_search_bar_constructed (GObject *object) +{ + EMailSearchBarPrivate *priv; + + priv = E_MAIL_SEARCH_BAR_GET_PRIVATE (object); + + e_mutual_binding_new ( + G_OBJECT (object), "case-sensitive", + G_OBJECT (priv->case_sensitive_button), "active"); +} + +static void +mail_search_bar_show (GtkWidget *widget) +{ + EMailSearchBar *search_bar; + + search_bar = E_MAIL_SEARCH_BAR (widget); + + /* Chain up to parent's show() method. */ + GTK_WIDGET_CLASS (parent_class)->show (widget); + + gtk_widget_grab_focus (search_bar->priv->entry); + + mail_search_bar_update_tokenizer (search_bar); +} + +static void +mail_search_bar_hide (GtkWidget *widget) +{ + EMailSearchBar *search_bar; + + search_bar = E_MAIL_SEARCH_BAR (widget); + + /* Chain up to parent's hide() method. */ + GTK_WIDGET_CLASS (parent_class)->hide (widget); + + mail_search_bar_update_tokenizer (search_bar); +} + +static gboolean +mail_search_bar_key_press_event (GtkWidget *widget, + GdkEventKey *event) +{ + if (event->keyval == GDK_Escape) { + gtk_widget_hide (widget); + return TRUE; + } + + /* Chain up to parent's key_press_event() method. */ + return GTK_WIDGET_CLASS (parent_class)-> + key_press_event (widget, event); +} + +static void +mail_search_bar_clear (EMailSearchBar *search_bar) +{ + g_free (search_bar->priv->active_search); + search_bar->priv->active_search = NULL; + + gtk_widget_hide (search_bar->priv->wrapped_next_box); + gtk_widget_hide (search_bar->priv->wrapped_prev_box); + gtk_widget_hide (search_bar->priv->matches_label); + + mail_search_bar_update_tokenizer (search_bar); +} + +static void +mail_search_bar_class_init (EMailSearchBarClass *class) +{ + GObjectClass *object_class; + GtkWidgetClass *widget_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMailSearchBarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = mail_search_bar_set_property; + object_class->get_property = mail_search_bar_get_property; + object_class->dispose = mail_search_bar_dispose; + object_class->finalize = mail_search_bar_finalize; + object_class->constructed = mail_search_bar_constructed; + + widget_class = GTK_WIDGET_CLASS (class); + widget_class->show = mail_search_bar_show; + widget_class->hide = mail_search_bar_hide; + widget_class->key_press_event = mail_search_bar_key_press_event; + + class->clear = mail_search_bar_clear; + + g_object_class_install_property ( + object_class, + PROP_CASE_SENSITIVE, + g_param_spec_boolean ( + "case-sensitive", + "Case Sensitive", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_HTML, + g_param_spec_object ( + "html", + "HTML Display", + NULL, + GTK_TYPE_HTML, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + object_class, + PROP_TEXT, + g_param_spec_string ( + "text", + "Search Text", + NULL, + NULL, + G_PARAM_READWRITE)); + + signals[CHANGED] = g_signal_new ( + "changed", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EMailSearchBarClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[CLEAR] = g_signal_new ( + "clear", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EMailSearchBarClass, clear), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} + +static void +mail_search_bar_init (EMailSearchBar *search_bar) +{ + GtkWidget *label; + GtkWidget *widget; + GtkWidget *container; + + search_bar->priv = E_MAIL_SEARCH_BAR_GET_PRIVATE (search_bar); + search_bar->priv->tokenizer = e_searching_tokenizer_new (); + + g_signal_connect_swapped ( + search_bar->priv->tokenizer, "match", + G_CALLBACK (mail_search_bar_update_matches), search_bar); + + gtk_box_set_spacing (GTK_BOX (search_bar), 12); + + container = GTK_WIDGET (search_bar); + + widget = gtk_hbox_new (FALSE, 1); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_button_new (); + gtk_button_set_image ( + GTK_BUTTON (widget), gtk_image_new_from_stock ( + GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU)); + gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE); + gtk_widget_set_tooltip_text (widget, _("Close the find bar")); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + g_signal_connect_swapped ( + widget, "clicked", + G_CALLBACK (gtk_widget_hide), search_bar); + + widget = gtk_label_new_with_mnemonic (_("Fin_d:")); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 3); + gtk_widget_show (widget); + + label = widget; + + widget = gtk_entry_new (); + gtk_entry_set_icon_from_stock ( + GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, + GTK_STOCK_CLEAR); + gtk_entry_set_icon_tooltip_text ( + GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, + _("Clear the search")); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); + gtk_widget_set_size_request (widget, 200, -1); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + search_bar->priv->entry = g_object_ref (widget); + gtk_widget_show (widget); + + g_signal_connect_swapped ( + widget, "activate", + G_CALLBACK (mail_search_bar_find_next_cb), search_bar); + + g_signal_connect_swapped ( + widget, "changed", + G_CALLBACK (mail_search_bar_changed_cb), search_bar); + + g_signal_connect_swapped ( + widget, "icon-release", + G_CALLBACK (mail_search_bar_icon_release_cb), search_bar); + + widget = gtk_button_new_with_mnemonic (_("_Previous")); + gtk_button_set_image ( + GTK_BUTTON (widget), gtk_image_new_from_stock ( + GTK_STOCK_GO_BACK, GTK_ICON_SIZE_MENU)); + gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE); + gtk_widget_set_tooltip_text ( + widget, _("Find the previous occurrence of the phrase")); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + g_signal_connect_swapped ( + widget, "clicked", + G_CALLBACK (mail_search_bar_find_previous_cb), search_bar); + + widget = gtk_button_new_with_mnemonic (_("_Next")); + gtk_button_set_image ( + GTK_BUTTON (widget), gtk_image_new_from_stock ( + GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU)); + gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE); + gtk_widget_set_tooltip_text ( + widget, _("Find the next occurrence of the phrase")); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + g_signal_connect_swapped ( + widget, "clicked", + G_CALLBACK (mail_search_bar_find_next_cb), search_bar); + + widget = gtk_check_button_new_with_mnemonic (_("Mat_ch case")); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + search_bar->priv->case_sensitive_button = g_object_ref (widget); + gtk_widget_show (widget); + + g_signal_connect_swapped ( + widget, "toggled", + G_CALLBACK (mail_search_bar_toggled_cb), search_bar); + + g_signal_connect_swapped ( + widget, "toggled", + G_CALLBACK (mail_search_bar_find_next_cb), search_bar); + + container = GTK_WIDGET (search_bar); + + widget = gtk_hbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + search_bar->priv->wrapped_next_box = g_object_ref (widget); + gtk_widget_hide (widget); + + container = widget; + + widget = gtk_image_new_from_icon_name ( + "wrapped", GTK_ICON_SIZE_MENU); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + widget = gtk_label_new ( + _("Reached bottom of page, continued from top")); + gtk_label_set_ellipsize ( + GTK_LABEL (widget), PANGO_ELLIPSIZE_END); + gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + gtk_widget_show (widget); + + container = GTK_WIDGET (search_bar); + + widget = gtk_hbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + search_bar->priv->wrapped_prev_box = g_object_ref (widget); + gtk_widget_hide (widget); + + container = widget; + + widget = gtk_image_new_from_icon_name ( + "wrapped", GTK_ICON_SIZE_MENU); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + widget = gtk_label_new ( + _("Reached top of page, continued from bottom")); + gtk_label_set_ellipsize ( + GTK_LABEL (widget), PANGO_ELLIPSIZE_END); + gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + gtk_widget_show (widget); + + container = GTK_WIDGET (search_bar); + + widget = gtk_label_new (NULL); + gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 12); + search_bar->priv->matches_label = g_object_ref (widget); + gtk_widget_show (widget); +} + +GType +e_mail_search_bar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMailSearchBarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_search_bar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailSearchBar), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_search_bar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + GTK_TYPE_HBOX, "EMailSearchBar", &type_info, 0); + } + + return type; +} + +GtkWidget * +e_mail_search_bar_new (GtkHTML *html) +{ + g_return_val_if_fail (GTK_IS_HTML (html), NULL); + + return g_object_new (E_TYPE_MAIL_SEARCH_BAR, "html", html, NULL); +} + +void +e_mail_search_bar_clear (EMailSearchBar *search_bar) +{ + g_return_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar)); + + g_signal_emit (search_bar, signals[CLEAR], 0); +} + +void +e_mail_search_bar_changed (EMailSearchBar *search_bar) +{ + g_return_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar)); + + g_signal_emit (search_bar, signals[CHANGED], 0); +} + +GtkHTML * +e_mail_search_bar_get_html (EMailSearchBar *search_bar) +{ + g_return_val_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar), NULL); + + return search_bar->priv->html; +} + +ESearchingTokenizer * +e_mail_search_bar_get_tokenizer (EMailSearchBar *search_bar) +{ + g_return_val_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar), NULL); + + return search_bar->priv->tokenizer; +} + +gboolean +e_mail_search_bar_get_case_sensitive (EMailSearchBar *search_bar) +{ + GtkToggleButton *button; + + g_return_val_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar), FALSE); + + button = GTK_TOGGLE_BUTTON (search_bar->priv->case_sensitive_button); + + return gtk_toggle_button_get_active (button); +} + +void +e_mail_search_bar_set_case_sensitive (EMailSearchBar *search_bar, + gboolean case_sensitive) +{ + GtkToggleButton *button; + + g_return_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar)); + + button = GTK_TOGGLE_BUTTON (search_bar->priv->case_sensitive_button); + + gtk_toggle_button_set_active (button, case_sensitive); + + g_object_notify (G_OBJECT (search_bar), "case-sensitive"); +} + +gchar * +e_mail_search_bar_get_text (EMailSearchBar *search_bar) +{ + GtkEntry *entry; + const gchar *text; + + g_return_val_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar), NULL); + + entry = GTK_ENTRY (search_bar->priv->entry); + text = gtk_entry_get_text (entry); + + return g_strstrip (g_strdup (text)); +} + +void +e_mail_search_bar_set_text (EMailSearchBar *search_bar, + const gchar *text) +{ + GtkEntry *entry; + + g_return_if_fail (E_IS_MAIL_SEARCH_BAR (search_bar)); + + entry = GTK_ENTRY (search_bar->priv->entry); + + if (text == NULL) + text = ""; + + /* This will trigger a "notify::text" signal. */ + gtk_entry_set_text (entry, text); +} diff --git a/mail/e-mail-search-bar.h b/mail/e-mail-search-bar.h new file mode 100644 index 0000000000..7f19e176b7 --- /dev/null +++ b/mail/e-mail-search-bar.h @@ -0,0 +1,85 @@ +/* + * e-mail-search-bar.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SEARCH_BAR_H +#define E_MAIL_SEARCH_BAR_H + +#include +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MAIL_SEARCH_BAR \ + (e_mail_search_bar_get_type ()) +#define E_MAIL_SEARCH_BAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_SEARCH_BAR, EMailSearchBar)) +#define E_MAIL_SEARCH_BAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_SEARCH_BAR, EMailSearchBarClass)) +#define E_IS_MAIL_SEARCH_BAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_SEARCH_BAR)) +#define E_IS_MAIL_SEARCH_BAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_SEARCH_BAR)) +#define E_MAIL_SEARCH_BAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_SEARCH_BAR, EMailSearchBarClass)) + +G_BEGIN_DECLS + +typedef struct _EMailSearchBar EMailSearchBar; +typedef struct _EMailSearchBarClass EMailSearchBarClass; +typedef struct _EMailSearchBarPrivate EMailSearchBarPrivate; + +struct _EMailSearchBar { + GtkHBox parent; + EMailSearchBarPrivate *priv; +}; + +struct _EMailSearchBarClass { + GtkHBoxClass parent_class; + + /* Signals */ + void (*changed) (EMailSearchBar *search_bar); + void (*clear) (EMailSearchBar *search_bar); +}; + +GType e_mail_search_bar_get_type (void); +GtkWidget * e_mail_search_bar_new (GtkHTML *html); +void e_mail_search_bar_clear (EMailSearchBar *search_bar); +void e_mail_search_bar_changed (EMailSearchBar *search_bar); +GtkHTML * e_mail_search_bar_get_html (EMailSearchBar *search_bar); +ESearchingTokenizer * + e_mail_search_bar_get_tokenizer (EMailSearchBar *search_bar); +gboolean e_mail_search_bar_get_case_sensitive + (EMailSearchBar *search_bar); +void e_mail_search_bar_set_case_sensitive + (EMailSearchBar *search_bar, + gboolean case_sensitive); +gchar * e_mail_search_bar_get_text (EMailSearchBar *search_bar); +void e_mail_search_bar_set_text (EMailSearchBar *search_bar, + const gchar *text); + +G_END_DECLS + +#endif /* E_MAIL_SEARCH_BAR_H */ diff --git a/mail/e-searching-tokenizer.c b/mail/e-searching-tokenizer.c index 9704ebb96d..3d98cdeb4f 100644 --- a/mail/e-searching-tokenizer.c +++ b/mail/e-searching-tokenizer.c @@ -1052,10 +1052,10 @@ e_searching_tokenizer_get_type (void) return type; } -HTMLTokenizer * +ESearchingTokenizer * e_searching_tokenizer_new (void) { - return (HTMLTokenizer *) g_object_new (E_TYPE_SEARCHING_TOKENIZER, NULL); + return g_object_new (E_TYPE_SEARCHING_TOKENIZER, NULL); } /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ diff --git a/mail/e-searching-tokenizer.h b/mail/e-searching-tokenizer.h index ecc914dab7..37a0048c0c 100644 --- a/mail/e-searching-tokenizer.h +++ b/mail/e-searching-tokenizer.h @@ -52,7 +52,7 @@ struct _ESearchingTokenizerClass { GType e_searching_tokenizer_get_type (void); -HTMLTokenizer *e_searching_tokenizer_new (void); +ESearchingTokenizer *e_searching_tokenizer_new (void); /* For now, just a simple API */ diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c index 9a80a0c254..0aba4c1045 100644 --- a/mail/em-folder-browser.c +++ b/mail/em-folder-browser.c @@ -79,6 +79,7 @@ #include "e-util/e-error.h" #include "e-util/e-util-private.h" #include "e-util/e-util-labels.h" +#include "e-mail-search-bar.h" #include "em-utils.h" #include "em-composer-utils.h" #include "em-format-html-display.h" @@ -106,6 +107,7 @@ CamelStore *vfolder_store; /* the 1 static vfolder store */ struct _EMFolderBrowserPrivate { GtkWidget *preview; /* container for message display */ GtkWidget *scroll; + GtkWidget *search_bar; GtkWidget *subscribe_editor; @@ -239,7 +241,6 @@ static ESearchBarItem emfb_search_scope_items[] = { E_FILTERBAR_CURRENT_FOLDER, E_FILTERBAR_CURRENT_ACCOUNT, E_FILTERBAR_ALL_ACCOUNTS, - E_FILTERBAR_CURRENT_MESSAGE, { NULL, -1, 0 } }; @@ -485,6 +486,7 @@ emfb_init(GObject *o) EMFolderBrowser *emfb = (EMFolderBrowser *)o; RuleContext *search_context = mail_component_peek_search_context (mail_component_peek ()); struct _EMFolderBrowserPrivate *p; + GtkWidget *html; EMEvent *eme; EMEventTargetFolderBrowser *target; @@ -527,7 +529,6 @@ emfb_init(GObject *o) efb->account_search_cancel = NULL; e_search_bar_set_menu ((ESearchBar *)emfb->search, emfb_search_items); e_search_bar_set_scopeoption ((ESearchBar *)emfb->search, emfb_search_scope_items); - e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, FALSE); emfb->priv->scope_restricted = TRUE; g_signal_connect(emfb, "realize", G_CALLBACK(emfb_realize), NULL); gtk_widget_show((GtkWidget *)emfb->search); @@ -561,14 +562,21 @@ emfb_init(GObject *o) gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)p->scroll, GTK_SHADOW_IN); gtk_widget_show(p->scroll); - p->preview = gtk_vbox_new (FALSE, 6); - gtk_container_add((GtkContainer *)p->scroll, (GtkWidget *)emfb->view.preview->formathtml.html); - gtk_widget_show((GtkWidget *)emfb->view.preview->formathtml.html); + html = GTK_WIDGET (emfb->view.preview->formathtml.html); + + p->preview = gtk_vbox_new (FALSE, 1); + p->search_bar = e_mail_search_bar_new (GTK_HTML (html)); + gtk_container_add((GtkContainer *)p->scroll, html); + gtk_widget_show(html); gtk_box_pack_start ((GtkBox *)p->preview, p->scroll, TRUE, TRUE, 0); - gtk_box_pack_start ((GtkBox *)p->preview, em_format_html_get_search_dialog (emfb->view.preview), FALSE, FALSE, 0); + gtk_box_pack_start ((GtkBox *)p->preview, p->search_bar, FALSE, FALSE, 0); gtk_paned_pack2 (GTK_PANED (emfb->vpane), p->preview, TRUE, FALSE); gtk_widget_show(p->preview); + g_signal_connect_swapped ( + p->search_bar, "changed", + G_CALLBACK (em_format_redraw), emfb->view.preview); + /** @HookPoint-EMFolderBrower: Folder Browser * @Id: emfb.created * @Class: org.gnome.evolution.mail.events:1.0 @@ -637,6 +645,14 @@ emfb_destroy(GtkObject *o) ((GtkObjectClass *)emfb_parent)->destroy(o); } +static void +emfb_show_search_bar (EMFolderView *folder_view) +{ + EMFolderBrowser *browser = (EMFolderBrowser *) folder_view; + + gtk_widget_show (browser->priv->search_bar); +} + static void emfb_class_init(GObjectClass *klass) { @@ -666,6 +682,7 @@ emfb_class_init(GObjectClass *klass) ((GtkObjectClass *)klass)->destroy = emfb_destroy; ((EMFolderViewClass *)klass)->set_folder = emfb_set_folder; ((EMFolderViewClass *)klass)->activate = emfb_activate; + ((EMFolderViewClass *)klass)->show_search_bar = emfb_show_search_bar; } GType @@ -711,7 +728,6 @@ void em_folder_browser_show_preview(EMFolderBrowser *emfb, gboolean state) if ((emfb->view.preview_active ^ state) == 0 || emfb->view.list == NULL) { if (state && emfb->priv->scope_restricted && emfb->view.list->cursor_uid && *(emfb->view.list->cursor_uid)) { - e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, TRUE); emfb->priv->scope_restricted = FALSE; } @@ -733,7 +749,6 @@ void em_folder_browser_show_preview(EMFolderBrowser *emfb, gboolean state) if (emfb->view.list->cursor_uid) { char *uid = g_alloca(strlen(emfb->view.list->cursor_uid)+1); - e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, TRUE); emfb->priv->scope_restricted = FALSE; strcpy(uid, emfb->view.list->cursor_uid); em_folder_view_set_message(&emfb->view, uid, FALSE); @@ -749,7 +764,6 @@ void em_folder_browser_show_preview(EMFolderBrowser *emfb, gboolean state) emfb->view.displayed_uid = NULL; gtk_widget_hide(emfb->priv->preview); - e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, FALSE); emfb->priv->scope_restricted = TRUE; /* mail_display_set_message (emfb->mail_display, NULL, NULL, NULL); @@ -841,6 +855,8 @@ static void emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data) { EMFolderBrowser *emfb = data; + EMailSearchBar *search_bar; + ESearchingTokenizer *tokenizer; GList *partl; struct _camel_search_words *words; int i; @@ -877,15 +893,26 @@ emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char partl = partl->next; } - em_format_html_display_set_search(emfb->view.preview, - EM_FORMAT_HTML_DISPLAY_SEARCH_SECONDARY|EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE, - strings); - while (strings) { - GSList *n = strings->next; - g_free(strings->data); - g_slist_free_1(strings); - strings = n; + search_bar = E_MAIL_SEARCH_BAR (emfb->priv->search_bar); + + /* XXX This is a hack, but this code is on its way out anyway. + * Function is called once before the search bar is created. */ + if (!E_IS_MAIL_SEARCH_BAR (search_bar)) + return; + + tokenizer = e_mail_search_bar_get_tokenizer (search_bar); + + e_searching_tokenizer_set_secondary_case_sensitivity (tokenizer, FALSE); + e_searching_tokenizer_set_secondary_search_string (tokenizer, NULL); + + while (strings != NULL) { + e_searching_tokenizer_add_secondary_search_string ( + tokenizer, strings->data); + g_free (strings->data); + strings = g_slist_delete_link (strings, strings); } + + e_mail_search_bar_changed (search_bar); } static char * @@ -1125,18 +1152,6 @@ emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb) id = e_search_bar_get_search_scope (esb); switch (id) { - case E_FILTERBAR_CURRENT_MESSAGE_ID: - word = e_search_bar_get_text (esb); - if ( word && *word ) { - gtk_widget_set_sensitive (esb->option_button, FALSE); - em_format_html_display_search_with (emfb->view.preview, word); - } else { - em_format_html_display_search_close (emfb->view.preview); - } - g_free (word); - return; - break; - case E_FILTERBAR_CURRENT_FOLDER_ID: g_object_get (esb, "query", &search_word, NULL); break; @@ -1386,10 +1401,8 @@ emfb_list_message_selected (MessageList *ml, const char *uid, EMFolderBrowser *e return; if (uid && *uid && emfb->priv->scope_restricted && emfb->view.preview_active) { - e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, TRUE); emfb->priv->scope_restricted = FALSE; } else if ( !(uid && *uid) && !emfb->priv->scope_restricted) { - e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, FALSE); emfb->priv->scope_restricted = TRUE; } diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index e31d8d727c..62bab8a48f 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -956,7 +956,7 @@ emfv_popup_flag_completed(EPopup *ep, EPopupItem *pitem, void *data) em_utils_flag_for_followup_completed((GtkWidget *)emfv, emfv->folder, uids); if (emfv->preview) - em_format_redraw (emfv->preview); + em_format_redraw (EM_FORMAT (emfv->preview)); } static void @@ -968,7 +968,7 @@ emfv_popup_flag_clear(EPopup *ep, EPopupItem *pitem, void *data) em_utils_flag_for_followup_clear((GtkWidget *)emfv, emfv->folder, uids); if (emfv->preview) - em_format_redraw (emfv->preview); + em_format_redraw (EM_FORMAT (emfv->preview)); } static void @@ -1808,13 +1808,7 @@ emfv_message_search(BonoboUIComponent *uic, void *data, const char *path) { EMFolderView *emfv = data; - if (!emfv->list_active) /* We are in new mail window */ - em_format_html_display_search(emfv->preview); - else { - /* We are in top level. Just grab focus to Search Bar */ - gtk_widget_grab_focus (((ESearchBar *)((EMFolderBrowser *) emfv)->search)->entry); - gtk_option_menu_set_history (GTK_OPTION_MENU (((ESearchBar *)((EMFolderBrowser *) emfv)->search)->scopeoption), 3); - } + em_folder_view_show_search_bar (emfv); } static void @@ -3271,3 +3265,15 @@ emfv_on_html_button_released_cb (GtkHTML *html, GdkEventButton *button, EMFolder return FALSE; } +void +em_folder_view_show_search_bar (EMFolderView *emfv) +{ + EMFolderViewClass *class; + + g_return_if_fail (EM_IS_FOLDER_VIEW (emfv)); + + class = EM_FOLDER_VIEW_GET_CLASS (emfv); + g_return_if_fail (class->show_search_bar != NULL); + + class->show_search_bar (emfv); +} diff --git a/mail/em-folder-view.h b/mail/em-folder-view.h index 4af4760cac..b69a4a1a05 100644 --- a/mail/em-folder-view.h +++ b/mail/em-folder-view.h @@ -124,6 +124,8 @@ struct _EMFolderViewClass { void (*set_folder)(EMFolderView *emfv, struct _CamelFolder *folder, const char *uri); void (*set_message)(EMFolderView *emfv, const char *uid, int nomarkseen); + void (*show_search_bar)(EMFolderView *emfv); + /* Signals */ void (*on_url)(EMFolderView *emfv, const char *uri, const char *nice_uri); @@ -153,6 +155,7 @@ guint32 em_folder_view_disable_mask(EMFolderView *emfv); void em_folder_view_set_statusbar(EMFolderView *emfv, gboolean statusbar); void em_folder_view_set_hide_deleted(EMFolderView *emfv, gboolean status); void em_folder_view_setup_view_instance (EMFolderView *emfv); +void em_folder_view_show_search_bar (EMFolderView *emfv); G_END_DECLS diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index aba9c64069..cf1626ecd0 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -40,7 +40,6 @@ #include #include -#include #include @@ -76,7 +75,6 @@ #include "e-mail-attachment-bar.h" #include "em-format-html-display.h" -#include "e-searching-tokenizer.h" #include "em-icon-stream.h" #include "em-utils.h" #include "em-popup.h" @@ -97,17 +95,6 @@ #define d(x) struct _EMFormatHTMLDisplayPrivate { - /* For the interactive search dialogue */ - /* TODO: Should this be more subtle, like the mozilla one? */ - GtkHBox *search_dialog; - GtkWidget *search_entry; - GtkWidget *search_entry_box; - GtkWidget *search_matches_label; - GtkWidget *search_case_check; - char *search_text; - int search_wrap; /* are we doing a wrap search */ - gboolean search_active; /* if the search is active */ - GtkWidget *attachment_view; /* weak reference */ }; @@ -167,7 +154,6 @@ static void efhd_format_source(EMFormat *, CamelStream *, CamelMimePart *); static void efhd_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, const char *, const EMFormatHandler *); static void efhd_format_optional(EMFormat *, CamelStream *, CamelMimePart *, CamelStream *); static void efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid); -static void efhd_complete(EMFormat *); static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); @@ -246,9 +232,6 @@ efhd_init(GObject *o) efhd->priv = g_malloc0(sizeof(*efhd->priv)); - efhd->search_tok = (ESearchingTokenizer *)e_searching_tokenizer_new(); - gtk_html_set_tokenizer (efh->html, (HTMLTokenizer *)efhd->search_tok); - g_signal_connect(efh->html, "realize", G_CALLBACK(efhd_gtkhtml_realise), o); g_signal_connect(efh->html, "style-set", G_CALLBACK(efhd_gtkhtml_style_set), o); /* we want to convert url's etc */ @@ -265,7 +248,6 @@ efhd_finalise(GObject *o) /* check pending stuff */ - g_free(efhd->priv->search_text); g_free(efhd->priv); ((GObjectClass *)efhd_parent)->finalize(o); @@ -291,7 +273,6 @@ efhd_class_init(GObjectClass *klass) ((EMFormatClass *)klass)->format_attachment = efhd_format_attachment; ((EMFormatClass *)klass)->format_optional = efhd_format_optional; ((EMFormatClass *)klass)->format_secure = efhd_format_secure; - ((EMFormatClass *)klass)->complete = efhd_complete; klass->finalize = efhd_finalise; @@ -400,316 +381,6 @@ void em_format_html_display_set_caret_mode(EMFormatHTMLDisplay *efhd, gboolean s gtk_html_set_caret_mode(((EMFormatHTML *)efhd)->html, state); } -void -em_format_html_display_set_search(EMFormatHTMLDisplay *efhd, int type, GSList *strings) -{ - switch(type&3) { - case EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY: - e_searching_tokenizer_set_primary_case_sensitivity(efhd->search_tok, (type&EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE) == 0); - e_searching_tokenizer_set_primary_search_string(efhd->search_tok, NULL); - while (strings) { - e_searching_tokenizer_add_primary_search_string(efhd->search_tok, strings->data); - strings = strings->next; - } - break; - case EM_FORMAT_HTML_DISPLAY_SEARCH_SECONDARY: - default: - e_searching_tokenizer_set_secondary_case_sensitivity(efhd->search_tok, (type&EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE) == 0); - e_searching_tokenizer_set_secondary_search_string(efhd->search_tok, NULL); - while (strings) { - e_searching_tokenizer_add_secondary_search_string(efhd->search_tok, strings->data); - strings = strings->next; - } - break; - } - - d(printf("redrawing with search\n")); - em_format_redraw((EMFormat *)efhd); -} - -static void -efhd_update_matches(EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - char *str; - /* message-search popup match count string */ - char *fmt = _("Matches: %d"); - - if (p->search_dialog) { - str = alloca(strlen(fmt)+32); - sprintf(str, fmt, e_searching_tokenizer_match_count(efhd->search_tok)); - gtk_label_set_text((GtkLabel *)p->search_matches_label, str); - } - gtk_widget_show((GtkWidget *)p->search_matches_label); - -} - -static void -efhd_update_search(EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - GSList *words = NULL; - int flags = 0; - - if (!gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check)) - flags = EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE | EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY; - else - flags = EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY; - - if (p->search_text) - words = g_slist_append(words, p->search_text); - - em_format_html_display_set_search(efhd, flags, words); - g_slist_free(words); -} - -static void -efhd_search_response(GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - char *txt = g_strdup(gtk_entry_get_text((GtkEntry *)p->search_entry)); - - g_strstrip(txt); - if (p->search_text && strcmp(p->search_text, txt) == 0 && !p->search_wrap) { - gtk_html_engine_search_set_forward (((EMFormatHTML *)efhd)->html, TRUE); - if (!gtk_html_engine_search_next(((EMFormatHTML *)efhd)->html)) - p->search_wrap = TRUE; - g_free(txt); - } else { - g_free(p->search_text); - p->search_text = txt; - if (!p->search_wrap) - efhd_update_search(efhd); - p->search_wrap = FALSE; - gtk_html_engine_search(((EMFormatHTML *)efhd)->html, txt, - gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check), - TRUE, FALSE); - } -} - - -static void -efhd_search_response_back (GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - char *txt = g_strdup(gtk_entry_get_text((GtkEntry *)p->search_entry)); - - g_strstrip(txt); - if (p->search_text && strcmp(p->search_text, txt) == 0 && !p->search_wrap) { - gtk_html_engine_search_set_forward (((EMFormatHTML *)efhd)->html, FALSE); - if (!gtk_html_engine_search_next(((EMFormatHTML *)efhd)->html)) - p->search_wrap = TRUE; - g_free(txt); - } else { - g_free(p->search_text); - p->search_text = txt; - if (!p->search_wrap) - efhd_update_search(efhd); - p->search_wrap = FALSE; - gtk_html_engine_search(((EMFormatHTML *)efhd)->html, txt, - gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check), - FALSE, FALSE); - } -} - - -static void -efhd_search_destroy(GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - g_free(p->search_text); - p->search_text = NULL; - gtk_widget_hide((GtkWidget *)p->search_dialog); - em_format_html_display_set_search(efhd, EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY, NULL); - p->search_active = FALSE; -} - -static void -efhd_search_case_toggled(GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - g_free(p->search_text); - p->search_text = NULL; - efhd_search_response(w, efhd); -} - -static gboolean -efhd_key_pressed (GtkWidget *w, GdkEventKey *event, EMFormatHTMLDisplay *efhd) -{ - if (event->keyval == GDK_Escape){ - efhd_search_destroy (w, efhd); - return TRUE; - } - return FALSE; -} - -static void -clear_button_clicked_cb (GtkWidget *widget, gpointer dummy, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - gtk_entry_set_text (GTK_ENTRY (p->search_entry), ""); - - g_signal_emit_by_name (p->search_entry, "activate", efhd); -} - -/* Controlls the visibility of icon_entry's visibility */ -static void -icon_entry_changed_cb (GtkWidget *widget, GtkWidget *clear_button) -{ - const char *text = gtk_entry_get_text (GTK_ENTRY (widget)); - - if (text && *text) - gtk_widget_show (clear_button); - else - gtk_widget_hide (clear_button); -} - -GtkWidget * -em_format_html_get_search_dialog (EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - GtkWidget *hbox2, *button3, *button2, *label1; - GtkWidget *icon_entry, *clear_button; - - p->search_entry_box = gtk_hbox_new (FALSE, 0); - - label1 = gtk_label_new_with_mnemonic (_("Fin_d:")); - gtk_widget_show (label1); - gtk_box_pack_start ((GtkBox *)(p->search_entry_box), label1, FALSE, FALSE, 5); - - /* Icon entry */ - icon_entry = e_icon_entry_new (); - p->search_entry = e_icon_entry_get_entry (E_ICON_ENTRY (icon_entry)); - gtk_label_set_mnemonic_widget (GTK_LABEL (label1), p->search_entry); - gtk_widget_show (p->search_entry); - clear_button = e_icon_entry_create_button ("gtk-clear"); - e_icon_entry_pack_widget (E_ICON_ENTRY (icon_entry), clear_button, FALSE); - gtk_widget_show_all (icon_entry); - gtk_widget_hide (clear_button); - - g_signal_connect (G_OBJECT (clear_button), "button-press-event", (GCallback) clear_button_clicked_cb, efhd); - g_signal_connect (G_OBJECT (p->search_entry), "changed", (GCallback) icon_entry_changed_cb, clear_button); - - gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, FALSE, FALSE, 0); - /* gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, TRUE, TRUE, 0); */ - - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, FALSE, FALSE, 5); - /* gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, TRUE, TRUE, 5); */ - - button3 = gtk_button_new_with_mnemonic (_("_Previous")); - gtk_button_set_image (GTK_BUTTON (button3), GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON))); - gtk_widget_show (button3); - gtk_box_pack_start (GTK_BOX (hbox2), button3, FALSE, FALSE, 5); - - button2 = gtk_button_new_with_mnemonic (_("_Next")); - gtk_button_set_image (GTK_BUTTON (button2), gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON)); - gtk_widget_show (button2); - gtk_box_pack_start (GTK_BOX (hbox2), button2, FALSE, FALSE, 5); - - p->search_case_check = gtk_check_button_new_with_mnemonic (_("M_atch case")); - gtk_widget_show (p->search_case_check); - gtk_box_pack_start (GTK_BOX (hbox2), p->search_case_check, FALSE, FALSE, 0); - - p->search_matches_label = gtk_label_new (""); - gtk_widget_show (p->search_matches_label); - gtk_box_pack_start (GTK_BOX (hbox2), p->search_matches_label, TRUE, TRUE, 0); - p->search_dialog = GTK_HBOX (hbox2); - - p->search_wrap = FALSE; - - g_signal_connect (p->search_entry, "activate", G_CALLBACK(efhd_search_response), efhd); - g_signal_connect (p->search_entry, "key-press-event", G_CALLBACK(efhd_key_pressed), efhd); - g_signal_connect (p->search_case_check, "toggled", G_CALLBACK(efhd_search_case_toggled), efhd); - g_signal_connect (button2, "clicked", G_CALLBACK(efhd_search_response), efhd); - g_signal_connect (button3, "clicked", G_CALLBACK(efhd_search_response_back), efhd); - - p->search_active = FALSE; - - efhd_update_matches(efhd); - - return (GtkWidget *)p->search_dialog; - -} - -static void -set_focus_cb (GtkWidget *window, GtkWidget *widget, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - GtkWidget *sbar = GTK_WIDGET (p->search_dialog); - - while (widget != NULL && widget != sbar) { - widget = widget->parent; - } - - if (widget != sbar) - efhd_search_destroy(widget, efhd); -} - -/** - * em_format_html_display_search: - * @efhd: - * - * Run an interactive search dialogue. - **/ -void -em_format_html_display_search(EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog){ - GtkWidget *toplevel; - - gtk_widget_show (GTK_WIDGET (p->search_dialog)); - gtk_widget_grab_focus (p->search_entry); - gtk_widget_show (p->search_entry_box); - - p->search_active = TRUE; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (p->search_dialog)); - - g_signal_connect (toplevel, "set-focus", - G_CALLBACK (set_focus_cb), efhd); - } - -} -/** - * em_format_html_display_search_with: - * @efhd: - * - * Run an interactive search dialogue. - **/ -void -em_format_html_display_search_with (EMFormatHTMLDisplay *efhd, char *word) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog){ - gtk_widget_show (GTK_WIDGET (p->search_dialog)); - p->search_active = TRUE; - - /* Set the query */ - gtk_entry_set_text (GTK_ENTRY (p->search_entry), word); - gtk_widget_hide (p->search_entry_box); - - /* Trigger the search */ - g_signal_emit_by_name (p->search_entry, "activate", efhd); - } -} - -void -em_format_html_display_search_close (EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog && p->search_active) - efhd_search_destroy(GTK_WIDGET (p->search_dialog), efhd); -} - void em_format_html_display_cut (EMFormatHTMLDisplay *efhd) { @@ -889,15 +560,6 @@ efhd_html_on_url (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd) g_signal_emit((GObject *)efhd, efhd_signals[EFHD_ON_URL], 0, url); } -static void -efhd_complete(EMFormat *emf) -{ - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)emf; - - if (efhd->priv->search_dialog && efhd->priv->search_active) - efhd_update_matches(efhd); -} - /* ********************************************************************** */ /* TODO: move the dialogue elsehwere */ diff --git a/mail/em-format-html-display.h b/mail/em-format-html-display.h index 10a379d7f6..99234e9c1e 100644 --- a/mail/em-format-html-display.h +++ b/mail/em-format-html-display.h @@ -105,8 +105,6 @@ void em_format_html_display_search_with void em_format_html_display_search_close (EMFormatHTMLDisplay *efhd); -GtkWidget * em_format_html_get_search_dialog(EMFormatHTMLDisplay *efhd); - void em_format_html_display_cut (EMFormatHTMLDisplay *efhd); void em_format_html_display_copy (EMFormatHTMLDisplay *efhd); void em_format_html_display_paste (EMFormatHTMLDisplay *efhd); diff --git a/mail/em-format.c b/mail/em-format.c index 1d5570be96..826ef11b63 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -772,7 +772,43 @@ emf_busy(EMFormat *emf) * a display refresh, or it can be used to generate an identical layout, * e.g. to print what the user has shown inline. **/ -/* e_format_format_clone is a macro */ +void +em_format_format_clone (EMFormat *emf, + CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *message, + EMFormat *source) +{ + EMFormatClass *class; + + g_return_if_fail (EM_IS_FORMAT (emf)); + g_return_if_fail (folder == NULL || CAMEL_IS_FOLDER (folder)); + g_return_if_fail (message == NULL || CAMEL_IS_MIME_MESSAGE (message)); + g_return_if_fail (source == NULL || EM_IS_FORMAT (source)); + + class = EM_FORMAT_GET_CLASS (emf); + g_return_if_fail (class->format_clone != NULL); + class->format_clone (emf, folder, uid, message, source); +} + +void +em_format_format (EMFormat *emf, + CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *message) +{ + /* em_format_format_clone() will check the arguments. */ + em_format_format_clone (emf, folder, uid, message, NULL); +} + +void +em_format_redraw (EMFormat *emf) +{ + g_return_if_fail (EM_IS_FORMAT (emf)); + + em_format_format_clone ( + emf, emf->folder, emf->uid, emf->message, emf); +} /** * em_format_set_session: diff --git a/mail/em-format.h b/mail/em-format.h index 92c6b3dddf..f11e73937a 100644 --- a/mail/em-format.h +++ b/mail/em-format.h @@ -324,14 +324,10 @@ void em_format_push_level(EMFormat *emf); void em_format_pull_level(EMFormat *emf); /* clones inline state/view and format, or use to redraw */ -#define em_format_format_clone(emf, folder, uid, msg, src) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_clone((emf), (folder), (uid), (msg), (src)) +void em_format_format_clone (EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *message, EMFormat *source); /* formats a new message */ -#define em_format_format(emf, folder, uid, msg) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_clone((emf), (folder), (uid), (msg), NULL) -#define em_format_redraw(emf) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_clone((EMFormat *)(emf), \ - ((EMFormat *)(emf))->folder, \ - ((EMFormat *)(emf))->uid, \ - ((EMFormat *)(emf))->message, \ - (EMFormat *)(emf)) +void em_format_format(EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *message); +void em_format_redraw(EMFormat *emf); void em_format_format_error(EMFormat *emf, CamelStream *stream, const char *fmt, ...); #define em_format_format_attachment(emf, stream, msg, type, info) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_attachment((emf), (stream), (msg), (type), (info)) #define em_format_format_source(emf, stream, msg) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_source((emf), (stream), (msg)) diff --git a/mail/em-message-browser.c b/mail/em-message-browser.c index 728b27ec43..973708bc2b 100644 --- a/mail/em-message-browser.c +++ b/mail/em-message-browser.c @@ -48,6 +48,7 @@ #include "e-util/e-util-private.h" +#include "e-mail-search-bar.h" #include "em-format-html-display.h" #include "em-message-browser.h" #include "em-menu.h" @@ -63,6 +64,7 @@ struct _EMMessageBrowserPrivate { GtkWidget *preview; /* container for message display */ + GtkWidget *search_bar; }; static gpointer parent_class; @@ -224,6 +226,14 @@ emmb_destroy (GtkObject *gtk_object) GTK_OBJECT_CLASS (parent_class)->destroy (gtk_object); } +static void +emmb_show_search_bar (EMFolderView *folder_view) +{ + EMMessageBrowser *browser = EM_MESSAGE_BROWSER (folder_view); + + gtk_widget_show (browser->priv->search_bar); +} + static void emmb_class_init (EMMessageBrowserClass *class) { @@ -240,12 +250,14 @@ emmb_class_init (EMMessageBrowserClass *class) folder_view_class->update_message_style = FALSE; folder_view_class->set_message = emmb_set_message; folder_view_class->activate = emmb_activate; + folder_view_class->show_search_bar = emmb_show_search_bar; } static void emmb_init (EMMessageBrowser *emmb) { EMFolderView *emfv = EM_FOLDER_VIEW (emmb); + GtkWidget *container; GtkWidget *widget; gchar *filename; @@ -265,25 +277,35 @@ emmb_init (EMMessageBrowser *emmb) EVOLUTION_UIDIR, "evolution-mail-message.xml", NULL); emfv->ui_files = g_slist_append (emfv->ui_files, filename); + gtk_box_set_spacing (GTK_BOX (emmb), 1); + + container = GTK_WIDGET (emmb); + widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - gtk_widget_show (widget); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); emmb->priv->preview = widget; + gtk_widget_show (widget); + + widget = e_mail_search_bar_new (emfv->preview->formathtml.html); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + emmb->priv->search_bar = widget; + gtk_widget_hide (widget); + + g_signal_connect_swapped ( + widget, "changed", + G_CALLBACK (em_format_redraw), emfv->preview); + + container = emmb->priv->preview; widget = GTK_WIDGET (emfv->preview->formathtml.html); - gtk_container_add (GTK_CONTAINER (emmb->priv->preview), widget); + gtk_container_add (GTK_CONTAINER (container), widget); gtk_widget_show (widget); - gtk_box_pack_start ( - GTK_BOX (emmb), emmb->priv->preview, TRUE, TRUE, 0); - gtk_box_pack_start( - GTK_BOX (emmb), em_format_html_get_search_dialog ( - emfv->preview), FALSE, FALSE, 0); - /** @HookPoint-EMMenu: Standalone Message View Menu * @Id: org.gnome.evolution.mail.messagebrowser * @Class: org.gnome.evolution.mail.bonobomenu:1.0 diff --git a/mail/em-utils.c b/mail/em-utils.c index 7685e76845..958864647d 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -804,7 +804,7 @@ tag_editor_response (GtkWidget *dialog, int button, struct ted_t *ted) camel_tag_list_free (&tags); if (ted->emfv->preview) - em_format_redraw(ted->emfv->preview); + em_format_redraw (EM_FORMAT (ted->emfv->preview)); } gtk_widget_destroy (dialog); -- cgit