The patch needs to be against the HEAD version, stable is in a fairly
frozen state, and no new features like this will be implemented there.

Also note this might require slightly more work as some of the
interfaces have changed.

On Sun, 2002-04-28 at 04:45, Colin Walters wrote:
> Hello, the following patch adds two new options to allow more control
> over rendering HTML email.  Complex HTML mail (tables, funky fonts)
> takes an extra second or two to render on my machine, so I always want
> to turn HTML mail into an attachment, but I imagine most people will
> just want the first option.
> 
> It's against the Debian 1.0.3 source tree, mainly because I couldn't get
> the CVS tree to actually build and work.
> 
> 2002-04-27  Colin Walters  <[EMAIL PROTECTED]>
> 
>       * mail-config.c (struct MailConfig): Represent them with new
>       boolean variables `prefer_html' and `inline_html'.
>       (mail_config_write_on_exit): Write them.
>       (config_read): Read them.
>       (mail_config_get_prefer_html, mail_config_set_prefer_html)
>       (mail_config_get_inline_html, mail_config_set_inline_html):
>       Accessors.
> 
>       * mail-config.h: Declare accessors.
> 
>       * mail-config.glade (chkPreferHTML, chkInlineHTML): New
>       togglebutton widgets.
>       
>       * mail-accounts.c (prefer_html_toggled): New function.
>       (inline_html_toggled): Ditto.
>       (construct): Bind them to chkPreferHTML and chkInlineHTML widgets,
>       respectively.
>       
>       * mail-accounts.h (struct _MailAccountsDialog): New toggle buttons
>       `prefer_html' and `inline_html'.
>       
>       * mail-format.c (mail_part_is_inline): Handle inline html option.
>       (handle_multipart_alternative): Handle prefer html option. 
> 
> 
> 
> 
> ----
> 

> diff -ru evolution-1.0.3/mail/mail-accounts.c 
>evolution-1.0.3.new/mail/mail-accounts.c
> --- evolution-1.0.3/mail/mail-accounts.c      Mon Dec 10 14:55:20 2001
> +++ evolution-1.0.3.new/mail/mail-accounts.c  Sat Apr 27 14:13:56 2002
> @@ -602,6 +602,18 @@
>  }
>  
>  static void
> +prefer_html_toggled (GtkToggleButton *button, gpointer data)
> +{
> +     mail_config_set_prefer_html (gtk_toggle_button_get_active (button));
> +}
> +
> +static void
> +inline_html_toggled (GtkToggleButton *button, gpointer data)
> +{
> +     mail_config_set_inline_html (gtk_toggle_button_get_active (button));
> +}
> +
> +static void
>  timeout_toggled (GtkToggleButton *button, gpointer data)
>  {
>       mail_config_set_do_seen_timeout (gtk_toggle_button_get_active (button));
> @@ -865,7 +877,17 @@
>       gtk_spin_button_set_value (dialog->timeout, (1.0 * 
>mail_config_get_mark_as_seen_timeout ()) / 1000.0);
>       gtk_signal_connect (GTK_OBJECT (dialog->timeout), "changed",
>                           GTK_SIGNAL_FUNC (timeout_changed), dialog);
> -     
> +
> +     dialog->prefer_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget(gui, 
>"chkPreferHTML"));
> +     gtk_toggle_button_set_active (dialog->prefer_html, mail_config_get_prefer_html 
>());
> +     gtk_signal_connect (GTK_OBJECT (dialog->prefer_html), "toggled",
> +                         GTK_SIGNAL_FUNC (prefer_html_toggled), dialog);
> +     
> +     dialog->inline_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget(gui, 
>"chkInlineHTML"));
> +     gtk_toggle_button_set_active (dialog->inline_html, mail_config_get_inline_html 
>());
> +     gtk_signal_connect (GTK_OBJECT (dialog->inline_html), "toggled",
> +                         GTK_SIGNAL_FUNC (inline_html_toggled), dialog);
> +
>       dialog->images_never = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, 
>"radioImagesNever"));
>       gtk_toggle_button_set_active (dialog->images_never, mail_config_get_http_mode 
>() == MAIL_CONFIG_HTTP_NEVER);
>       gtk_signal_connect (GTK_OBJECT (dialog->images_never), "toggled",
> diff -ru evolution-1.0.3/mail/mail-accounts.h 
>evolution-1.0.3.new/mail/mail-accounts.h
> --- evolution-1.0.3/mail/mail-accounts.h      Sat Oct 27 14:21:05 2001
> +++ evolution-1.0.3.new/mail/mail-accounts.h  Sat Apr 27 14:14:16 2002
> @@ -76,6 +76,8 @@
>       GnomeColorPicker *citation_color;
>       GtkToggleButton *timeout_toggle;
>       GtkSpinButton *timeout;
> +     GtkToggleButton *prefer_html;
> +     GtkToggleButton *inline_html;
>       GtkToggleButton *images_always, *images_sometimes, *images_never;
>       /*GtkToggleButton *thread_list;*/
>       /*GtkToggleButton *show_preview;*/
> diff -ru evolution-1.0.3/mail/mail-config.c evolution-1.0.3.new/mail/mail-config.c
> --- evolution-1.0.3/mail/mail-config.c        Fri Dec 14 16:56:20 2001
> +++ evolution-1.0.3.new/mail/mail-config.c    Sat Apr 27 14:09:58 2002
> @@ -78,6 +78,8 @@
>       gboolean hide_deleted;
>       gint paned_size;
>       gboolean send_html;
> +     gboolean prefer_html;
> +     gboolean inline_html;
>       gboolean confirm_unwanted_html;
>       gboolean citation_highlight;
>       guint32  citation_color;
> @@ -516,6 +518,14 @@
>       config->send_html = bonobo_config_get_boolean_with_default (config->db,
>               "/Mail/Format/send_html", FALSE, NULL);
>  
> +     /* Prefer seeing HTML */
> +     config->prefer_html = bonobo_config_get_boolean_with_default (config->db,
> +             "/Mail/Format/prefer_html", TRUE, NULL);
> +
> +     /* Inline HTML */
> +     config->inline_html = bonobo_config_get_boolean_with_default (config->db,
> +             "/Mail/Format/inline_html", TRUE, NULL);
> +
>       /* Confirm Sending Unwanted HTML */
>       config->confirm_unwanted_html = bonobo_config_get_boolean_with_default 
>(config->db,
>               "/Mail/Format/confirm_unwanted_html", TRUE, NULL);
> @@ -826,6 +839,14 @@
>       bonobo_config_set_boolean (config->db, "/Mail/Format/send_html", 
>                                  config->send_html, NULL);
>  
> +     /* Prefer seeing HTML */
> +     bonobo_config_set_boolean (config->db, "/Mail/Format/prefer_html", 
> +                                config->prefer_html, NULL);
> +
> +     /* Render HTML */
> +     bonobo_config_set_boolean (config->db, "/Mail/Format/inline_html", 
> +                                config->inline_html, NULL);
> +
>       /* Confirm Sending Unwanted HTML */
>       bonobo_config_set_boolean (config->db, "/Mail/Format/confirm_unwanted_html",
>                                  config->confirm_unwanted_html, NULL);
> @@ -1153,6 +1174,30 @@
>  {
>       config->send_html = send_html;
>  }
> +
> +mail_config_get_prefer_html (void)
> +{
> +     return config->prefer_html;
> +}
> +
> +void
> +mail_config_set_prefer_html (gboolean prefer_html)
> +{
> +     config->prefer_html = prefer_html;
> +}
> +
> +gboolean
> +mail_config_get_inline_html (void)
> +{
> +     return config->inline_html;
> +}
> +
> +void
> +mail_config_set_inline_html (gboolean inline_html)
> +{
> +     config->inline_html = inline_html;
> +}
> +
>  
>  gboolean
>  mail_config_get_confirm_unwanted_html (void)
> diff -ru evolution-1.0.3/mail/mail-config.glade 
>evolution-1.0.3.new/mail/mail-config.glade
> --- evolution-1.0.3/mail/mail-config.glade    Mon Oct 22 19:42:42 2001
> +++ evolution-1.0.3.new/mail/mail-config.glade        Sat Apr 27 14:10:59 2002
> @@ -2742,6 +2742,34 @@
>        </widget>
>  
>        <widget>
> +     <class>GtkCheckButton</class>
> +     <name>chkPreferHTML</name>
> +     <can_focus>True</can_focus>
> +     <label>_Prefer rendering mail in HTML format by default</label>
> +     <active>True</active>
> +     <draw_indicator>True</draw_indicator>
> +     <child>
> +       <padding>0</padding>
> +       <expand>False</expand>
> +       <fill>False</fill>
> +     </child>
> +      </widget>
> +
> +      <widget>
> +     <class>GtkCheckButton</class>
> +     <name>chkInlineHTML</name>
> +     <can_focus>True</can_focus>
> +     <label>_Display HTML-only mail</label>
> +     <active>True</active>
> +     <draw_indicator>True</draw_indicator>
> +     <child>
> +       <padding>0</padding>
> +       <expand>False</expand>
> +       <fill>False</fill>
> +     </child>
> +      </widget>
> +      
> +      <widget>
>       <class>GtkFrame</class>
>       <name>frame1</name>
>       <label>In HTML mail</label>
> diff -ru evolution-1.0.3/mail/mail-config.h evolution-1.0.3.new/mail/mail-config.h
> --- evolution-1.0.3/mail/mail-config.h        Thu Nov  8 17:31:53 2001
> +++ evolution-1.0.3.new/mail/mail-config.h    Sat Apr 27 14:12:02 2002
> @@ -134,6 +134,12 @@
>  gboolean mail_config_get_send_html            (void);
>  void     mail_config_set_send_html            (gboolean send_html);
>  
> +gboolean mail_config_get_prefer_html            (void);
> +void     mail_config_set_prefer_html            (gboolean prefer_html);
> +
> +gboolean mail_config_get_inline_html            (void);
> +void     mail_config_set_inline_html            (gboolean inline_html);
> +
>  gboolean mail_config_get_confirm_unwanted_html (void);
>  void     mail_config_set_confirm_unwanted_html (gboolean html_warning);
>  
> diff -ru evolution-1.0.3/mail/mail-format.c evolution-1.0.3.new/mail/mail-format.c
> --- evolution-1.0.3/mail/mail-format.c        Tue Feb 19 10:50:27 2002
> +++ evolution-1.0.3.new/mail/mail-format.c    Sat Apr 27 14:10:24 2002
> @@ -515,6 +515,13 @@
>       CamelContentType *content_type;
>       char *type;
>       gboolean anon;
> +
> +     /* If the user has explicitly specified to override text/html
> +        to be an attachment, then do so. */
> +     content_type = camel_mime_part_get_content_type (part);
> +     if (!mail_config_get_inline_html() &&
> +         header_content_type_is (content_type, "text", "html"))
> +             return FALSE;
>       
>       /* If it has an explicit disposition, return that. */
>       disposition = camel_mime_part_get_disposition (part);
> @@ -524,7 +531,6 @@
>       /* Certain types should default to inline. FIXME: this should
>        * be customizable.
>        */
> -     content_type = camel_mime_part_get_content_type (part);
>       if (!header_content_type_is (content_type, "message", "*"))
>               return TRUE;
>       
> @@ -1976,7 +1982,7 @@
>       
>       multipart = CAMEL_MULTIPART (wrapper);
>       
> -     mime_part = find_preferred_alternative (multipart, FALSE);
> +     mime_part = find_preferred_alternative (multipart, 
>!mail_config_get_prefer_html() || !mail_config_get_inline_html());
>       if (mime_part)
>               return format_mime_part (mime_part, md);
>       else


_______________________________________________
evolution-hackers maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/evolution-hackers

Reply via email to