PATCH: text-color support



hello,

someone mentioned something about hard reading balsa text because the
textcolor is not adjustable. this little patch fixes this issue. its
hard to tell if this doesnt break any themes, or if this is the correct
way to do it.

anyways here it is. i appreciate someone else to review my patch too,
since i dont know for sure if i catched up everything correctly, since
there are a couple of gtk_text_insert calls in balsa code.

so please someone review this too. thank you.

btw: settings are beeing saved, this patch doesnt color compose window
     since we use gtk_editable.

-- 
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@stud.fh-wilhelmshaven.de
WWW.....: http://www.fh-wilhelmshaven.de/~akcaagaa
diff -ruN balsa-cvs/src/balsa-app.h balsa/src/balsa-app.h
--- balsa-cvs/src/balsa-app.h	Wed Oct 17 13:57:43 2001
+++ balsa/src/balsa-app.h	Wed Oct 17 13:57:41 2001
@@ -76,6 +76,7 @@
 #define DEFAULT_QUOTE_REGEX  "^(([ \tA-Z])\1*[|>:}#])"
 
 #define DEFAULT_URL_COLOR    "rgb:A000/0000/0000"
+#define DEFAULT_TEXT_COLOR   "rgb:0000/0000/0000"
 
 #define MAILBOX_MANAGER_WIDTH 350
 #define MAILBOX_MANAGER_HEIGHT 400
@@ -245,6 +246,9 @@
     /* text color of URL's */
     GdkColor url_color;
 
+    /* text color */
+    GdkColor text_color;
+
     GtkToolbarStyle toolbar_style;
     GnomeMDIMode mdi_style;
     guint pwindow_option;
diff -ruN balsa-cvs/src/balsa-message.c balsa/src/balsa-message.c
--- balsa-cvs/src/balsa-message.c	Wed Oct 17 13:57:43 2001
+++ balsa/src/balsa-message.c	Wed Oct 17 13:57:41 2001
@@ -616,14 +616,14 @@
     else
 	fnt = gdk_font_load(balsa_app.subject_font);
 
-    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL, label, -1);
+    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, &balsa_app.text_color, NULL, label, -1);
 
     if (value && *value != '\0') {
 	if (strlen(label) < 15)
-	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL,
+	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, &balsa_app.text_color, NULL,
 			    pad, 15 - strlen(label));
 	else
-	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL,
+	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, &balsa_app.text_color, NULL,
 			    pad, 1);
 
 	wrapped_value = g_strdup(value);
@@ -640,18 +640,18 @@
 		line_end++;
 
 	    if (line_start != wrapped_value)
-		gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL,
+		gtk_text_insert(GTK_TEXT(bm->header_text), fnt, &balsa_app.text_color, NULL,
 				pad, 15);
-	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL,
+	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, &balsa_app.text_color, NULL,
 			    line_start, line_end - line_start);
-	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL, cr,
+	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, &balsa_app.text_color, NULL, cr,
 			    -1);
 	    if (*line_end != '\0')
 		line_end++;
 	}
 	g_free(wrapped_value);
     } else {
-	gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL, cr,
+	gtk_text_insert(GTK_TEXT(bm->header_text), fnt, &balsa_app.text_color, NULL, cr,
 			-1);
     }
 }
@@ -1864,7 +1864,7 @@
 	if (regcomp(&rex, balsa_app.quote_regex, REG_EXTENDED) != 0) {
 	    g_warning
 		("part_info_init_mimetext: quote regex compilation failed.");
-	    gtk_text_insert(GTK_TEXT(item), fnt, NULL, NULL, ptr, -1);
+	    gtk_text_insert(GTK_TEXT(item), fnt, &balsa_app.text_color, NULL, ptr, -1);
 	} else {
 	    gint ypos = 0;
 
@@ -1883,7 +1883,7 @@
 					     &balsa_app.quoted_color[quote_level],
 					     line, url_reg, &url_list, ypos);
 		} else
-		    gtk_text_insert_with_url(GTK_TEXT(item), fnt, NULL, 
+		    gtk_text_insert_with_url(GTK_TEXT(item), fnt, &balsa_app.text_color, 
 					     line, url_reg, &url_list, ypos);
 		g_free(line);
 	    }
diff -ruN balsa-cvs/src/pref-manager.c balsa/src/pref-manager.c
--- balsa-cvs/src/pref-manager.c	Wed Oct 17 13:57:43 2001
+++ balsa/src/pref-manager.c	Wed Oct 17 13:57:41 2001
@@ -121,6 +121,7 @@
     GtkWidget *unread_color;
     GtkWidget *quoted_color[MAX_QUOTED_COLOR];
     GtkWidget *url_color;
+    GtkWidget *text_color;
 
     /* quote regex */
     GtkWidget *quote_pattern;
@@ -479,6 +480,10 @@
 		       GTK_SIGNAL_FUNC(properties_modified_cb),
 		       property_box);
 
+    gtk_signal_connect(GTK_OBJECT(pui->text_color), "released",
+		       GTK_SIGNAL_FUNC(properties_modified_cb),
+		       property_box);
+
     /* Gnome Property Box Signals */
     gtk_signal_connect(GTK_OBJECT(property_box), "destroy",
 		       GTK_SIGNAL_FUNC(destroy_pref_window_cb), pui);
@@ -728,6 +733,15 @@
 			       &(balsa_app.url_color.blue),
 			       0);			       
 
+    /* text color */
+    gdk_colormap_free_colors(gdk_window_get_colormap(GTK_WIDGET(pbox)->window),
+			     &balsa_app.text_color, 1);
+    gnome_color_picker_get_i16(GNOME_COLOR_PICKER(pui->text_color),
+			       &(balsa_app.text_color.red),
+			       &(balsa_app.text_color.green),
+			       &(balsa_app.text_color.blue),
+			       0);			       
+
     /* Information dialogs */
     menu_item =
 	gtk_menu_get_active(GTK_MENU(pui->information_message_menu));
@@ -972,6 +986,11 @@
 			       balsa_app.url_color.green,
 			       balsa_app.url_color.blue, 0);
 
+    gnome_color_picker_set_i16(GNOME_COLOR_PICKER(pui->text_color),
+			       balsa_app.text_color.red,
+			       balsa_app.text_color.green,
+			       balsa_app.text_color.blue, 0);
+
     /* Information Message */
     gtk_menu_set_active(GTK_MENU(pui->information_message_menu),
 			balsa_app.information_message);
@@ -1878,6 +1897,13 @@
 
     pui->url_color = color_box(GTK_BOX(vbox9), _("Hyperlink color"));
 
+    color_frame = gtk_frame_new(_("Text Color"));
+    gtk_container_set_border_width(GTK_CONTAINER(color_frame), 5);
+    gtk_box_pack_start(GTK_BOX(vbox8), color_frame, FALSE, FALSE, 0);
+    vbox9 = vbox_in_container(color_frame);
+
+    pui->text_color = color_box(GTK_BOX(vbox9), _("Text color"));
+
     /* Fonts Preferences Page */
     vbox9 = gtk_vbox_new(FALSE, 0);
     gtk_notebook_append_page(GTK_NOTEBOOK(subnb), vbox9,
diff -ruN balsa-cvs/src/save-restore.c balsa/src/save-restore.c
--- balsa-cvs/src/save-restore.c	Wed Oct 17 13:57:43 2001
+++ balsa/src/save-restore.c	Wed Oct 17 13:57:41 2001
@@ -543,6 +543,9 @@
     /* URL coloring */
     load_color("UrlColor=" DEFAULT_URL_COLOR, &balsa_app.url_color);
 
+    /* Text coloring */
+    load_color("TextColor=" DEFAULT_TEXT_COLOR, &balsa_app.text_color);
+
     /* ... font used to display messages */
     g_free(balsa_app.message_font);
     balsa_app.message_font =
@@ -841,6 +844,7 @@
     }
 
     save_color("UrlColor", &balsa_app.url_color);
+    save_color("TextColor", &balsa_app.text_color);
 
     gnome_config_pop_prefix();
 
diff -ruN balsa-cvs/src/sendmsg-window.c balsa/src/sendmsg-window.c
--- balsa-cvs/src/sendmsg-window.c	Wed Oct 17 13:57:43 2001
+++ balsa/src/sendmsg-window.c	Wed Oct 17 13:57:41 2001
@@ -1686,8 +1686,8 @@
 	    if (!strcmp(body_type, "text/plain") &&
 		(rbdy = process_mime_part(message, body, NULL, -1, FALSE,
                                           msg->flow))) {
-		gtk_text_insert(GTK_TEXT(msg->text), NULL, NULL, NULL, 
-				rbdy->str, rbdy->len);
+		gtk_text_insert(GTK_TEXT(msg->text), NULL, &balsa_app.text_color,
+			       	NULL, rbdy->str, rbdy->len);
 		g_string_free(rbdy, TRUE);
 	    }
 	    g_free(body_type);
@@ -2445,7 +2445,7 @@
 	    if (balsa_app.debug)
 		printf("%s cnt: %d (max: %d)\n", fname, cnt, sizeof(buf));
 	    gtk_text_insert(GTK_TEXT(bsmsg->text), bsmsg->font,
-			    NULL, NULL, buf, cnt);
+			    &balsa_app.text_color, NULL, buf, cnt);
 	}
 	if (balsa_app.debug)
 	    printf("%s cnt: %d (max: %d)\n", fname, cnt, sizeof(buf));
diff -ruN balsa-cvs/src/spell-check.c balsa/src/spell-check.c
--- balsa-cvs/src/spell-check.c	Wed Oct 17 13:57:43 2001
+++ balsa/src/spell-check.c	Wed Oct 17 13:57:41 2001
@@ -1013,7 +1013,7 @@
 	gtk_text_set_point(spell_check->text, 0);
 	gtk_text_forward_delete(spell_check->text, length);
 	gtk_text_insert(spell_check->text, spell_check->font,
-			NULL, NULL,
+			&balsa_app.text_color, NULL,
 			spell_check->original_text,
 			strlen(spell_check->original_text));
 	gtk_text_thaw(spell_check->text);
@@ -1159,7 +1159,7 @@
     gtk_text_forward_delete(spell_check->text,
 			    spell_check->end_pos - spell_check->start_pos);
     gtk_text_insert(spell_check->text, spell_check->font,
-		    NULL, NULL,
+		    &balsa_app.text_color, NULL,
 		    word, spell_check->end_pos - spell_check->start_pos);
     g_free(word);
     gtk_text_thaw(spell_check->text);
@@ -1373,6 +1373,6 @@
     /* remove and replace the current word. */
     gtk_text_set_point(spell_check->text, spell_check->start_pos);
     gtk_text_forward_delete(spell_check->text, old_length);
-    gtk_text_insert(spell_check->text, spell_check->font, NULL,
+    gtk_text_insert(spell_check->text, spell_check->font, &balsa_app.text_color,
 		    NULL, new_word, new_length);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]