summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-bar-window.c40
-rw-r--r--src/gui/curses/gui-curses-main.c2
-rw-r--r--src/gui/curses/gui-curses-window.c2
-rw-r--r--src/gui/gtk/gui-gtk-main.c2
-rw-r--r--src/gui/gui-bar-item.c6
-rw-r--r--src/gui/gui-bar-window.c50
-rw-r--r--src/gui/gui-bar.c537
-rw-r--r--src/gui/gui-bar.h45
-rw-r--r--src/gui/gui-window.c2
9 files changed, 264 insertions, 422 deletions
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c
index c4898c43b..072b0c150 100644
--- a/src/gui/curses/gui-curses-bar-window.c
+++ b/src/gui/curses/gui-curses-bar-window.c
@@ -104,9 +104,9 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
bar_window->y,
bar_window->x);
- if (CONFIG_INTEGER(bar_window->bar->separator))
+ if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
{
- switch (CONFIG_INTEGER(bar_window->bar->position))
+ switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
{
case GUI_BAR_POSITION_BOTTOM:
GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator = newwin (1,
@@ -162,8 +162,8 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
if (reset_color_before_display)
{
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_COLOR(bar_window->bar->color_fg),
- CONFIG_COLOR(bar_window->bar->color_bg));
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
}
x_with_hidden = *x;
@@ -222,19 +222,19 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
case GUI_COLOR_BAR_FG_CHAR:
/* bar foreground */
gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_INTEGER(bar_window->bar->color_fg));
+ CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]));
string += 2;
break;
case GUI_COLOR_BAR_DELIM_CHAR:
/* bar delimiter */
gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_INTEGER(bar_window->bar->color_delim));
+ CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_DELIM]));
string += 2;
break;
case GUI_COLOR_BAR_BG_CHAR:
/* bar background */
gui_window_set_custom_color_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_INTEGER(bar_window->bar->color_bg));
+ CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
string += 2;
break;
case GUI_COLOR_BAR_START_INPUT_CHAR:
@@ -356,8 +356,8 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
"%c%c%02d,%02d ",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_FG_BG_CHAR,
- CONFIG_COLOR(bar_window->bar->color_fg),
- CONFIG_COLOR(bar_window->bar->color_bg));
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
length_reinit_color = strlen (space_with_reinit_color);
snprintf (str_start_input, sizeof (str_start_input), "%c%c%c",
@@ -383,15 +383,15 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
items = string_explode (content, "\n", 0, 0, &items_count);
if (items_count == 0)
{
- if (CONFIG_INTEGER(bar_window->bar->size) == 0)
+ if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
gui_bar_window_set_current_size (bar_window->bar, 1);
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_COLOR(bar_window->bar->color_bg));
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
}
else
{
/* bar with auto size ? then compute new size, according to content */
- if (CONFIG_INTEGER(bar_window->bar->size) == 0)
+ if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
{
/* search longer line and optimal number of lines */
max_length = 0;
@@ -418,7 +418,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if (max_length == 0)
max_length = 1;
- switch (CONFIG_INTEGER(bar_window->bar->position))
+ switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
{
case GUI_BAR_POSITION_BOTTOM:
case GUI_BAR_POSITION_TOP:
@@ -440,7 +440,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_COLOR(bar_window->bar->color_bg));
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
x = 0;
y = 0;
some_data_not_displayed = 0;
@@ -533,7 +533,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
y = 0;
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(config_color_bar_more),
- CONFIG_INTEGER(bar_window->bar->color_bg));
+ CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
y, x, "--");
}
@@ -546,7 +546,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
y = (bar_window->height > 1) ? bar_window->height - 1 : 0;
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(config_color_bar_more),
- CONFIG_INTEGER(bar_window->bar->color_bg));
+ CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
y, x, "++");
}
@@ -557,10 +557,10 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
else
{
- if (CONFIG_INTEGER(bar_window->bar->size) == 0)
+ if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
gui_bar_window_set_current_size (bar_window->bar, 1);
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_COLOR(bar_window->bar->color_bg));
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
}
/* move cursor if it was asked in an item content (input_text does that
@@ -573,9 +573,9 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
wnoutrefresh (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);
- if (CONFIG_INTEGER(bar_window->bar->separator))
+ if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
{
- switch (CONFIG_INTEGER(bar_window->bar->position))
+ switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
{
case GUI_BAR_POSITION_BOTTOM:
gui_window_set_weechat_color (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator,
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 440438af8..615b45678 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -138,7 +138,7 @@ gui_main_init ()
but no window was created (GUI was not initialized) */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT)
+ if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
&& (!ptr_bar->bar_window))
{
gui_bar_window_new (ptr_bar, NULL);
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index 3bef625ce..e125fb121 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -923,7 +923,7 @@ gui_window_refresh_windows ()
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if (CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
{
gui_bar_window_calculate_pos_size (ptr_bar->bar_window, NULL);
gui_bar_window_create_win (ptr_bar->bar_window);
diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c
index ca8403432..188c9a619 100644
--- a/src/gui/gtk/gui-gtk-main.c
+++ b/src/gui/gtk/gui-gtk-main.c
@@ -199,7 +199,7 @@ gui_main_init ()
but no window was created (GUI was not initialized) */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT)
+ if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
&& (!ptr_bar->bar_window))
{
gui_bar_window_new (ptr_bar, NULL);
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index 13fa8f606..6c336859f 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -357,12 +357,12 @@ gui_bar_item_get_value (const char *name, struct t_gui_bar *bar,
"%c%c%02d",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_FG_CHAR,
- CONFIG_COLOR(bar->color_delim));
+ CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_DELIM]));
snprintf (bar_color, sizeof (bar_color),
"%c%c%02d",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_FG_CHAR,
- CONFIG_COLOR(bar->color_fg));
+ CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_FG]));
}
snprintf (result, length,
"%s%s%s%s%s%s",
@@ -446,7 +446,7 @@ gui_bar_item_update (const char *item_name)
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if (!CONFIG_BOOLEAN(ptr_bar->hidden))
+ if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
{
gui_bar_get_item_index (ptr_bar, item_name, &index_item, &index_subitem);
if ((index_item >= 0) && (index_subitem >= 0))
diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c
index ba1cd1a89..ad3e905ae 100644
--- a/src/gui/gui-bar-window.c
+++ b/src/gui/gui-bar-window.c
@@ -120,10 +120,10 @@ gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
if (bar && (ptr_bar_window->bar == bar))
return total_size;
- if (!CONFIG_BOOLEAN(ptr_bar_window->bar->hidden))
+ if (!CONFIG_BOOLEAN(ptr_bar_window->bar->options[GUI_BAR_OPTION_HIDDEN]))
{
- if ((CONFIG_INTEGER(ptr_bar_window->bar->type) != GUI_BAR_TYPE_ROOT)
- && (CONFIG_INTEGER(ptr_bar_window->bar->position) == (int)position))
+ if ((CONFIG_INTEGER(ptr_bar_window->bar->options[GUI_BAR_OPTION_TYPE]) != GUI_BAR_TYPE_ROOT)
+ && (CONFIG_INTEGER(ptr_bar_window->bar->options[GUI_BAR_OPTION_POSITION]) == (int)position))
{
switch (position)
{
@@ -138,7 +138,7 @@ gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
case GUI_BAR_NUM_POSITIONS:
break;
}
- if (CONFIG_INTEGER(ptr_bar_window->bar->separator))
+ if (CONFIG_INTEGER(ptr_bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
total_size++;
}
}
@@ -180,7 +180,7 @@ gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
add_right = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_RIGHT);
}
- switch (CONFIG_INTEGER(bar_window->bar->position))
+ switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
{
case GUI_BAR_POSITION_BOTTOM:
bar_window->x = x1 + add_left;
@@ -224,7 +224,7 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window)
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
{
- if (CONFIG_INTEGER(bar->priority) >= CONFIG_INTEGER(ptr_bar_window->bar->priority))
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY]) >= CONFIG_INTEGER(ptr_bar_window->bar->options[GUI_BAR_OPTION_PRIORITY]))
return ptr_bar_window;
}
@@ -394,16 +394,16 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
"%c%c%02d,%02d",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_FG_BG_CHAR,
- CONFIG_COLOR(bar_window->bar->color_fg),
- CONFIG_COLOR(bar_window->bar->color_bg));
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
length_reinit_color = strlen (reinit_color);
snprintf (reinit_color_space, sizeof (reinit_color_space),
"%c%c%02d,%02d ",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_FG_BG_CHAR,
- CONFIG_COLOR(bar_window->bar->color_fg),
- CONFIG_COLOR(bar_window->bar->color_bg));
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
+ CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
length_reinit_color_space = strlen (reinit_color_space);
content = NULL;
@@ -499,8 +499,8 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
else
splitted_items[i] = NULL;
}
- if ((CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_BOTTOM)
- || (CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_TOP))
+ if ((CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]) == GUI_BAR_POSITION_BOTTOM)
+ || (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]) == GUI_BAR_POSITION_TOP))
{
columns = bar_window->width / (max_length_screen + 1);
if (columns == 0)
@@ -614,7 +614,7 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
if (window)
{
- if ((CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_WINDOW)
+ if ((CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_WINDOW)
&& (!gui_bar_check_conditions_for_window (bar, window)))
return 1;
}
@@ -672,14 +672,14 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
new_bar_window->scroll_y = 0;
new_bar_window->cursor_x = -1;
new_bar_window->cursor_y = -1;
- new_bar_window->current_size = (CONFIG_INTEGER(bar->size) == 0) ?
- 1 : CONFIG_INTEGER(bar->size);
+ new_bar_window->current_size = (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]) == 0) ?
+ 1 : CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]);
new_bar_window->items_count = 0;
new_bar_window->items_subcount = NULL;
new_bar_window->items_content = NULL;
new_bar_window->items_refresh_needed = NULL;
gui_bar_window_objects_init (new_bar_window);
- gui_bar_window_content_build (new_bar_window, window);
+ gui_bar_window_content_alloc (new_bar_window);
if (gui_init_ok)
{
@@ -706,10 +706,10 @@ gui_bar_window_recreate_bar_windows (struct t_gui_bar *bar)
struct t_gui_window *ptr_win;
struct t_gui_bar_window *ptr_bar_win;
- if (CONFIG_BOOLEAN(bar->hidden))
+ if (CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN]))
return;
- if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
{
gui_bar_window_calculate_pos_size (bar->bar_window, NULL);
gui_bar_window_create_win (bar->bar_window);
@@ -760,7 +760,7 @@ gui_bar_window_get_max_size_in_window (struct t_gui_bar_window *bar_window,
if (bar_window && window)
{
- switch (CONFIG_INTEGER(bar_window->bar->position))
+ switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
{
case GUI_BAR_POSITION_BOTTOM:
case GUI_BAR_POSITION_TOP:
@@ -830,16 +830,16 @@ gui_bar_window_set_current_size (struct t_gui_bar *bar, int size)
else
{
new_size = size;
- if ((size != 0) && (CONFIG_INTEGER(bar->size_max) > 0)
- && (size > CONFIG_INTEGER(bar->size_max)))
+ if ((size != 0) && (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE_MAX]) > 0)
+ && (size > CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE_MAX])))
{
- new_size = CONFIG_INTEGER(bar->size_max);
+ new_size = CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE_MAX]);
if (new_size < 1)
new_size = 1;
}
}
- if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
{
if (bar->bar_window->current_size != new_size)
{
@@ -921,7 +921,7 @@ gui_bar_window_remove_unused_bars (struct t_gui_window *window)
{
next_bar_win = ptr_bar_win->next_bar_window;
- if ((CONFIG_INTEGER(ptr_bar_win->bar->type) == GUI_BAR_TYPE_WINDOW)
+ if ((CONFIG_INTEGER(ptr_bar_win->bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_WINDOW)
&& (!gui_bar_check_conditions_for_window (ptr_bar_win->bar, window)))
{
gui_bar_window_free (ptr_bar_win, window);
@@ -950,7 +950,7 @@ gui_bar_window_add_missing_bars (struct t_gui_window *window)
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_WINDOW)
+ if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_WINDOW)
&& gui_bar_check_conditions_for_window (ptr_bar, window))
{
if (!gui_bar_window_search_bar (window, ptr_bar))
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index 192d99961..02ae62970 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -46,6 +46,10 @@ char *gui_bar_option_string[GUI_BAR_NUM_OPTIONS] =
{ "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_option_default[GUI_BAR_NUM_OPTIONS] =
+{ "0", "0", "0", "", "top", "horizontal",
+ "vertical", "0", "0", "default", "default",
+ "default", "off", "" };
char *gui_bar_type_string[GUI_BAR_NUM_TYPES] =
{ "root", "window" };
char *gui_bar_position_string[GUI_BAR_NUM_POSITIONS] =
@@ -171,7 +175,7 @@ gui_bar_get_min_width (struct t_gui_bar *bar)
struct t_gui_bar_window *ptr_bar_win;
int min_width;
- if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
return bar->bar_window->width;
min_width = INT_MAX;
@@ -208,7 +212,7 @@ gui_bar_get_min_height (struct t_gui_bar *bar)
struct t_gui_bar_window *ptr_bar_win;
int min_height;
- if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
return bar->bar_window->height;
min_height = INT_MAX;
@@ -246,7 +250,7 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size)
sub_width = 0;
sub_height = 0;
- switch (CONFIG_INTEGER(bar->position))
+ switch (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION]))
{
case GUI_BAR_POSITION_BOTTOM:
case GUI_BAR_POSITION_TOP:
@@ -263,7 +267,7 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size)
for (ptr_window = gui_windows; ptr_window;
ptr_window = ptr_window->next_window)
{
- if ((CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ if ((CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
|| (gui_bar_window_search_bar (ptr_window, bar)))
{
if ((ptr_window->win_chat_width - sub_width < GUI_WINDOW_CHAT_MIN_WIDTH)
@@ -284,11 +288,11 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size)
enum t_gui_bar_filling
gui_bar_get_filling (struct t_gui_bar *bar)
{
- if ((CONFIG_INTEGER(bar->position) == GUI_BAR_POSITION_BOTTOM)
- || (CONFIG_INTEGER(bar->position) == GUI_BAR_POSITION_TOP))
- return CONFIG_INTEGER(bar->filling_top_bottom);
+ if ((CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION]) == GUI_BAR_POSITION_BOTTOM)
+ || (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION]) == GUI_BAR_POSITION_TOP))
+ return CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM]);
- return CONFIG_INTEGER(bar->filling_left_right);
+ return CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT]);
}
/*
@@ -342,7 +346,7 @@ gui_bar_find_pos (struct t_gui_bar *bar)
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if (CONFIG_INTEGER(bar->priority) >= CONFIG_INTEGER(ptr_bar->priority))
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY]) >= CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_PRIORITY]))
return ptr_bar;
}
@@ -442,13 +446,13 @@ gui_bar_root_get_size (struct t_gui_bar *bar, enum t_gui_bar_position position)
if (bar && (ptr_bar == bar))
return total_size;
- if (!CONFIG_BOOLEAN(ptr_bar->hidden))
+ if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
{
- if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT)
- && (CONFIG_INTEGER(ptr_bar->position) == (int)position))
+ if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
+ && (CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_POSITION]) == (int)position))
{
total_size += gui_bar_window_get_current_size (ptr_bar->bar_window);
- if (CONFIG_INTEGER(ptr_bar->separator))
+ if (CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SEPARATOR]))
total_size++;
}
}
@@ -560,7 +564,7 @@ gui_bar_refresh (struct t_gui_bar *bar)
{
struct t_gui_window *ptr_win;
- if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
gui_window_refresh_needed = 1;
else
{
@@ -582,7 +586,7 @@ gui_bar_draw (struct t_gui_bar *bar)
struct t_gui_window *ptr_win;
struct t_gui_bar_window *ptr_bar_win;
- if (CONFIG_BOOLEAN(bar->hidden))
+ if (CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN]))
return;
if (bar->bar_window)
@@ -711,8 +715,8 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
{
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if (!CONFIG_BOOLEAN(ptr_bar->hidden)
- && (CONFIG_INTEGER(ptr_bar->type) != GUI_BAR_TYPE_ROOT))
+ if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN])
+ && (CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) != GUI_BAR_TYPE_ROOT))
{
gui_bar_window_new (ptr_bar, ptr_win);
}
@@ -767,8 +771,8 @@ gui_bar_config_change_priority (void *data, struct t_config_option *option)
{
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if (!CONFIG_BOOLEAN(ptr_bar->hidden)
- && (CONFIG_INTEGER(ptr_bar->type) != GUI_BAR_TYPE_ROOT))
+ if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN])
+ && (CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) != GUI_BAR_TYPE_ROOT))
{
gui_bar_window_new (ptr_bar, ptr_win);
}
@@ -797,9 +801,10 @@ gui_bar_config_change_conditions (void *data, struct t_config_option *option)
if (ptr_bar->conditions_array)
string_free_exploded (ptr_bar->conditions_array);
- if (CONFIG_STRING(ptr_bar->conditions) && CONFIG_STRING(ptr_bar->conditions)[0])
+ if (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS])
+ && CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS])[0])
{
- ptr_bar->conditions_array = string_explode (CONFIG_STRING(ptr_bar->conditions),
+ ptr_bar->conditions_array = string_explode (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS]),
",", 0, 0,
&ptr_bar->conditions_count);
}
@@ -826,7 +831,7 @@ gui_bar_config_change_position (void *data, struct t_config_option *option)
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
- if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->hidden))
+ if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
gui_bar_refresh (ptr_bar);
gui_window_refresh_needed = 1;
@@ -845,7 +850,7 @@ gui_bar_config_change_filling (void *data, struct t_config_option *option)
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
- if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->hidden))
+ if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
gui_bar_refresh (ptr_bar);
gui_window_refresh_needed = 1;
@@ -877,7 +882,7 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
- new_value = CONFIG_INTEGER(ptr_bar->size) + number;
+ new_value = CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]) + number;
}
}
else if (strncmp (value, "--", 2) == 0)
@@ -886,7 +891,7 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
- new_value = CONFIG_INTEGER(ptr_bar->size) - number;
+ new_value = CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]) - number;
}
}
else
@@ -902,12 +907,12 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
return 0;
if ((new_value > 0) &&
- ((CONFIG_INTEGER(ptr_bar->size) == 0)
- || (new_value > CONFIG_INTEGER(ptr_bar->size))))
+ ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]) == 0)
+ || (new_value > CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]))))
{
- if (!CONFIG_BOOLEAN(ptr_bar->hidden)
+ if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN])
&& !gui_bar_check_size_add (ptr_bar,
- new_value - CONFIG_INTEGER(ptr_bar->size)))
+ new_value - CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE])))
return 0;
}
@@ -933,7 +938,7 @@ gui_bar_config_change_size (void *data, struct t_config_option *option)
if (ptr_bar)
{
gui_bar_window_set_current_size (ptr_bar,
- CONFIG_INTEGER(ptr_bar->size));
+ CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]));
gui_window_refresh_needed = 1;
}
}
@@ -965,7 +970,7 @@ gui_bar_config_change_color (void *data, struct t_config_option *option)
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
- if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->hidden))
+ if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
gui_bar_refresh (ptr_bar);
}
@@ -982,7 +987,7 @@ gui_bar_config_change_separator (void *data, struct t_config_option *option)
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
- if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->hidden))
+ if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
gui_bar_refresh (ptr_bar);
}
@@ -1001,9 +1006,9 @@ gui_bar_config_change_items (void *data, struct t_config_option *option)
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
{
- gui_bar_set_items_array (ptr_bar, CONFIG_STRING(ptr_bar->items));
+ gui_bar_set_items_array (ptr_bar, CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_ITEMS]));
- if (!CONFIG_BOOLEAN(ptr_bar->hidden))
+ if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
{
gui_bar_content_build_bar_windows (ptr_bar);
gui_bar_ask_refresh (ptr_bar);
@@ -1029,33 +1034,33 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name)
if (option_name)
{
snprintf (option_name, length, "%s.hidden", name);
- config_file_option_rename (bar->hidden, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_HIDDEN], option_name);
snprintf (option_name, length, "%s.priority", name);
- config_file_option_rename (bar->priority, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_PRIORITY], option_name);
snprintf (option_name, length, "%s.type", name);
- config_file_option_rename (bar->type, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_TYPE], option_name);
snprintf (option_name, length, "%s.conditions", name);
- config_file_option_rename (bar->conditions, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_CONDITIONS], option_name);
snprintf (option_name, length, "%s.position", name);
- config_file_option_rename (bar->position, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_POSITION], option_name);
snprintf (option_name, length, "%s.filling_top_bottom", name);
- config_file_option_rename (bar->filling_top_bottom, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM], option_name);
snprintf (option_name, length, "%s.filling_left_right", name);
- config_file_option_rename (bar->filling_left_right, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT], option_name);
snprintf (option_name, length, "%s.size", name);
- config_file_option_rename (bar->size, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_SIZE], option_name);
snprintf (option_name, length, "%s.size_max", name);
- config_file_option_rename (bar->size_max, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_SIZE_MAX], option_name);
snprintf (option_name, length, "%s.color_fg", name);
- config_file_option_rename (bar->color_fg, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_COLOR_FG], option_name);
snprintf (option_name, length, "%s.color_delim", name);
- config_file_option_rename (bar->color_delim, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_COLOR_DELIM], option_name);
snprintf (option_name, length, "%s.color_bg", name);
- config_file_option_rename (bar->color_bg, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_COLOR_BG], option_name);
snprintf (option_name, length, "%s.separator", name);
- config_file_option_rename (bar->separator, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_SEPARATOR], option_name);
snprintf (option_name, length, "%s.items", name);
- config_file_option_rename (bar->items, option_name);
+ config_file_option_rename (bar->options[GUI_BAR_OPTION_ITEMS], option_name);
if (bar->name)
free (bar->name);
@@ -1083,10 +1088,10 @@ gui_bar_set_priority (struct t_gui_bar *bar, const char *priority)
number = 0;
/* bar number is already ok? */
- if (number == CONFIG_INTEGER(bar->priority))
+ if (number == CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY]))
return;
- config_file_option_set (bar->priority, priority, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_PRIORITY], priority, 1);
}
}
@@ -1103,9 +1108,10 @@ gui_bar_set_position (struct t_gui_bar *bar, const char *position)
return;
position_value = gui_bar_search_position (position);
- if ((position_value >= 0) && (CONFIG_INTEGER(bar->position) != position_value))
+ if ((position_value >= 0)
+ && (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION]) != position_value))
{
- config_file_option_set (bar->position, position, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_POSITION], position, 1);
}
}
@@ -1129,9 +1135,9 @@ gui_bar_set_size (struct t_gui_bar *bar, const char *size)
{
new_size = number;
if (size[0] == '+')
- new_size = CONFIG_INTEGER(bar->size) + new_size;
+ new_size = CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]) + new_size;
else if (value[0] == '-')
- new_size = CONFIG_INTEGER(bar->size) - new_size;
+ new_size = CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]) - new_size;
if ((size[0] == '-') && (new_size < 1))
return;
if (new_size < 0)
@@ -1139,16 +1145,16 @@ gui_bar_set_size (struct t_gui_bar *bar, const char *size)
/* check if new size is ok if it's more than before */
if ((new_size != 0) &&
- ((CONFIG_INTEGER(bar->size) == 0)
- || (new_size > CONFIG_INTEGER(bar->size))))
+ ((CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]) == 0)
+ || (new_size > CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]))))
{
if (!gui_bar_check_size_add (bar,
- new_size - CONFIG_INTEGER(bar->size)))
+ new_size - CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE])))
return;
}
snprintf (value, sizeof (value), "%d", new_size);
- config_file_option_set (bar->size, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_SIZE], value, 1);
gui_bar_window_set_current_size (bar, new_size);
}
@@ -1172,11 +1178,11 @@ gui_bar_set_size_max (struct t_gui_bar *bar, const char *size)
return;
snprintf (value, sizeof (value), "%ld", number);
- config_file_option_set (bar->size_max, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_SIZE_MAX], value, 1);
if ((number > 0) &&
- ((CONFIG_INTEGER(bar->size) == 0)
- || (number < CONFIG_INTEGER(bar->size))))
+ ((CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]) == 0)
+ || (number < CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE]))))
gui_bar_set_size (bar, value);
}
}
@@ -1199,7 +1205,7 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
}
else if (string_strcasecmp (property, "hidden") == 0)
{
- config_file_option_set (bar->hidden, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_HIDDEN], value, 1);
return 1;
}
else if (string_strcasecmp (property, "priority") == 0)
@@ -1209,7 +1215,7 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
}
else if (string_strcasecmp (property, "conditions") == 0)
{
- config_file_option_set (bar->conditions, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_CONDITIONS], value, 1);
return 1;
}
else if (string_strcasecmp (property, "position") == 0)
@@ -1219,12 +1225,12 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
}
else if (string_strcasecmp (property, "filling_top_bottom") == 0)
{
- config_file_option_set (bar->filling_top_bottom, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM], value, 1);
return 1;
}
else if (string_strcasecmp (property, "filling_left_right") == 0)
{
- config_file_option_set (bar->filling_left_right, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT], value, 1);
return 1;
}
else if (string_strcasecmp (property, "size") == 0)
@@ -1241,25 +1247,25 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
}
else if (string_strcasecmp (property, "color_fg") == 0)
{
- config_file_option_set (bar->color_fg, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_COLOR_FG], value, 1);
gui_bar_refresh (bar);
return 1;
}
else if (string_strcasecmp (property, "color_delim") == 0)
{
- config_file_option_set (bar->color_delim, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_COLOR_DELIM], value, 1);
gui_bar_refresh (bar);
return 1;
}
else if (string_strcasecmp (property, "color_bg") == 0)
{
- config_file_option_set (bar->color_bg, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_COLOR_BG], value, 1);
gui_bar_refresh (bar);
return 1;
}
else if (string_strcasecmp (property, "separator") == 0)
{
- config_file_option_set (bar->separator,
+ config_file_option_set (bar->options[GUI_BAR_OPTION_SEPARATOR],
(strcmp (value, "1") == 0) ? "on" : "off",
1);
gui_bar_refresh (bar);
@@ -1267,7 +1273,7 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
}
else if (string_strcasecmp (property, "items") == 0)
{
- config_file_option_set (bar->items, value, 1);
+ config_file_option_set (bar->options[GUI_BAR_OPTION_ITEMS], value, 1);
gui_bar_draw (bar);
return 1;
}
@@ -1455,46 +1461,46 @@ gui_bar_create_option_temp (struct t_gui_bar *temp_bar, int index_option,
switch (index_option)
{
case GUI_BAR_OPTION_HIDDEN:
- temp_bar->hidden = new_option;
+ temp_bar->options[GUI_BAR_OPTION_HIDDEN] = new_option;
break;
case GUI_BAR_OPTION_PRIORITY:
- temp_bar->priority = new_option;
+ temp_bar->options[GUI_BAR_OPTION_PRIORITY] = new_option;
break;
case GUI_BAR_OPTION_TYPE:
- temp_bar->type = new_option;
+ temp_bar->options[GUI_BAR_OPTION_TYPE] = new_option;
break;
case GUI_BAR_OPTION_CONDITIONS:
- temp_bar->conditions = new_option;
+ temp_bar->options[GUI_BAR_OPTION_CONDITIONS] = new_option;
break;
case GUI_BAR_OPTION_POSITION:
- temp_bar->position = new_option;
+ temp_bar->options[GUI_BAR_OPTION_POSITION] = new_option;
break;
case GUI_BAR_OPTION_FILLING_TOP_BOTTOM:
- temp_bar->filling_top_bottom = new_option;
+ temp_bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM] = new_option;
break;
case GUI_BAR_OPTION_FILLING_LEFT_RIGHT:
- temp_bar->filling_left_right = new_option;
+ temp_bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT] = new_option;
break;
case GUI_BAR_OPTION_SIZE:
- temp_bar->size = new_option;
+ temp_bar->options[GUI_BAR_OPTION_SIZE] = new_option;
break;
case GUI_BAR_OPTION_SIZE_MAX:
- temp_bar->size_max = new_option;
+ temp_bar->options[GUI_BAR_OPTION_SIZE_MAX] = new_option;
break;
case GUI_BAR_OPTION_COLOR_FG:
- temp_bar->color_fg = new_option;
+ temp_bar->options[GUI_BAR_OPTION_COLOR_FG] = new_option;
break;
case GUI_BAR_OPTION_COLOR_DELIM:
- temp_bar->color_delim = new_option;
+ temp_bar->options[GUI_BAR_OPTION_COLOR_DELIM] = new_option;
break;
case GUI_BAR_OPTION_COLOR_BG:
- temp_bar->color_bg = new_option;
+ temp_bar->options[GUI_BAR_OPTION_COLOR_BG] = new_option;
break;
case GUI_BAR_OPTION_SEPARATOR:
- temp_bar->separator = new_option;
+ temp_bar->options[GUI_BAR_OPTION_SEPARATOR] = new_option;
break;
case GUI_BAR_OPTION_ITEMS:
- temp_bar->items = new_option;
+ temp_bar->options[GUI_BAR_OPTION_ITEMS] = new_option;
break;
}
}
@@ -1508,25 +1514,16 @@ struct t_gui_bar *
gui_bar_alloc (const char *name)
{
struct t_gui_bar *new_bar;
-
+ int i;
+
new_bar = malloc (sizeof (*new_bar));
if (new_bar)
{
new_bar->name = strdup (name);
- new_bar->hidden = NULL;
- new_bar->priority = NULL;
- new_bar->type = NULL;
- new_bar->conditions = NULL;
- new_bar->position = 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;
- new_bar->color_delim = NULL;
- new_bar->color_bg = NULL;
- new_bar->separator = NULL;
- new_bar->items = NULL;
+ for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
+ {
+ new_bar->options[i] = NULL;
+ }
new_bar->conditions_count = 0;
new_bar->conditions_array = NULL;
new_bar->items_count = 0;
@@ -1568,10 +1565,10 @@ gui_bar_new_with_options (const char *name,
new_bar = gui_bar_alloc (name);
if (new_bar)
{
- new_bar->hidden = hidden;
- new_bar->priority = priority;
- new_bar->type = type;
- new_bar->conditions = conditions;
+ new_bar->options[GUI_BAR_OPTION_HIDDEN] = hidden;
+ new_bar->options[GUI_BAR_OPTION_PRIORITY] = priority;
+ new_bar->options[GUI_BAR_OPTION_TYPE] = type;
+ new_bar->options[GUI_BAR_OPTION_CONDITIONS] = conditions;
if (CONFIG_STRING(conditions) && CONFIG_STRING(conditions)[0])
{
new_bar->conditions_array = string_explode (CONFIG_STRING(conditions),
@@ -1583,16 +1580,16 @@ gui_bar_new_with_options (const char *name,
new_bar->conditions_count = 0;
new_bar->conditions_array = NULL;
}
- new_bar->position = position;
- 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;
- new_bar->color_delim = color_delim;
- new_bar->color_bg = color_bg;
- new_bar->separator = separator;
- new_bar->items = items;
+ new_bar->options[GUI_BAR_OPTION_POSITION] = position;
+ new_bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM] = filling_top_bottom;
+ new_bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT] = filling_left_right;
+ new_bar->options[GUI_BAR_OPTION_SIZE] = size;
+ new_bar->options[GUI_BAR_OPTION_SIZE_MAX] = size_max;
+ new_bar->options[GUI_BAR_OPTION_COLOR_FG] = color_fg;
+ new_bar->options[GUI_BAR_OPTION_COLOR_DELIM] = color_delim;
+ new_bar->options[GUI_BAR_OPTION_COLOR_BG] = color_bg;
+ new_bar->options[GUI_BAR_OPTION_SEPARATOR] = separator;
+ new_bar->options[GUI_BAR_OPTION_ITEMS] = items;
new_bar->items_count = 0;
new_bar->items_subcount = NULL;
new_bar->items_array = NULL;
@@ -1604,7 +1601,7 @@ gui_bar_new_with_options (const char *name,
gui_bar_insert (new_bar);
/* add window bar */
- if (CONFIG_INTEGER(new_bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(new_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
{
/* create only one window for bar */
gui_bar_window_new (new_bar, NULL);
@@ -1741,173 +1738,51 @@ void
gui_bar_use_temp_bars ()
{
struct t_gui_bar *ptr_temp_bar, *next_temp_bar;
+ int i, num_options_ok;
for (ptr_temp_bar = gui_temp_bars; ptr_temp_bar;
ptr_temp_bar = ptr_temp_bar->next_bar)
{
- if (!ptr_temp_bar->hidden)
- ptr_temp_bar->hidden = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_HIDDEN,
- "0");
- if (!ptr_temp_bar->priority)
- ptr_temp_bar->priority = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_PRIORITY,
- "0");
- if (!ptr_temp_bar->type)
- ptr_temp_bar->type = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_TYPE,
- "0");
- if (!ptr_temp_bar->conditions)
- ptr_temp_bar->conditions = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_CONDITIONS,
- "");
-
- if (!ptr_temp_bar->position)
- ptr_temp_bar->position = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_POSITION,
- "top");
-
- 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,
- GUI_BAR_OPTION_SIZE,
- "0");
-
- if (!ptr_temp_bar->size_max)
- ptr_temp_bar->size_max = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_SIZE_MAX,
- "0");
-
- if (!ptr_temp_bar->color_fg)
- ptr_temp_bar->color_fg = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_COLOR_FG,
- "default");
-
- if (!ptr_temp_bar->color_delim)
- ptr_temp_bar->color_delim = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_COLOR_DELIM,
- "default");
-
- if (!ptr_temp_bar->color_bg)
- ptr_temp_bar->color_bg = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_COLOR_BG,
- "default");
-
- if (!ptr_temp_bar->separator)
- ptr_temp_bar->separator = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_SEPARATOR,
- "off");
-
- if (!ptr_temp_bar->items)
- ptr_temp_bar->items = gui_bar_create_option (ptr_temp_bar->name,
- GUI_BAR_OPTION_ITEMS,
- "");
+ num_options_ok = 0;
+ for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
+ {
+ if (!ptr_temp_bar->options[i])
+ {
+ ptr_temp_bar->options[i] = gui_bar_create_option (ptr_temp_bar->name,
+ i,
+ gui_bar_option_default[i]);
+ }
+ if (ptr_temp_bar->options[i])
+ num_options_ok++;
+ }
- 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_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
- && ptr_temp_bar->items)
+ if (num_options_ok == GUI_BAR_NUM_OPTIONS)
{
gui_bar_new_with_options (ptr_temp_bar->name,
- ptr_temp_bar->hidden,
- ptr_temp_bar->priority,
- ptr_temp_bar->type,
- ptr_temp_bar->conditions,
- 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,
- ptr_temp_bar->items);
+ ptr_temp_bar->options[GUI_BAR_OPTION_HIDDEN],
+ ptr_temp_bar->options[GUI_BAR_OPTION_PRIORITY],
+ ptr_temp_bar->options[GUI_BAR_OPTION_TYPE],
+ ptr_temp_bar->options[GUI_BAR_OPTION_CONDITIONS],
+ ptr_temp_bar->options[GUI_BAR_OPTION_POSITION],
+ ptr_temp_bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM],
+ ptr_temp_bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT],
+ ptr_temp_bar->options[GUI_BAR_OPTION_SIZE],
+ ptr_temp_bar->options[GUI_BAR_OPTION_SIZE_MAX],
+ ptr_temp_bar->options[GUI_BAR_OPTION_COLOR_FG],
+ ptr_temp_bar->options[GUI_BAR_OPTION_COLOR_DELIM],
+ ptr_temp_bar->options[GUI_BAR_OPTION_COLOR_BG],
+ ptr_temp_bar->options[GUI_BAR_OPTION_SEPARATOR],
+ ptr_temp_bar->options[GUI_BAR_OPTION_ITEMS]);
}
else
{
- if (ptr_temp_bar->hidden)
+ for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
{
- config_file_option_free (ptr_temp_bar->hidden);
- ptr_temp_bar->hidden = NULL;
- }
- if (ptr_temp_bar->priority)
- {
- config_file_option_free (ptr_temp_bar->priority);
- ptr_temp_bar->priority = NULL;
- }
- if (ptr_temp_bar->type)
- {
- config_file_option_free (ptr_temp_bar->type);
- ptr_temp_bar->type = NULL;
- }
- if (ptr_temp_bar->conditions)
- {
- config_file_option_free (ptr_temp_bar->conditions);
- ptr_temp_bar->conditions = NULL;
- }
- if (ptr_temp_bar->position)
- {
- config_file_option_free (ptr_temp_bar->position);
- ptr_temp_bar->position = NULL;
- }
- 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_left_right);
- ptr_temp_bar->filling_left_right = NULL;
- }
- if (ptr_temp_bar->size)
- {
- config_file_option_free (ptr_temp_bar->size);
- ptr_temp_bar->size = NULL;
- }
- if (ptr_temp_bar->size_max)
- {
- config_file_option_free (ptr_temp_bar->size_max);
- ptr_temp_bar->size_max = NULL;
- }
- if (ptr_temp_bar->color_fg)
- {
- config_file_option_free (ptr_temp_bar->color_fg);
- ptr_temp_bar->color_fg = NULL;
- }
- if (ptr_temp_bar->color_delim)
- {
- config_file_option_free (ptr_temp_bar->color_delim);
- ptr_temp_bar->color_delim = NULL;
- }
- if (ptr_temp_bar->color_bg)
- {
- config_file_option_free (ptr_temp_bar->color_bg);
- ptr_temp_bar->color_bg = NULL;
- }
- if (ptr_temp_bar->separator)
- {
- config_file_option_free (ptr_temp_bar->separator);
- ptr_temp_bar->separator = NULL;
- }
- if (ptr_temp_bar->items)
- {
- config_file_option_free (ptr_temp_bar->items);
- ptr_temp_bar->items = NULL;
+ if (ptr_temp_bar->options[i])
+ {
+ config_file_option_free (ptr_temp_bar->options[i]);
+ ptr_temp_bar->options[i] = NULL;
+ }
}
}
}
@@ -1945,18 +1820,18 @@ gui_bar_create_default_input ()
{
/* add item "input_text" to input bar */
length = 1;
- if (CONFIG_STRING(ptr_bar->items))
- length += strlen (CONFIG_STRING(ptr_bar->items));
+ if (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_ITEMS]))
+ length += strlen (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_ITEMS]));
length += 1; /* "," */
length += strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]);
buf = malloc (length);
if (buf)
{
snprintf (buf, length, "%s,%s",
- (CONFIG_STRING(ptr_bar->items)) ?
- CONFIG_STRING(ptr_bar->items) : "",
+ (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_ITEMS])) ?
+ CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_ITEMS]) : "",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]);
- config_file_option_set (ptr_bar->items, buf, 1);
+ config_file_option_set (ptr_bar->options[GUI_BAR_OPTION_ITEMS], buf, 1);
gui_chat_printf (NULL, _("Bar \"%s\" updated"),
GUI_BAR_DEFAULT_NAME_INPUT);
gui_bar_draw (ptr_bar);
@@ -2172,8 +2047,11 @@ gui_bar_update (const char *name)
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if (!CONFIG_BOOLEAN(ptr_bar->hidden) && (strcmp (ptr_bar->name, name) == 0))
+ if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN])
+ && (strcmp (ptr_bar->name, name) == 0))
+ {
gui_bar_ask_refresh (ptr_bar);
+ }
}
}
@@ -2258,7 +2136,7 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_buffer *buffer,
}
}
- if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
gui_bar_window_scroll (bar->bar_window, NULL,
add_x, scroll_beginning, scroll_end,
add, percent, number);
@@ -2294,6 +2172,8 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_buffer *buffer,
void
gui_bar_free (struct t_gui_bar *bar)
{
+ int i;
+
if (!bar)
return;
@@ -2319,34 +2199,11 @@ gui_bar_free (struct t_gui_bar *bar)
/* free data */
if (bar->name)
free (bar->name);
- if (bar->hidden)
- config_file_option_free (bar->hidden);
- if (bar->priority)
- config_file_option_free (bar->priority);
- if (bar->type)
- config_file_option_free (bar->type);
- if (bar->conditions)
- config_file_option_free (bar->conditions);
- if (bar->position)
- config_file_option_free (bar->position);
- 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)
- config_file_option_free (bar->size_max);
- if (bar->color_fg)
- config_file_option_free (bar->color_fg);
- if (bar->color_delim)
- config_file_option_free (bar->color_delim);
- if (bar->color_bg)
- config_file_option_free (bar->color_bg);
- if (bar->separator)
- config_file_option_free (bar->separator);
- if (bar->items)
- config_file_option_free (bar->items);
+ for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
+ {
+ if (bar->options[i])
+ config_file_option_free (bar->options[i]);
+ }
if (bar->conditions_array)
string_free_exploded (bar->conditions_array);
gui_bar_free_items_array (bar);
@@ -2412,13 +2269,13 @@ gui_bar_add_to_infolist (struct t_infolist *infolist,
if (!ptr_item)
return 0;
- if (!infolist_new_var_integer (ptr_item, "hidden", CONFIG_INTEGER(bar->hidden)))
+ if (!infolist_new_var_integer (ptr_item, "hidden", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_HIDDEN])))
return 0;
- if (!infolist_new_var_integer (ptr_item, "priority", CONFIG_INTEGER(bar->priority)))
+ if (!infolist_new_var_integer (ptr_item, "priority", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY])))
return 0;
- if (!infolist_new_var_integer (ptr_item, "type", CONFIG_INTEGER(bar->type)))
+ if (!infolist_new_var_integer (ptr_item, "type", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE])))
return 0;
- if (!infolist_new_var_string (ptr_item, "conditions", CONFIG_STRING(bar->conditions)))
+ if (!infolist_new_var_string (ptr_item, "conditions", CONFIG_STRING(bar->options[GUI_BAR_OPTION_CONDITIONS])))
return 0;
if (!infolist_new_var_integer (ptr_item, "conditions_count", bar->conditions_count))
return 0;
@@ -2430,25 +2287,25 @@ gui_bar_add_to_infolist (struct t_infolist *infolist,
bar->conditions_array[i]))
return 0;
}
- if (!infolist_new_var_integer (ptr_item, "position", CONFIG_INTEGER(bar->position)))
+ if (!infolist_new_var_integer (ptr_item, "position", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION])))
return 0;
- if (!infolist_new_var_integer (ptr_item, "filling_top_bottom", CONFIG_INTEGER(bar->filling_top_bottom)))
+ if (!infolist_new_var_integer (ptr_item, "filling_top_bottom", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM])))
return 0;
- if (!infolist_new_var_integer (ptr_item, "filling_left_right", CONFIG_INTEGER(bar->filling_left_right)))
+ if (!infolist_new_var_integer (ptr_item, "filling_left_right", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT])))
return 0;
- if (!infolist_new_var_integer (ptr_item, "size", CONFIG_INTEGER(bar->size)))
+ if (!infolist_new_var_integer (ptr_item, "size", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE])))
return 0;
- if (!infolist_new_var_integer (ptr_item, "size_max", CONFIG_INTEGER(bar->size_max)))
+ if (!infolist_new_var_integer (ptr_item, "size_max", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE_MAX])))
return 0;
- if (!infolist_new_var_string (ptr_item, "color_fg", gui_color_get_name (CONFIG_COLOR(bar->color_fg))))
+ if (!infolist_new_var_string (ptr_item, "color_fg", gui_color_get_name (CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_FG]))))
return 0;
- if (!infolist_new_var_string (ptr_item, "color_delim", gui_color_get_name (CONFIG_COLOR(bar->color_delim))))
+ if (!infolist_new_var_string (ptr_item, "color_delim", gui_color_get_name (CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_DELIM]))))
return 0;
- if (!infolist_new_var_string (ptr_item, "color_bg", gui_color_get_name (CONFIG_COLOR(bar->color_bg))))
+ if (!infolist_new_var_string (ptr_item, "color_bg", gui_color_get_name (CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_BG]))))
return 0;
- if (!infolist_new_var_integer (ptr_item, "separator", CONFIG_INTEGER(bar->separator)))
+ if (!infolist_new_var_integer (ptr_item, "separator", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SEPARATOR])))
return 0;
- if (!infolist_new_var_string (ptr_item, "items", CONFIG_STRING(bar->items)))
+ if (!infolist_new_var_string (ptr_item, "items", CONFIG_STRING(bar->options[GUI_BAR_OPTION_ITEMS])))
return 0;
if (!infolist_new_var_integer (ptr_item, "items_count", bar->items_count))
return 0;
@@ -2484,36 +2341,36 @@ gui_bar_print_log ()
log_printf ("");
log_printf ("[bar (addr:0x%lx)]", ptr_bar);
log_printf (" name . . . . . . . . . : '%s'", ptr_bar->name);
- log_printf (" hidden . . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->hidden));
- log_printf (" priority . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->priority));
+ log_printf (" hidden . . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]));
+ log_printf (" priority . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_PRIORITY]));
log_printf (" type . . . . . . . . . : %d (%s)",
- CONFIG_INTEGER(ptr_bar->type),
- gui_bar_type_string[CONFIG_INTEGER(ptr_bar->type)]);
- log_printf (" conditions . . . . . . : '%s'", CONFIG_STRING(ptr_bar->conditions));
+ CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]),
+ gui_bar_type_string[CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE])]);
+ log_printf (" conditions . . . . . . : '%s'", CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS]));
log_printf (" conditions_count . . . : %d", ptr_bar->conditions_count);
log_printf (" conditions_array . . . : 0x%lx", ptr_bar->conditions_array);
log_printf (" position . . . . . . . : %d (%s)",
- CONFIG_INTEGER(ptr_bar->position),
- gui_bar_position_string[CONFIG_INTEGER(ptr_bar->position)]);
+ CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_POSITION]),
+ gui_bar_position_string[CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_POSITION])]);
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)]);
+ CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM]),
+ gui_bar_filling_string[CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_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));
+ CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT]),
+ gui_bar_filling_string[CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT])]);
+ log_printf (" size . . . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]));
+ log_printf (" size_max . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE_MAX]));
log_printf (" color_fg . . . . . . . : %d",
- CONFIG_COLOR(ptr_bar->color_fg),
- gui_color_get_name (CONFIG_COLOR(ptr_bar->color_fg)));
+ CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_FG]),
+ gui_color_get_name (CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_FG])));
log_printf (" color_delim. . . . . . : %d",
- CONFIG_COLOR(ptr_bar->color_delim),
- gui_color_get_name (CONFIG_COLOR(ptr_bar->color_delim)));
+ CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_DELIM]),
+ gui_color_get_name (CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_DELIM])));
log_printf (" color_bg . . . . . . . : %d",
- CONFIG_COLOR(ptr_bar->color_bg),
- gui_color_get_name (CONFIG_COLOR(ptr_bar->color_bg)));
- log_printf (" separator. . . . . . . : %d", CONFIG_INTEGER(ptr_bar->separator));
- log_printf (" items. . . . . . . . . : '%s'", CONFIG_STRING(ptr_bar->items));
+ CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_BG]),
+ gui_color_get_name (CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_BG])));
+ log_printf (" separator. . . . . . . : %d", CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SEPARATOR]));
+ log_printf (" items. . . . . . . . . : '%s'", CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_ITEMS]));
log_printf (" items_count. . . . . . : %d", ptr_bar->items_count);
for (i = 0; i < ptr_bar->items_count; i++)
{
diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h
index ab6b37967..5b9484912 100644
--- a/src/gui/gui-bar.h
+++ b/src/gui/gui-bar.h
@@ -31,20 +31,20 @@ struct t_gui_buffer;
enum t_gui_bar_option
{
- GUI_BAR_OPTION_HIDDEN = 0,
- GUI_BAR_OPTION_PRIORITY,
- GUI_BAR_OPTION_TYPE,
- GUI_BAR_OPTION_CONDITIONS,
- GUI_BAR_OPTION_POSITION,
- GUI_BAR_OPTION_FILLING_TOP_BOTTOM,
- GUI_BAR_OPTION_FILLING_LEFT_RIGHT,
- GUI_BAR_OPTION_SIZE,
- GUI_BAR_OPTION_SIZE_MAX,
- GUI_BAR_OPTION_COLOR_FG,
- GUI_BAR_OPTION_COLOR_DELIM,
- GUI_BAR_OPTION_COLOR_BG,
- GUI_BAR_OPTION_SEPARATOR,
- GUI_BAR_OPTION_ITEMS,
+ GUI_BAR_OPTION_HIDDEN = 0, /* true if bar is hidden */
+ GUI_BAR_OPTION_PRIORITY, /* bar priority */
+ GUI_BAR_OPTION_TYPE, /* type (root or window) */
+ GUI_BAR_OPTION_CONDITIONS, /* conditions for display */
+ GUI_BAR_OPTION_POSITION, /* bottom, top, left, right */
+ GUI_BAR_OPTION_FILLING_TOP_BOTTOM, /* filling when pos. is top/bottom */
+ GUI_BAR_OPTION_FILLING_LEFT_RIGHT, /* filling when pos. is left/right */
+ GUI_BAR_OPTION_SIZE, /* size of bar (in chars, 0 = auto) */
+ GUI_BAR_OPTION_SIZE_MAX, /* max size of bar (0 = no limit) */
+ GUI_BAR_OPTION_COLOR_FG, /* default text color for bar */
+ GUI_BAR_OPTION_COLOR_DELIM, /* default delimiter color for bar */
+ GUI_BAR_OPTION_COLOR_BG, /* default background color for bar */
+ GUI_BAR_OPTION_SEPARATOR, /* true if separator line displayed */
+ GUI_BAR_OPTION_ITEMS, /* bar items */
/* number of bar options */
GUI_BAR_NUM_OPTIONS,
};
@@ -81,22 +81,7 @@ struct t_gui_bar
{
/* user choices */
char *name; /* bar name */
- struct t_config_option *hidden; /* true if bar is hidden */
- struct t_config_option *priority; /* bar priority */
- struct t_config_option *type; /* type (root or window) */
- struct t_config_option *conditions; /* conditions for display */
- struct t_config_option *position; /* bottom, top, left, right */
- struct t_config_option *filling_top_bottom; /* filling when position is */
- /* top/bottom (horizontal/vertical) */
- struct t_config_option *filling_left_right; /* filling when position is */
- /* left/right (horizontal/vertical) */
- struct t_config_option *size; /* size of bar (in chars, 0 = auto) */
- struct t_config_option *size_max; /* max size of bar (0 = no limit) */
- struct t_config_option *color_fg; /* default text color for bar */
- struct t_config_option *color_delim;/* default delimiter color for bar */
- struct t_config_option *color_bg; /* default background color for bar */
- struct t_config_option *separator; /* true if separator line displayed */
- struct t_config_option *items; /* bar items */
+ struct t_config_option *options[GUI_BAR_NUM_OPTIONS];
/* internal vars */
int conditions_count; /* number of conditions */
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index f4d4cc229..1d4fd3371 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -253,7 +253,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
/* create bar windows */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- if (CONFIG_INTEGER(ptr_bar->type) != GUI_BAR_TYPE_ROOT)
+ if (CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) != GUI_BAR_TYPE_ROOT)
gui_bar_window_new (ptr_bar, new_window);
}
}