1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 04:25:42 +02:00

Partial support of bars, with custom items.

Today only root bars are partially working (refresh is not always performed),
and bars are not saved in configuration file. To be continued...
This commit is contained in:
Sebastien Helleu
2008-03-05 16:19:10 +01:00
parent d64e852a38
commit 14d393b11e
49 changed files with 5582 additions and 242 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+65
View File
@@ -814,6 +814,71 @@ script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
}
}
/*
* script_api_bar_item_new: add a new bar item
*/
struct t_gui_bar_item *
script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *name,
char *(*build_callback)(void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
int remaining_space),
char *function_build)
{
struct t_script_callback *new_script_callback;
struct t_gui_bar_item *new_item;
new_script_callback = script_callback_alloc ();
if (!new_script_callback)
return NULL;
new_item = weechat_bar_item_new (name,
(function_build && function_build[0]) ?
build_callback : NULL,
(function_build && function_build[0]) ?
new_script_callback : NULL);
if (!new_item)
{
free (new_script_callback);
return NULL;
}
new_script_callback->script = script;
new_script_callback->function = (function_build && function_build[0]) ?
strdup (function_build) : NULL;
new_script_callback->bar_item = new_item;
script_callback_add (script, new_script_callback);
return new_item;
}
/*
* script_api_bar_item_remove: remove a bar item
*/
void
script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_bar_item *item)
{
struct t_script_callback *ptr_script_callback;
if (!weechat_plugin || !script || !item)
return;
weechat_bar_item_remove (item);
for (ptr_script_callback = script->callbacks; ptr_script_callback;
ptr_script_callback = ptr_script_callback->next_callback)
{
if (ptr_script_callback->bar_item == item)
script_callback_remove (script, ptr_script_callback);
}
}
/*
* script_api_command: execute a command (simulate user entry)
*/
+11
View File
@@ -151,6 +151,17 @@ extern void script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
int switch_to_another);
extern struct t_gui_bar_item *script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *name,
char *(*build_callback)(void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
int remaining_space),
char *function_build);
extern void script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_bar_item *item);
extern void script_api_command (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
+6 -1
View File
@@ -46,6 +46,7 @@ script_callback_alloc ()
new_script_callback->config_option = NULL;
new_script_callback->hook = NULL;
new_script_callback->buffer = NULL;
new_script_callback->bar_item = NULL;
return new_script_callback;
}
@@ -85,7 +86,7 @@ script_callback_remove (struct t_plugin_script *script,
if (script->callbacks == script_callback)
script->callbacks = script_callback->next_callback;
/* unhook and free data */
/* free data */
if (script_callback->function)
free (script_callback->function);
@@ -117,8 +118,12 @@ script_callback_print_log (struct t_weechat_plugin *weechat_plugin,
weechat_log_printf ("[callback (addr:0x%x)]", script_callback);
weechat_log_printf (" script. . . . . . . : 0x%x", script_callback->script);
weechat_log_printf (" function. . . . . . : '%s'", script_callback->function);
weechat_log_printf (" config_file . . . . : '%s'", script_callback->config_file);
weechat_log_printf (" config_section. . . : '%s'", script_callback->config_section);
weechat_log_printf (" config_option . . . : '%s'", script_callback->config_option);
weechat_log_printf (" hook. . . . . . . . : 0x%x", script_callback->hook);
weechat_log_printf (" buffer. . . . . . . : 0x%x", script_callback->buffer);
weechat_log_printf (" bar_item. . . . . . : 0x%x", script_callback->bar_item);
weechat_log_printf (" prev_callback . . . : 0x%x", script_callback->prev_callback);
weechat_log_printf (" next_callback . . . : 0x%x", script_callback->next_callback);
}
+2 -1
View File
@@ -27,7 +27,8 @@ struct t_script_callback
struct t_config_section *config_section; /* not NULL for config section */
struct t_config_option *config_option; /* not NULL for config option */
struct t_hook *hook; /* not NULL for hook */
struct t_gui_buffer *buffer; /* not NULL for buffer callback*/
struct t_gui_buffer *buffer; /* not NULL for buffer */
struct t_gui_bar_item *bar_item; /* not NULL for bar item */
struct t_script_callback *prev_callback; /* link to next callback */
struct t_script_callback *next_callback; /* link to previous callback */
};
+5
View File
@@ -416,10 +416,12 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
for (ptr_script_callback = script->callbacks; ptr_script_callback;
ptr_script_callback = ptr_script_callback->next_callback)
{
/* unhook */
if (ptr_script_callback->hook)
{
weechat_unhook (ptr_script_callback->hook);
}
/* free config file */
if (ptr_script_callback->config_file
&& !ptr_script_callback->config_section
&& !ptr_script_callback->config_option)
@@ -428,6 +430,9 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
weechat_config_write (ptr_script_callback->config_file);
weechat_config_free (ptr_script_callback->config_file);
}
/* remove bar item */
if (ptr_script_callback->bar_item)
weechat_bar_item_remove (ptr_script_callback->bar_item);
}
/* remove all callbacks created by this script */