2007-08-06 [wwp] 2.10.0cvs96
[claws.git] / src / textview.c
index a57fb100b64b95d137edc1c2fb6d7de6e48d41e5..de774ac42cb8c62bda0c7a3f82ebf89b4aee34f8 100644 (file)
@@ -99,7 +99,7 @@ static GdkColor emphasis_color = {
        (gulong)0,
        (gushort)0,
        (gushort)0,
-       (gushort)0xcfff
+       (gushort)0
 };
 
 static GdkCursor *hand_cursor = NULL;
@@ -495,7 +495,6 @@ void textview_init(TextView *textview)
 static void textview_update_message_colors(TextView *textview)
 {
        GdkColor black = {0, 0, 0, 0};
-       GdkColor colored_emphasis = {0, 0, 0, 0xcfff};
        GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview->text));
 
        GtkTextTagTable *tags = gtk_text_buffer_get_tag_table(buffer);
@@ -517,7 +516,8 @@ static void textview_update_message_colors(TextView *textview)
                                               &uri_color);
                gtkut_convert_int_to_gdk_color(prefs_common.signature_col,
                                               &signature_color);
-               emphasis_color = colored_emphasis;
+               gtkut_convert_int_to_gdk_color(prefs_common.emphasis_col,
+                                              &emphasis_color);
        }
        if (prefs_common.enable_color && prefs_common.enable_bgcolor) {
                gtkut_convert_int_to_gdk_color(prefs_common.quote_level1_bgcol,
@@ -844,6 +844,8 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        GtkTextView *text;
        GtkTextBuffer *buffer;
        GtkTextIter iter;
+       const gchar *name;
+       gchar *content_type;
 
        if (!partinfo) return;
 
@@ -855,29 +857,57 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        gtk_text_buffer_get_start_iter(buffer, &iter);
 
        TEXTVIEW_INSERT("\n");
-       TEXTVIEW_INSERT(_("  The following can be performed on this part by\n"));
-       TEXTVIEW_INSERT(_("  right-clicking the icon or list item:\n"));
+
+       name = procmime_mimeinfo_get_parameter(partinfo, "filename");
+       if (name == NULL)
+               name = procmime_mimeinfo_get_parameter(partinfo, "name");
+       if (name != NULL) {
+               content_type = procmime_get_content_type_str(partinfo->type,
+                                                    partinfo->subtype);
+               TEXTVIEW_INSERT("  ");
+               TEXTVIEW_INSERT_BOLD(name);
+               TEXTVIEW_INSERT(" (");
+               TEXTVIEW_INSERT(content_type);
+               TEXTVIEW_INSERT(", ");
+               TEXTVIEW_INSERT(to_human_readable(partinfo->length));
+               TEXTVIEW_INSERT("):\n\n");
+               
+               g_free(content_type);
+       }
+       TEXTVIEW_INSERT(_("  The following can be performed on this part\n"));
+#ifndef MAEMO
+       TEXTVIEW_INSERT(_("  by right-clicking the icon or list item:"));
+#endif
+       TEXTVIEW_INSERT("\n");
 
        TEXTVIEW_INSERT(_("     - To save, select "));
        TEXTVIEW_INSERT_LINK(_("'Save as...'"), "sc://save_as", NULL);
 #ifndef MAEMO
-       TEXTVIEW_INSERT(_(" (Shortcut key: 'y')\n"));
+       TEXTVIEW_INSERT(_(" (Shortcut key: 'y')"));
 #endif
+       TEXTVIEW_INSERT("\n");
+
        TEXTVIEW_INSERT(_("     - To display as text, select "));
        TEXTVIEW_INSERT_LINK(_("'Display as text'"), "sc://display_as_text", NULL);
+
 #ifndef MAEMO
-       TEXTVIEW_INSERT(_(" (Shortcut key: 't')\n"));
+       TEXTVIEW_INSERT(_(" (Shortcut key: 't')"));
 #endif
+       TEXTVIEW_INSERT("\n");
+
        TEXTVIEW_INSERT(_("     - To open with an external program, select "));
        TEXTVIEW_INSERT_LINK(_("'Open'"), "sc://open", NULL);
+
 #ifndef MAEMO
        TEXTVIEW_INSERT(_(" (Shortcut key: 'l')\n"));
        TEXTVIEW_INSERT(_("       (alternately double-click, or click the middle "));
        TEXTVIEW_INSERT(_("mouse button)\n"));
        TEXTVIEW_INSERT(_("     - Or use "));
        TEXTVIEW_INSERT_LINK(_("'Open with...'"), "sc://open_with", NULL);
-       TEXTVIEW_INSERT(_(" (Shortcut key: 'o')\n"));
+       TEXTVIEW_INSERT(_(" (Shortcut key: 'o')"));
 #endif
+       TEXTVIEW_INSERT("\n");
+
        textview_show_icon(textview, GTK_STOCK_DIALOG_INFO);
 }
 
@@ -888,7 +918,6 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
        CodeConverter *conv;
        const gchar *charset, *p, *cmd;
        GSList *cur;
-       int lines = 0;
        
        if (textview->messageview->forced_charset)
                charset = textview->messageview->forced_charset;
@@ -977,9 +1006,6 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
                while (fgets(buf, sizeof(buf), tmpfp)) {
                        textview_write_line(textview, buf, conv, TRUE);
                        
-                       lines++;
-                       if (lines % 500 == 0)
-                               GTK_EVENTS_FLUSH();
                        if (textview->stop_loading) {
                                fclose(tmpfp);
                                waitpid(pid, pfd, 0);
@@ -994,16 +1020,12 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
 #endif
        } else {
 textview_default:
-               lines = 0;
                tmpfp = g_fopen(mimeinfo->data.filename, "rb");
                fseek(tmpfp, mimeinfo->offset, SEEK_SET);
                debug_print("Viewing text content of type: %s (length: %d)\n", mimeinfo->subtype, mimeinfo->length);
                while ((ftell(tmpfp) < mimeinfo->offset + mimeinfo->length) &&
                       (fgets(buf, sizeof(buf), tmpfp) != NULL)) {
                        textview_write_line(textview, buf, conv, TRUE);
-                       lines++;
-                       if (lines % 500 == 0)
-                               GTK_EVENTS_FLUSH();
                        if (textview->stop_loading) {
                                fclose(tmpfp);
                                return;
@@ -1015,7 +1037,6 @@ textview_default:
        conv_code_converter_destroy(conv);
        procmime_force_encoding(0);
 
-       lines = 0;
        textview->uri_list = g_slist_reverse(textview->uri_list);
        for (cur = textview->uri_list; cur; cur = cur->next) {
                ClickableText *uri = (ClickableText *)cur->data;
@@ -1024,14 +1045,13 @@ textview_default:
                if (!prefs_common.hide_quotes ||
                    uri->quote_level+1 < prefs_common.hide_quotes) {
                        textview_toggle_quote(textview, cur, uri, TRUE);
-                       lines++;
-                       if (lines % 500 == 0)
-                               GTK_EVENTS_FLUSH();
                        if (textview->stop_loading) {
                                return;
                        }
                }
        }
+       
+       GTK_EVENTS_FLUSH();
 }
 
 static void textview_show_html(TextView *textview, FILE *fp,
@@ -2093,6 +2113,7 @@ static gint textview_key_pressed(GtkWidget *widget, GdkEventKey *event,
        case GDK_y:
        case GDK_t:
        case GDK_l:
+       case GDK_o:
        case GDK_c:
        case GDK_a:
                if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) == 0) {