1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

Add infolists for bars/bar items/bar windows, code cleanup for bars

This commit is contained in:
Sebastien Helleu
2008-12-13 19:43:11 +01:00
parent 6f74945a66
commit ec545c70b1
28 changed files with 968 additions and 322 deletions
+3 -5
View File
@@ -101,16 +101,14 @@ command_bar_list (int full)
_("height") : _("width"),
(CONFIG_INTEGER(ptr_bar->size) == 0) ? _("auto") : str_size);
gui_chat_printf (NULL,
_(" priority: %d, fg: %s, bg: %s, items: %s%s (plugin: "
"%s)"),
_(" priority: %d, fg: %s, bg: %s, items: %s%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]) ?
CONFIG_STRING(ptr_bar->items) : "-",
(CONFIG_INTEGER(ptr_bar->separator)) ?
_(", with separator") : "",
(ptr_bar->plugin) ? ptr_bar->plugin->name : "-");
_(", with separator") : "");
}
else
{
@@ -246,7 +244,7 @@ command_bar (void *data, struct t_gui_buffer *buffer,
if (error && !error[0])
{
/* create bar */
if (gui_bar_new (NULL, argv[2], "0", "0", str_type,
if (gui_bar_new (argv[2], "0", "0", str_type,
(pos_condition) ? pos_condition : "",
argv[4],
"horizontal", "vertical",
+24 -20
View File
@@ -112,33 +112,37 @@ gui_main_init ()
/* init bar items */
gui_bar_item_init ();
/* create new window/buffer */
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
{
gui_current_window = gui_windows;
ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL);
if (ptr_buffer)
{
gui_init_ok = 1;
gui_buffer_set_title (ptr_buffer,
"WeeChat " WEECHAT_COPYRIGHT_DATE
" - " WEECHAT_WEBSITE);
}
else
gui_init_ok = 0;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_set ();
}
gui_init_ok = 0;
if (gui_init_ok)
/* create core buffer */
ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL);
if (ptr_buffer)
{
gui_init_ok = 1;
/* set title for core buffer */
gui_buffer_set_title (ptr_buffer,
"WeeChat " WEECHAT_COPYRIGHT_DATE
" - " WEECHAT_WEBSITE);
/* create main window (using full space) */
if (gui_window_new (NULL, ptr_buffer, 0, 0, COLS, LINES, 100, 100))
{
gui_current_window = gui_windows;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_set ();
}
/* create bar windows for root bars (they were read from config,
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) && (!ptr_bar->bar_window))
if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT)
&& (!ptr_bar->bar_window))
{
gui_bar_window_new (ptr_bar, NULL);
}
}
for (ptr_bar_win = gui_windows->bar_windows;
ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
+2 -4
View File
@@ -980,7 +980,7 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage)
if ((height1 >= GUI_WINDOW_MIN_HEIGHT) && (height2 >= GUI_WINDOW_MIN_HEIGHT)
&& (percentage > 0) && (percentage <= 100))
{
new_window = gui_window_new (window,
new_window = gui_window_new (window, window->buffer,
window->win_x, window->win_y,
window->win_width, height1,
100, percentage);
@@ -992,7 +992,6 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage)
window->win_height_pct = 100 - percentage;
/* assign same buffer for new window (top window) */
new_window->buffer = window->buffer;
new_window->buffer->num_displayed++;
gui_window_switch_to_buffer (window, window->buffer, 1);
@@ -1025,7 +1024,7 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage)
if ((width1 >= GUI_WINDOW_MIN_WIDTH) && (width2 >= GUI_WINDOW_MIN_WIDTH)
&& (percentage > 0) && (percentage <= 100))
{
new_window = gui_window_new (window,
new_window = gui_window_new (window, window->buffer,
window->win_x + width1 + 1, window->win_y,
width2, window->win_height,
percentage, 100);
@@ -1036,7 +1035,6 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage)
window->win_width_pct = 100 - percentage;
/* assign same buffer for new window (right window) */
new_window->buffer = window->buffer;
new_window->buffer->num_displayed++;
gui_window_switch_to_buffer (window, window->buffer, 1);
-7
View File
@@ -59,13 +59,6 @@ extern void gui_color_pre_init ();
extern void gui_color_init ();
extern void gui_color_end ();
/* bar functions */
extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
struct t_gui_window *window);
extern void gui_bar_window_create_win (struct t_gui_bar_window *bar_window);
extern int gui_bar_window_remove_unused_bars (struct t_gui_window *window);
extern int gui_bar_window_add_missing_bars (struct t_gui_window *window);
/* chat functions */
extern void gui_chat_calculate_line_diff (struct t_gui_window *window,
struct t_gui_line **line,
+39 -15
View File
@@ -35,6 +35,7 @@
#include "../../plugins/plugin.h"
#include "../gui-bar.h"
#include "../gui-bar-item.h"
#include "../gui-bar-window.h"
#include "../gui-chat.h"
#include "../gui-main.h"
#include "../gui-buffer.h"
@@ -84,6 +85,8 @@ void
gui_main_init ()
{
struct t_gui_buffer *ptr_buffer;
struct t_gui_bar *ptr_bar;
struct t_gui_bar_window *ptr_bar_win;
GdkColor color_fg, color_bg;
gui_color_init ();
@@ -170,23 +173,44 @@ gui_main_init ()
gtk_widget_show_all (gui_gtk_main_window);
/* create new window/buffer */
if (gui_window_new (NULL, 0, 0, 0, 0, 100, 100))
gui_init_ok = 0;
/* create core buffer */
ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL);
if (ptr_buffer)
{
gui_current_window = gui_windows;
ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL);
if (ptr_buffer)
{
gui_init_ok = 1;
gui_buffer_set_title (ptr_buffer,
PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE
" - " WEECHAT_WEBSITE);
}
else
gui_init_ok = 0;
gui_init_ok = 1;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_set ();
/* set title for core buffer */
gui_buffer_set_title (ptr_buffer,
"WeeChat " WEECHAT_COPYRIGHT_DATE
" - " WEECHAT_WEBSITE);
/* create main window (using full space) */
if (gui_window_new (NULL, ptr_buffer, 0, 0, 0, 0, 100, 100))
{
gui_current_window = gui_windows;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_set ();
}
/* create bar windows for root bars (they were read from config,
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)
&& (!ptr_bar->bar_window))
{
gui_bar_window_new (ptr_bar, NULL);
}
}
for (ptr_bar_win = gui_windows->bar_windows;
ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
{
gui_bar_window_calculate_pos_size (ptr_bar_win, gui_windows);
gui_bar_window_create_win (ptr_bar_win);
}
}
}
+2 -4
View File
@@ -480,7 +480,7 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage)
if ((percentage > 0) && (percentage <= 100))
{
new_window = gui_window_new (window,
new_window = gui_window_new (window, window->buffer,
window->win_x, window->win_y,
window->win_width, height1,
100, percentage);
@@ -492,7 +492,6 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage)
window->win_height_pct = 100 - percentage;
/* assign same buffer for new window (top window) */
new_window->buffer = window->buffer;
new_window->buffer->num_displayed++;
gui_window_switch_to_buffer (window, window->buffer, 1);
@@ -526,7 +525,7 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage)
if ((percentage > 0) && (percentage <= 100))
{
new_window = gui_window_new (window,
new_window = gui_window_new (window, window->buffer,
window->win_x + width1 + 1, window->win_y,
width2, window->win_height,
percentage, 100);
@@ -537,7 +536,6 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage)
window->win_width_pct = 100 - percentage;
/* assign same buffer for new window (right window) */
new_window->buffer = window->buffer;
new_window->buffer->num_displayed++;
gui_window_switch_to_buffer (window, window->buffer, 1);
+92 -27
View File
@@ -30,12 +30,14 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
#include "../plugins/plugin.h"
#include "gui-bar-item.h"
#include "gui-bar.h"
#include "gui-bar-window.h"
#include "gui-buffer.h"
#include "gui-chat.h"
#include "gui-color.h"
@@ -59,6 +61,31 @@ struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL;
struct t_hook *gui_bar_item_timer = NULL;
/*
* gui_bar_item_valid: check if a bar item pointer exists
* return 1 if bar item exists
* 0 if bar item is not found
*/
int
gui_bar_item_valid (struct t_gui_bar_item *bar_item)
{
struct t_gui_bar_item *ptr_bar_item;
if (!bar_item)
return 0;
for (ptr_bar_item = gui_bar_items; ptr_bar_item;
ptr_bar_item = ptr_bar_item->next_item)
{
if (ptr_bar_item == bar_item)
return 1;
}
/* bar item not found */
return 0;
}
/*
* gui_bar_item_search: search a bar item
*/
@@ -189,29 +216,6 @@ gui_bar_item_search_with_plugin (struct t_weechat_plugin *plugin,
return item_found_plugin;
}
/*
* gui_bar_contains_item: return 1 if a bar contains item, O otherwise
*/
int
gui_bar_contains_item (struct t_gui_bar *bar, const char *item_name)
{
int i;
if (!bar || !item_name || !item_name[0])
return 0;
for (i = 0; i < bar->items_count; i++)
{
/* skip non letters chars at beginning (prefix) */
if (gui_bar_item_string_is_item (bar->items_array[i], item_name))
return 1;
}
/* item is not in bar */
return 0;
}
/*
* gui_bar_item_used_in_a_bar: return 1 if an item is used in at least one bar
* if partial_name == 1, then search a bar that
@@ -396,7 +400,8 @@ gui_bar_item_get_value (const char *name, struct t_gui_bar *bar,
item_value = NULL;
if (item_name)
{
ptr_item = gui_bar_item_search_with_plugin ((window) ? window->buffer->plugin : NULL,
ptr_item = gui_bar_item_search_with_plugin ((window && window->buffer) ?
window->buffer->plugin : NULL,
0,
item_name);
if (ptr_item)
@@ -550,13 +555,43 @@ void
gui_bar_item_update (const char *item_name)
{
struct t_gui_bar *ptr_bar;
struct t_gui_window *ptr_window;
struct t_gui_bar_window *ptr_bar_window;
int item_index;
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (!CONFIG_BOOLEAN(ptr_bar->hidden)
&& gui_bar_contains_item (ptr_bar, item_name))
if (!CONFIG_BOOLEAN(ptr_bar->hidden))
{
gui_bar_ask_refresh (ptr_bar);
item_index = gui_bar_get_item_index (ptr_bar, item_name);
if (item_index >= 0)
{
if (ptr_bar->bar_window)
{
gui_bar_window_content_build_item (ptr_bar->bar_window,
NULL,
item_index);
}
else
{
for (ptr_window = gui_windows; ptr_window;
ptr_window = ptr_window->next_window)
{
for (ptr_bar_window = ptr_window->bar_windows;
ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
{
if (ptr_bar_window->bar == ptr_bar)
{
gui_bar_window_content_build_item (ptr_bar_window,
ptr_window,
item_index);
}
}
}
}
gui_bar_ask_refresh (ptr_bar);
}
}
}
}
@@ -1467,6 +1502,36 @@ gui_bar_item_end ()
gui_bar_item_free_all ();
}
/*
* gui_bar_item_add_to_infolist: add a bar item in an infolist
* return 1 if ok, 0 if error
*/
int
gui_bar_item_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar_item *bar_item)
{
struct t_infolist_item *ptr_item;
if (!infolist || !bar_item)
return 0;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_pointer (ptr_item, "plugin", bar_item->plugin))
return 0;
if (!infolist_new_var_string (ptr_item, "name", bar_item->name))
return 0;
if (!infolist_new_var_pointer (ptr_item, "build_callback", bar_item->build_callback))
return 0;
if (!infolist_new_var_pointer (ptr_item, "build_callback_data", bar_item->build_callback_data))
return 0;
return 1;
}
/*
* gui_bar_item_print_log: print bar items infos in log (usually for crash dump)
*/
+5
View File
@@ -71,7 +71,10 @@ extern char *gui_bar_item_names[];
/* functions */
extern int gui_bar_item_valid (struct t_gui_bar_item *bar_item);
extern struct t_gui_bar_item *gui_bar_item_search (const char *name);
extern int gui_bar_item_string_is_item (const char *string,
const char *item_name);
extern int gui_bar_item_used_in_a_bar (const char *item_name,
int partial_name);
extern char *gui_bar_item_get_value (const char *name,
@@ -93,6 +96,8 @@ extern void gui_bar_item_free_all ();
extern void gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin);
extern void gui_bar_item_init ();
extern void gui_bar_item_end ();
extern int gui_bar_item_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar_item *bar_item);
extern void gui_bar_item_print_log ();
#endif /* gui-bar-item.h */
+204 -4
View File
@@ -29,13 +29,55 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "gui-bar-window.h"
#include "gui-bar.h"
#include "gui-bar-item.h"
#include "gui-color.h"
#include "gui-window.h"
/*
* gui_bar_window_valid: check if a bar window pointer exists
* return 1 if bar window exists
* 0 if bar window is not found
*/
int
gui_bar_window_valid (struct t_gui_bar_window *bar_window)
{
struct t_gui_bar *ptr_bar;
struct t_gui_window *ptr_window;
struct t_gui_bar_window *ptr_bar_window;
if (!bar_window)
return 0;
/* check root bars */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (ptr_bar->bar_window && (ptr_bar->bar_window == bar_window))
return 1;
}
/* check window bars */
for (ptr_window = gui_windows; ptr_window;
ptr_window = ptr_window->next_window)
{
for (ptr_bar_window = ptr_window->bar_windows; ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
{
if (ptr_bar_window == bar_window)
return 1;
}
}
/* bar window not found */
return 0;
}
/*
* gui_bar_window_search_bar: search a reference to a bar in a window
*/
@@ -189,6 +231,97 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window)
return NULL;
}
/*
* gui_bar_window_content_alloc: allocate content for a bar window
*/
void
gui_bar_window_content_alloc (struct t_gui_bar_window *bar_window)
{
int i;
bar_window->items_count = bar_window->bar->items_count;
bar_window->items_content = malloc((bar_window->items_count) *
sizeof (bar_window->items_content[0]));
if (bar_window->items_content)
{
for (i = 0; i < bar_window->items_count; i++)
{
bar_window->items_content[i] = NULL;
}
}
else
bar_window->items_count = 0;
}
/*
* gui_bar_window_content_free: free content of a bar window
*/
void
gui_bar_window_content_free (struct t_gui_bar_window *bar_window)
{
int i;
if (bar_window->items_content)
{
for (i = 0; i < bar_window->items_count; i++)
{
if (bar_window->items_content[i])
free (bar_window->items_content[i]);
}
free (bar_window->items_content);
bar_window->items_content = NULL;
}
}
/*
* gui_bar_window_content_build_item: build content of an item for a bar window,
* by calling callback for each item, then
* concat values (according to bar position
* and filling)
*/
void
gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window,
struct t_gui_window *window,
int item_index)
{
log_printf ("bar_window: build item '%s'", bar_window->bar->items_array[item_index]);
if (bar_window->items_content[item_index])
free (bar_window->items_content[item_index]);
bar_window->items_content[item_index] =
gui_bar_item_get_value (bar_window->bar->items_array[item_index],
bar_window->bar, window,
0, 0, 0);
}
/*
* gui_bar_window_content_build: build content of a bar window, by calling
* callback for each item, then concat values
* (according to bar position and filling)
*/
void
gui_bar_window_content_build (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
int i;
if (bar_window->items_count != bar_window->bar->items_count)
{
gui_bar_window_content_free (bar_window);
gui_bar_window_content_alloc (bar_window);
}
for (i = 0; i < bar_window->items_count; i++)
{
gui_bar_window_content_build_item (bar_window, window, i);
}
}
/*
* gui_bar_window_new: create a new "window bar" for a bar, in screen or a window
* if window is not NULL, bar window will be in this window
@@ -262,8 +395,10 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
new_bar_window->cursor_y = -1;
new_bar_window->current_size = (CONFIG_INTEGER(bar->size) == 0) ?
1 : CONFIG_INTEGER(bar->size);
new_bar_window->content = NULL;
new_bar_window->items_content = NULL;
new_bar_window->items_count = 0;
gui_bar_window_objects_init (new_bar_window);
gui_bar_window_content_build (new_bar_window, window);
if (gui_init_ok)
{
@@ -404,8 +539,7 @@ gui_bar_window_free (struct t_gui_bar_window *bar_window,
}
/* free data */
if (bar_window->content)
free (bar_window->content);
gui_bar_window_content_free (bar_window);
gui_bar_window_objects_free (bar_window);
free (bar_window->gui_objects);
@@ -547,6 +681,61 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
}
}
/*
* gui_bar_window_add_to_infolist: add a bar window in an infolist
* return 1 if ok, 0 if error
*/
int
gui_bar_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar_window *bar_window)
{
struct t_infolist_item *ptr_item;
int i;
char option_name[64];
if (!infolist || !bar_window)
return 0;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_pointer (ptr_item, "bar", bar_window->bar))
return 0;
if (!infolist_new_var_integer (ptr_item, "x", bar_window->x))
return 0;
if (!infolist_new_var_integer (ptr_item, "y", bar_window->y))
return 0;
if (!infolist_new_var_integer (ptr_item, "width", bar_window->width))
return 0;
if (!infolist_new_var_integer (ptr_item, "height", bar_window->height))
return 0;
if (!infolist_new_var_integer (ptr_item, "scroll_x", bar_window->scroll_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "scroll_y", bar_window->scroll_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "cursor_x", bar_window->cursor_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "cursor_y", bar_window->cursor_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "current_size", bar_window->current_size))
return 0;
if (!infolist_new_var_integer (ptr_item, "items_count", bar_window->current_size))
return 0;
for (i = 0; i < bar_window->items_count; i++)
{
snprintf (option_name, sizeof (option_name), "items_content_%05d", i + 1);
if (!infolist_new_var_string (ptr_item, option_name,
bar_window->items_content[i]))
return 0;
}
if (!infolist_new_var_pointer (ptr_item, "gui_objects", bar_window->gui_objects))
return 0;
return 1;
}
/*
* gui_bar_window_print_log: print bar window infos in log (usually for crash dump)
*/
@@ -554,8 +743,10 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
void
gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
{
int i;
log_printf ("");
log_printf (" [window bar (addr:0x%lx)]", bar_window);
log_printf (" [window bar (addr:0x%lx)]", bar_window);
log_printf (" bar . . . . . . . : 0x%lx ('%s')",
bar_window->bar,
(bar_window->bar) ? bar_window->bar->name : "");
@@ -568,6 +759,15 @@ gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
log_printf (" cursor_x. . . . . . : %d", bar_window->cursor_x);
log_printf (" cursor_y. . . . . . : %d", bar_window->cursor_y);
log_printf (" current_size. . . . : %d", bar_window->current_size);
log_printf (" items_count . . . . : %d", bar_window->items_count);
for (i = 0; i < bar_window->items_count; i++)
{
log_printf (" items_content[%03d]. : '%s' (item: '%s')",
i,
bar_window->items_content[i],
(bar_window->bar->items_count >= i + 1) ?
bar_window->bar->items_array[i] : "?");
}
log_printf (" gui_objects . . . . : 0x%lx", bar_window->gui_objects);
gui_bar_window_objects_print_log (bar_window);
log_printf (" prev_bar_window . . : 0x%lx", bar_window->prev_bar_window);
+13 -1
View File
@@ -32,7 +32,8 @@ struct t_gui_bar_window
int cursor_x, cursor_y; /* use to move cursor on screen (for */
/* input_text item) */
int current_size; /* current size (width or height) */
char *content; /* bar window content (data displayed) */
int items_count; /* number of items */
char **items_content; /* content for each item of bar */
void *gui_objects; /* pointer to a GUI specific struct */
struct t_gui_bar_window *prev_bar_window; /* link to previous bar win */
/* (only for non-root bars) */
@@ -42,6 +43,12 @@ struct t_gui_bar_window
/* functions */
extern int gui_bar_window_valid (struct t_gui_bar_window *bar_window);
extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
struct t_gui_window *window);
extern void gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window,
struct t_gui_window *window,
int item_index);
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);
@@ -53,11 +60,16 @@ extern int gui_bar_window_new (struct t_gui_bar *bar,
struct t_gui_window *window);
extern void gui_bar_window_free (struct t_gui_bar_window *bar_window,
struct t_gui_window *window);
extern int gui_bar_window_remove_unused_bars (struct t_gui_window *window);
extern int gui_bar_window_add_missing_bars (struct t_gui_window *window);
extern void gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
struct t_gui_window *window,
int add_x, int scroll_beginning,
int scroll_end, int add, int percent,
int value);
extern int gui_bar_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar_window *bar_window);
extern void gui_bar_window_print_log (struct t_gui_bar_window *bar_window);
/* functions (GUI dependent) */
+133 -36
View File
@@ -29,6 +29,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../plugins/plugin.h"
@@ -59,6 +60,30 @@ struct t_gui_bar *gui_temp_bars = NULL; /* bars used when reading config */
struct t_gui_bar *last_gui_temp_bar = NULL;
/*
* gui_bar_valid: check if a bar pointer exists
* return 1 if bar exists
* 0 if bar is not found
*/
int
gui_bar_valid (struct t_gui_bar *bar)
{
struct t_gui_bar *ptr_bar;
if (!bar)
return 0;
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (ptr_bar == bar)
return 1;
}
/* bar not found */
return 0;
}
/*
* gui_bar_search_option search a bar option name
* return index of option in array
@@ -265,6 +290,31 @@ gui_bar_get_option_filling (struct t_gui_bar *bar)
return bar->filling_left_right;
}
/*
* gui_bar_get_item_index: return index of item in bar (position of item in
* items list)
* return -1 if item is not in bar
*/
int
gui_bar_get_item_index (struct t_gui_bar *bar, const char *item_name)
{
int i;
if (!bar || !item_name || !item_name[0])
return -1;
for (i = 0; i < bar->items_count; i++)
{
/* skip non letters chars at beginning (prefix) */
if (gui_bar_item_string_is_item (bar->items_array[i], item_name))
return i;
}
/* item is not in bar */
return -1;
}
/*
* gui_bar_find_pos: find position for a bar in list (keeping list sorted
* by priority)
@@ -1367,7 +1417,6 @@ gui_bar_alloc (const char *name)
new_bar = malloc (sizeof (*new_bar));
if (new_bar)
{
new_bar->plugin = NULL;
new_bar->name = strdup (name);
new_bar->hidden = NULL;
new_bar->priority = NULL;
@@ -1401,7 +1450,7 @@ gui_bar_alloc (const char *name)
*/
struct t_gui_bar *
gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name,
gui_bar_new_with_options (const char *name,
struct t_config_option *hidden,
struct t_config_option *priority,
struct t_config_option *type,
@@ -1424,7 +1473,6 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name,
new_bar = gui_bar_alloc (name);
if (new_bar)
{
new_bar->plugin = plugin;
new_bar->hidden = hidden;
new_bar->priority = priority;
new_bar->type = type;
@@ -1493,9 +1541,8 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name,
*/
struct t_gui_bar *
gui_bar_new (struct t_weechat_plugin *plugin, const char *name,
const char *hidden, const char *priority, const char *type,
const char *conditions, const char *position,
gui_bar_new (const char *name, const char *hidden, const char *priority,
const char *type, const char *conditions, const char *position,
const char *filling_top_bottom, const char *filling_left_right,
const char *size, const char *size_max,
const char *color_fg, const char *color_delim,
@@ -1554,7 +1601,7 @@ gui_bar_new (struct t_weechat_plugin *plugin, const 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_hidden,
new_bar = gui_bar_new_with_options (name, option_hidden,
option_priority, option_type,
option_conditions, option_position,
option_filling_top_bottom,
@@ -1686,8 +1733,7 @@ gui_bar_use_temp_bars ()
&& ptr_temp_bar->color_bg && ptr_temp_bar->separator
&& ptr_temp_bar->items)
{
gui_bar_new_with_options (NULL,
ptr_temp_bar->name,
gui_bar_new_with_options (ptr_temp_bar->name,
ptr_temp_bar->hidden,
ptr_temp_bar->priority,
ptr_temp_bar->type,
@@ -1849,7 +1895,7 @@ gui_bar_create_default_input ()
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT],
gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH],
gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]);
if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_INPUT,
if (gui_bar_new (GUI_BAR_DEFAULT_NAME_INPUT,
"0", /* hidden */
"1000", /* priority */
"window", /* type */
@@ -1888,7 +1934,7 @@ gui_bar_create_default_title ()
if (!ptr_bar)
{
/* create title bar */
if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_TITLE,
if (gui_bar_new (GUI_BAR_DEFAULT_NAME_TITLE,
"0", /* hidden */
"500", /* priority */
"window", /* type */
@@ -1949,7 +1995,7 @@ gui_bar_create_default_status ()
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER],
gui_bar_item_names[GUI_BAR_ITEM_COMPLETION],
gui_bar_item_names[GUI_BAR_ITEM_SCROLL]);
if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_STATUS,
if (gui_bar_new (GUI_BAR_DEFAULT_NAME_STATUS,
"0", /* hidden */
"500", /* priority */
"window", /* type */
@@ -1987,7 +2033,7 @@ gui_bar_create_default_nicklist ()
if (!ptr_bar)
{
/* create nicklist bar */
if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_NICKLIST,
if (gui_bar_new (GUI_BAR_DEFAULT_NAME_NICKLIST,
"0", /* hidden */
"200", /* priority */
"window", /* type */
@@ -2229,27 +2275,6 @@ gui_bar_free_all ()
}
}
/*
* gui_bar_free_all_plugin: delete all bars for a plugin
*/
void
gui_bar_free_all_plugin (struct t_weechat_plugin *plugin)
{
struct t_gui_bar *ptr_bar, *next_bar;
ptr_bar = gui_bars;
while (ptr_bar)
{
next_bar = ptr_bar->next_bar;
if (ptr_bar->plugin == plugin)
gui_bar_free (ptr_bar);
ptr_bar = next_bar;
}
}
/*
* gui_bar_free_bar_windows: free bar windows for a bar
*/
@@ -2275,6 +2300,80 @@ gui_bar_free_bar_windows (struct t_gui_bar *bar)
}
}
/*
* gui_bar_add_to_infolist: add a bar in an infolist
* return 1 if ok, 0 if error
*/
int
gui_bar_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar *bar)
{
struct t_infolist_item *ptr_item;
int i;
char option_name[64];
if (!infolist || !bar)
return 0;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_integer (ptr_item, "hidden", CONFIG_INTEGER(bar->hidden)))
return 0;
if (!infolist_new_var_integer (ptr_item, "priority", CONFIG_INTEGER(bar->priority)))
return 0;
if (!infolist_new_var_integer (ptr_item, "type", CONFIG_INTEGER(bar->type)))
return 0;
if (!infolist_new_var_string (ptr_item, "conditions", CONFIG_STRING(bar->conditions)))
return 0;
if (!infolist_new_var_integer (ptr_item, "conditions_count", bar->conditions_count))
return 0;
for (i = 0; i < bar->conditions_count; i++)
{
snprintf (option_name, sizeof (option_name),
"conditions_array_%05d", i + 1);
if (!infolist_new_var_string (ptr_item, option_name,
bar->conditions_array[i]))
return 0;
}
if (!infolist_new_var_integer (ptr_item, "position", CONFIG_INTEGER(bar->position)))
return 0;
if (!infolist_new_var_integer (ptr_item, "filling_top_bottom", CONFIG_INTEGER(bar->filling_top_bottom)))
return 0;
if (!infolist_new_var_integer (ptr_item, "filling_left_right", CONFIG_INTEGER(bar->filling_left_right)))
return 0;
if (!infolist_new_var_integer (ptr_item, "size", CONFIG_INTEGER(bar->size)))
return 0;
if (!infolist_new_var_integer (ptr_item, "size_max", CONFIG_INTEGER(bar->size_max)))
return 0;
if (!infolist_new_var_string (ptr_item, "color_fg", gui_color_get_name (CONFIG_COLOR(bar->color_fg))))
return 0;
if (!infolist_new_var_string (ptr_item, "color_delim", gui_color_get_name (CONFIG_COLOR(bar->color_delim))))
return 0;
if (!infolist_new_var_string (ptr_item, "color_bg", gui_color_get_name (CONFIG_COLOR(bar->color_bg))))
return 0;
if (!infolist_new_var_integer (ptr_item, "separator", CONFIG_INTEGER(bar->separator)))
return 0;
if (!infolist_new_var_string (ptr_item, "items", CONFIG_STRING(bar->items)))
return 0;
if (!infolist_new_var_integer (ptr_item, "items_count", bar->items_count))
return 0;
for (i = 0; i < bar->items_count; i++)
{
snprintf (option_name, sizeof (option_name),
"items_array_%05d", i + 1);
if (!infolist_new_var_string (ptr_item, option_name,
bar->items_array[i]))
return 0;
}
if (!infolist_new_var_pointer (ptr_item, "bar_window", bar->bar_window))
return 0;
return 1;
}
/*
* gui_bar_print_log: print bar infos in log (usually for crash dump)
*/
@@ -2288,8 +2387,6 @@ gui_bar_print_log ()
{
log_printf ("");
log_printf ("[bar (addr:0x%lx)]", ptr_bar);
log_printf (" plugin . . . . . . . . : 0x%lx ('%s')",
ptr_bar->plugin, plugin_get_name (ptr_bar->plugin));
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));
+6 -5
View File
@@ -78,7 +78,6 @@ enum t_gui_bar_filling
struct t_gui_bar
{
/* user choices */
struct t_weechat_plugin *plugin; /* plugin */
char *name; /* bar name */
struct t_config_option *hidden; /* true if bar is hidden */
struct t_config_option *priority; /* bar priority */
@@ -121,10 +120,13 @@ extern struct t_gui_bar *last_gui_temp_bar;
/* functions */
extern int gui_bar_valid (struct t_gui_bar *bar);
extern int gui_bar_search_option (const char *option_name);
extern int gui_bar_search_type (const char *type);
extern int gui_bar_search_position (const char *position);
extern struct t_config_option *gui_bar_get_option_filling (struct t_gui_bar *bar);
extern int gui_bar_get_item_index (struct t_gui_bar *bar,
const char *item_name);
extern int gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
struct t_gui_window *window);
extern int gui_bar_root_get_size (struct t_gui_bar *bar,
@@ -136,8 +138,7 @@ extern int gui_bar_set (struct t_gui_bar *bar, const char *property, const char
extern void gui_bar_create_option_temp (struct t_gui_bar *temp_bar,
int index_option, const char *value);
extern struct t_gui_bar *gui_bar_alloc (const char *name);
extern struct t_gui_bar *gui_bar_new (struct t_weechat_plugin *plugin,
const char *name,
extern struct t_gui_bar *gui_bar_new (const char *name,
const char *hidden,
const char *priority,
const char *type,
@@ -163,9 +164,9 @@ extern int gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_buffer *buffer,
const char *scroll);
extern void gui_bar_free (struct t_gui_bar *bar);
extern void gui_bar_free_all ();
extern void gui_bar_free_all_plugin (struct t_weechat_plugin *plugin);
extern void gui_bar_free_bar_windows (struct t_gui_bar *bar);
extern void gui_bar_window_print_log (struct t_gui_bar_window *bar_window);
extern int gui_bar_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar *bar);
extern void gui_bar_print_log ();
#endif /* gui-bar.h */
+8 -13
View File
@@ -257,6 +257,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
{
struct t_gui_buffer *new_buffer;
struct t_gui_completion *new_completion;
int first_buffer_creation;
if (!name)
return NULL;
@@ -363,24 +364,18 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
gui_buffer_local_var_add (new_buffer, "name", name);
/* add buffer to buffers list */
first_buffer_creation = (gui_buffers == NULL);
gui_buffer_insert (new_buffer);
/* first buffer creation ? */
if (!gui_current_window->buffer)
{
gui_current_window->buffer = new_buffer;
gui_current_window->first_line_displayed = 1;
gui_current_window->start_line = NULL;
gui_current_window->start_line_pos = 0;
gui_window_switch_to_buffer (gui_current_window, new_buffer, 0);
}
/* check if this buffer should be assigned to a window,
according to windows layout saved */
gui_layout_window_check_buffer (new_buffer);
hook_signal_send ("buffer_open",
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
if (!first_buffer_creation)
{
hook_signal_send ("buffer_open",
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
}
}
else
return NULL;
+6 -5
View File
@@ -129,7 +129,8 @@ gui_window_tree_free (struct t_gui_window_tree **tree)
*/
struct t_gui_window *
gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height,
gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
int x, int y, int width, int height,
int width_pct, int height_pct)
{
struct t_gui_window *new_window;
@@ -141,7 +142,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height
x, y, width, height);
#endif
if (parent)
if (parent_window)
{
child1 = malloc (sizeof (*child1));
if (!child1)
@@ -152,7 +153,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height
free (child1);
return NULL;
}
ptr_tree = parent->ptr_tree;
ptr_tree = parent_window->ptr_tree;
if (width_pct == 100)
{
@@ -168,7 +169,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height
/* parent window leaf becomes node and we add 2 leafs below
(#1 is parent win, #2 is new win) */
parent->ptr_tree = child1;
parent_window->ptr_tree = child1;
child1->parent_node = ptr_tree;
child1->child1 = NULL;
child1->child2 = NULL;
@@ -225,7 +226,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height
new_window->refresh_needed = 0;
/* buffer and layout infos */
new_window->buffer = NULL;
new_window->buffer = buffer;
new_window->layout_plugin_name = NULL;
new_window->layout_buffer_name = NULL;
+2 -1
View File
@@ -107,7 +107,8 @@ extern int gui_window_tree_init (struct t_gui_window *window);
extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *node,
struct t_gui_window *window);
extern void gui_window_tree_free (struct t_gui_window_tree **tree);
extern struct t_gui_window *gui_window_new (struct t_gui_window *parent,
extern struct t_gui_window *gui_window_new (struct t_gui_window *parent_window,
struct t_gui_buffer *buffer,
int x, int y, int width, int height,
int width_pct, int height_pct);
extern int gui_window_valid (struct t_gui_window *window);
+217 -85
View File
@@ -38,6 +38,9 @@
#include "../core/wee-infolist.h"
#include "../core/wee-input.h"
#include "../core/wee-string.h"
#include "../gui/gui-bar.h"
#include "../gui/gui-bar-item.h"
#include "../gui/gui-bar-window.h"
#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
@@ -288,6 +291,9 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
void *pointer, const char *arguments)
{
struct t_infolist *ptr_infolist;
struct t_gui_bar *ptr_bar;
struct t_gui_bar_item *ptr_bar_item;
struct t_gui_bar_window *ptr_bar_window;
struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line;
struct t_gui_filter *ptr_filter;
@@ -300,8 +306,128 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (!infolist_name || !infolist_name[0])
return NULL;
if (string_strcasecmp (infolist_name, "buffer") == 0)
if (string_strcasecmp (infolist_name, "bar") == 0)
{
/* invalid bar pointer ? */
if (pointer && (!gui_bar_valid (pointer)))
return NULL;
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one bar */
if (!gui_bar_add_to_infolist (ptr_infolist, pointer))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
else
{
/* build list with all bars */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (!gui_bar_add_to_infolist (ptr_infolist, ptr_bar))
{
infolist_free (ptr_infolist);
return NULL;
}
}
return ptr_infolist;
}
}
}
else if (string_strcasecmp (infolist_name, "bar_item") == 0)
{
/* invalid bar item pointer ? */
if (pointer && (!gui_bar_item_valid (pointer)))
return NULL;
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one bar item */
if (!gui_bar_item_add_to_infolist (ptr_infolist, pointer))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
else
{
/* build list with all bar items */
for (ptr_bar_item = gui_bar_items; ptr_bar_item;
ptr_bar_item = ptr_bar_item->next_item)
{
if (!gui_bar_item_add_to_infolist (ptr_infolist, ptr_bar_item))
{
infolist_free (ptr_infolist);
return NULL;
}
}
return ptr_infolist;
}
}
}
else if (string_strcasecmp (infolist_name, "bar_window") == 0)
{
/* invalid bar window pointer ? */
if (pointer && (!gui_bar_window_valid (pointer)))
return NULL;
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one bar window */
if (!gui_bar_window_add_to_infolist (ptr_infolist, pointer))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
else
{
/* build list with all bar windows (from root and window bars) */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (ptr_bar->bar_window)
{
if (!gui_bar_window_add_to_infolist (ptr_infolist, ptr_bar->bar_window))
{
infolist_free (ptr_infolist);
return NULL;
}
}
}
for (ptr_window = gui_windows; ptr_window;
ptr_window = ptr_window->next_window)
{
for (ptr_bar_window = ptr_window->bar_windows;
ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
{
if (!gui_bar_window_add_to_infolist (ptr_infolist, ptr_bar_window))
{
infolist_free (ptr_infolist);
return NULL;
}
}
}
return ptr_infolist;
}
}
}
else if (string_strcasecmp (infolist_name, "buffer") == 0)
{
/* invalid buffer pointer ? */
if (pointer && (!gui_buffer_valid (pointer)))
@@ -380,6 +506,36 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "hook") == 0)
{
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (!hook_add_to_infolist (ptr_infolist, arguments))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "hotlist") == 0)
{
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
if (!gui_hotlist_add_to_infolist (ptr_infolist, ptr_hotlist))
{
infolist_free (ptr_infolist);
return NULL;
}
}
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "nicklist") == 0)
{
/* invalid buffer pointer ? */
@@ -397,6 +553,54 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "option") == 0)
{
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (!config_file_add_to_infolist (ptr_infolist, arguments))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "plugin") == 0)
{
/* invalid plugin pointer ? */
if (pointer && (!plugin_valid (pointer)))
return NULL;
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one plugin */
if (!plugin_add_to_infolist (ptr_infolist, pointer))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
else
{
/* build list with all plugins */
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
if (!plugin_add_to_infolist (ptr_infolist, ptr_plugin))
{
infolist_free (ptr_infolist);
return NULL;
}
}
return ptr_infolist;
}
}
}
else if (string_strcasecmp (infolist_name, "window") == 0)
{
/* invalid window pointer ? */
@@ -451,84 +655,6 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
}
}
else if (string_strcasecmp (infolist_name, "hotlist") == 0)
{
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
if (!gui_hotlist_add_to_infolist (ptr_infolist, ptr_hotlist))
{
infolist_free (ptr_infolist);
return NULL;
}
}
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "option") == 0)
{
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (!config_file_add_to_infolist (ptr_infolist, arguments))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "hook") == 0)
{
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (!hook_add_to_infolist (ptr_infolist, arguments))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
}
else if (string_strcasecmp (infolist_name, "plugin") == 0)
{
/* invalid plugin pointer ? */
if (pointer && (!plugin_valid (pointer)))
return NULL;
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one plugin */
if (!plugin_add_to_infolist (ptr_infolist, pointer))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
else
{
/* build list with all plugins */
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
if (!plugin_add_to_infolist (ptr_infolist, ptr_plugin))
{
infolist_free (ptr_infolist);
return NULL;
}
}
return ptr_infolist;
}
}
}
/* infolist not found */
return NULL;
@@ -699,22 +825,28 @@ plugin_api_init ()
&plugin_api_info_get_internal, NULL);
/* WeeChat core infolist hooks */
hook_infolist (NULL, "bar", N_("list of bars"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "bar_item", N_("list of bar items"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "bar_window", N_("list of bar windows"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "buffer", N_("list of buffers"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "buffer_lines", N_("lines of a buffer"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "filter", N_("list of filters"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "window", N_("list of windows"),
hook_infolist (NULL, "hook", N_("list of hooks"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "hotlist", N_("list of buffers in hotlist"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "option", N_("list of options"),
hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "hook", N_("list of hooks"),
hook_infolist (NULL, "option", N_("list of options"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "plugin", N_("list of plugins"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "window", N_("list of windows"),
&plugin_api_infolist_get_internal, NULL);
}
+2 -2
View File
@@ -175,9 +175,9 @@ char *
script_ptr2str (void *pointer)
{
char pointer_str[128];
if (!pointer)
return strdup ("");
return strdup ("0x0");
snprintf (pointer_str, sizeof (pointer_str),
"0x%lx", (long unsigned int)pointer);
+7 -8
View File
@@ -496,8 +496,7 @@ struct t_weechat_plugin
void (*bar_item_update) (const char *name);
void (*bar_item_remove) (struct t_gui_bar_item *item);
struct t_gui_bar *(*bar_search) (const char *name);
struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin,
const char *name,
struct t_gui_bar *(*bar_new) (const char *name,
const char *hidden,
const char *priority,
const char *type,
@@ -1004,12 +1003,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__filling_left_right, __size, __size_max, \
__color_fg, __color_delim, __color_bg, \
__separator, __items) \
weechat_plugin->bar_new(weechat_plugin, __name, __hidden, \
__priority, __type, __condition, \
__position, __filling_top_bottom, \
__filling_left_right, __size, __size_max, \
__color_fg, __color_delim, __color_bg, \
__separator, __items)
weechat_plugin->bar_new(__name, __hidden, __priority, __type, \
__condition, __position, \
__filling_top_bottom, __filling_left_right, \
__size, __size_max, __color_fg, \
__color_delim, __color_bg, __separator, \
__items)
#define weechat_bar_set(__bar, __property, __value) \
weechat_plugin->bar_set(__bar, __property, __value)
#define weechat_bar_update(__name) \