From 5b140dc1c18fa12b56438bd1045bf2960602b022 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 20 Mar 2001 16:50:43 +0000 Subject: set color in html citation 2001-03-20 Radek Doulik * mail-tools.c (mail_tool_quote_message): set color in html citation * mail-config.c: added citation highlighting configuration * mail-tools.c (mail_tool_quote_message): use citation highlighting * mail-display.c (mail_text_write): use citation highlighting svn path=/trunk/; revision=8848 --- mail/ChangeLog | 12 +++++++++++ mail/mail-accounts.c | 40 +++++++++++++++++++++++++++++++++++ mail/mail-accounts.h | 2 ++ mail/mail-config.c | 52 ++++++++++++++++++++++++++++++++++++++++++++- mail/mail-config.glade | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ mail/mail-config.h | 6 ++++++ mail/mail-display.c | 10 +++++---- mail/mail-tools.c | 20 +++++++++--------- 8 files changed, 184 insertions(+), 15 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 8ceca6555f..bf2f31181a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,15 @@ +2001-03-20 Radek Doulik + + * mail-tools.c (mail_tool_quote_message): set color in html + citation + + * mail-config.c: added citation highlighting configuration + + * mail-tools.c (mail_tool_quote_message): use citation + highlighting + + * mail-display.c (mail_text_write): use citation highlighting + 2001-03-20 Christopher James Lahey * folder-browser.c (etree_key): Made this check if the control diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index 76d91fabaa..9c48df2c00 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -372,6 +372,27 @@ send_html_toggled (GtkToggleButton *button, gpointer data) mail_config_set_send_html (gtk_toggle_button_get_active (button)); } +static void +citation_highlight_toggled (GtkToggleButton *button, gpointer data) +{ + mail_config_set_citation_highlight (gtk_toggle_button_get_active (button)); +} + +static void +citation_color_set (GnomeColorPicker *cp, guint r, guint g, guint b, guint a) +{ + guint32 rgb; + + rgb = r >> 8; + rgb <<= 8; + rgb |= g >> 8; + rgb <<= 8; + rgb |= b >> 8; + + mail_config_set_citation_color (rgb); +} + + static void timeout_changed (GtkEntry *entry, gpointer data) { @@ -404,6 +425,14 @@ pgp_path_changed (GtkEntry *entry, gpointer data) mail_config_set_pgp_type (type); } +static void +set_color (GnomeColorPicker *cp) +{ + guint32 rgb = mail_config_get_citation_color (); + + gnome_color_picker_set_i8 (cp, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff); +} + static void construct (MailAccountsDialog *dialog) { @@ -470,6 +499,17 @@ construct (MailAccountsDialog *dialog) gtk_signal_connect (GTK_OBJECT (dialog->send_html), "toggled", GTK_SIGNAL_FUNC (send_html_toggled), dialog); + dialog->citation_highlight = GTK_CHECK_BUTTON (glade_xml_get_widget (gui, "chckHighlightCitations")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->citation_highlight), + mail_config_get_citation_highlight ()); + gtk_signal_connect (GTK_OBJECT (dialog->citation_highlight), "toggled", + GTK_SIGNAL_FUNC (citation_highlight_toggled), dialog); + + dialog->citation_color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, "colorpickerCitations")); + set_color (dialog->citation_color); + gtk_signal_connect (GTK_OBJECT (dialog->citation_color), "color_set", + GTK_SIGNAL_FUNC (citation_color_set), dialog); + dialog->timeout = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spinMarkTimeout")); gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->timeout), (1.0 * mail_config_get_mark_as_seen_timeout ()) / 1000.0); diff --git a/mail/mail-accounts.h b/mail/mail-accounts.h index dcee0528c6..016200484b 100644 --- a/mail/mail-accounts.h +++ b/mail/mail-accounts.h @@ -65,6 +65,8 @@ struct _MailAccountsDialog { /* "Other" widgets */ GtkCheckButton *send_html; + GtkCheckButton *citation_highlight; + GnomeColorPicker *citation_color; GtkSpinButton *timeout; GnomeFileEntry *pgp_path; }; diff --git a/mail/mail-config.c b/mail/mail-config.c index 33edd27ecc..9630def2df 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -40,6 +40,8 @@ typedef struct { gboolean view_source; gint paned_size; gboolean send_html; + gboolean citation_highlight; + guint32 citation_color; gboolean prompt_empty_subject; gint seen_timeout; @@ -193,7 +195,7 @@ mail_config_clear (void) g_slist_free (config->news); config->news = NULL; } - + /* overkill? */ memset (config, 0, sizeof (MailConfig)); } @@ -335,6 +337,20 @@ config_read (void) config->send_html = FALSE; g_free (str); + /* Citation */ + str = g_strdup_printf ("=%s/config/Mail=/Display/citation_highlight", + evolution_dir); + config->citation_highlight = gnome_config_get_bool_with_default (str, &def); + if (def) + config->citation_highlight = TRUE; + g_free (str); + str = g_strdup_printf ("=%s/config/Mail=/Display/citation_color", + evolution_dir); + config->citation_color = gnome_config_get_int_with_default (str, &def); + if (def) + config->citation_color = 0x737373; + g_free (str); + /* Mark as seen timeout */ str = g_strdup_printf ("=%s/config/Mail=/Display/seen_timeout", evolution_dir); @@ -509,6 +525,16 @@ mail_config_write_on_exit (void) gnome_config_set_bool (str, config->send_html); g_free (str); + /* Citation */ + str = g_strdup_printf ("=%s/config/Mail=/Display/citation_highlight", + evolution_dir); + gnome_config_set_bool (str, config->citation_highlight); + g_free (str); + str = g_strdup_printf ("=%s/config/Mail=/Display/citation_color", + evolution_dir); + gnome_config_set_int (str, config->citation_color); + g_free (str); + /* Empty Subject */ str = g_strdup_printf ("=%s/config/Mail=/Prompts/empty_subject", evolution_dir); @@ -593,6 +619,30 @@ mail_config_set_send_html (gboolean send_html) config->send_html = send_html; } +gboolean +mail_config_get_citation_highlight (void) +{ + return config->citation_highlight; +} + +void +mail_config_set_citation_highlight (gboolean citation_highlight) +{ + config->citation_highlight = citation_highlight; +} + +guint32 +mail_config_get_citation_color (void) +{ + return config->citation_color; +} + +void +mail_config_set_citation_color (guint32 citation_color) +{ + config->citation_color = citation_color; +} + gint mail_config_get_mark_as_seen_timeout (void) { diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 4a902dd31e..53fa0649b4 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -2002,6 +2002,63 @@ Click "Finish" to save your settings. + + GtkHBox + hbox42 + False + 0 + + 0 + False + True + + + + GtkCheckButton + chckHighlightCitations + True + + False + True + + 0 + False + False + + + + + GnomeColorPicker + colorpickerCitations + True + True + False + Pick a color + + 0 + False + False + + + + + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + GtkHBox hbox38 diff --git a/mail/mail-config.h b/mail/mail-config.h index 3f1207bd79..f800e48275 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -93,6 +93,12 @@ void mail_config_set_paned_size (gint size); gboolean mail_config_get_send_html (void); void mail_config_set_send_html (gboolean send_html); +gboolean mail_config_get_citation_highlight (void); +void mail_config_set_citation_highlight (gboolean); + +guint32 mail_config_get_citation_color (void); +void mail_config_set_citation_color (guint32); + gint mail_config_get_mark_as_seen_timeout (void); void mail_config_set_mark_as_seen_timeout (gint timeout); diff --git a/mail/mail-display.c b/mail/mail-display.c index 4458256d14..fa755c15d8 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -885,10 +885,12 @@ mail_text_write (GtkHTML *html, GtkHTMLStream *stream, buf = g_strdup_vprintf (format, ap); va_end (ap); - htmltext = e_text_to_html (buf, - E_TEXT_TO_HTML_CONVERT_URLS | - E_TEXT_TO_HTML_CONVERT_NL | - E_TEXT_TO_HTML_CONVERT_SPACES); + htmltext = e_text_to_html_full (buf, + E_TEXT_TO_HTML_CONVERT_URLS | + E_TEXT_TO_HTML_CONVERT_NL | + E_TEXT_TO_HTML_CONVERT_SPACES | + (mail_config_get_citation_highlight () ? E_TEXT_TO_HTML_MARK_CITATION : 0), + mail_config_get_citation_color ()); gtk_html_write (html, stream, "", 4); gtk_html_write (html, stream, htmltext, strlen (htmltext)); gtk_html_write (html, stream, "", 5); diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 48a0bd94e8..9f78e100b9 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -307,15 +307,12 @@ mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...) } if (is_html) { - if (credits) { - ret_text = g_strdup_printf ("
\n%s\n%s\n" - "
\n", - credits, text); - } else { - ret_text = g_strdup_printf ("
\n%s\n" - "
\n", - text); - } + ret_text = g_strdup_printf ("
\n%s%s%s\n" + "
\n", + mail_config_get_citation_color (), + credits ? credits : "", + credits ? "\n" : "", + text); } else { gchar *s, *d, *quoted_text; gint lines, len, offset = 0; @@ -360,7 +357,10 @@ mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...) *d = '\0'; /* Now convert that to HTML. */ - ret_text = e_text_to_html (quoted_text, E_TEXT_TO_HTML_PRE); + ret_text = e_text_to_html_full (quoted_text, E_TEXT_TO_HTML_PRE + | (mail_config_get_citation_highlight () + ? E_TEXT_TO_HTML_MARK_CITATION : 0), + mail_config_get_citation_color ()); g_free (quoted_text); } -- cgit