summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/gui-color.c19
-rw-r--r--src/gui/gui-color.h2
-rw-r--r--src/plugins/plugin-api.c10
3 files changed, 19 insertions, 12 deletions
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index 66795d5c5..cb29c2b05 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -43,12 +43,12 @@ struct t_gui_color *gui_color[GUI_COLOR_NUM_COLORS]; /* GUI colors */
/*
- * gui_color_search_config_int: search a color with configuration option name
- * return color found (number >= 0), -1 if not found
+ * gui_color_search_config: search a color with configuration option name
+ * return color string, NULL if not found
*/
-int
-gui_color_search_config_int (const char *color_name)
+const char *
+gui_color_search_config (const char *color_name)
{
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
@@ -63,13 +63,20 @@ gui_color_search_config_int (const char *color_name)
ptr_option = ptr_option->next_option)
{
if (string_strcasecmp (ptr_option->name, color_name) == 0)
- return ptr_option->min;
+ {
+ if (ptr_option->min < 0)
+ {
+ return gui_color_get_custom (
+ gui_color_get_name (CONFIG_COLOR(ptr_option)));
+ }
+ return GUI_COLOR(ptr_option->min);
+ }
}
}
}
/* color not found */
- return -1;
+ return NULL;
}
/*
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 7feae6497..0fa33f07d 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -126,7 +126,7 @@ extern struct t_gui_color *gui_color[];
/* color functions */
-extern int gui_color_search_config_int (const char *color_name);
+extern const char *gui_color_search_config (const char *color_name);
extern const char *gui_color_get_custom (const char *color_name);
extern char *gui_color_decode (const char *string, const char *replacement);
extern void gui_color_free (struct t_gui_color *color);
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index db34f20c9..bab3f4391 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -215,16 +215,16 @@ plugin_api_prefix (const char *prefix)
const char *
plugin_api_color (const char *color_name)
{
- int num_color;
+ const char *str_color;
if (!color_name)
return GUI_NO_COLOR;
/* name is a weechat color option ? => then return this color */
- num_color = gui_color_search_config_int (color_name);
- if (num_color >= 0)
- return GUI_COLOR(num_color);
-
+ str_color = gui_color_search_config (color_name);
+ if (str_color)
+ return str_color;
+
return gui_color_get_custom (color_name);
}