From 7306501cdbb96eb047d76d183d16cbd152b2c524 Mon Sep 17 00:00:00 2001 From: Rakksor Date: Wed, 25 Jan 2017 06:25:32 +0100 Subject: [PATCH 1/2] make message window themable --- src/highlighting.c | 28 +++++++++++++++++++++++++++- src/highlighting.h | 4 ++++ src/msgwindow.c | 43 +++++++++++++++++++++++++++---------------- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/highlighting.c b/src/highlighting.c index 5dd0e0f435..bbb6359ee4 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -60,6 +60,10 @@ static gchar *whitespace_chars = NULL; +gint msg_context = 0x880000; +gint msg_default = 0x000000; +gint msg_error = 0xff0000; +gint msg_message = 0x0000cc; typedef struct { @@ -456,7 +460,29 @@ static void add_named_style(GKeyFile *config, const gchar *key) GeanyLexerStyle *style = g_new0(GeanyLexerStyle, 1); parse_keyfile_style(config, list, &gsd_default, style); - g_hash_table_insert(named_style_hash, g_strdup(key), style); + + if (!strcmp(key, "msg_context")) + { + msg_context = style->foreground; + g_free(style); + } + else if (!strcmp(key, "msg_default")) + { + msg_default = style->foreground; + g_free(style); + } + else if (!strcmp(key, "msg_error")) + { + msg_error = style->foreground; + g_free(style); + } + else if (!strcmp(key, "msg_message")) + { + msg_message = style->foreground; + g_free(style); + } + else + g_hash_table_insert(named_style_hash, g_strdup(key), style); } g_strfreev(list); } diff --git a/src/highlighting.h b/src/highlighting.h index c1190516f4..4aa3cd6aa7 100644 --- a/src/highlighting.h +++ b/src/highlighting.h @@ -45,6 +45,10 @@ typedef struct GeanyLexerStyle } GeanyLexerStyle; +extern gint msg_context; +extern gint msg_default; +extern gint msg_error; +extern gint msg_message; const GeanyLexerStyle *highlighting_get_style(gint ft_id, gint style_id); diff --git a/src/msgwindow.c b/src/msgwindow.c index 3a5e2c4000..9a242c2d1f 100644 --- a/src/msgwindow.c +++ b/src/msgwindow.c @@ -37,6 +37,7 @@ #include "document.h" #include "callbacks.h" #include "filetypes.h" +#include "highlighting.h" #include "keybindings.h" #include "main.h" #include "navqueue.h" @@ -262,21 +263,30 @@ static void prepare_compiler_tree_view(void) /*g_signal_connect(selection, "changed", G_CALLBACK(on_msg_tree_selection_changed), NULL);*/ } - -static const GdkColor color_error = {0, 65535, 0, 0}; - -static const GdkColor *get_color(gint msg_color) +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 ;-) */ - + gint color; switch (msg_color) { - case COLOR_RED: return &color_error; - case COLOR_DARK_RED: return &dark_red; - case COLOR_BLUE: return &blue; - default: return NULL; + case COLOR_RED: + color = msg_error; + break; + case COLOR_DARK_RED: + color = msg_context; + break; + case COLOR_BLUE: + color = msg_message; + break; + default: + color = msg_default; } + + gint red = color & 0xFF; + gint green = (color >> 8) & 0xFF; + gint blue = (color >> 16) & 0xFF; + GdkColor gdk_color = {0, red * 255, green * 255, blue * 255}; + + return gdk_color; } @@ -304,7 +314,7 @@ void msgwin_compiler_add(gint msg_color, const gchar *format, ...) void msgwin_compiler_add_string(gint msg_color, const gchar *msg) { GtkTreeIter iter; - const GdkColor *color = get_color(msg_color); + const GdkColor color = get_color(msg_color); gchar *utf8_msg; if (! g_utf8_validate(msg, -1, NULL)) @@ -314,7 +324,7 @@ void msgwin_compiler_add_string(gint msg_color, const gchar *msg) gtk_list_store_append(msgwindow.store_compiler, &iter); gtk_list_store_set(msgwindow.store_compiler, &iter, - COMPILER_COL_COLOR, color, COMPILER_COL_STRING, utf8_msg, -1); + COMPILER_COL_COLOR, &color, COMPILER_COL_STRING, utf8_msg, -1); if (ui_prefs.msgwindow_visible && interface_prefs.compiler_tab_autoscroll) { @@ -380,7 +390,7 @@ void msgwin_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar * void msgwin_msg_add_string(gint msg_color, gint line, GeanyDocument *doc, const gchar *string) { GtkTreeIter iter; - const GdkColor *color = get_color(msg_color); + const GdkColor color = get_color(msg_color); gchar *tmp; gsize len; gchar *utf8_msg; @@ -405,7 +415,7 @@ void msgwin_msg_add_string(gint msg_color, gint line, GeanyDocument *doc, const gtk_list_store_append(msgwindow.store_msg, &iter); gtk_list_store_set(msgwindow.store_msg, &iter, MSG_COL_LINE, line, MSG_COL_DOC_ID, doc ? doc->id : 0, MSG_COL_COLOR, - color, MSG_COL_STRING, utf8_msg, -1); + &color, MSG_COL_STRING, utf8_msg, -1); g_free(tmp); if (utf8_msg != tmp) @@ -730,7 +740,8 @@ gboolean msgwin_goto_compiler_file_line(gboolean focus_editor) { /* if the item is not coloured red, it's not an error line */ gtk_tree_model_get(model, &iter, COMPILER_COL_COLOR, &color, -1); - if (color == NULL || ! gdk_color_equal(color, &color_error)) + const GdkColor error = get_color(COLOR_RED); + if (color == NULL || ! gdk_color_equal(color, &error)) { if (color != NULL) gdk_color_free(color); From 50b689fd8ac96ca49aa4f3b1aa32e39265fd0363 Mon Sep 17 00:00:00 2001 From: Rakksor Date: Wed, 25 Jan 2017 06:59:29 +0100 Subject: [PATCH 2/2] added documentation for message window theme options --- doc/geany.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/doc/geany.txt b/doc/geany.txt index 670b540f1b..403245db07 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -4597,6 +4597,33 @@ indicator_error *Example:* ``indicator_error=0xff0000`` +msg_default + The default foreground color in the compiler tab of the message window. + + Only the first argument (foreground color) is used. + + *Example:* ``msg_default=0x000000`` + +msg_error + The foreground color of compiler errors in the message window. + + Only the first argument (foreground color) is used. + + *Example:* ``msg_error=0xff0000`` + +msg_context + The foreground color of the surrounding lines of compiler errors. + + Only the first argument (foreground color) is used. + + *Example:* ``msg_context=0x880000`` + +msg_message + The foreground color of messages and commands in the message window. + + Only the first argument (foreground color) is used. + + *Example:* ``msg_message=0x0000cc`` [settings] section ``````````````````