diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-07-10 17:53:22 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-07-10 17:53:22 +0200 |
commit | f93837d5c891385f54b83ab62bd05f1b001812a3 (patch) | |
tree | d3ae0f5e9ee302a9f378befadaf88e59acf22f07 /src/gui/gui-bar.c | |
parent | abe0e1306813d13e40d65655f66230549b8b286a (diff) | |
download | weechat-f93837d5c891385f54b83ab62bd05f1b001812a3.zip |
Split "filling" bar value into "filling_top_bottom" and "filling_left_right" to have a filling specific to top/bottom bars (vs left/right bars)
Diffstat (limited to 'src/gui/gui-bar.c')
-rw-r--r-- | src/gui/gui-bar.c | 177 |
1 files changed, 123 insertions, 54 deletions
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index e513b6967..e07b57173 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -40,8 +40,9 @@ char *gui_bar_option_string[GUI_BAR_NUM_OPTIONS] = -{ "hidden", "priority", "type", "conditions", "position", "filling", "size", - "size_max", "color_fg", "color_delim", "color_bg", "separator", "items" }; +{ "hidden", "priority", "type", "conditions", "position", "filling_top_bottom", + "filling_left_right", "size", "size_max", "color_fg", "color_delim", + "color_bg", "separator", "items" }; char *gui_bar_type_string[GUI_BAR_NUM_TYPES] = { "root", "window" }; char *gui_bar_position_string[GUI_BAR_NUM_POSITIONS] = @@ -121,6 +122,24 @@ gui_bar_search_position (const char *position) } /* + * gui_bar_get_option_filling: return pointer to filling option + * if position is top/bottom, then return pointer + * on option "filling_top_bottom" + * if position is left/right, then return pointer + * on option "filling_left_right" + */ + +struct t_config_option * +gui_bar_get_option_filling (struct t_gui_bar *bar) +{ + if ((CONFIG_INTEGER(bar->position) == GUI_BAR_POSITION_BOTTOM) + || (CONFIG_INTEGER(bar->position) == GUI_BAR_POSITION_TOP)) + return bar->filling_top_bottom; + + return bar->filling_left_right; +} + +/* * gui_bar_find_pos: find position for a bar in list (keeping list sorted * by priority) */ @@ -713,8 +732,10 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name) config_file_option_rename (bar->conditions, option_name); snprintf (option_name, length, "%s.position", name); config_file_option_rename (bar->position, option_name); - snprintf (option_name, length, "%s.filling", name); - config_file_option_rename (bar->filling, option_name); + snprintf (option_name, length, "%s.filling_top_bottom", name); + config_file_option_rename (bar->filling_top_bottom, option_name); + snprintf (option_name, length, "%s.filling_left_right", name); + config_file_option_rename (bar->filling_left_right, option_name); snprintf (option_name, length, "%s.size", name); config_file_option_rename (bar->size, option_name); snprintf (option_name, length, "%s.size_max", name); @@ -890,9 +911,14 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value) gui_bar_set_position (bar, value); return 1; } - else if (string_strcasecmp (property, "filling") == 0) + else if (string_strcasecmp (property, "filling_top_bottom") == 0) + { + config_file_option_set (bar->filling_top_bottom, value, 1); + return 1; + } + else if (string_strcasecmp (property, "filling_left_right") == 0) { - config_file_option_set (bar->filling, value, 1); + config_file_option_set (bar->filling_left_right, value, 1); return 1; } else if (string_strcasecmp (property, "size") == 0) @@ -1007,12 +1033,23 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value "bottom|top|left|right", 0, 0, value, NULL, NULL, &gui_bar_config_change_position, NULL, NULL, NULL); break; - case GUI_BAR_OPTION_FILLING: + case GUI_BAR_OPTION_FILLING_TOP_BOTTOM: ptr_option = config_file_new_option ( weechat_config_file, weechat_config_section_bar, option_name, "integer", N_("bar filling direction (\"horizontal\" (from left to " - "right) or \"vertical\" (from top to bottom))"), + "right) or \"vertical\" (from top to bottom)) when bar " + "position is top or bottom"), + "horizontal|vertical", 0, 0, value, + NULL, NULL, &gui_bar_config_change_filling, NULL, NULL, NULL); + break; + case GUI_BAR_OPTION_FILLING_LEFT_RIGHT: + ptr_option = config_file_new_option ( + weechat_config_file, weechat_config_section_bar, + option_name, "integer", + N_("bar filling direction (\"horizontal\" (from left to " + "right) or \"vertical\" (from top to bottom)) when bar " + "position is left or right"), "horizontal|vertical", 0, 0, value, NULL, NULL, &gui_bar_config_change_filling, NULL, NULL, NULL); break; @@ -1123,8 +1160,11 @@ gui_bar_create_option_temp (struct t_gui_bar *temp_bar, int index_option, case GUI_BAR_OPTION_POSITION: temp_bar->position = new_option; break; - case GUI_BAR_OPTION_FILLING: - temp_bar->filling = new_option; + case GUI_BAR_OPTION_FILLING_TOP_BOTTOM: + temp_bar->filling_top_bottom = new_option; + break; + case GUI_BAR_OPTION_FILLING_LEFT_RIGHT: + temp_bar->filling_left_right = new_option; break; case GUI_BAR_OPTION_SIZE: temp_bar->size = new_option; @@ -1170,7 +1210,8 @@ gui_bar_alloc (const char *name) new_bar->type = NULL; new_bar->conditions = NULL; new_bar->position = NULL; - new_bar->filling = NULL; + new_bar->filling_top_bottom = NULL; + new_bar->filling_left_right = NULL; new_bar->size = NULL; new_bar->size_max = NULL; new_bar->color_fg = NULL; @@ -1202,7 +1243,8 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name, struct t_config_option *type, struct t_config_option *conditions, struct t_config_option *position, - struct t_config_option *filling, + struct t_config_option *filling_top_bottom, + struct t_config_option *filling_left_right, struct t_config_option *size, struct t_config_option *size_max, struct t_config_option *color_fg, @@ -1235,7 +1277,8 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name, new_bar->conditions_array = NULL; } new_bar->position = position; - new_bar->filling = filling; + new_bar->filling_top_bottom = filling_top_bottom; + new_bar->filling_left_right = filling_left_right; new_bar->size = size; new_bar->size_max = size_max; new_bar->color_fg = color_fg; @@ -1289,16 +1332,18 @@ struct t_gui_bar * gui_bar_new (struct t_weechat_plugin *plugin, const char *name, const char *hidden, const char *priority, const char *type, const char *conditions, const char *position, - const char *filling, const char *size, const char *size_max, + const char *filling_top_bottom, const char *filling_left_right, + const char *size, const char *size_max, const char *color_fg, const char *color_delim, const char *color_bg, const char *separators, const char *items) { struct t_config_option *option_hidden, *option_priority, *option_type; struct t_config_option *option_conditions, *option_position; - struct t_config_option *option_filling, *option_size; - struct t_config_option *option_size_max, *option_color_fg; - struct t_config_option *option_color_delim, *option_color_bg; - struct t_config_option *option_separator, *option_items; + struct t_config_option *option_filling_top_bottom, *option_filling_left_right; + struct t_config_option *option_size, *option_size_max; + struct t_config_option *option_color_fg, *option_color_delim; + struct t_config_option *option_color_bg, *option_separator; + struct t_config_option *option_items; struct t_gui_bar *new_bar; if (!name || !name[0]) @@ -1326,8 +1371,10 @@ gui_bar_new (struct t_weechat_plugin *plugin, const char *name, conditions); option_position = gui_bar_create_option (name, GUI_BAR_OPTION_POSITION, position); - option_filling = gui_bar_create_option (name, GUI_BAR_OPTION_FILLING, - filling); + option_filling_top_bottom = gui_bar_create_option (name, GUI_BAR_OPTION_FILLING_TOP_BOTTOM, + filling_top_bottom); + option_filling_left_right = gui_bar_create_option (name, GUI_BAR_OPTION_FILLING_LEFT_RIGHT, + filling_left_right); option_size = gui_bar_create_option (name, GUI_BAR_OPTION_SIZE, size); option_size_max = gui_bar_create_option (name, GUI_BAR_OPTION_SIZE_MAX, @@ -1346,10 +1393,12 @@ gui_bar_new (struct t_weechat_plugin *plugin, const char *name, new_bar = gui_bar_new_with_options (plugin, name, option_hidden, option_priority, option_type, option_conditions, option_position, - option_filling, option_size, - option_size_max, option_color_fg, - option_color_delim, option_color_bg, - option_separator, option_items); + option_filling_top_bottom, + option_filling_left_right, + option_size, option_size_max, + option_color_fg, option_color_delim, + option_color_bg, option_separator, + option_items); if (!new_bar) { if (option_hidden) @@ -1362,8 +1411,10 @@ gui_bar_new (struct t_weechat_plugin *plugin, const char *name, config_file_option_free (option_conditions); if (option_position) config_file_option_free (option_position); - if (option_filling) - config_file_option_free (option_filling); + if (option_filling_top_bottom) + config_file_option_free (option_filling_top_bottom); + if (option_filling_left_right) + config_file_option_free (option_filling_left_right); if (option_size) config_file_option_free (option_size); if (option_size_max) @@ -1417,13 +1468,15 @@ gui_bar_use_temp_bars () GUI_BAR_OPTION_POSITION, "top"); - if (!ptr_temp_bar->filling) - ptr_temp_bar->filling = gui_bar_create_option (ptr_temp_bar->name, - GUI_BAR_OPTION_FILLING, - (ptr_temp_bar->position - && ((CONFIG_INTEGER(ptr_temp_bar->position) == GUI_BAR_POSITION_LEFT) - || (CONFIG_INTEGER(ptr_temp_bar->position) == GUI_BAR_POSITION_RIGHT))) ? - "vertical" : "horizontal"); + if (!ptr_temp_bar->filling_top_bottom) + ptr_temp_bar->filling_top_bottom = gui_bar_create_option (ptr_temp_bar->name, + GUI_BAR_OPTION_FILLING_TOP_BOTTOM, + "horizontal"); + + if (!ptr_temp_bar->filling_left_right) + ptr_temp_bar->filling_left_right = gui_bar_create_option (ptr_temp_bar->name, + GUI_BAR_OPTION_FILLING_LEFT_RIGHT, + "vertical"); if (!ptr_temp_bar->size) ptr_temp_bar->size = gui_bar_create_option (ptr_temp_bar->name, @@ -1462,7 +1515,8 @@ gui_bar_use_temp_bars () if (ptr_temp_bar->hidden && ptr_temp_bar->priority && ptr_temp_bar->type && ptr_temp_bar->conditions - && ptr_temp_bar->position && ptr_temp_bar->filling + && ptr_temp_bar->position && ptr_temp_bar->filling_top_bottom + && ptr_temp_bar->filling_left_right && ptr_temp_bar->size && ptr_temp_bar->size_max && ptr_temp_bar->color_fg && ptr_temp_bar->color_delim && ptr_temp_bar->color_bg && ptr_temp_bar->separator @@ -1475,7 +1529,8 @@ gui_bar_use_temp_bars () ptr_temp_bar->type, ptr_temp_bar->conditions, ptr_temp_bar->position, - ptr_temp_bar->filling, + ptr_temp_bar->filling_top_bottom, + ptr_temp_bar->filling_left_right, ptr_temp_bar->size, ptr_temp_bar->size_max, ptr_temp_bar->color_fg, @@ -1511,10 +1566,15 @@ gui_bar_use_temp_bars () config_file_option_free (ptr_temp_bar->position); ptr_temp_bar->position = NULL; } - if (ptr_temp_bar->filling) + if (ptr_temp_bar->filling_top_bottom) + { + config_file_option_free (ptr_temp_bar->filling_top_bottom); + ptr_temp_bar->filling_top_bottom = NULL; + } + if (ptr_temp_bar->filling_left_right) { - config_file_option_free (ptr_temp_bar->filling); - ptr_temp_bar->filling = NULL; + config_file_option_free (ptr_temp_bar->filling_left_right); + ptr_temp_bar->filling_left_right = NULL; } if (ptr_temp_bar->size) { @@ -1625,7 +1685,8 @@ gui_bar_create_default () "window", /* type */ "", /* conditions */ "bottom", /* position */ - "horizontal", /* filling */ + "horizontal", /* filling_top_bottom */ + "vertical", /* filling_left_right */ "1", /* size */ "0", /* size_max */ gui_color_get_name (CONFIG_COLOR(config_color_input)), @@ -1676,7 +1737,8 @@ gui_bar_create_default () "window", /* type */ "", /* conditions */ "bottom", /* position */ - "horizontal", /* filling */ + "horizontal", /* filling_top_bottom */ + "vertical", /* filling_left_right */ "1", /* size */ "0", /* size_max */ gui_color_get_name (CONFIG_COLOR(config_color_status)), @@ -1703,7 +1765,8 @@ gui_bar_create_default () "window", /* type */ "", /* conditions */ "top", /* position */ - "horizontal", /* filling */ + "horizontal", /* filling_top_bottom */ + "vertical" , /* filling_left_right */ "1", /* size */ "0", /* size_max */ gui_color_get_name (CONFIG_COLOR(config_color_title)), @@ -1723,14 +1786,15 @@ gui_bar_create_default () { /* create nicklist bar */ if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_NICKLIST, - "0", /* hidden */ - "200", /* priority */ - "window", /* type */ - "nicklist", /* conditions */ - "right", /* position */ - "vertical", /* filling */ - "0", /* size */ - "0", /* size_max */ + "0", /* hidden */ + "200", /* priority */ + "window", /* type */ + "nicklist", /* conditions */ + "right", /* position */ + "horizontal", /* filling_top_bottom */ + "vertical", /* filling_left_right */ + "0", /* size */ + "0", /* size_max */ gui_color_get_name (CONFIG_COLOR(config_color_nicklist)), gui_color_get_name (CONFIG_COLOR(config_color_nicklist)), gui_color_get_name (CONFIG_COLOR(config_color_nicklist_bg)), @@ -1798,8 +1862,10 @@ gui_bar_free (struct t_gui_bar *bar) config_file_option_free (bar->conditions); if (bar->position) config_file_option_free (bar->position); - if (bar->filling) - config_file_option_free (bar->filling); + if (bar->filling_top_bottom) + config_file_option_free (bar->filling_top_bottom); + if (bar->filling_left_right) + config_file_option_free (bar->filling_left_right); if (bar->size) config_file_option_free (bar->size); if (bar->size_max) @@ -1882,9 +1948,12 @@ gui_bar_print_log () log_printf (" position . . . . . . . : %d (%s)", CONFIG_INTEGER(ptr_bar->position), gui_bar_position_string[CONFIG_INTEGER(ptr_bar->position)]); - log_printf (" filling. . . . . . . . : %d (%s)", - CONFIG_INTEGER(ptr_bar->filling), - gui_bar_filling_string[CONFIG_INTEGER(ptr_bar->filling)]); + log_printf (" filling_top_bottom . . : %d (%s)", + CONFIG_INTEGER(ptr_bar->filling_top_bottom), + gui_bar_filling_string[CONFIG_INTEGER(ptr_bar->filling_top_bottom)]); + log_printf (" filling_left_right . . : %d (%s)", + CONFIG_INTEGER(ptr_bar->filling_left_right), + gui_bar_filling_string[CONFIG_INTEGER(ptr_bar->filling_left_right)]); log_printf (" size . . . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->size)); log_printf (" size_max . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->size_max)); log_printf (" color_fg . . . . . . . : %d", |