diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 13 | ||||
-rw-r--r-- | src/core/wee-config.c | 42 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-bar.c | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-bar.c | 2 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 412 | ||||
-rw-r--r-- | src/gui/gui-bar.h | 21 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 11 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 28 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 12 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 21 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 17 |
11 files changed, 322 insertions, 261 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index f54dd57cf..fb4266c62 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -88,9 +88,8 @@ command_bar (void *data, struct t_gui_buffer *buffer, 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: %s (cond: %s), %s, filling: %s, " "%s: %s"), - ptr_bar->number, GUI_COLOR(GUI_COLOR_CHAT_BUFFER), ptr_bar->name, GUI_COLOR(GUI_COLOR_CHAT), @@ -105,8 +104,9 @@ command_bar (void *data, struct t_gui_buffer *buffer, _("height") : _("width"), (CONFIG_INTEGER(ptr_bar->size) == 0) ? _("auto") : str_size); gui_chat_printf (NULL, - _(" fg: %s, bg: %s, items: %s%s (plugin: " + _(" priority: %d, fg: %s, bg: %s, items: %s%s (plugin: " "%s)"), + CONFIG_INTEGER(ptr_bar->priority), gui_color_get_name (CONFIG_COLOR(ptr_bar->color_fg)), gui_color_get_name (CONFIG_COLOR(ptr_bar->color_bg)), (CONFIG_STRING(ptr_bar->items) && CONFIG_STRING(ptr_bar->items)[0]) ? @@ -202,7 +202,8 @@ command_bar (void *data, struct t_gui_buffer *buffer, if (error && !error[0]) { /* create bar */ - if (gui_bar_new (NULL, argv[2], str_type, pos_condition, argv[4], + if (gui_bar_new (NULL, argv[2], "0", str_type, pos_condition, + argv[4], ((position == GUI_BAR_POSITION_LEFT) || (position == GUI_BAR_POSITION_RIGHT)) ? "vertical" : "horizontal", @@ -2509,7 +2510,7 @@ command_init () N_("manage bars"), N_("[add barname type[,cond1,cond2,...] position size " "separator item1,item2,...] | [del barname] | " - "[set barname name|number|condition|position|filling|" + "[set barname name|priority|condition|position|filling|" "size|separator|items value] | [list] | [listitems]"), N_(" add: add a new bar\n" " barname: name of bar (must be unique)\n" @@ -2532,7 +2533,7 @@ command_init () " set: set a value for a bar property\n" " list: list all bars\n" "listitems: list all bar items"), - "add|del|set|list|listitems %r name|number|conditions|" + "add|del|set|list|listitems %r name|priority|conditions|" "position|filling|size|separator|items", &command_bar, NULL); hook_command (NULL, "buffer", diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 162d747aa..fef497462 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -538,7 +538,6 @@ config_weechat_bar_read (void *data, struct t_config_file *config_file, { char *pos_option, *bar_name; struct t_gui_bar *ptr_temp_bar; - struct t_config_option *ptr_option; int index_option; /* make C compiler happy */ @@ -584,45 +583,8 @@ config_weechat_bar_read (void *data, struct t_config_file *config_file, index_option = gui_bar_search_option (pos_option); if (index_option >= 0) { - ptr_option = gui_bar_create_option (ptr_temp_bar->name, - index_option, - value); - if (ptr_option) - { - switch (index_option) - { - case GUI_BAR_OPTION_TYPE: - ptr_temp_bar->type = ptr_option; - break; - case GUI_BAR_OPTION_CONDITIONS: - ptr_temp_bar->conditions = ptr_option; - break; - case GUI_BAR_OPTION_POSITION: - ptr_temp_bar->position = ptr_option; - break; - case GUI_BAR_OPTION_FILLING: - ptr_temp_bar->filling = ptr_option; - break; - case GUI_BAR_OPTION_SIZE: - ptr_temp_bar->size = ptr_option; - break; - case GUI_BAR_OPTION_SIZE_MAX: - ptr_temp_bar->size_max = ptr_option; - break; - case GUI_BAR_OPTION_COLOR_FG: - ptr_temp_bar->color_fg = ptr_option; - break; - case GUI_BAR_OPTION_COLOR_BG: - ptr_temp_bar->color_bg = ptr_option; - break; - case GUI_BAR_OPTION_SEPARATOR: - ptr_temp_bar->separator = ptr_option; - break; - case GUI_BAR_OPTION_ITEMS: - ptr_temp_bar->items = ptr_option; - break; - } - } + gui_bar_create_option_temp (ptr_temp_bar, index_option, + value); } } diff --git a/src/gui/curses/gui-curses-bar.c b/src/gui/curses/gui-curses-bar.c index 21207f7de..fd644ad05 100644 --- a/src/gui/curses/gui-curses-bar.c +++ b/src/gui/curses/gui-curses-bar.c @@ -309,7 +309,7 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window) /* * gui_bar_window_find_pos: find position for bar window (keeping list sorted - * by bar number) + * by bar priority) */ struct t_gui_bar_window * @@ -320,7 +320,7 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window) for (ptr_bar_window = GUI_CURSES(window)->bar_windows; ptr_bar_window; ptr_bar_window = ptr_bar_window->next_bar_window) { - if (ptr_bar_window->bar->number > bar->number) + if (CONFIG_INTEGER(bar->priority) >= CONFIG_INTEGER(ptr_bar_window->bar->priority)) return ptr_bar_window; } diff --git a/src/gui/gtk/gui-gtk-bar.c b/src/gui/gtk/gui-gtk-bar.c index d4853d97d..60fac1be7 100644 --- a/src/gui/gtk/gui-gtk-bar.c +++ b/src/gui/gtk/gui-gtk-bar.c @@ -165,7 +165,7 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window) for (ptr_bar_window = GUI_GTK(window)->bar_windows; ptr_bar_window; ptr_bar_window = ptr_bar_window->next_bar_window) { - if (ptr_bar_window->bar->number > bar->number) + if (CONFIG_INTEGER(bar->priority) >= CONFIG_INTEGER(ptr_bar_window->bar->priority)) return ptr_bar_window; } diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 29a6c834a..abd5d99d8 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -39,7 +39,7 @@ char *gui_bar_option_str[GUI_BAR_NUM_OPTIONS] = -{ "type", "conditions", "position", "filling", "size", "size_max", +{ "priority", "type", "conditions", "position", "filling", "size", "size_max", "color_fg", "color_bg", "separator", "items" }; char *gui_bar_type_str[GUI_BAR_NUM_TYPES] = { "root", "window" }; @@ -120,6 +120,68 @@ gui_bar_search_position (char *position) } /* + * gui_bar_find_pos: find position for a bar in list (keeping list sorted + * by priority) + */ + +struct t_gui_bar * +gui_bar_find_pos (struct t_gui_bar *bar) +{ + struct t_gui_bar *ptr_bar; + + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if (CONFIG_INTEGER(bar->priority) >= CONFIG_INTEGER(ptr_bar->priority)) + return ptr_bar; + } + + /* bar not found, add to end of list */ + return NULL; +} + +/* + * gui_bar_insert: insert a bar to the list (at good position, according to + * priority) + */ + +void +gui_bar_insert (struct t_gui_bar *bar) +{ + struct t_gui_bar *pos_bar; + + if (gui_bars) + { + pos_bar = gui_bar_find_pos (bar); + if (pos_bar) + { + /* insert bar into the list (before position found) */ + bar->prev_bar = pos_bar->prev_bar; + bar->next_bar = pos_bar; + if (pos_bar->prev_bar) + (pos_bar->prev_bar)->next_bar = bar; + else + gui_bars = bar; + pos_bar->prev_bar = bar; + } + else + { + /* add bar to the end */ + bar->prev_bar = last_gui_bar; + bar->next_bar = NULL; + last_gui_bar->next_bar = bar; + last_gui_bar = bar; + } + } + else + { + bar->prev_bar = NULL; + bar->next_bar = NULL; + gui_bars = bar; + last_gui_bar = bar; + } +} + +/* * gui_bar_check_conditions_for_window: return 1 if bar should be displayed in * this window, according to condition(s) * on bar @@ -203,25 +265,6 @@ gui_bar_search (char *name) } /* - * gui_bar_search_by_number: search a bar by number - */ - -struct t_gui_bar * -gui_bar_search_by_number (int number) -{ - struct t_gui_bar *ptr_bar; - - for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) - { - if (ptr_bar->number == number) - return ptr_bar; - } - - /* bar not found */ - return NULL; -} - -/* * gui_bar_search_with_option_name: search a bar with name of option * (like "uptime.type") */ @@ -545,11 +588,13 @@ gui_bar_set_name (struct t_gui_bar *bar, char *name) if (!name || !name[0]) return; - + length = strlen (name) + 64; option_name = malloc (length); if (option_name) { + snprintf (option_name, length, "%s.priority", name); + config_file_option_rename (bar->priority, option_name); snprintf (option_name, length, "%s.type", name); config_file_option_rename (bar->type, option_name); snprintf (option_name, length, "%s.conditions", name); @@ -580,89 +625,61 @@ gui_bar_set_name (struct t_gui_bar *bar, char *name) } /* - * gui_bar_set_number: set number for a bar + * gui_bar_set_priority: set priority for a bar */ void -gui_bar_set_number (struct t_gui_bar *bar, int number) +gui_bar_set_priority (struct t_gui_bar *bar, char *priority) { + long number; + char *error; struct t_gui_bar *ptr_bar; struct t_gui_window *ptr_win; - int i; - - if (number < 1) - number = 1; - - /* bar number is already ok? */ - if (number == bar->number) - return; - /* remove bar from list */ - if (bar == gui_bars) - { - gui_bars = bar->next_bar; - gui_bars->prev_bar = NULL; - } - if (bar == last_gui_bar) - { - last_gui_bar = bar->prev_bar; - last_gui_bar->next_bar = NULL; - } - if (bar->prev_bar) - (bar->prev_bar)->next_bar = bar->next_bar; - if (bar->next_bar) - (bar->next_bar)->prev_bar = bar->prev_bar; - - if (number == 1) - { - gui_bars->prev_bar = bar; - bar->prev_bar = NULL; - bar->next_bar = gui_bars; - gui_bars = bar; - } - else + error = NULL; + number = strtol (priority, &error, 10); + if (error && !error[0]) { - /* assign new number to all bars */ - i = 1; - for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) - { - ptr_bar->number = i++; - } + if (number < 0) + number = 0; + + /* bar number is already ok? */ + if (number == CONFIG_INTEGER(bar->priority)) + return; - ptr_bar = gui_bar_search_by_number (number); - if (ptr_bar) + config_file_option_set (bar->priority, priority, 1); + + /* remove bar from list */ + if (bar == gui_bars) { - /* add bar before ptr_bar */ - bar->prev_bar = ptr_bar->prev_bar; - bar->next_bar = ptr_bar; - if (ptr_bar->prev_bar) - (ptr_bar->prev_bar)->next_bar = bar; - ptr_bar->prev_bar = bar; + gui_bars = bar->next_bar; + gui_bars->prev_bar = NULL; } - else + if (bar == last_gui_bar) { - /* add to end of list */ - bar->prev_bar = last_gui_bar; - bar->next_bar = NULL; - last_gui_bar->next_bar = bar; - last_gui_bar = bar; + last_gui_bar = bar->prev_bar; + last_gui_bar->next_bar = NULL; } - } - - /* assign new number to all bars */ - i = 1; - for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) - { - ptr_bar->number = i++; - gui_bar_free_bar_windows (ptr_bar); - } - - for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) - { + if (bar->prev_bar) + (bar->prev_bar)->next_bar = bar->next_bar; + if (bar->next_bar) + (bar->next_bar)->prev_bar = bar->prev_bar; + + gui_bar_insert (bar); + + /* free 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) - gui_bar_window_new (ptr_bar, ptr_win); + gui_bar_free_bar_windows (ptr_bar); + } + + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + { + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if (CONFIG_INTEGER(ptr_bar->type) != GUI_BAR_TYPE_ROOT) + gui_bar_window_new (ptr_bar, ptr_win); + } } } } @@ -766,9 +783,6 @@ gui_bar_set_size_max (struct t_gui_bar *bar, char *size) int gui_bar_set (struct t_gui_bar *bar, char *property, char *value) { - long number; - char *error; - if (!bar || !property || !value) return 0; @@ -777,15 +791,10 @@ gui_bar_set (struct t_gui_bar *bar, char *property, char *value) gui_bar_set_name (bar, value); return 1; } - else if (string_strcasecmp (property, "number") == 0) + else if (string_strcasecmp (property, "priority") == 0) { - error = NULL; - number = strtol (value, &error, 10); - if (error && !error[0]) - { - gui_bar_set_number (bar, number); - gui_window_refresh_needed = 1; - } + gui_bar_set_priority (bar, value); + gui_window_refresh_needed = 1; return 1; } else if (string_strcasecmp (property, "conditions") == 0) @@ -847,43 +856,6 @@ gui_bar_set (struct t_gui_bar *bar, char *property, char *value) } /* - * gui_bar_alloc: allocate and initialize new bar structure - */ - -struct t_gui_bar * -gui_bar_alloc (char *name) -{ - struct t_gui_bar *new_bar; - - new_bar = malloc (sizeof (*new_bar)); - if (new_bar) - { - new_bar->plugin = NULL; - new_bar->number = 0; - new_bar->name = strdup (name); - new_bar->type = NULL; - new_bar->conditions = NULL; - new_bar->position = NULL; - new_bar->filling = NULL; - new_bar->size = NULL; - new_bar->size_max = NULL; - new_bar->color_fg = NULL; - new_bar->color_bg = NULL; - new_bar->separator = NULL; - new_bar->items = NULL; - new_bar->conditions_count = 0; - new_bar->conditions_array = NULL; - new_bar->items_count = 0; - new_bar->items_array = NULL; - new_bar->bar_window = NULL; - new_bar->prev_bar = NULL; - new_bar->next_bar = NULL; - } - - return new_bar; -} - -/* * gui_bar_create_option: create an option for a bar */ @@ -905,6 +877,14 @@ gui_bar_create_option (char *bar_name, int index_option, char *value) switch (index_option) { + case GUI_BAR_OPTION_PRIORITY: + ptr_option = config_file_new_option ( + weechat_config_file, weechat_config_section_bar, + option_name, "integer", + N_("bar priority (high number means bar displayed first)"), + NULL, 0, INT_MAX, value, + NULL, NULL, NULL, NULL, NULL, NULL); + break; case GUI_BAR_OPTION_TYPE: ptr_option = config_file_new_option ( weechat_config_file, weechat_config_section_bar, @@ -1004,11 +984,104 @@ gui_bar_create_option (char *bar_name, int index_option, char *value) } /* + * gui_bar_create_option_temp: create option for a temporary bar (when reading + * config file) + */ + +void +gui_bar_create_option_temp (struct t_gui_bar *temp_bar, int index_option, + char *value) +{ + struct t_config_option *new_option; + + new_option = gui_bar_create_option (temp_bar->name, + index_option, + value); + if (new_option) + { + switch (index_option) + { + case GUI_BAR_OPTION_PRIORITY: + temp_bar->priority = new_option; + break; + case GUI_BAR_OPTION_TYPE: + temp_bar->type = new_option; + break; + case GUI_BAR_OPTION_CONDITIONS: + temp_bar->conditions = new_option; + break; + case GUI_BAR_OPTION_POSITION: + temp_bar->position = new_option; + break; + case GUI_BAR_OPTION_FILLING: + temp_bar->filling = new_option; + break; + case GUI_BAR_OPTION_SIZE: + temp_bar->size = new_option; + break; + case GUI_BAR_OPTION_SIZE_MAX: + temp_bar->size_max = new_option; + break; + case GUI_BAR_OPTION_COLOR_FG: + temp_bar->color_fg = new_option; + break; + case GUI_BAR_OPTION_COLOR_BG: + temp_bar->color_bg = new_option; + break; + case GUI_BAR_OPTION_SEPARATOR: + temp_bar->separator = new_option; + break; + case GUI_BAR_OPTION_ITEMS: + temp_bar->items = new_option; + break; + } + } +} + +/* + * gui_bar_alloc: allocate and initialize new bar structure + */ + +struct t_gui_bar * +gui_bar_alloc (char *name) +{ + struct t_gui_bar *new_bar; + + new_bar = malloc (sizeof (*new_bar)); + if (new_bar) + { + new_bar->plugin = NULL; + new_bar->name = strdup (name); + new_bar->priority = 0; + new_bar->type = NULL; + new_bar->conditions = NULL; + new_bar->position = NULL; + new_bar->filling = NULL; + new_bar->size = NULL; + new_bar->size_max = NULL; + new_bar->color_fg = NULL; + new_bar->color_bg = NULL; + new_bar->separator = NULL; + new_bar->items = NULL; + new_bar->conditions_count = 0; + new_bar->conditions_array = NULL; + new_bar->items_count = 0; + new_bar->items_array = NULL; + new_bar->bar_window = NULL; + new_bar->prev_bar = NULL; + new_bar->next_bar = NULL; + } + + return new_bar; +} + +/* * gui_bar_new_with_options: create a new bar with options */ struct t_gui_bar * gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name, + struct t_config_option *priority, struct t_config_option *type, struct t_config_option *conditions, struct t_config_option *position, @@ -1028,7 +1101,7 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name, if (new_bar) { new_bar->plugin = plugin; - new_bar->number = (last_gui_bar) ? last_gui_bar->number + 1 : 1; + new_bar->priority = priority; new_bar->type = type; new_bar->conditions = conditions; if (CONFIG_STRING(conditions) && CONFIG_STRING(conditions)[0]) @@ -1063,14 +1136,8 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name, } new_bar->bar_window = NULL; - /* add bar to bars queue */ - new_bar->prev_bar = last_gui_bar; - if (gui_bars) - last_gui_bar->next_bar = new_bar; - else - gui_bars = new_bar; - last_gui_bar = new_bar; - new_bar->next_bar = NULL; + /* add bar to bars list */ + gui_bar_insert (new_bar); /* add window bar */ if (CONFIG_INTEGER(new_bar->type) == GUI_BAR_TYPE_ROOT) @@ -1099,13 +1166,13 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name, struct t_gui_bar * gui_bar_new (struct t_weechat_plugin *plugin, char *name, - char *type, char *conditions, char *position, char *filling, - char *size, char *size_max, char *color_fg, char *color_bg, - char *separators, char *items) + char *priority, char *type, char *conditions, char *position, + char *filling, char *size, char *size_max, char *color_fg, + char *color_bg, char *separators, char *items) { - struct t_config_option *option_type, *option_conditions, *option_position; - struct t_config_option *option_filling, *option_size, *option_size_max; - struct t_config_option *option_color_fg, *option_color_bg; + struct t_config_option *option_priority, *option_type, *option_conditions; + struct t_config_option *option_position, *option_filling, *option_size; + struct t_config_option *option_size_max, *option_color_fg, *option_color_bg; struct t_config_option *option_separator, *option_items; struct t_gui_bar *new_bar; @@ -1124,6 +1191,8 @@ gui_bar_new (struct t_weechat_plugin *plugin, char *name, if (gui_bar_search_position (position) < 0) return NULL; + option_priority = gui_bar_create_option (name, GUI_BAR_OPTION_PRIORITY, + priority); option_type = gui_bar_create_option (name, GUI_BAR_OPTION_TYPE, type); option_conditions = gui_bar_create_option (name, GUI_BAR_OPTION_CONDITIONS, @@ -1145,14 +1214,16 @@ gui_bar_new (struct t_weechat_plugin *plugin, char *name, "on" : "off"); option_items = gui_bar_create_option (name, GUI_BAR_OPTION_ITEMS, items); - new_bar = gui_bar_new_with_options (plugin, name, option_type, - option_conditions, option_position, - option_filling, option_size, - option_size_max, option_color_fg, - option_color_bg, option_separator, - option_items); + new_bar = gui_bar_new_with_options (plugin, name, option_priority, + option_type,option_conditions, + option_position, option_filling, + option_size, option_size_max, + option_color_fg, option_color_bg, + option_separator, option_items); if (!new_bar) { + if (option_priority) + config_file_option_free (option_priority); if (option_type) config_file_option_free (option_type); if (option_conditions) @@ -1190,6 +1261,10 @@ gui_bar_use_temp_bars () for (ptr_temp_bar = gui_temp_bars; ptr_temp_bar; ptr_temp_bar = ptr_temp_bar->next_bar) { + 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, @@ -1242,13 +1317,15 @@ gui_bar_use_temp_bars () GUI_BAR_OPTION_ITEMS, ""); - if (ptr_temp_bar->type && ptr_temp_bar->conditions - && ptr_temp_bar->position && ptr_temp_bar->filling - && ptr_temp_bar->size && ptr_temp_bar->size_max - && ptr_temp_bar->color_fg && ptr_temp_bar->color_bg - && ptr_temp_bar->separator && ptr_temp_bar->items) + if (ptr_temp_bar->priority && ptr_temp_bar->type + && ptr_temp_bar->conditions && ptr_temp_bar->position + && ptr_temp_bar->filling && ptr_temp_bar->size + && ptr_temp_bar->size_max && ptr_temp_bar->color_fg + && ptr_temp_bar->color_bg && ptr_temp_bar->separator + && ptr_temp_bar->items) { gui_bar_new_with_options (NULL, ptr_temp_bar->name, + ptr_temp_bar->priority, ptr_temp_bar->type, ptr_temp_bar->conditions, ptr_temp_bar->position, @@ -1262,6 +1339,11 @@ gui_bar_use_temp_bars () } else { + 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); @@ -1374,6 +1456,8 @@ gui_bar_free (struct t_gui_bar *bar) /* free data */ if (bar->name) free (bar->name); + if (bar->priority) + config_file_option_free (bar->priority); if (bar->type) config_file_option_free (bar->type); if (bar->conditions) @@ -1450,8 +1534,8 @@ gui_bar_print_log () log_printf (""); log_printf ("[bar (addr:0x%x)]", ptr_bar); log_printf (" plugin . . . . . . . . : 0x%x", ptr_bar->plugin); - log_printf (" number . . . . . . . . : %d", ptr_bar->number); log_printf (" name . . . . . . . . . : '%s'", ptr_bar->name); + log_printf (" priority . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->priority)); log_printf (" type . . . . . . . . . : %d (%s)", CONFIG_INTEGER(ptr_bar->type), gui_bar_type_str[CONFIG_INTEGER(ptr_bar->type)]); diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h index 32b91cc63..f0cfb6a2a 100644 --- a/src/gui/gui-bar.h +++ b/src/gui/gui-bar.h @@ -25,7 +25,8 @@ struct t_gui_window; enum t_gui_bar_option { - GUI_BAR_OPTION_TYPE = 0, + GUI_BAR_OPTION_PRIORITY = 0, + GUI_BAR_OPTION_TYPE, GUI_BAR_OPTION_CONDITIONS, GUI_BAR_OPTION_POSITION, GUI_BAR_OPTION_FILLING, @@ -69,8 +70,8 @@ struct t_gui_bar { /* user choices */ struct t_weechat_plugin *plugin; /* plugin */ - int number; /* bar number */ char *name; /* bar name */ + 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 */ @@ -115,16 +116,16 @@ extern int gui_bar_root_get_size (struct t_gui_bar *bar, extern struct t_gui_bar *gui_bar_search (char *name); extern void gui_bar_set_current_size (struct t_gui_bar *bar, int current_size); extern int gui_bar_set (struct t_gui_bar *bar, char *property, char *value); +extern void gui_bar_create_option_temp (struct t_gui_bar *temp_bar, + int index_option, char *value); extern struct t_gui_bar *gui_bar_alloc (char *name); -extern struct t_config_option *gui_bar_create_option (char *bar_name, - int index_option, - char *value); extern struct t_gui_bar *gui_bar_new (struct t_weechat_plugin *plugin, - char *name, char *type, char *conditions, - char *position, char *filling, - char *size, char *size_max, - char *color_fg, char *color_bg, - char *separator, char *items); + char *name, char *priority, char *type, + char *conditions, char *position, + char *filling, char *size, + char *size_max, char *color_fg, + char *color_bg, char *separator, + char *items); extern void gui_bar_use_temp_bars (); extern void gui_bar_update (char *name); extern void gui_bar_free (struct t_gui_bar *bar); diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 9629e9e53..667f55eae 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -3996,8 +3996,8 @@ weechat_lua_api_bar_search (lua_State *L) static int weechat_lua_api_bar_new (lua_State *L) { - const char *name, *type, *conditions, *position, *filling, *size; - const char *size_max, *color_fg, *color_bg, *separator, *items; + const char *name, *priority, *type, *conditions, *position, *filling; + const char *size, *size_max, *color_fg, *color_bg, *separator, *items; char *result; int n; @@ -4011,6 +4011,7 @@ weechat_lua_api_bar_new (lua_State *L) } name = NULL; + priority = NULL; type = NULL; conditions = NULL; position = NULL; @@ -4024,13 +4025,14 @@ weechat_lua_api_bar_new (lua_State *L) n = lua_gettop (lua_current_interpreter); - if (n < 11) + if (n < 12) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); LUA_RETURN_EMPTY; } - name = lua_tostring (lua_current_interpreter, -11); + name = lua_tostring (lua_current_interpreter, -12); + priority = lua_tostring (lua_current_interpreter, -11); type = lua_tostring (lua_current_interpreter, -10); conditions = lua_tostring (lua_current_interpreter, -9); position = lua_tostring (lua_current_interpreter, -8); @@ -4043,6 +4045,7 @@ weechat_lua_api_bar_new (lua_State *L) items = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (weechat_bar_new ((char *)name, + (char *)priority, (char *)type, (char *)conditions, (char *)position, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 0ed6308ee..51698344a 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -3314,8 +3314,8 @@ static XS (XS_weechat_bar_search) static XS (XS_weechat_bar_new) { - char *result, *name, *type, *conditions, *position, *filling, *size; - char *size_max, *color_fg, *color_bg, *separator, *bar_items; + char *result, *name, *priority, *type, *conditions, *position, *filling; + char *size, *size_max, *color_fg, *color_bg, *separator, *bar_items; dXSARGS; /* make C compiler happy */ @@ -3327,24 +3327,26 @@ static XS (XS_weechat_bar_new) PERL_RETURN_EMPTY; } - if (items < 11) + if (items < 12) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); PERL_RETURN_EMPTY; } name = SvPV (ST (0), PL_na); - type = SvPV (ST (1), PL_na); - conditions = SvPV (ST (2), PL_na); - position = SvPV (ST (3), PL_na); - filling = SvPV (ST (4), PL_na); - size = SvPV (ST (5), PL_na); - size_max = SvPV (ST (6), PL_na); - color_fg = SvPV (ST (7), PL_na); - color_bg = SvPV (ST (8), PL_na); - separator = SvPV (ST (9), PL_na); - bar_items = SvPV (ST (10), PL_na); + priority = SvPV (ST (1), PL_na); + type = SvPV (ST (2), PL_na); + conditions = SvPV (ST (3), PL_na); + position = SvPV (ST (4), PL_na); + filling = SvPV (ST (5), PL_na); + size = SvPV (ST (6), PL_na); + size_max = SvPV (ST (7), PL_na); + color_fg = SvPV (ST (8), PL_na); + color_bg = SvPV (ST (9), PL_na); + separator = SvPV (ST (10), PL_na); + bar_items = SvPV (ST (11), PL_na); result = script_ptr2str (weechat_bar_new (name, + priority, type, conditions, position, diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index cbd5da57a..87a7c53c4 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -3527,8 +3527,8 @@ weechat_python_api_bar_search (PyObject *self, PyObject *args) static PyObject * weechat_python_api_bar_new (PyObject *self, PyObject *args) { - char *name, *type, *conditions, *position, *filling, *size, *size_max; - char *color_fg, *color_bg, *separator, *items, *result; + char *name, *priority, *type, *conditions, *position, *filling, *size; + char *size_max, *color_fg, *color_bg, *separator, *items, *result; PyObject *object; /* make C compiler happy */ @@ -3541,6 +3541,7 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args) } name = NULL; + priority = NULL; type = NULL; conditions = NULL; position = NULL; @@ -3552,15 +3553,16 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args) separator = NULL; items = NULL; - if (!PyArg_ParseTuple (args, "sssssssssss", &name, &conditions, &type, - &position, &filling, &size, &size_max, &color_fg, - &color_bg, &separator, &items)) + if (!PyArg_ParseTuple (args, "ssssssssssss", &name, &priority, &conditions, + &type, &position, &filling, &size, &size_max, + &color_fg, &color_bg, &separator, &items)) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); PYTHON_RETURN_EMPTY; } result = script_ptr2str (weechat_bar_new (name, + priority, type, conditions, position, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 158601ec0..6b72b6ec4 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -4050,13 +4050,14 @@ weechat_ruby_api_bar_search (VALUE class, VALUE name) */ static VALUE -weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, +weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE priority, VALUE type, VALUE conditions, VALUE position, VALUE filling, VALUE size, VALUE size_max, VALUE color_fg, VALUE color_bg, VALUE separator, VALUE items) { - char *c_name, *c_type, *c_conditions, *c_position, *c_filling, *c_size; - char *c_size_max, *c_color_fg, *c_color_bg, *c_separator, *c_items; + char *c_name, *c_priority, *c_type, *c_conditions, *c_position, *c_filling; + char *c_size, *c_size_max, *c_color_fg, *c_color_bg, *c_separator; + char *c_items; char *result; VALUE return_value; @@ -4070,6 +4071,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, } c_name = NULL; + c_priority = NULL; c_type = NULL; c_conditions = NULL; c_position = NULL; @@ -4081,16 +4083,17 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, c_separator = NULL; c_items = NULL; - if (NIL_P (name) || NIL_P (type) || NIL_P (conditions) || NIL_P (position) - || NIL_P (filling) || NIL_P (size) || NIL_P (size_max) - || NIL_P (color_fg) || NIL_P (color_bg) || NIL_P (separator) - || NIL_P (items)) + if (NIL_P (name) || NIL_P (priority) || NIL_P (type) || NIL_P (conditions) + || NIL_P (position) || NIL_P (filling) || NIL_P (size) + || NIL_P (size_max) || NIL_P (color_fg) || NIL_P (color_bg) + || NIL_P (separator) || NIL_P (items)) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); RUBY_RETURN_EMPTY; } Check_Type (name, T_STRING); + Check_Type (priority, T_STRING); Check_Type (type, T_STRING); Check_Type (conditions, T_STRING); Check_Type (position, T_STRING); @@ -4103,6 +4106,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, Check_Type (items, T_STRING); c_name = STR2CSTR (name); + c_priority = STR2CSTR (priority); c_type = STR2CSTR (type); c_conditions = STR2CSTR (conditions); c_position = STR2CSTR (position); @@ -4115,6 +4119,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, c_items = STR2CSTR (items); result = script_ptr2str (weechat_bar_new (c_name, + c_priority, c_type, c_conditions, c_position, @@ -4725,7 +4730,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "bar_item_update", &weechat_ruby_api_bar_item_update, 1); rb_define_module_function (ruby_mWeechat, "bar_item_remove", &weechat_ruby_api_bar_item_remove, 1); rb_define_module_function (ruby_mWeechat, "bar_search", &weechat_ruby_api_bar_search, 1); - rb_define_module_function (ruby_mWeechat, "bar_new", &weechat_ruby_api_bar_new, 11); + rb_define_module_function (ruby_mWeechat, "bar_new", &weechat_ruby_api_bar_new, 12); rb_define_module_function (ruby_mWeechat, "bar_set", &weechat_ruby_api_bar_set, 3); rb_define_module_function (ruby_mWeechat, "bar_update", &weechat_ruby_api_bar_update, 1); rb_define_module_function (ruby_mWeechat, "bar_remove", &weechat_ruby_api_bar_remove, 1); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 7eeed8326..b9baf6a50 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -376,10 +376,11 @@ struct t_weechat_plugin void (*bar_item_remove) (struct t_gui_bar_item *item); struct t_gui_bar *(*bar_search) (char *name); struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin, char *name, - char *type, char *condition, char *position, - char *filling, char *size, char *size_max, - char *color_fg, char *color_bg, - char *separator, char *items); + char *priority, char *type, char *condition, + char *position, char *filling, char *size, + char *size_max, char *color_fg, + char *color_bg, char *separator, + char *items); int (*bar_set) (struct t_gui_bar *bar, char *property, char *value); void (*bar_update) (char *name); void (*bar_remove) (struct t_gui_bar *bar); @@ -773,10 +774,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_plugin->bar_item_remove(__item) #define weechat_bar_search(__name) \ weechat_plugin->bar_search(__name) -#define weechat_bar_new(__name, __type, __condition, __position, \ - __filling, __size, __size_max, __color_fg, \ - __color_bg, __separator, __items) \ - weechat_plugin->bar_new(weechat_plugin, __name, __type, \ +#define weechat_bar_new(__name, __priority, __type, __condition, \ + __position, __filling, __size, __size_max, \ + __color_fg, __color_bg, __separator, __items) \ + weechat_plugin->bar_new(weechat_plugin, __name, __priority, __type, \ __condition, __position, __filling, __size, \ __size_max, __color_fg, __color_bg, \ __separator, __items) |