1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 15:53:12 +02:00

Add hook infolist to plugins API, fix bugs with gettext in plugins

This commit is contained in:
Sebastien Helleu
2008-08-22 21:34:29 +02:00
parent 4185de5219
commit 74d595498d
12 changed files with 345 additions and 62 deletions
+6 -6
View File
@@ -545,12 +545,12 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* /charset command */
weechat_hook_command ("charset",
_("change charset for current buffer"),
_("[[decode | encode] charset] | [reset]"),
_(" decode: change decoding charset\n"
" encode: change encoding charset\n"
"charset: new charset for current buffer\n"
" reset: reset charsets for current buffer"),
N_("change charset for current buffer"),
N_("[[decode | encode] charset] | [reset]"),
N_(" decode: change decoding charset\n"
" encode: change encoding charset\n"
"charset: new charset for current buffer\n"
" reset: reset charsets for current buffer"),
"decode|encode|reset",
&charset_command_cb, NULL);
+17 -17
View File
@@ -404,41 +404,41 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
demo_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
weechat_hook_command ("demo_printf",
_("print some messages on current ubffer"),
_("[text]"),
_("text: write this text"),
N_("print some messages on current ubffer"),
N_("[text]"),
N_("text: write this text"),
"",
&demo_printf_command_cb, NULL);
weechat_hook_command ("demo_buffer",
_("open a new buffer"),
_("category name"),
N_("open a new buffer"),
N_("category name"),
"",
"",
&demo_buffer_command_cb, NULL);
weechat_hook_command ("demo_buffer_set",
_("set a buffer property"),
_("property value"),
N_("set a buffer property"),
N_("property value"),
"",
"",
&demo_buffer_set_command_cb, NULL);
weechat_hook_command ("demo_infolist",
_("get and display an infolist"),
_("infolist"),
_("infolist: infolist to display (values: buffer, "
"buffer_lines)"),
N_("get and display an infolist"),
N_("infolist"),
N_("infolist: infolist to display (values: buffer, "
"buffer_lines)"),
"buffer|buffer_lines",
&demo_infolist_command_cb, NULL);
weechat_hook_command ("demo_info",
_("get and display an info"),
_("info"),
_("info: info to display (values: version, "
"weechat_dir, weechat_libdir, weechat_sharedir, "
"charset_terminal, charset_internal, inactivity, "
"input, input_mask, input_pos)"),
N_("get and display an info"),
N_("info"),
N_("info: info to display (values: version, "
"weechat_dir, weechat_libdir, weechat_sharedir, "
"charset_terminal, charset_internal, inactivity, "
"input, input_mask, input_pos)"),
"version|weechat_dir|weechat_libdir|"
"weechat_sharedir|charset_terminal|charset_internal|"
"inactivity|input|input_mask|input_pos",
+1 -1
View File
@@ -2870,7 +2870,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
if (mask)
{
snprintf (mask, length, "irc.server.%s.*", server_found->name);
infolist = weechat_infolist_get ("options", NULL, mask);
infolist = weechat_infolist_get ("option", NULL, mask);
free (mask);
while (weechat_infolist_next (infolist))
{
+2 -2
View File
@@ -316,7 +316,7 @@ irc_config_server_delete_cb (void *data, struct t_config_option *option)
{
snprintf (mask, length, "irc.server.%s.*",
ptr_server->name);
infolist = weechat_infolist_get ("options", NULL, mask);
infolist = weechat_infolist_get ("option", NULL, mask);
i = 0;
while (weechat_infolist_next (infolist))
{
@@ -346,7 +346,7 @@ irc_config_reload_servers_from_config ()
char *full_name, *option_name, *server_name, *pos_option;
int i, index_option;
infolist = weechat_infolist_get ("options", NULL, "irc.server.*");
infolist = weechat_infolist_get ("option", NULL, "irc.server.*");
while (weechat_infolist_next (infolist))
{
full_name = weechat_infolist_string (infolist, "full_name");
+2 -2
View File
@@ -885,7 +885,7 @@ irc_server_duplicate (struct t_irc_server *server, const char *new_server_name)
if (!mask)
return 0;
snprintf (mask, length, "irc.server.%s.*", server->name);
infolist = weechat_infolist_get ("options", NULL, mask);
infolist = weechat_infolist_get ("option", NULL, mask);
free (mask);
while (weechat_infolist_next (infolist))
{
@@ -944,7 +944,7 @@ irc_server_rename (struct t_irc_server *server, const char *new_server_name)
if (!mask)
return 0;
snprintf (mask, length, "irc.server.%s.*", server->name);
infolist = weechat_infolist_get ("options", NULL, mask);
infolist = weechat_infolist_get ("option", NULL, mask);
free (mask);
while (weechat_infolist_next (infolist))
{
+10 -10
View File
@@ -494,16 +494,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* /notify command */
weechat_hook_command ("notify",
_("change notify level for current buffer"),
_("reset | none | highlight | message | all"),
_(" reset: reset notify level to default value\n"
" none: buffer will never be in hotlist\n"
"highlight: buffer will be in hotlist for "
"highlights only\n"
" message: buffer will be in hotlist for "
"highlights and user messages only\n"
" all: buffer will be in hotlist for "
"any text printed"),
N_("change notify level for current buffer"),
N_("reset | none | highlight | message | all"),
N_(" reset: reset notify level to default value\n"
" none: buffer will never be in hotlist\n"
"highlight: buffer will be in hotlist for "
"highlights only\n"
" message: buffer will be in hotlist for "
"highlights and user messages only\n"
" all: buffer will be in hotlist for "
"any text printed"),
"reset|none|highlight|message|all",
&notify_command_cb, NULL);
+20 -2
View File
@@ -34,6 +34,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-input.h"
#include "../core/wee-string.h"
@@ -293,6 +294,10 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, const char *info)
{
return WEECHAT_SHAREDIR;
}
else if (string_strcasecmp (info, "weechat_localedir") == 0)
{
return LOCALEDIR;
}
else if (string_strcasecmp (info, "charset_terminal") == 0)
{
return weechat_local_charset;
@@ -469,7 +474,7 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
}
}
}
else if (string_strcasecmp (name, "options") == 0)
else if (string_strcasecmp (name, "option") == 0)
{
ptr_infolist = infolist_new ();
if (ptr_infolist)
@@ -482,8 +487,21 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
return ptr_infolist;
}
}
else if (string_strcasecmp (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;
}
}
/* list not found */
/* infolist not found */
return NULL;
}
+8 -8
View File
@@ -132,14 +132,14 @@ script_init (struct t_weechat_plugin *weechat_plugin,
completion, weechat_plugin->name);
}
weechat_hook_command (weechat_plugin->name,
_("list/load/unload scripts"),
_("[list [name]] | [listfull [name]] "
"[load filename] | [autoload] | "
"[reload] | [unload [name]]"),
_("filename: script (file) to load\n"
"name: a script name\n\n"
"Without argument, this command "
"lists all loaded scripts."),
N_("list/load/unload scripts"),
N_("[list [name]] | [listfull [name]] "
"[load filename] | [autoload] | "
"[reload] | [unload [name]]"),
N_("filename: script (file) to load\n"
"name: a script name\n\n"
"Without argument, this command "
"lists all loaded scripts."),
(string) ? string : completion,
callback_command, NULL);
if (string)
+1 -1
View File
@@ -198,6 +198,6 @@ xfer_command_init ()
weechat_hook_command ("xfer",
N_("xfer control"),
"",
_("Open buffer with xfer list"),
N_("Open buffer with xfer list"),
"list|listfull", &xfer_command_xfer, NULL);
}