From 253a05d03cb3d827a0da0002cb48231bd238caa3 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Thu, 25 May 2006 04:59:47 +0000 Subject: Added support for collapsible headers for To/Cc/Bcc svn path=/trunk/; revision=32020 --- mail/ChangeLog | 20 +++++++++ mail/em-folder-view.c | 5 +++ mail/em-format-html-display.c | 25 ++++++++++- mail/em-format-html.c | 94 +++++++++++++++++++++++++++++++++++---- mail/em-format-html.h | 8 ++++ mail/em-mailer-prefs.c | 22 ++++++++- mail/em-mailer-prefs.h | 2 + mail/evolution-mail.schemas.in.in | 30 +++++++++++++ mail/mail-config.c | 34 +++++++++++++- mail/mail-config.glade | 79 +++++++++++++++++++++++++++++++- mail/mail-config.h | 1 + 11 files changed, 306 insertions(+), 14 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index b2b502157f..5725fa6901 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,23 @@ +2006-05-25 Srinivasa Ragavan + + Added support for collapsible headers for To/Cc/Bcc fields. + + * em-folder-view.c: (emfv_format_link_clicked), (emfv_on_url_cb): + * em-format-html-display.c: (efhd_html_button_press_event), + (efhd_html_link_clicked), (efhd_html_on_url), (efhd_format_clone): + * em-format-html.c: (efh_url_requested), (efh_format_text_header), + (efh_format_address), (efh_format_header): + * em-format-html.h: + * em-mailer-prefs.c: (address_compress_count_changed), + (toggle_button_init), (em_mailer_prefs_construct): + * em-mailer-prefs.h: + * evolution-mail.schemas.in.in: + * mail-config.c: (gconf_address_count_changed), + (gconf_address_compress_changed), (mail_config_init), + (mail_config_get_labels), (mail_config_get_address_count): + * mail-config.glade: + * mail-config.h: + 2006-05-24 Srinivasa Ragavan ** Fixes bug #342676 diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 7da694b6a0..7add999ec3 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -2427,6 +2427,9 @@ emfv_list_selection_change(ETree *tree, EMFolderView *emfv) static void emfv_format_link_clicked(EMFormatHTMLDisplay *efhd, const char *uri, EMFolderView *emfv) { + if (!strncmp (uri, "##", 2)) + return; + if (!g_ascii_strncasecmp (uri, "mailto:", 7)) { em_utils_compose_new_message_with_mailto (uri, emfv->folder_uri); } else if (*uri == '#') { @@ -2823,6 +2826,8 @@ emfv_on_url_cb (GObject *emitter, const char *url, EMFolderView *emfv) g_free(addr); camel_url_free(curl); camel_object_unref(cia); + } else if (!strncmp (url, "##", 2)) { + nice_url = g_strdup_printf (_("Click to hide/unhide addresses"), url); } else nice_url = g_strdup_printf (_("Click to open %s"), url); } diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 3a18ad28ab..5f9160787a 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -687,6 +687,9 @@ efhd_html_button_press_event (GtkWidget *widget, GdkEventButton *event, EMFormat d(printf("popup button pressed\n")); + if (uri && !strncmp (uri, "##", 2)) + return TRUE; + if (uri) { puri = em_format_find_puri((EMFormat *)efhd, uri); d(printf("poup event, uri = '%s' part = '%p'\n", uri, puri?puri->part:NULL)); @@ -725,13 +728,32 @@ static void efhd_html_link_clicked (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd) { d(printf("link clicked event '%s'\n", url)); - g_signal_emit((GObject *)efhd, efhd_signals[EFHD_LINK_CLICKED], 0, url); + if (url && !strncmp(url, "##", 2)) { + if (!strcmp (url, "##TO##")) + if (!(((EMFormatHTML *) efhd)->header_wrap_flags & EM_FORMAT_HTML_HEADER_TO)) + ((EMFormatHTML *) efhd)->header_wrap_flags |= EM_FORMAT_HTML_HEADER_TO; + else + ((EMFormatHTML *) efhd)->header_wrap_flags &= ~EM_FORMAT_HTML_HEADER_TO; + else if (!strcmp (url, "##CC##")) + if (!(((EMFormatHTML *) efhd)->header_wrap_flags & EM_FORMAT_HTML_HEADER_CC)) + ((EMFormatHTML *) efhd)->header_wrap_flags |= EM_FORMAT_HTML_HEADER_CC; + else + ((EMFormatHTML *) efhd)->header_wrap_flags &= ~EM_FORMAT_HTML_HEADER_CC; + else if (!strcmp (url, "##BCC##")) + if (!(((EMFormatHTML *) efhd)->header_wrap_flags & EM_FORMAT_HTML_HEADER_BCC)) + ((EMFormatHTML *) efhd)->header_wrap_flags |= EM_FORMAT_HTML_HEADER_BCC; + else + ((EMFormatHTML *) efhd)->header_wrap_flags &= ~EM_FORMAT_HTML_HEADER_BCC; + em_format_redraw((EMFormat *)efhd); + } else + g_signal_emit((GObject *)efhd, efhd_signals[EFHD_LINK_CLICKED], 0, url); } static void efhd_html_on_url (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd) { d(printf("on_url event '%s'\n", url)); + g_signal_emit((GObject *)efhd, efhd_signals[EFHD_ON_URL], 0, url); } @@ -1119,6 +1141,7 @@ static void efhd_format_clone(EMFormat *emf, CamelFolder *folder, const char *ui efhd->priv->show_bar = ((EMFormatHTMLDisplay *)src)->priv->show_bar; else efhd->priv->show_bar = FALSE; + ((EMFormatHTML *) emf)->header_wrap_flags = 0; } ((EMFormatClass *)efhd_parent)->format_clone(emf, folder, uid, msg, src); diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 35e1d9f2da..eb9034ee42 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -563,6 +563,16 @@ efh_url_requested(GtkHTML *html, const char *url, GtkHTMLStream *handle, EMForma } else if (g_ascii_strncasecmp(url, "http:", 5) == 0 || g_ascii_strncasecmp(url, "https:", 6) == 0) { d(printf(" adding job, get %s\n", url)); job = em_format_html_job_new(efh, emfh_gethttp, g_strdup(url)); + } else if (g_ascii_strncasecmp(url, "/", 1) == 0) { + char *data = NULL; + int length = 0; + gboolean status; + + status = g_file_get_contents (url, &data, &length, NULL); + if (status) + gtk_html_stream_write (handle, data, length); + + gtk_html_stream_close(handle, status? GTK_HTML_STREAM_OK : GTK_HTML_STREAM_ERROR); } else { d(printf("HTML Includes reference to unknown uri '%s'\n", url)); gtk_html_stream_close(handle, GTK_HTML_STREAM_ERROR); @@ -1442,7 +1452,7 @@ efh_format_text_header (EMFormatHTML *emfh, CamelStream *stream, const char *lab html = value; else html = mhtml = camel_text_to_html (value, emfh->text_html_flags, 0); - + if (emfh->simple_headers) { fmt = "%s: %s
"; } else { @@ -1451,8 +1461,11 @@ efh_format_text_header (EMFormatHTML *emfh, CamelStream *stream, const char *lab fmt = "%s: %s"; else fmt = "%s: %s"; + } else if (flags & EM_FORMAT_HTML_HEADER_NODEC) { + fmt = "%s %s"; } else { - if (flags & EM_FORMAT_HEADER_BOLD) + + if (flags & EM_FORMAT_HEADER_BOLD) fmt = "%s: %s"; else fmt = "%s: %s"; @@ -1469,19 +1482,28 @@ static char *addrspec_hdrs[] = { "resent-to", "resent-cc", "resent-bcc", NULL }; -#if 0 /* FIXME: include Sender and Resent-* headers too? */ /* For Translators only: The following strings are used in the header table in the preview pane */ static char *i18n_hdrs[] = { N_("From"), N_("Reply-To"), N_("To"), N_("Cc"), N_("Bcc") }; -#endif -static void -efh_format_address (GString *out, struct _camel_header_address *a) +static gchar * +efh_format_address (EMFormatHTML *efh, GString *out, struct _camel_header_address *a, gchar *field) { guint32 flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; char *name, *mailto, *addr; + int i=0; + gboolean wrap = FALSE; + char *str = NULL; + int limit = mail_config_get_address_count (); + + if (field ) { + if ((!strcmp (field, i18n_hdrs[2]) && !(efh->header_wrap_flags & EM_FORMAT_HTML_HEADER_TO)) + || (!strcmp (field, i18n_hdrs[3]) && !(efh->header_wrap_flags & EM_FORMAT_HTML_HEADER_CC)) + || (!strcmp (field, i18n_hdrs[4]) && !(efh->header_wrap_flags & EM_FORMAT_HTML_HEADER_BCC))) + wrap = TRUE; + } while (a) { if (a->name) @@ -1517,7 +1539,7 @@ efh_format_address (GString *out, struct _camel_header_address *a) break; case CAMEL_HEADER_ADDRESS_GROUP: g_string_append_printf (out, "%s: ", name); - efh_format_address (out, a->v.members); + efh_format_address (efh, out, a->v.members, NULL); g_string_append_printf (out, ";"); break; default: @@ -1526,11 +1548,54 @@ efh_format_address (GString *out, struct _camel_header_address *a) } g_free (name); - + + i++; a = a->next; if (a) g_string_append (out, ", "); + + /* Let us add a '...' if we have more addresses */ + if (limit > 0 && wrap && a && (i>(limit-1))) { + + if (!strcmp (field, i18n_hdrs[2])) { + + g_string_append (out, "..."); + str = g_strdup (" "); + + return str; + } + else if (!strcmp (field, i18n_hdrs[3])) { + g_string_append (out, "..."); + str = g_strdup (" "); + + return str; + } + else if (!strcmp (field, i18n_hdrs[4])) { + g_string_append (out, "..."); + str = g_strdup (" "); + + return str; + } + } + + } + + if (limit > 0 && i>(limit-1)) { + + + if (!strcmp (field, i18n_hdrs[2])) { + str = g_strdup_printf (" "); + } + else if (!strcmp (field, i18n_hdrs[3])) { + str = g_strdup (" "); + } + else if (!strcmp (field, i18n_hdrs[4])) { + str = g_strdup (" "); + } } + + return str; + } static void @@ -1540,6 +1605,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct char *name, *value = NULL, *p; const char *label, *txt; int addrspec = 0, i; + char *str_field = NULL; name = alloca(strlen(header->name)+1); strcpy(name, header->name); @@ -1555,6 +1621,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct if (addrspec) { struct _camel_header_address *addrs; GString *html; + char *img; if (!(addrs = camel_header_address_decode(header->value, emf->charset ? emf->charset : emf->default_charset))) return; @@ -1573,7 +1640,15 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct label = _(name); html = g_string_new(""); - efh_format_address(html, addrs); + img = efh_format_address(emf, html, addrs, label); + + if (img) { +// str_field = g_strdup_printf ("
%s%s:
", img, label); + str_field = g_strdup_printf ("%s%s:", img, label); + label = str_field; + flags |= EM_FORMAT_HTML_HEADER_NODEC; + g_free (img); + } camel_header_address_unref(addrs); txt = value = html->str; g_string_free(html, FALSE); @@ -1660,6 +1735,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct efh_format_text_header(efh, stream, label, txt, flags); g_free(value); + g_free (str_field); } static void diff --git a/mail/em-format-html.h b/mail/em-format-html.h index a524912cfb..383313b3bf 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -43,6 +43,12 @@ struct _CamelMimePart; struct _CamelMedium; struct _CamelStream; +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, +}; + /* A HTMLJob will be executed in another thread, in sequence, It's job is to write to its stream, close it if successful, then exit */ @@ -132,6 +138,7 @@ struct _EMFormatHTMLPObject { #define EM_FORMAT_HTML_HEADER_NOCOLUMNS (EM_FORMAT_HEADER_LAST) #define EM_FORMAT_HTML_HEADER_HTML (EM_FORMAT_HEADER_LAST<<1) /* header already in html format */ +#define EM_FORMAT_HTML_HEADER_NODEC (EM_FORMAT_HEADER_LAST<<2) /* header already in html format */ #define EM_FORMAT_HTML_HEADER_LAST (EM_FORMAT_HEADER_LAST<<8) #define EM_FORMAT_HTML_VPAD "
\n" @@ -186,6 +193,7 @@ struct _EMFormatHTML { unsigned int simple_headers:1; /* simple header format, no box/table */ unsigned int hide_headers:1; /* no headers at all */ unsigned int show_rupert:1; /* whether we print rupert or not */ + guint32 header_wrap_flags; }; struct _EMFormatHTMLClass { diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index f15dcf3990..96110a4a6f 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -448,6 +448,16 @@ mark_seen_timeout_changed (GtkSpinButton *spin, EMMailerPrefs *prefs) gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/mark_seen_timeout", timeout, NULL); } +static void +address_compress_count_changed (GtkSpinButton *spin, EMMailerPrefs *prefs) +{ + int count; + + count = (int) gtk_spin_button_get_value (prefs->address_count); + + gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/address_count", count, NULL); +} + static void spin_button_init (EMMailerPrefs *prefs, GtkSpinButton *spin, const char *key, float div, GCallback value_changed) { @@ -540,7 +550,7 @@ toggle_button_init (EMMailerPrefs *prefs, GtkToggleButton *toggle, int not, cons bool = gconf_client_get_bool (prefs->gconf, key, NULL); gtk_toggle_button_set_active (toggle, not ? !bool : bool); - + if (toggled) { g_object_set_data ((GObject *) toggle, "key", (void *) key); g_signal_connect (toggle, "toggled", toggled, prefs); @@ -755,6 +765,16 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) spin_button_init (prefs, prefs->timeout, "/apps/evolution/mail/display/mark_seen_timeout", 1000.0, G_CALLBACK (mark_seen_timeout_changed)); + + prefs->address_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "address_checkbox")); + toggle_button_init (prefs, prefs->address_toggle, FALSE, + "/apps/evolution/mail/display/address_compress", + G_CALLBACK (toggle_button_toggled)); + + prefs->address_count = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "address_spin")); + spin_button_init (prefs, prefs->address_count, + "/apps/evolution/mail/display/address_count", + 1, G_CALLBACK (address_compress_count_changed)); prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); charset_menu_init (prefs); diff --git a/mail/em-mailer-prefs.h b/mail/em-mailer-prefs.h index 0d5eb2cc97..2249fefd7a 100644 --- a/mail/em-mailer-prefs.h +++ b/mail/em-mailer-prefs.h @@ -74,6 +74,8 @@ struct _EMMailerPrefs { /* Message Display */ struct _GtkToggleButton *timeout_toggle; struct _GtkSpinButton *timeout; + struct _GtkToggleButton *address_toggle; + struct _GtkSpinButton *address_count; struct _GtkOptionMenu *charset; struct _GtkToggleButton *citation_highlight; struct _GnomeColorPicker *citation_color; diff --git a/mail/evolution-mail.schemas.in.in b/mail/evolution-mail.schemas.in.in index dfc5416c70..f4466ac44e 100644 --- a/mail/evolution-mail.schemas.in.in +++ b/mail/evolution-mail.schemas.in.in @@ -429,6 +429,36 @@ + + /schemas/apps/evolution/mail/display/address_compress + /apps/evolution/mail/display/address_compress + evolution-mail + boolean + true + + Compress display of addresses in TO/CC/BCC + + Compress display of addresses in TO/CC/BCC to the number + specified in address_count. + + + + + + /schemas/apps/evolution/mail/display/address_count + /apps/evolution/mail/display/address_count + evolution-mail + int + 5 + + Number of addresses to display in TO/CC/BCC + + This sets the number of addresses to show in default message list + view, beyond which a '...' is shown. + + + + /schemas/apps/evolution/mail/display/thread_subject /apps/evolution/mail/display/thread_subject diff --git a/mail/mail-config.c b/mail/mail-config.c index 65223f81a8..fb06f9e17f 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -106,6 +106,10 @@ typedef struct { guint spell_notify_id; guint mark_citations__notify_id; guint citation_colour_notify_id; + guint address_count_notify_id; + guint address_compress_notify_id; + gboolean address_compress; + gint address_count; GPtrArray *mime_types; guint mime_types_notify_id; @@ -320,6 +324,20 @@ gconf_style_changed (GConfClient *client, guint cnxn_id, config_write_style (); } +static void +gconf_address_count_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + config->address_count = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/address_count", NULL); +} + +static void +gconf_address_compress_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + config->address_compress = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/address_compress", NULL); +} + static void gconf_mime_types_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) @@ -352,6 +370,10 @@ mail_config_init (void) GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/fonts", gconf_style_changed, NULL, NULL, NULL); + config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/address_compress", + gconf_address_compress_changed, NULL, NULL, NULL); + config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/address_count", + gconf_address_count_changed, NULL, NULL, NULL); config->spell_notify_id = gconf_client_notify_add (config->gconf, "/GNOME/Spell", gconf_style_changed, NULL, NULL, NULL); config->mark_citations__notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/mark_citations", @@ -373,7 +395,8 @@ mail_config_init (void) config_cache_labels (); config_cache_mime_types (); - + config->address_compress = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/address_compress", NULL); + config->address_count = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/address_count", NULL); config->accounts = e_account_list_new (config->gconf); config->signatures = e_signature_list_new (config->gconf); } @@ -506,6 +529,15 @@ mail_config_get_labels (void) return config->labels; } +int +mail_config_get_address_count (void) +{ + if (!config->address_compress) + return -1; + + return config->address_count; +} + const char * mail_config_get_label_color_by_name (const char *name) { diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 5dafaec6b4..9f4f8a7005 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -1324,7 +1324,6 @@ For example: "Work" or "Personal" 0.5 0 0 - source_path PANGO_ELLIPSIZE_NONE -1 False @@ -4961,6 +4960,82 @@ For example: "Work" or "Personal" + + + True + False + 0 + + + + True + True + _Shrink To / Cc / Bcc headers to + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 5 1 100 1 10 10 + + + 2 + False + False + + + + + + True + addresses + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 2 + False + False + + + + + 0 + False + False + + + True @@ -8758,8 +8833,8 @@ for display purposes only. - True + GTK_FILE_CHOOSER_ACTION_OPEN True False diff --git a/mail/mail-config.h b/mail/mail-config.h index ec8fd74b5b..9d6e82879b 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -133,6 +133,7 @@ struct _EAccountList *mail_config_get_accounts (void); void mail_config_add_account (struct _EAccount *account); void mail_config_remove_account (struct _EAccount *account); void mail_config_set_default_account (struct _EAccount *account); +int mail_config_get_address_count (void); void mail_config_remove_account_proxies (struct _EAccount *account); void mail_config_prune_proxies (void); -- cgit