diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-23 12:29:43 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-23 12:29:43 +0200 |
commit | e5afd593ab1342b265b373169ce7a62a9c6cbf1a (patch) | |
tree | ae8bba1ad4f9001d2ee4d21e46e88be7fcc440b6 | |
parent | 868df211222f2ba81eaba3a5d9d96f12abf26653 (diff) | |
download | weechat-e5afd593ab1342b265b373169ce7a62a9c6cbf1a.zip |
Fix default value of bar items options (bug #31422)
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/gui/gui-bar-item.c | 14 | ||||
-rw-r--r-- | src/gui/gui-bar-item.h | 1 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 150 | ||||
-rw-r--r-- | src/gui/gui-bar.h | 2 |
5 files changed, 77 insertions, 91 deletions
@@ -7,6 +7,7 @@ v0.3.4-dev, 2010-10-23 Version 0.3.4 (under dev!) -------------------------- +* core: fix default value of bar items options (bug #31422) * core: fix bug with buffer name in "/bar scroll" command * core: add new option weechat.look.hotlist_unique_numbers (task #10691) * core: add property "no_highlight_nicks" in buffers to disable highlight diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index df4492746..407b3c502 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -61,6 +61,20 @@ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] = "buffer_filter", "buffer_nicklist_count", "scroll", "hotlist", "completion", "buffer_title", "buffer_nicklist" }; +char *gui_bar_items_default_for_bars[][2] = +{ { GUI_BAR_DEFAULT_NAME_INPUT, + "[input_prompt]+(away),[input_search],[input_paste],input_text" }, + { GUI_BAR_DEFAULT_NAME_TITLE, + "buffer_title" }, + { GUI_BAR_DEFAULT_NAME_STATUS, + "[time],[buffer_count],[buffer_plugin],buffer_number+:+" + "buffer_name+{buffer_nicklist_count}+buffer_filter,[lag],[hotlist]," + "completion,scroll" }, + { GUI_BAR_DEFAULT_NAME_NICKLIST, + "buffer_nicklist" }, + { NULL, + NULL }, +}; struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL; struct t_hook *gui_bar_item_timer = NULL; diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index 3e194a448..4e31589ad 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -68,6 +68,7 @@ struct t_gui_bar_item_hook extern struct t_gui_bar_item *gui_bar_items; extern struct t_gui_bar_item *last_gui_bar_item; extern char *gui_bar_item_names[]; +extern char *gui_bar_items_default_for_bars[][2]; /* functions */ diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 81d8e22b4..a70afbf21 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -1199,6 +1199,29 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value) } /* + * gui_bar_default_items: return default items for a bar name + * default bars (input, title, status, nicklist) have + * default items, all other bars have empty default + * items + */ + +const char * +gui_bar_default_items (const char *bar_name) +{ + int i; + static char empty_items[1] = { '\0' }; + + for (i = 0; gui_bar_items_default_for_bars[i][0]; i++) + { + if (strcmp (gui_bar_items_default_for_bars[i][0], bar_name) == 0) + return gui_bar_items_default_for_bars[i][1]; + } + + /* no default items in bar */ + return empty_items; +} + +/* * gui_bar_create_option: create an option for a bar */ @@ -1347,7 +1370,7 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value weechat_config_file, weechat_config_section_bar, option_name, "string", N_("items of bar"), - NULL, 0, 0, value, NULL, 0, + NULL, 0, 0, gui_bar_default_items (bar_name), value, 0, NULL, NULL, &gui_bar_config_change_items, NULL, NULL, NULL); break; case GUI_BAR_NUM_OPTIONS: @@ -1758,45 +1781,24 @@ gui_bar_create_default_input () else { /* create input bar */ - length = 1 /* "[" */ - + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT]) - + 3 /* "]+(" */ - + 4 /* "away" */ - + 3 /* "),[" */ - + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH]) - + 3 /* "],[" */ - + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE]) - + 2 /* "]," */ - + strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]) - + 1 /* \0 */; - buf = malloc (length); - if (buf) + if (gui_bar_new (GUI_BAR_DEFAULT_NAME_INPUT, + "0", /* hidden */ + "1000", /* priority */ + "window", /* type */ + "", /* conditions */ + "bottom", /* position */ + "horizontal", /* filling_top_bottom */ + "vertical", /* filling_left_right */ + "1", /* size */ + "0", /* size_max */ + "default", /* color fg */ + "cyan", /* color delim */ + "default", /* color bg */ + "0", /* separators */ + gui_bar_default_items (GUI_BAR_DEFAULT_NAME_INPUT))) /* items */ { - snprintf (buf, length, "[%s]+(away),[%s],[%s],%s", - gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT], - gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH], - gui_bar_item_names[GUI_BAR_ITEM_INPUT_PASTE], - gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]); - if (gui_bar_new (GUI_BAR_DEFAULT_NAME_INPUT, - "0", /* hidden */ - "1000", /* priority */ - "window", /* type */ - "", /* conditions */ - "bottom", /* position */ - "horizontal", /* filling_top_bottom */ - "vertical", /* filling_left_right */ - "1", /* size */ - "0", /* size_max */ - "default", /* color fg */ - "cyan", /* color delim */ - "default", /* color bg */ - "0", /* separators */ - buf)) /* items */ - { - gui_chat_printf (NULL, _("Bar \"%s\" created"), - GUI_BAR_DEFAULT_NAME_INPUT); - } - free (buf); + gui_chat_printf (NULL, _("Bar \"%s\" created"), + GUI_BAR_DEFAULT_NAME_INPUT); } } } @@ -1830,7 +1832,7 @@ gui_bar_create_default_title () "cyan", /* color delim */ "blue", /* color bg */ "0", /* separators */ - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE])) /* items */ + gui_bar_default_items (GUI_BAR_DEFAULT_NAME_TITLE))) /* items */ { gui_chat_printf (NULL, _("Bar \"%s\" created"), GUI_BAR_DEFAULT_NAME_TITLE); @@ -1846,62 +1848,30 @@ void gui_bar_create_default_status () { struct t_gui_bar *ptr_bar; - int length; - char *buf; /* search status bar */ ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_STATUS); if (!ptr_bar) { /* create status bar */ - length = strlen (gui_bar_item_names[GUI_BAR_ITEM_TIME]) - + strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_COUNT]) - + strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN]) - + strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]) - + 1 /* ":" */ - + strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME]) - + strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT]) - + strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER]) - + 3 /* "lag" */ - + strlen (gui_bar_item_names[GUI_BAR_ITEM_HOTLIST]) - + strlen (gui_bar_item_names[GUI_BAR_ITEM_COMPLETION]) - + strlen (gui_bar_item_names[GUI_BAR_ITEM_SCROLL]) - + (12 * 4) /* all items delimiters: ",:+[]()" */ - + 1; - buf = malloc (length); - if (buf) + if (gui_bar_new (GUI_BAR_DEFAULT_NAME_STATUS, + "0", /* hidden */ + "500", /* priority */ + "window", /* type */ + "", /* conditions */ + "bottom", /* position */ + "horizontal", /* filling_top_bottom */ + "vertical", /* filling_left_right */ + "1", /* size */ + "0", /* size_max */ + "default", /* color fg */ + "cyan", /* color delim */ + "blue", /* color bg */ + "0", /* separators */ + gui_bar_default_items (GUI_BAR_DEFAULT_NAME_STATUS))) /* items */ { - snprintf (buf, length, "[%s],[%s],[%s],%s+:+%s+{%s}+%s,[lag],[%s],%s,%s", - gui_bar_item_names[GUI_BAR_ITEM_TIME], - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_COUNT], - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN], - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER], - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME], - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT], - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER], - gui_bar_item_names[GUI_BAR_ITEM_HOTLIST], - gui_bar_item_names[GUI_BAR_ITEM_COMPLETION], - gui_bar_item_names[GUI_BAR_ITEM_SCROLL]); - if (gui_bar_new (GUI_BAR_DEFAULT_NAME_STATUS, - "0", /* hidden */ - "500", /* priority */ - "window", /* type */ - "", /* conditions */ - "bottom", /* position */ - "horizontal", /* filling_top_bottom */ - "vertical", /* filling_left_right */ - "1", /* size */ - "0", /* size_max */ - "default", /* color fg */ - "cyan", /* color delim */ - "blue", /* color bg */ - "0", /* separators */ - buf)) /* items */ - { - gui_chat_printf (NULL, _("Bar \"%s\" created"), - GUI_BAR_DEFAULT_NAME_STATUS); - } - free (buf); + gui_chat_printf (NULL, _("Bar \"%s\" created"), + GUI_BAR_DEFAULT_NAME_STATUS); } } } @@ -1934,7 +1904,7 @@ gui_bar_create_default_nicklist () "cyan", /* color delim */ "default", /* color bg */ "1", /* separators */ - gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST])) /* items */ + gui_bar_default_items (GUI_BAR_DEFAULT_NAME_NICKLIST))) /* items */ { gui_chat_printf (NULL, _("Bar \"%s\" created"), GUI_BAR_DEFAULT_NAME_NICKLIST); diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h index 1cae7b642..61ab1bfa6 100644 --- a/src/gui/gui-bar.h +++ b/src/gui/gui-bar.h @@ -25,8 +25,8 @@ struct t_gui_window; struct t_gui_buffer; #define GUI_BAR_DEFAULT_NAME_INPUT "input" -#define GUI_BAR_DEFAULT_NAME_STATUS "status" #define GUI_BAR_DEFAULT_NAME_TITLE "title" +#define GUI_BAR_DEFAULT_NAME_STATUS "status" #define GUI_BAR_DEFAULT_NAME_NICKLIST "nicklist" enum t_gui_bar_option |