Revision: 1887 http://geany.svn.sourceforge.net/geany/?rev=1887&view=rev Author: ntrel Date: 2007-09-17 09:33:17 -0700 (Mon, 17 Sep 2007)
Log Message: ----------- Add foreground colouring to messages items.
Modified Paths: -------------- trunk/ChangeLog trunk/src/msgwindow.c trunk/src/msgwindow.h trunk/src/search.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-09-17 15:46:41 UTC (rev 1886) +++ trunk/ChangeLog 2007-09-17 16:33:17 UTC (rev 1887) @@ -9,6 +9,8 @@ Add tag_type treeview iter. * tagmanager/haxe.c: Show Haxe enum types in the symbol list. + * src/msgwindow.c, src/msgwindow.h, src/search.c: + Add foreground colouring to messages items.
2007-09-13 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/msgwindow.c =================================================================== --- trunk/src/msgwindow.c 2007-09-17 15:46:41 UTC (rev 1886) +++ trunk/src/msgwindow.c 2007-09-17 16:33:17 UTC (rev 1887) @@ -135,11 +135,14 @@ GtkTreeSelection *selection; PangoFontDescription *pfd;
- msgwindow.store_msg = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_STRING); + // doc idx, line, bg, fg, str + msgwindow.store_msg = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_INT, + GDK_TYPE_COLOR, GDK_TYPE_COLOR, G_TYPE_STRING); gtk_tree_view_set_model(GTK_TREE_VIEW(msgwindow.tree_msg), GTK_TREE_MODEL(msgwindow.store_msg));
renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(NULL, renderer, "background-gdk", 2, "text", 3, NULL); + column = gtk_tree_view_column_new_with_attributes(NULL, renderer, + "background-gdk", 2, "foreground-gdk", 3, "text", 4, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(msgwindow.tree_msg), column);
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(msgwindow.tree_msg), FALSE); @@ -193,6 +196,22 @@
static const GdkColor color_error = {0, 65535, 0, 0};
+static const GdkColor *get_color(gint msg_color) +{ + static const GdkColor dark_red = {0, 65535 / 2, 0, 0}; + static const GdkColor blue = {0, 0, 0, 0xD000}; // not too bright ;-) + static const GdkColor black = {0, 0, 0, 0}; + + switch (msg_color) + { + case COLOR_RED: return &color_error; + case COLOR_DARK_RED: return &dark_red; + case COLOR_BLUE: return &blue; + default: return &black; + } +} + + void msgwin_compiler_add_fmt(gint msg_color, const gchar *format, ...) { gchar string[512]; @@ -210,19 +229,8 @@ { GtkTreeIter iter; GtkTreePath *path; - const GdkColor *color; - const GdkColor dark_red = {0, 65535 / 2, 0, 0}; - const GdkColor blue = {0, 0, 0, 0xD000}; // not too bright ;-) - const GdkColor black = {0, 0, 0, 0}; + const GdkColor *color = get_color(msg_color);
- switch (msg_color) - { - case COLOR_RED: color = &color_error; break; - case COLOR_DARK_RED: color = &dark_red; break; - case COLOR_BLUE: color = &blue; break; - default: color = &black; - } - gtk_list_store_append(msgwindow.store_compiler, &iter); gtk_list_store_set(msgwindow.store_compiler, &iter, 0, color, 1, msg, -1);
@@ -251,7 +259,7 @@ }
-void msgwin_msg_add_fmt(gint line, gint idx, const gchar *format, ...) +void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...) { gchar string[512]; va_list args; @@ -260,21 +268,22 @@ g_vsnprintf(string, 512, format, args); va_end(args);
- msgwin_msg_add(line, idx, string); + msgwin_msg_add(msg_color, line, idx, string); }
// adds string to the msg treeview -void msgwin_msg_add(gint line, gint idx, const gchar *string) +void msgwin_msg_add(gint msg_color, gint line, gint idx, const gchar *string) { GtkTreeIter iter; static gint state = 0; + const GdkColor *color = get_color(msg_color);
if (! ui_prefs.msgwindow_visible) msgwin_show_hide(TRUE);
gtk_list_store_append(msgwindow.store_msg, &iter); gtk_list_store_set(msgwindow.store_msg, &iter, 0, line, 1, idx, 2, - ((state++ % 2) == 0) ? &white : &dark, 3, string, -1); + ((state++ % 2) == 0) ? &white : &dark, 3, color, 4, string, -1);
gtk_widget_set_sensitive(lookup_widget(app->window, "next_message1"), TRUE); } @@ -776,7 +785,7 @@ gint idx, line; gchar *string;
- gtk_tree_model_get(model, &iter, 0, &line, 1, &idx, 3, &string, -1); + gtk_tree_model_get(model, &iter, 0, &line, 1, &idx, 4, &string, -1); if (line >= 0 && idx >= 0) { ret = utils_goto_line(idx, line); // checks valid idx
Modified: trunk/src/msgwindow.h =================================================================== --- trunk/src/msgwindow.h 2007-09-17 15:46:41 UTC (rev 1886) +++ trunk/src/msgwindow.h 2007-09-17 16:33:17 UTC (rev 1887) @@ -70,9 +70,9 @@ void msgwin_show_hide(gboolean show);
-void msgwin_msg_add_fmt(gint line, gint idx, const gchar *format, ...) G_GNUC_PRINTF (3, 4); +void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...) G_GNUC_PRINTF (4, 5);
-void msgwin_msg_add(gint line, gint idx, const gchar *string); +void msgwin_msg_add(gint msg_color, gint line, gint idx, const gchar *string);
void msgwin_compiler_add_fmt(gint msg_color, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
Modified: trunk/src/search.c =================================================================== --- trunk/src/search.c 2007-09-17 15:46:41 UTC (rev 1886) +++ trunk/src/search.c 2007-09-17 16:33:17 UTC (rev 1887) @@ -1202,7 +1202,7 @@ str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"), prefs.tools_grep_cmd, opts, search_text, dir); utf8_str = utils_get_utf8_from_locale(str); - msgwin_msg_add(-1, -1, utf8_str); + msgwin_msg_add(COLOR_BLUE, -1, -1, utf8_str); utils_free_pointers(str, utf8_str, NULL); ret = TRUE; } @@ -1261,7 +1261,7 @@
while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg) { - msgwin_msg_add(-1, -1, g_strstrip(msg)); + msgwin_msg_add(COLOR_BLACK, -1, -1, g_strstrip(msg)); g_free(msg); } } @@ -1276,6 +1276,7 @@ { #ifdef G_OS_UNIX const gchar *msg = _("Search failed."); + gint color = COLOR_DARK_RED;
if (WIFEXITED(status)) { @@ -1286,14 +1287,15 @@ gint count = gtk_tree_model_iter_n_children( GTK_TREE_MODEL(msgwindow.store_msg), NULL) - 1;
- msgwin_msg_add_fmt(-1, -1, _("Search completed with %d matches."), count); + msgwin_msg_add_fmt(COLOR_BLUE, -1, -1, _("Search completed with %d matches."), count); ui_set_statusbar(_("Search completed with %d matches."), count); break; } case 1: msg = _("No matches found."); + color = COLOR_BLUE; default: - msgwin_msg_add(-1, -1, msg); + msgwin_msg_add(color, -1, -1, msg); ui_set_statusbar("%s", msg); break; } @@ -1332,7 +1334,7 @@ count++; line = sci_get_line_from_position(doc_list[idx].sci, pos); buffer = sci_get_line(doc_list[idx].sci, line); - msgwin_msg_add_fmt(line + 1, idx, + msgwin_msg_add_fmt(COLOR_BLACK, line + 1, idx, "%s:%d : %s", short_file_name, line + 1, g_strstrip(buffer)); g_free(buffer);
@@ -1372,14 +1374,15 @@ if (! found) // no matches were found { ui_set_statusbar(_("No matches found for "%s"."), search_text); - msgwin_msg_add_fmt(-1, -1, _("No matches found for "%s"."), search_text); + msgwin_msg_add_fmt(COLOR_BLUE, -1, -1, _("No matches found for "%s"."), search_text); } else { gint count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(msgwindow.store_msg), NULL);
ui_set_statusbar(_("Found %d matches for "%s"."), count, search_text); - msgwin_msg_add_fmt(-1, -1, _("Found %d matches for "%s"."), count, search_text); + msgwin_msg_add_fmt(COLOR_BLUE, -1, -1, _("Found %d matches for "%s"."), count, + search_text); } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.