Fixed bug with bar auto-sizing in windows

This commit is contained in:
Sebastien Helleu 2008-04-24 15:39:34 +02:00
parent ab6684c60a
commit 16e11ef25e
15 changed files with 192 additions and 136 deletions

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-23 18:30+0200\n"
"POT-Creation-Date: 2008-04-24 15:24+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -114,7 +114,7 @@ msgid "List of bars:"
msgstr "Seznam pro aliasy:\n"
#, fuzzy, c-format
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s"
msgstr "%sna %s%s%s/%s%s%s:%s ignoruji %s%s%s od %s%s\n"
#, fuzzy
@ -608,8 +608,8 @@ msgstr "řídit buffery"
msgid ""
"[add barname type[,cond1,cond2,...] position size separator item1,item2,...] "
"| [del barname] | [set barname name|number|condition|position|size|separator|"
"items value] | [list] | [listitems]"
"| [del barname] | [set barname name|number|condition|position|filling|size|"
"separator|items value] | [list] | [listitems]"
msgstr ""
msgid ""
@ -623,6 +623,7 @@ msgid ""
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing means no separator\n"
"item1,...: items for this bar\n"

View File

@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-23 18:30+0200\n"
"POT-Creation-Date: 2008-04-24 15:24+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -119,7 +119,7 @@ msgid "List of bars:"
msgstr "Liste der Aliases:\n"
#, fuzzy, c-format
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s"
msgstr "%sin %s%s%s/%s%s%s:%s ignoriere %s%s%s von %s%s\n"
#, fuzzy
@ -616,8 +616,8 @@ msgstr "Puffer verwalten"
msgid ""
"[add barname type[,cond1,cond2,...] position size separator item1,item2,...] "
"| [del barname] | [set barname name|number|condition|position|size|separator|"
"items value] | [list] | [listitems]"
"| [del barname] | [set barname name|number|condition|position|filling|size|"
"separator|items value] | [list] | [listitems]"
msgstr ""
msgid ""
@ -631,6 +631,7 @@ msgid ""
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing means no separator\n"
"item1,...: items for this bar\n"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-23 18:30+0200\n"
"POT-Creation-Date: 2008-04-24 15:24+0200\n"
"PO-Revision-Date: 2007-09-19 12:09+0200\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -116,7 +116,7 @@ msgid "List of bars:"
msgstr "Lista de alias:\n"
#, fuzzy, c-format
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s"
msgstr "%sen %s%s%s/%s%s%s:%s ignorando %s%s%s de %s%s\n"
msgid "height"
@ -612,8 +612,8 @@ msgstr "gestionar los búfers"
msgid ""
"[add barname type[,cond1,cond2,...] position size separator item1,item2,...] "
"| [del barname] | [set barname name|number|condition|position|size|separator|"
"items value] | [list] | [listitems]"
"| [del barname] | [set barname name|number|condition|position|filling|size|"
"separator|items value] | [list] | [listitems]"
msgstr ""
msgid ""
@ -627,6 +627,7 @@ msgid ""
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing means no separator\n"
"item1,...: items for this bar\n"

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: 2008-04-23 18:32+0200\n"
"POT-Creation-Date: 2008-04-24 15:24+0200\n"
"PO-Revision-Date: 2008-04-24 15:26+0200\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n"
@ -111,8 +111,8 @@ msgid "List of bars:"
msgstr "Liste des barres:"
#, c-format
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr " %3d. %s%s%s: %s (cond: %s), %s, remplissage: %s, %s: %s%s%d%s"
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s"
msgstr " %3d. %s%s%s: %s (cond: %s), %s, remplissage: %s, %s: %s"
msgid "height"
msgstr "hauteur"
@ -559,12 +559,9 @@ msgstr "gestion des barres"
msgid ""
"[add barname type[,cond1,cond2,...] position size separator item1,item2,...] "
"| [del barname] | [set barname name|number|condition|position|size|separator|"
"items value] | [list] | [listitems]"
msgstr ""
"[add nombarre type[,cond1,cond2,...] position taille separateur objet1,"
"objet2,...] | [del nombarre] | [set nombarre name|condition|position|size|"
"separator|items valeur] | [list] | [listitems]"
"| [del barname] | [set barname name|number|condition|position|filling|size|"
"separator|items value] | [list] | [listitems]"
msgstr "[add nombarre type[,cond1,cond2,...] position taille separateur objet1,objet2,...] | [del nombarre] | [set nombarre name|condition|position|filling|size|separator|items valeur] | [list] | [listitems]"
msgid ""
" add: add a new bar\n"
@ -577,6 +574,7 @@ msgid ""
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing means no separator\n"
"item1,...: items for this bar\n"
@ -588,18 +586,16 @@ msgstr ""
" add: ajoute une nouvelle barre\n"
" nombarre: nom de la barre (doit être unique)\n"
" type: root: en dehors des fenêtres\n"
" window: dans les fenêtres, avec condition(s) optionnelle(s) "
"(voir ci-dessous)\n"
" cond1,...: condition(s) pour afficher cette barre (seulement pour le type "
"\"window\") :\n"
" window: dans les fenêtres, avec condition(s) optionnelle(s) (voir ci-dessous)\n"
" cond1,...: condition(s) pour afficher cette barre (seulement pour le type \"window\") :\n"
" active: sur la fenêtre active\n"
" inactive: sur les fenêtres inactives\n"
" nicklist: sue les fenêtres avec liste de pseudos\n"
" sans condition, la barre est toujours affichée\n"
" position: bottom (bas), top (haut), left (gauche) ou right (droite)\n"
" filling: horizontal ou vertical\n"
" taille: taille de la barre (en caractères)\n"
"separateur: 1 pour utiliser un séparateur (ligne), 0 ou rien signifie sans "
"séparateur\n"
"separateur: 1 pour utiliser un séparateur (ligne), 0 ou rien signifie sans séparateur\n"
"objet1,...: objets pour cette barre\n"
" del: supprime une barre\n"
" set: changer la valeur d'une propriété de la barre\n"

View File

@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-23 18:30+0200\n"
"POT-Creation-Date: 2008-04-24 15:24+0200\n"
"PO-Revision-Date: 2007-10-10 18:07+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -120,7 +120,7 @@ msgid "List of bars:"
msgstr "Aliaszok listája:\n"
#, fuzzy, c-format
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s"
msgstr "%s %s%s%s/%s%s%s:%s %s%s%s mellőzése a következő(k)től: %s%s\n"
#, fuzzy
@ -614,8 +614,8 @@ msgstr "pufferek kezelése"
msgid ""
"[add barname type[,cond1,cond2,...] position size separator item1,item2,...] "
"| [del barname] | [set barname name|number|condition|position|size|separator|"
"items value] | [list] | [listitems]"
"| [del barname] | [set barname name|number|condition|position|filling|size|"
"separator|items value] | [list] | [listitems]"
msgstr ""
msgid ""
@ -629,6 +629,7 @@ msgid ""
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing means no separator\n"
"item1,...: items for this bar\n"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-23 18:30+0200\n"
"POT-Creation-Date: 2008-04-24 15:24+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -116,7 +116,7 @@ msgid "List of bars:"
msgstr "Список сокращений:\n"
#, fuzzy, c-format
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s"
msgstr "%sна %s%s%s/%s%s%s:%s игнорирует %s%s%s с %s%s\n"
#, fuzzy
@ -610,8 +610,8 @@ msgstr "управление буферами"
msgid ""
"[add barname type[,cond1,cond2,...] position size separator item1,item2,...] "
"| [del barname] | [set barname name|number|condition|position|size|separator|"
"items value] | [list] | [listitems]"
"| [del barname] | [set barname name|number|condition|position|filling|size|"
"separator|items value] | [list] | [listitems]"
msgstr ""
msgid ""
@ -625,6 +625,7 @@ msgid ""
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing means no separator\n"
"item1,...: items for this bar\n"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-23 18:30+0200\n"
"POT-Creation-Date: 2008-04-24 15:24+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -94,7 +94,7 @@ msgid "List of bars:"
msgstr ""
#, c-format
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s"
msgstr ""
msgid "height"
@ -534,8 +534,8 @@ msgstr ""
msgid ""
"[add barname type[,cond1,cond2,...] position size separator item1,item2,...] "
"| [del barname] | [set barname name|number|condition|position|size|separator|"
"items value] | [list] | [listitems]"
"| [del barname] | [set barname name|number|condition|position|filling|size|"
"separator|items value] | [list] | [listitems]"
msgstr ""
msgid ""
@ -549,6 +549,7 @@ msgid ""
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing means no separator\n"
"item1,...: items for this bar\n"

View File

@ -66,7 +66,7 @@ command_bar (void *data, struct t_gui_buffer *buffer,
{
int type, position;
long number;
char *error, *str_type, *pos_condition;
char *error, *str_type, *pos_condition, str_size[16];
struct t_gui_bar *ptr_bar;
struct t_gui_bar_item *ptr_item;
@ -85,9 +85,11 @@ command_bar (void *data, struct t_gui_buffer *buffer,
for (ptr_bar = gui_bars; ptr_bar;
ptr_bar = ptr_bar->next_bar)
{
snprintf (str_size, sizeof (str_size),
"%d", CONFIG_INTEGER(ptr_bar->size));
gui_chat_printf (NULL,
_(" %3d. %s%s%s: %s (cond: %s), %s, filling: %s, "
"%s: %s%s%d%s"),
"%s: %s"),
ptr_bar->number,
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
ptr_bar->name,
@ -101,10 +103,7 @@ command_bar (void *data, struct t_gui_buffer *buffer,
((CONFIG_INTEGER(ptr_bar->position) == GUI_BAR_POSITION_BOTTOM)
|| (CONFIG_INTEGER(ptr_bar->position) == GUI_BAR_POSITION_TOP)) ?
_("height") : _("width"),
(CONFIG_INTEGER(ptr_bar->size) == 0) ? _("auto") : "",
(CONFIG_INTEGER(ptr_bar->size) == 0) ? " (" : "",
ptr_bar->current_size,
(CONFIG_INTEGER(ptr_bar->size) == 0) ? ")" : "");
(CONFIG_INTEGER(ptr_bar->size) == 0) ? _("auto") : str_size);
gui_chat_printf (NULL,
_(" fg: %s, bg: %s, items: %s%s (plugin: "
"%s)"),
@ -2510,8 +2509,8 @@ command_init ()
N_("manage bars"),
N_("[add barname type[,cond1,cond2,...] position size "
"separator item1,item2,...] | [del barname] | "
"[set barname name|number|condition|position|size|"
"separator|items value] | [list] | [listitems]"),
"[set barname name|number|condition|position|filling|"
"size|separator|items value] | [list] | [listitems]"),
N_(" add: add a new bar\n"
" barname: name of bar (must be unique)\n"
" type: root: outside windows),\n"
@ -2524,6 +2523,7 @@ command_init ()
" nicklist: on windows with nicklist\n"
" without condition, bar is always displayed\n"
" position: bottom, top, left or right\n"
" filling: horizontal or vertical\n"
" size: size of bar (in chars)\n"
"separator: 1 for using separator (line), 0 or nothing "
"means no separator\n"
@ -2533,7 +2533,7 @@ command_init ()
" list: list all bars\n"
"listitems: list all bar items"),
"add|del|set|list|listitems %r name|number|conditions|"
"position|size|separator|items",
"position|filling|size|separator|items",
&command_bar, NULL);
hook_command (NULL, "buffer",
N_("manage buffers"),

View File

@ -60,6 +60,43 @@ gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar)
return NULL;
}
/*
* gui_bar_window_get_current_size: get current size of bar window
* return width or height, depending on bar
* position
*/
int
gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window)
{
return bar_window->current_size;
}
/*
* gui_bar_window_set_current_size: set current size of all bar windows for a bar
*/
void
gui_bar_window_set_current_size (struct t_gui_bar *bar, int size)
{
struct t_gui_window *ptr_win;
struct t_gui_bar_window *ptr_bar_win;
if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
bar->bar_window->current_size = (size == 0) ? 1 : size;
else
{
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
for (ptr_bar_win = GUI_CURSES(ptr_win)->bar_windows;
ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
{
ptr_bar_win->current_size = (size == 0) ? 1 : size;
}
}
}
}
/*
* gui_bar_window_get_size: get total bar size (window bars) for a position
* bar is optional, if not NULL, size is computed
@ -186,26 +223,26 @@ gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
{
case GUI_BAR_POSITION_BOTTOM:
bar_window->x = x1 + add_left;
bar_window->y = y2 - add_bottom - bar_window->bar->current_size + 1;
bar_window->y = y2 - add_bottom - bar_window->current_size + 1;
bar_window->width = x2 - x1 + 1 - add_left - add_right;
bar_window->height = bar_window->bar->current_size;
bar_window->height = bar_window->current_size;
break;
case GUI_BAR_POSITION_TOP:
bar_window->x = x1 + add_left;
bar_window->y = y1 + add_top;
bar_window->width = x2 - x1 + 1 - add_left - add_right;
bar_window->height = bar_window->bar->current_size;
bar_window->height = bar_window->current_size;
break;
case GUI_BAR_POSITION_LEFT:
bar_window->x = x1 + add_left;
bar_window->y = y1 + add_top;
bar_window->width = bar_window->bar->current_size;
bar_window->width = bar_window->current_size;
bar_window->height = y2 - add_top - add_bottom - y1 + 1;
break;
case GUI_BAR_POSITION_RIGHT:
bar_window->x = x2 - add_right - bar_window->bar->current_size + 1;
bar_window->x = x2 - add_right - bar_window->current_size + 1;
bar_window->y = y1 + add_top;
bar_window->width = bar_window->bar->current_size;
bar_window->width = bar_window->current_size;
bar_window->height = y2 - y1 + 1;
break;
case GUI_BAR_NUM_POSITIONS:
@ -356,6 +393,13 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
new_bar_window->win_bar = NULL;
new_bar_window->win_separator = NULL;
new_bar_window->x = 0;
new_bar_window->y = 0;
new_bar_window->width = 1;
new_bar_window->height = 1;
new_bar_window->current_size = (CONFIG_INTEGER(bar->size) == 0) ?
1 : CONFIG_INTEGER(bar->size);
if (gui_init_ok)
{
gui_bar_window_calculate_pos_size (new_bar_window, window);
@ -363,13 +407,6 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
if (window)
window->refresh_needed = 1;
}
else
{
new_bar_window->x = 0;
new_bar_window->y = 0;
new_bar_window->width = 1;
new_bar_window->height = 1;
}
return 1;
}
@ -726,7 +763,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
items = string_explode (content, "\n", 0, 0, &items_count);
if (items_count == 0)
{
gui_bar_set_current_size (bar_window->bar, 1);
gui_bar_window_set_current_size (bar_window->bar, 1);
gui_bar_window_recreate_bar_windows (bar_window->bar);
gui_window_clear (bar_window->win_bar,
CONFIG_COLOR(bar_window->bar->color_bg));
@ -761,18 +798,19 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
num_lines = optimal_number_of_lines;
else
num_lines = items_count;
if (bar_window->bar->current_size != num_lines)
if (bar_window->current_size != num_lines)
{
gui_bar_set_current_size (bar_window->bar, num_lines);
gui_bar_window_set_current_size (bar_window->bar,
num_lines);
gui_bar_window_recreate_bar_windows (bar_window->bar);
}
break;
case GUI_BAR_POSITION_LEFT:
case GUI_BAR_POSITION_RIGHT:
if (bar_window->bar->current_size != max_length)
if (bar_window->current_size != max_length)
{
gui_bar_set_current_size (bar_window->bar,
max_length);
gui_bar_window_set_current_size (bar_window->bar,
max_length);
gui_bar_window_recreate_bar_windows (bar_window->bar);
}
break;
@ -802,7 +840,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
else
{
gui_bar_set_current_size (bar_window->bar, 1);
gui_bar_window_set_current_size (bar_window->bar, 1);
gui_bar_window_recreate_bar_windows (bar_window->bar);
gui_window_clear (bar_window->win_bar,
CONFIG_COLOR(bar_window->bar->color_bg));
@ -954,6 +992,7 @@ gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
log_printf (" y . . . . . . . . : %d", bar_window->y);
log_printf (" width . . . . . . : %d", bar_window->width);
log_printf (" height. . . . . . : %d", bar_window->height);
log_printf (" current_size. . . : %d", bar_window->current_size);
log_printf (" win_bar . . . . . : 0x%x", bar_window->win_bar);
log_printf (" win_separator . . : 0x%x", bar_window->win_separator);
log_printf (" prev_bar_window . : 0x%x", bar_window->prev_bar_window);

View File

@ -204,10 +204,6 @@ gui_main_loop ()
/* execute hook timers */
hook_timer_exec ();
/* refresh window if needed */
if (gui_window_refresh_needed)
gui_window_refresh_screen ();
/* refresh status bar if needed */
if (gui_status_refresh_needed)
gui_status_draw (1);
@ -245,6 +241,10 @@ gui_main_loop ()
gui_input_draw (ptr_buffer, 1);
}
/* refresh window if needed */
if (gui_window_refresh_needed)
gui_window_refresh_screen ();
/* wait for keyboard or network activity */
FD_ZERO (&read_fds);
FD_ZERO (&write_fds);

View File

@ -44,6 +44,7 @@ struct t_gui_bar_window
int x, y; /* position of window */
int width, height; /* window size */
WINDOW *win_bar; /* bar Curses window */
int current_size; /* current size (width or height) */
WINDOW *win_separator; /* separator (optional) */
struct t_gui_bar_window *prev_bar_window; /* link to previous bar win */
/* (only for non-root bars) */

View File

@ -55,6 +55,43 @@ gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar)
return NULL;
}
/*
* gui_bar_window_get_current_size: get current size of bar window
* return width or height, depending on bar
* position
*/
int
gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window)
{
return bar_window->current_size;
}
/*
* gui_bar_window_set_current_size: set current size of all bar windows for a bar
*/
void
gui_bar_window_set_current_size (struct t_gui_bar *bar, int size)
{
struct t_gui_window *ptr_win;
struct t_gui_bar_window *ptr_bar_win;
if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
bar->bar_window->current_size = (size == 0) ? 1 : size;
else
{
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
for (ptr_bar_win = GUI_GTK(ptr_win)->bar_windows;
ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
{
ptr_bar_win->current_size = (size == 0) ? 1 : size;
}
}
}
}
/*
* gui_bar_window_get_size: get total bar size (window bars) for a position
* bar is optional, if not NULL, size is computed

View File

@ -59,6 +59,7 @@ struct t_gui_bar_window
struct t_gui_bar *bar; /* pointer to bar */
int x, y; /* position of window */
int width, height; /* window size */
int current_size; /* current size (width or height) */
struct t_gui_bar_window *prev_bar_window; /* link to previous bar win */
/* (only for non-root bars) */
struct t_gui_bar_window *next_bar_window; /* link to next bar win */

View File

@ -172,7 +172,7 @@ gui_bar_root_get_size (struct t_gui_bar *bar, enum t_gui_bar_position position)
if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT)
&& (CONFIG_INTEGER(ptr_bar->position) == (int)position))
{
total_size += ptr_bar->current_size;
total_size += gui_bar_window_get_current_size (ptr_bar->bar_window);
if (CONFIG_INTEGER(ptr_bar->separator))
total_size++;
}
@ -342,6 +342,8 @@ gui_bar_config_change_position (void *data, struct t_config_option *option)
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
gui_bar_refresh (ptr_bar);
gui_window_refresh_needed = 1;
}
/*
@ -355,10 +357,12 @@ gui_bar_config_change_filling (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
gui_bar_refresh (ptr_bar);
gui_window_refresh_needed = 1;
}
/*
@ -386,10 +390,16 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
if (number < 0)
return 0;
if (number <= ptr_bar->current_size
|| gui_bar_check_size_add (ptr_bar,
number - ptr_bar->current_size))
return 1;
if ((number != 0) &&
((CONFIG_INTEGER(ptr_bar->size) == 0)
|| (number > CONFIG_INTEGER(ptr_bar->size))))
{
if (!gui_bar_check_size_add (ptr_bar,
number - CONFIG_INTEGER(ptr_bar->size)))
return 0;
}
return 1;
}
}
@ -407,13 +417,13 @@ gui_bar_config_change_size (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
{
ptr_bar->current_size = (CONFIG_INTEGER(ptr_bar->size) == 0) ?
1 : CONFIG_INTEGER(ptr_bar->size);
gui_bar_refresh (ptr_bar);
gui_bar_window_set_current_size (ptr_bar,
CONFIG_INTEGER(ptr_bar->size_max));
gui_window_refresh_needed = 1;
}
}
@ -424,22 +434,11 @@ gui_bar_config_change_size (void *data, struct t_config_option *option)
void
gui_bar_config_change_size_max (void *data, struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
(void) data;
(void) option;
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
{
if ((CONFIG_INTEGER(ptr_bar->size_max) > 0)
&& (ptr_bar->current_size > CONFIG_INTEGER(ptr_bar->size_max)))
{
gui_bar_set_current_size (ptr_bar,
CONFIG_INTEGER(ptr_bar->size_max));
}
gui_window_refresh_needed = 1;
}
gui_window_refresh_needed = 1;
}
/*
@ -663,31 +662,6 @@ gui_bar_set_position (struct t_gui_bar *bar, char *position)
}
}
/*
* gui_bar_set_current_size: set current size for a bar
*/
void
gui_bar_set_current_size (struct t_gui_bar *bar, int current_size)
{
if (current_size < 0)
return;
if (current_size == 0)
current_size = 1;
if ((CONFIG_INTEGER(bar->size_max) > 0)
&& (current_size > CONFIG_INTEGER(bar->size_max)))
current_size = CONFIG_INTEGER(bar->size_max);
/* check if new size is ok if it's more than before */
if (current_size > bar->current_size
&& !gui_bar_check_size_add (bar, current_size - bar->current_size))
return;
bar->current_size = current_size;
}
/*
* gui_bar_set_size: set size for a bar
*/
@ -708,23 +682,28 @@ gui_bar_set_size (struct t_gui_bar *bar, char *size)
{
new_size = number;
if (size[0] == '+')
new_size = bar->current_size + new_size;
new_size = CONFIG_INTEGER(bar->size) + new_size;
else if (value[0] == '-')
new_size = bar->current_size - new_size;
new_size = CONFIG_INTEGER(bar->size) - new_size;
if ((size[0] == '-') && (new_size < 1))
return;
if (new_size < 0)
return;
/* check if new size is ok if it's more than before */
if (new_size > bar->current_size
&& !gui_bar_check_size_add (bar, new_size - bar->current_size))
return;
if ((new_size != 0) &&
((CONFIG_INTEGER(bar->size) == 0)
|| (new_size > CONFIG_INTEGER(bar->size))))
{
if (!gui_bar_check_size_add (bar,
new_size - CONFIG_INTEGER(bar->size)))
return;
}
snprintf (value, sizeof (value), "%d", new_size);
config_file_option_set (bar->size, value, 1);
bar->current_size = (new_size == 0) ? 1 : new_size;
gui_bar_window_set_current_size (bar, new_size);
}
}
@ -748,7 +727,9 @@ gui_bar_set_size_max (struct t_gui_bar *bar, char *size)
snprintf (value, sizeof (value), "%ld", number);
config_file_option_set (bar->size_max, value, 1);
if ((number > 0) && (number < bar->current_size))
if ((number > 0) &&
((CONFIG_INTEGER(bar->size) == 0)
|| (number < CONFIG_INTEGER(bar->size))))
gui_bar_set_size (bar, value);
}
}
@ -792,13 +773,11 @@ gui_bar_set (struct t_gui_bar *bar, char *property, char *value)
else if (string_strcasecmp (property, "position") == 0)
{
gui_bar_set_position (bar, value);
gui_bar_refresh (bar);
return 1;
}
else if (string_strcasecmp (property, "filling") == 0)
{
config_file_option_set (bar->filling, value, 1);
gui_bar_refresh (bar);
return 1;
}
else if (string_strcasecmp (property, "size") == 0)
@ -868,7 +847,6 @@ gui_bar_alloc (char *name)
new_bar->color_bg = NULL;
new_bar->separator = NULL;
new_bar->items = NULL;
new_bar->current_size = 1;
new_bar->conditions_count = 0;
new_bar->conditions_array = NULL;
new_bar->items_count = 0;
@ -1043,8 +1021,6 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name,
new_bar->position = position;
new_bar->filling = filling;
new_bar->size = size;
new_bar->current_size = (CONFIG_INTEGER(size) == 0) ?
1 : CONFIG_INTEGER(size);
new_bar->size_max = size_max;
new_bar->color_fg = color_fg;
new_bar->color_bg = color_bg;
@ -1472,7 +1448,6 @@ gui_bar_print_log ()
log_printf (" color_bg . . . . . . . : %d",
CONFIG_COLOR(ptr_bar->color_bg),
gui_color_get_name (CONFIG_COLOR(ptr_bar->color_bg)));
log_printf (" current_size . . . . . : %d", ptr_bar->current_size);
log_printf (" separator. . . . . . . : %d", CONFIG_INTEGER(ptr_bar->separator));
log_printf (" items. . . . . . . . . : '%s'", CONFIG_STRING(ptr_bar->items));
log_printf (" items_count. . . . . . : %d", ptr_bar->items_count);

View File

@ -83,7 +83,6 @@ struct t_gui_bar
struct t_config_option *items; /* bar items */
/* internal vars */
int current_size; /* current bar size (strictly > 0) */
int conditions_count; /* number of conditions */
char **conditions_array; /* exploded bar conditions */
int items_count; /* number of bar items */
@ -137,6 +136,8 @@ extern void gui_bar_print_log ();
extern struct t_gui_bar_window *gui_bar_window_search_bar (struct t_gui_window *window,
struct t_gui_bar *bar);
extern int gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window);
extern void gui_bar_window_set_current_size (struct t_gui_bar *bar, int size);
extern int gui_bar_window_get_size (struct t_gui_bar *bar,
struct t_gui_window *window,
enum t_gui_bar_position position);