Kaydet (Commit) 601fb23d authored tarafından Nick Treleaven's avatar Nick Treleaven

Add foreground colouring to messages items.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1887 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst f0c92858
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
Add tag_type treeview iter. Add tag_type treeview iter.
* tagmanager/haxe.c: * tagmanager/haxe.c:
Show Haxe enum types in the symbol list. 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> 2007-09-13 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
......
...@@ -135,11 +135,14 @@ static void prepare_msg_tree_view(void) ...@@ -135,11 +135,14 @@ static void prepare_msg_tree_view(void)
GtkTreeSelection *selection; GtkTreeSelection *selection;
PangoFontDescription *pfd; 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)); gtk_tree_view_set_model(GTK_TREE_VIEW(msgwindow.tree_msg), GTK_TREE_MODEL(msgwindow.store_msg));
renderer = gtk_cell_renderer_text_new(); 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_append_column(GTK_TREE_VIEW(msgwindow.tree_msg), column);
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(msgwindow.tree_msg), FALSE); gtk_tree_view_set_enable_search(GTK_TREE_VIEW(msgwindow.tree_msg), FALSE);
...@@ -193,6 +196,22 @@ static void prepare_compiler_tree_view(void) ...@@ -193,6 +196,22 @@ static void prepare_compiler_tree_view(void)
static const GdkColor color_error = {0, 65535, 0, 0}; 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, ...) void msgwin_compiler_add_fmt(gint msg_color, const gchar *format, ...)
{ {
gchar string[512]; gchar string[512];
...@@ -210,18 +229,7 @@ void msgwin_compiler_add(gint msg_color, const gchar *msg) ...@@ -210,18 +229,7 @@ void msgwin_compiler_add(gint msg_color, const gchar *msg)
{ {
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath *path; GtkTreePath *path;
const GdkColor *color; const GdkColor *color = get_color(msg_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};
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_append(msgwindow.store_compiler, &iter);
gtk_list_store_set(msgwindow.store_compiler, &iter, 0, color, 1, msg, -1); gtk_list_store_set(msgwindow.store_compiler, &iter, 0, color, 1, msg, -1);
...@@ -251,7 +259,7 @@ void msgwin_show_hide(gboolean show) ...@@ -251,7 +259,7 @@ void msgwin_show_hide(gboolean show)
} }
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]; gchar string[512];
va_list args; va_list args;
...@@ -260,21 +268,22 @@ void msgwin_msg_add_fmt(gint line, gint idx, const gchar *format, ...) ...@@ -260,21 +268,22 @@ void msgwin_msg_add_fmt(gint line, gint idx, const gchar *format, ...)
g_vsnprintf(string, 512, format, args); g_vsnprintf(string, 512, format, args);
va_end(args); va_end(args);
msgwin_msg_add(line, idx, string); msgwin_msg_add(msg_color, line, idx, string);
} }
// adds string to the msg treeview // 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; GtkTreeIter iter;
static gint state = 0; static gint state = 0;
const GdkColor *color = get_color(msg_color);
if (! ui_prefs.msgwindow_visible) msgwin_show_hide(TRUE); if (! ui_prefs.msgwindow_visible) msgwin_show_hide(TRUE);
gtk_list_store_append(msgwindow.store_msg, &iter); gtk_list_store_append(msgwindow.store_msg, &iter);
gtk_list_store_set(msgwindow.store_msg, &iter, 0, line, 1, idx, 2, 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); gtk_widget_set_sensitive(lookup_widget(app->window, "next_message1"), TRUE);
} }
...@@ -776,7 +785,7 @@ gboolean msgwin_goto_messages_file_line() ...@@ -776,7 +785,7 @@ gboolean msgwin_goto_messages_file_line()
gint idx, line; gint idx, line;
gchar *string; 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) if (line >= 0 && idx >= 0)
{ {
ret = utils_goto_line(idx, line); // checks valid idx ret = utils_goto_line(idx, line); // checks valid idx
......
...@@ -70,9 +70,9 @@ void msgwin_finalize(); ...@@ -70,9 +70,9 @@ void msgwin_finalize();
void msgwin_show_hide(gboolean show); 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); void msgwin_compiler_add_fmt(gint msg_color, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
......
...@@ -1202,7 +1202,7 @@ search_find_in_files(const gchar *search_text, const gchar *dir, const gchar *op ...@@ -1202,7 +1202,7 @@ search_find_in_files(const gchar *search_text, const gchar *dir, const gchar *op
str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"), str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"),
prefs.tools_grep_cmd, opts, search_text, dir); prefs.tools_grep_cmd, opts, search_text, dir);
utf8_str = utils_get_utf8_from_locale(str); 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); utils_free_pointers(str, utf8_str, NULL);
ret = TRUE; ret = TRUE;
} }
...@@ -1261,7 +1261,7 @@ static gboolean search_read_io (GIOChannel *source, ...@@ -1261,7 +1261,7 @@ static gboolean search_read_io (GIOChannel *source,
while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg) 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); g_free(msg);
} }
} }
...@@ -1276,6 +1276,7 @@ static void search_close_pid(GPid child_pid, gint status, gpointer user_data) ...@@ -1276,6 +1276,7 @@ static void search_close_pid(GPid child_pid, gint status, gpointer user_data)
{ {
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
const gchar *msg = _("Search failed."); const gchar *msg = _("Search failed.");
gint color = COLOR_DARK_RED;
if (WIFEXITED(status)) if (WIFEXITED(status))
{ {
...@@ -1286,14 +1287,15 @@ static void search_close_pid(GPid child_pid, gint status, gpointer user_data) ...@@ -1286,14 +1287,15 @@ static void search_close_pid(GPid child_pid, gint status, gpointer user_data)
gint count = gtk_tree_model_iter_n_children( gint count = gtk_tree_model_iter_n_children(
GTK_TREE_MODEL(msgwindow.store_msg), NULL) - 1; 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); ui_set_statusbar(_("Search completed with %d matches."), count);
break; break;
} }
case 1: case 1:
msg = _("No matches found."); msg = _("No matches found.");
color = COLOR_BLUE;
default: default:
msgwin_msg_add(-1, -1, msg); msgwin_msg_add(color, -1, -1, msg);
ui_set_statusbar("%s", msg); ui_set_statusbar("%s", msg);
break; break;
} }
...@@ -1332,7 +1334,7 @@ static gint find_document_usage(gint idx, const gchar *search_text, gint flags) ...@@ -1332,7 +1334,7 @@ static gint find_document_usage(gint idx, const gchar *search_text, gint flags)
count++; count++;
line = sci_get_line_from_position(doc_list[idx].sci, pos); line = sci_get_line_from_position(doc_list[idx].sci, pos);
buffer = sci_get_line(doc_list[idx].sci, line); 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)); "%s:%d : %s", short_file_name, line + 1, g_strstrip(buffer));
g_free(buffer); g_free(buffer);
...@@ -1372,14 +1374,15 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session ...@@ -1372,14 +1374,15 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session
if (! found) // no matches were found if (! found) // no matches were found
{ {
ui_set_statusbar(_("No matches found for \"%s\"."), search_text); 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 else
{ {
gint count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(msgwindow.store_msg), NULL); 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); 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);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment