[Goodies-commits] r7331 - in xfce4-dict/trunk: . lib

Enrico Troeger enrico at xfce.org
Tue May 12 23:14:19 CEST 2009


Author: enrico
Date: 2009-05-12 21:14:19 +0000 (Tue, 12 May 2009)
New Revision: 7331

Modified:
   xfce4-dict/trunk/ChangeLog
   xfce4-dict/trunk/lib/common.c
   xfce4-dict/trunk/lib/common.h
   xfce4-dict/trunk/lib/gui.c
   xfce4-dict/trunk/lib/prefs.c
Log:
Make error and success colours configurable.

Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog	2009-05-12 21:14:13 UTC (rev 7330)
+++ xfce4-dict/trunk/ChangeLog	2009-05-12 21:14:19 UTC (rev 7331)
@@ -5,6 +5,8 @@
    Add 'success' colour to mark found search terms.
    Colourise search terms according to the search result for better
    visual feedback.
+ * lib/common.c, lib/common.h, lib/gui.c, lib/prefs.c:
+   Make error and success colours configurable.
 
 
 2009-05-10  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: xfce4-dict/trunk/lib/common.c
===================================================================
--- xfce4-dict/trunk/lib/common.c	2009-05-12 21:14:13 UTC (rev 7330)
+++ xfce4-dict/trunk/lib/common.c	2009-05-12 21:14:19 UTC (rev 7331)
@@ -377,6 +377,8 @@
 	const gchar *geo = "-1;0;0;0;0;";
 	const gchar *link_color_str = "#0000ff";
 	const gchar *phon_color_str = "#006300";
+	const gchar *error_color_str = "#800000";
+	const gchar *success_color_str = "#107000";
 	const gchar *speedreader_font = "Sans 32";
 
 	if ((rc = xfce_rc_config_open(XFCE_RESOURCE_CONFIG, "xfce4-dict/xfce4-dict.rc", TRUE)) != NULL)
@@ -394,6 +396,8 @@
 
 		link_color_str = xfce_rc_read_entry(rc, "link_color", link_color_str);
 		phon_color_str = xfce_rc_read_entry(rc, "phonetic_color", phon_color_str);
+		error_color_str = xfce_rc_read_entry(rc, "error_color", error_color_str);
+		success_color_str = xfce_rc_read_entry(rc, "success_color", success_color_str);
 
 		speedreader_font = xfce_rc_read_entry(rc, "speedreader_font", speedreader_font);
 		wpm = xfce_rc_read_int_entry(rc, "speedreader_wpm", wpm);
@@ -433,6 +437,10 @@
 	gdk_color_parse(link_color_str, dd->link_color);
 	dd->phon_color = g_new0(GdkColor, 1);
 	gdk_color_parse(phon_color_str, dd->phon_color);
+	dd->error_color = g_new0(GdkColor, 1);
+	gdk_color_parse(error_color_str, dd->error_color);
+	dd->success_color = g_new0(GdkColor, 1);
+	gdk_color_parse(success_color_str, dd->success_color);
 
 	dd->speedreader_wpm = wpm;
 	dd->speedreader_font = g_strdup(speedreader_font);
@@ -447,7 +455,8 @@
 
 	if ((rc = xfce_rc_config_open(XFCE_RESOURCE_CONFIG, "xfce4-dict/xfce4-dict.rc", FALSE)) != NULL)
 	{
-		gchar *geometry_string, *link_color_str, *phon_color_str;
+		gchar *geometry_string;
+		gchar *link_color_str, *phon_color_str, *error_color_str, *success_color_str;
 
 		xfce_rc_write_int_entry(rc, "mode_in_use", dd->mode_in_use);
 		xfce_rc_write_int_entry(rc, "mode_default", dd->mode_default);
@@ -463,8 +472,12 @@
 
 		link_color_str = get_hex_from_color(dd->link_color);
 		phon_color_str = get_hex_from_color(dd->phon_color);
+		error_color_str = get_hex_from_color(dd->error_color);
+		success_color_str = get_hex_from_color(dd->success_color);
 		xfce_rc_write_entry(rc, "link_color", link_color_str);
 		xfce_rc_write_entry(rc, "phonetic_color", phon_color_str);
+		xfce_rc_write_entry(rc, "error_color", error_color_str);
+		xfce_rc_write_entry(rc, "success_color", success_color_str);
 
 		geometry_string = g_strdup_printf("%d;%d;%d;%d;%d;",
 			dd->geometry[0], dd->geometry[1], dd->geometry[2], dd->geometry[3], dd->geometry[4]);
@@ -475,6 +488,8 @@
 
 		g_free(link_color_str);
 		g_free(phon_color_str);
+		g_free(error_color_str);
+		g_free(success_color_str);
 		g_free(geometry_string);
 
 		xfce_rc_close(rc);
@@ -499,6 +514,8 @@
 
 	g_free(dd->link_color);
 	g_free(dd->phon_color);
+	g_free(dd->success_color);
+	g_free(dd->error_color);
 
 	if (dd->icon != NULL)
 		g_object_unref(dd->icon);

Modified: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h	2009-05-12 21:14:13 UTC (rev 7330)
+++ xfce4-dict/trunk/lib/common.h	2009-05-12 21:14:19 UTC (rev 7331)
@@ -105,11 +105,15 @@
 	GtkTextIter textiter;
 	GtkTextTag *link_tag;
 	GtkTextTag *phon_tag;
+	GtkTextTag *error_tag;
+	GtkTextTag *success_tag;
 	GtkTextMark *mark_click;
 	GdkPixbuf *icon;
 
 	GdkColor *link_color;
 	GdkColor *phon_color;
+	GdkColor *error_color;
+	GdkColor *success_color;
 
 	/* speed reader */
 	gint speedreader_wpm;

Modified: xfce4-dict/trunk/lib/gui.c
===================================================================
--- xfce4-dict/trunk/lib/gui.c	2009-05-12 21:14:13 UTC (rev 7330)
+++ xfce4-dict/trunk/lib/gui.c	2009-05-12 21:14:19 UTC (rev 7331)
@@ -45,8 +45,6 @@
 static GdkCursor *hand_cursor = NULL;
 static GdkCursor *regular_cursor = NULL;
 static gboolean entry_is_dirty = FALSE;
-static const GdkColor error_color = { 0, 0x8000, 0, 0 }; /* dark red */
-static const GdkColor success_color = { 0, 0x1000, 0x7000, 0 };
 
 
 /* all textview_* functions are from the gtk-demo app to get links in the textview working */
@@ -691,13 +689,13 @@
 			"style", PANGO_STYLE_ITALIC,
 			"indent", 10,
 			"pixels-below-lines", 5, NULL);
-	gtk_text_buffer_create_tag(dd->main_textbuffer,
+	dd->error_tag = gtk_text_buffer_create_tag(dd->main_textbuffer,
 			TAG_ERROR,
 			"style", PANGO_STYLE_ITALIC,
-			"foreground-gdk", &error_color, NULL);
-	gtk_text_buffer_create_tag(dd->main_textbuffer,
+			"foreground-gdk", dd->error_color, NULL);
+	dd->success_tag = gtk_text_buffer_create_tag(dd->main_textbuffer,
 			TAG_SUCCESS,
-			"foreground-gdk", &success_color, NULL);
+			"foreground-gdk", dd->success_color, NULL);
 	dd->phon_tag = gtk_text_buffer_create_tag(dd->main_textbuffer,
 			TAG_PHONETIC,
 			"style", PANGO_STYLE_ITALIC,

Modified: xfce4-dict/trunk/lib/prefs.c
===================================================================
--- xfce4-dict/trunk/lib/prefs.c	2009-05-12 21:14:13 UTC (rev 7330)
+++ xfce4-dict/trunk/lib/prefs.c	2009-05-12 21:14:19 UTC (rev 7331)
@@ -155,6 +155,8 @@
 	}
 	g_object_set(G_OBJECT(dd->link_tag), "foreground-gdk", dd->link_color, NULL);
 	g_object_set(G_OBJECT(dd->phon_tag), "foreground-gdk", dd->phon_color, NULL);
+	g_object_set(G_OBJECT(dd->error_tag), "foreground-gdk", dd->error_color, NULL);
+	g_object_set(G_OBJECT(dd->success_tag), "foreground-gdk", dd->success_color, NULL);
 
 	/* save settings */
 	dict_write_rc_file(dd);
@@ -297,7 +299,8 @@
 	 */
 #define PAGE_GENERAL /* only for navigation in Geany's symbol list ;-) */
 	{
-		GtkWidget *radio_button, *label, *table, *color_link, *color_phon;
+		GtkWidget *radio_button, *label, *table, *label4;
+		GtkWidget *color_link, *color_phon, *color_success, *color_error;
 		GSList *search_method;
 
 		notebook_vbox = gtk_vbox_new(FALSE, 2);
@@ -358,12 +361,18 @@
 
 		label1 = gtk_label_new(_("Link Color:"));
 		label2 = gtk_label_new(_("Phonetic Color:"));
+		label3 = gtk_label_new(_("Success Color:"));
+		label4 = gtk_label_new(_("Error Color:"));
 		color_link = gtk_color_button_new_with_color(dd->link_color);
 		color_phon = gtk_color_button_new_with_color(dd->phon_color);
+		color_error = gtk_color_button_new_with_color(dd->error_color);
+		color_success = gtk_color_button_new_with_color(dd->success_color);
 		g_signal_connect(color_link, "color-set", G_CALLBACK(color_set_cb), dd->link_color);
 		g_signal_connect(color_phon, "color-set", G_CALLBACK(color_set_cb), dd->phon_color);
+		g_signal_connect(color_error, "color-set", G_CALLBACK(color_set_cb), dd->error_color);
+		g_signal_connect(color_success, "color-set", G_CALLBACK(color_set_cb), dd->success_color);
 
-		table = gtk_table_new(2, 2, FALSE);
+		table = gtk_table_new(2, 4, FALSE);
 		gtk_widget_show(table);
 		gtk_table_set_row_spacings(GTK_TABLE(table), 5);
 		gtk_table_set_col_spacings(GTK_TABLE(table), 5);
@@ -386,6 +395,24 @@
 						(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
 						(GtkAttachOptions) (0), 5, 5);
 
+		gtk_table_attach(GTK_TABLE(table), label3, 2, 3, 0, 1,
+						(GtkAttachOptions) (GTK_FILL),
+						(GtkAttachOptions) (0), 5, 5);
+		gtk_misc_set_alignment(GTK_MISC(label3), 1, 0);
+
+		gtk_table_attach(GTK_TABLE(table), color_success, 3, 4, 0, 1,
+						(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
+						(GtkAttachOptions) (0), 5, 5);
+
+		gtk_table_attach(GTK_TABLE(table), label4, 2, 3, 1, 2,
+						(GtkAttachOptions) (GTK_FILL),
+						(GtkAttachOptions) (0), 5, 0);
+		gtk_misc_set_alignment(GTK_MISC(label4), 1, 0);
+
+		gtk_table_attach(GTK_TABLE(table), color_error, 3, 4, 1, 2,
+						(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
+						(GtkAttachOptions) (0), 5, 5);
+
 		gtk_widget_show_all(table);
 		gtk_box_pack_start(GTK_BOX(inner_vbox), table, FALSE, FALSE, 0);
 




More information about the Goodies-commits mailing list