api: add new function config_set_desc_plugin (task #10925)

v2.8-utf8proc
Sebastien Helleu 2011-04-26 17:47:49 +02:00
parent 51f836feb8
commit 3fd2af8184
27 changed files with 601 additions and 17 deletions

View File

@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.5-rc1, 2011-04-25
v0.3.5-rc1, 2011-04-26
Version 0.3.5 (under dev!)
@ -57,6 +57,7 @@ Version 0.3.5 (under dev!)
being added with command "/color"), auto reset of color pairs with option
weechat.look.color_pairs_auto_reset
* core: allow background for nick colors (using ":")
* api: add new function config_set_desc_plugin (task #10925)
* api: add new functions buffer_match_list and window_search_with_buffer
* plugins: fix memory leaks when setting buffer callbacks after /upgrade
(plugins: irc, relay, xfer, scripts)

View File

@ -5528,6 +5528,51 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
# ...
----------------------------------------
weechat_config_set_desc_plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_New in version 0.3.5._
Set description for option in plugins configuration file (plugins.conf).
Prototype:
[source,C]
----------------------------------------
void weechat_config_set_desc_plugin (const char *option_name,
const char *description);
----------------------------------------
Arguments:
* 'option_name': option name, WeeChat will add prefix "plugins.desc.xxx."
(where "xxx" is current plugin name)
* 'description': description for option
[NOTE]
It is not a problem if option (plugins.var.xxx.option_name) does not exist.
A future creation of option with this name will use this description.
C example:
[source,C]
----------------------------------------
weechat_config_set_desc_plugin ("option", "description of option");
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
weechat.config_set_desc_plugin(option_name, description)
# example
version = weechat.info_get("version_number", "") or 0
if int(version) >= 0x00030500:
weechat.config_set_desc_plugin("option", "description of option")
----------------------------------------
weechat_config_unset_plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -5586,6 +5586,52 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
# ...
----------------------------------------
weechat_config_set_desc_plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Nouveau dans la version 0.3.5._
Affecter une description pour une option dans le fichier de configuration des
extensions (plugins.conf).
Prototype :
[source,C]
----------------------------------------
void weechat_config_set_desc_plugin (const char *option_name,
const char *description);
----------------------------------------
Paramètres :
* 'option_name' : nom de l'option, WeeChat ajoutera le préfixe
"plugins.desc.xxx." (où "xxx" est le nom de l'extension courante)
* 'description' : description pour l'option
[NOTE]
Ce n'est pas un problème si l'option (plugins.var.xxx.option_name) n'existe pas.
Une création future de cette option utilisera cette description.
Exemple en C :
[source,C]
----------------------------------------
weechat_config_set_desc_plugin ("option", "description de l'option");
----------------------------------------
Script (Python) :
[source,python]
----------------------------------------
# prototype
weechat.config_set_desc_plugin(option_name, description)
# exemple
version = weechat.info_get("version_number", "") or 0
if int(version) >= 0x00030500:
weechat.config_set_desc_plugin("option", "description de l'option")
----------------------------------------
weechat_config_unset_plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -5528,6 +5528,52 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
# ...
----------------------------------------
// TRANSLATION MISSING
weechat_config_set_desc_plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Novità nella versione 0.3.5._
Set description for option in plugins configuration file (plugins.conf).
Prototipo:
[source,C]
----------------------------------------
void weechat_config_set_desc_plugin (const char *option_name,
const char *description);
----------------------------------------
Argomenti:
* 'option_name': option name, WeeChat will add prefix "plugins.desc.xxx."
(where "xxx" is current plugin name)
* 'description': description for option
[NOTE]
It is not a problem if option (plugins.var.xxx.option_name) does not exist.
A future creation of option with this name will use this description.
Esempio in C:
[source,C]
----------------------------------------
weechat_config_set_desc_plugin ("option", "description of option");
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototipo
weechat.config_set_desc_plugin(option_name, description)
# esempio
version = weechat.info_get("version_number", "") or 0
if int(version) >= 0x00030500:
weechat.config_set_desc_plugin("option", "description of option")
----------------------------------------
weechat_config_unset_plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-10 17:32+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6548,6 +6548,10 @@ msgstr "%sChyba: plugin \"%s\" nenalezen"
msgid "Plugins unloaded"
msgstr "Pluginy odebrány"
#, fuzzy
msgid "description of plugin option"
msgstr "ukazatel skriptu (volitelný)"
msgid "Actions (letter+enter):"
msgstr "Akce (písmeno+enter):"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-15 21:04+0100\n"
"Last-Translator: Nils G.\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6852,6 +6852,10 @@ msgstr "%sFehler: Die Erweiterung \"%s\" wurde nicht gefunden"
msgid "Plugins unloaded"
msgstr "Erweiterungen wurden deinstalliert"
#, fuzzy
msgid "description of plugin option"
msgstr "Skript Pointer (optional)"
msgid "Actions (letter+enter):"
msgstr "Aktion (Zeichen+Enter):"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-10 17:31+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6693,6 +6693,10 @@ msgstr "%sError: plugin \"%s\" no encontrado"
msgid "Plugins unloaded"
msgstr "Plugins descargados"
#, fuzzy
msgid "description of plugin option"
msgstr "puntero del script (opcional)"
msgid "Actions (letter+enter):"
msgstr "Acciones (letra+enter)"

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"PO-Revision-Date: 2011-04-24 08:58+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-25 19:59+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: French\n"
@ -6723,6 +6723,9 @@ msgstr "%sErreur: extension \"%s\" non trouvée"
msgid "Plugins unloaded"
msgstr "Extensions déchargées"
msgid "description of plugin option"
msgstr "description de l'option d'extension"
msgid "Actions (letter+enter):"
msgstr "Actions (lettre+entrée):"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-10 11:21+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6174,6 +6174,9 @@ msgstr "%s a \"%s\" modul nem található\n"
msgid "Plugins unloaded"
msgstr "Betöltött modulok:\n"
msgid "description of plugin option"
msgstr ""
msgid "Actions (letter+enter):"
msgstr ""

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-10 17:33+0200\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6664,6 +6664,10 @@ msgstr "%sErrore: plugin \"%s\" non trovato"
msgid "Plugins unloaded"
msgstr "Plugin disattivati"
#, fuzzy
msgid "description of plugin option"
msgstr "puntatore allo script (opzionale)"
msgid "Actions (letter+enter):"
msgstr "Azioni (lettera+invio)"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-10 17:32+0200\n"
"Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6638,6 +6638,10 @@ msgstr "%sBłąd: nie znaleziono wtyczki \"%s\""
msgid "Plugins unloaded"
msgstr "Wyładowano pluginy"
#, fuzzy
msgid "description of plugin option"
msgstr "wskaźnik skryptu (opcjonalne)"
msgid "Actions (letter+enter):"
msgstr "Akcje (litera+enter)"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-10 11:22+0200\n"
"Last-Translator: Ivan Sichmann Freitas <ivansichfreitas@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -5901,6 +5901,9 @@ msgstr ""
msgid "Plugins unloaded"
msgstr ""
msgid "description of plugin option"
msgstr ""
msgid "Actions (letter+enter):"
msgstr ""

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.5-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+0200\n"
"PO-Revision-Date: 2011-04-10 17:33+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6188,6 +6188,9 @@ msgstr "%s plugin \"%s\" не найден\n"
msgid "Plugins unloaded"
msgstr "Загруженные plugin'ы\n"
msgid "description of plugin option"
msgstr ""
msgid "Actions (letter+enter):"
msgstr ""

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: 2011-04-24 08:57+0200\n"
"POT-Creation-Date: 2011-04-26 17:47+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"
@ -5361,6 +5361,9 @@ msgstr ""
msgid "Plugins unloaded"
msgstr ""
msgid "description of plugin option"
msgstr ""
msgid "Actions (letter+enter):"
msgstr ""

View File

@ -168,6 +168,19 @@ plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
return plugin_config_set (plugin->name, option_name, value);
}
/*
* plugin_api_config_set_desc_plugin: set description of a plugin config option
*/
void
plugin_api_config_set_desc_plugin (struct t_weechat_plugin *plugin,
const char *option_name,
const char *description)
{
if (plugin && option_name)
plugin_config_set_desc (plugin->name, option_name, description);
}
/*
* plugin_api_config_unset_plugin: unset plugin config option
*/

View File

@ -36,6 +36,9 @@ extern int plugin_api_config_is_set_plugin (struct t_weechat_plugin *plugin,
extern int plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
const char *option_name,
const char *value);
extern void plugin_api_config_set_desc_plugin (struct t_weechat_plugin *plugin,
const char *option_name,
const char *description);
extern int plugin_api_config_unset_plugin (struct t_weechat_plugin *plugin,
const char *option_name);

View File

@ -43,6 +43,7 @@
struct t_config_file *plugin_config_file = NULL;
struct t_config_section *plugin_config_section_var = NULL;
struct t_config_section *plugin_config_section_desc = NULL;
/*
@ -130,6 +131,85 @@ plugin_config_set (const char *plugin_name, const char *option_name,
return rc;
}
/*
* plugin_config_desc_changed_cb: called when description of an option is
* changed
*/
void
plugin_config_desc_changed_cb (void *data, struct t_config_option *option)
{
struct t_config_option *ptr_option;
/* make C compiler happy */
(void) data;
ptr_option = config_file_search_option (plugin_config_file,
plugin_config_section_var,
option->name);
if (ptr_option)
{
if (ptr_option->description)
{
free (ptr_option->description);
ptr_option->description = NULL;
}
if (option->value)
ptr_option->description = strdup (option->value);
}
}
/*
* plugin_config_set_desc_internal: set description for a plugin option
* (internal function)
* This function should not be called directly.
*/
void
plugin_config_set_desc_internal (const char *option, const char *value)
{
struct t_config_option *ptr_option;
ptr_option = config_file_search_option (plugin_config_file,
plugin_config_section_desc,
option);
if (ptr_option)
{
config_file_option_set (ptr_option, value, 1);
}
else
{
ptr_option = config_file_new_option (
plugin_config_file, plugin_config_section_desc,
option, "string", _("description of plugin option"),
NULL, 0, 0, "", value, 0, NULL, NULL,
&plugin_config_desc_changed_cb, NULL, NULL, NULL);
}
}
/*
* plugin_config_set_desc: set description for a plugin option
*/
void
plugin_config_set_desc (const char *plugin_name, const char *option_name,
const char *description)
{
int length;
char *option_full_name;
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
option_full_name = malloc (length);
if (option_full_name)
{
snprintf (option_full_name, length, "%s.%s",
plugin_name, option_name);
string_tolower (option_full_name);
plugin_config_set_desc_internal (option_full_name, description);
free (option_full_name);
}
}
/*
* plugin_config_reload: reload plugins configuration file
*/
@ -140,8 +220,9 @@ plugin_config_reload (void *data, struct t_config_file *config_file)
/* make C compiler happy */
(void) data;
/* remove all plugin options */
/* remove all plugin options and descriptions */
config_file_section_free_options (plugin_config_section_var);
config_file_section_free_options (plugin_config_section_desc);
/* reload plugins config file */
return config_file_reload (config_file);
@ -156,20 +237,93 @@ plugin_config_create_option (void *data, struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
struct t_config_option *ptr_option;
struct t_config_option *ptr_option_desc, *ptr_option;
/* make C compiler happy */
(void) data;
ptr_option_desc = config_file_search_option (config_file,
plugin_config_section_desc,
option_name);
ptr_option = config_file_new_option (
config_file, section,
option_name, "string", NULL,
option_name, "string",
(ptr_option_desc) ? CONFIG_STRING(ptr_option_desc) : NULL,
NULL, 0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
return (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
/*
* plugin_config_create_desc: set plugin option description
*/
int
plugin_config_create_desc (void *data, struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
struct t_config_option *ptr_option_var, *ptr_option;
/* make C compiler happy */
(void) data;
ptr_option_var = config_file_search_option (config_file,
plugin_config_section_var,
option_name);
if (ptr_option_var)
{
if (ptr_option_var->description)
{
free (ptr_option_var->description);
ptr_option_var->description = NULL;
}
if (value)
ptr_option_var->description = strdup (value);
}
ptr_option = config_file_new_option (
config_file, section,
option_name, "string", _("description of plugin option"),
NULL, 0, 0, "", value, 0, NULL, NULL,
&plugin_config_desc_changed_cb, NULL, NULL, NULL);
return (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
/*
* plugin_config_delete_desc: delete plugin option description
*/
int
plugin_config_delete_desc (void *data, struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
struct t_config_option *ptr_option_var;
/* make C compiler happy */
(void) data;
(void) section;
ptr_option_var = config_file_search_option (config_file,
plugin_config_section_var,
option->name);
if (ptr_option_var)
{
if (ptr_option_var->description)
{
free (ptr_option_var->description);
ptr_option_var->description = NULL;
}
}
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
/*
* plugin_config_init: init plugins config structure
*/
@ -188,9 +342,19 @@ plugin_config_init ()
NULL, NULL,
&plugin_config_create_option, NULL,
NULL, NULL);
plugin_config_section_desc = config_file_new_section (
plugin_config_file, "desc", 1, 1,
NULL, NULL,
NULL, NULL,
NULL, NULL,
&plugin_config_create_desc, NULL,
&plugin_config_delete_desc, NULL);
}
else
{
plugin_config_section_var = NULL;
plugin_config_section_desc = NULL;
}
}
/*
@ -220,6 +384,7 @@ plugin_config_write ()
void
plugin_config_end ()
{
/* free all plugin config options */
/* free all plugin config options and descriptions */
config_file_section_free_options (plugin_config_section_var);
config_file_section_free_options (plugin_config_section_desc);
}

View File

@ -29,6 +29,9 @@ extern struct t_config_option *plugin_config_search (const char *plugin_name,
const char *option_name);
extern int plugin_config_set (const char *plugin_name, const char *option_name,
const char *value);
extern void plugin_config_set_desc (const char *plugin_name,
const char *option_name,
const char *description);
extern void plugin_config_init ();
extern int plugin_config_read ();
extern int plugin_config_write ();

View File

@ -575,6 +575,7 @@ plugin_load (const char *filename)
new_plugin->config_get_plugin = &plugin_api_config_get_plugin;
new_plugin->config_is_set_plugin = &plugin_api_config_is_set_plugin;
new_plugin->config_set_plugin = &plugin_api_config_set_plugin;
new_plugin->config_set_desc_plugin = &plugin_api_config_set_desc_plugin;
new_plugin->config_unset_plugin = &plugin_api_config_unset_plugin;
new_plugin->prefix = &plugin_api_prefix;

View File

@ -2911,6 +2911,44 @@ weechat_lua_api_config_set_plugin (lua_State *L)
LUA_RETURN_INT(rc);
}
/*
* weechat_lua_api_config_set_desc_plugin: set description of a plugin option
*/
static int
weechat_lua_api_config_set_desc_plugin (lua_State *L)
{
const char *option, *description;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script || !lua_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
LUA_RETURN_ERROR;
}
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
LUA_RETURN_ERROR;
}
option = lua_tostring (lua_current_interpreter, -2);
description = lua_tostring (lua_current_interpreter, -1);
script_api_config_set_desc_plugin (weechat_lua_plugin,
lua_current_script,
option,
description);
LUA_RETURN_OK;
}
/*
* weechat_lua_api_config_unset_plugin: unset plugin option
*/
@ -7800,6 +7838,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "config_get_plugin", &weechat_lua_api_config_get_plugin },
{ "config_is_set_plugin", &weechat_lua_api_config_is_set_plugin },
{ "config_set_plugin", &weechat_lua_api_config_set_plugin },
{ "config_set_desc_plugin", &weechat_lua_api_config_set_desc_plugin },
{ "config_unset_plugin", &weechat_lua_api_config_unset_plugin },
{ "prefix", &weechat_lua_api_prefix },
{ "color", &weechat_lua_api_color },

View File

@ -2610,6 +2610,41 @@ XS (XS_weechat_api_config_set_plugin)
PERL_RETURN_INT(rc);
}
/*
* weechat::config_set_desc_plugin: set description of a plugin option
*/
XS (XS_weechat_api_config_set_desc_plugin)
{
char *option, *description;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script || !perl_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PERL_RETURN_ERROR;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PERL_RETURN_ERROR;
}
option = SvPV (ST (0), PL_na);
description = SvPV (ST (1), PL_na);
script_api_config_set_desc_plugin (weechat_perl_plugin,
perl_current_script,
option,
description);
PERL_RETURN_OK;
}
/*
* weechat::config_unset_plugin: unset a plugin option
*/
@ -6729,6 +6764,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::config_get_plugin", XS_weechat_api_config_get_plugin, "weechat");
newXS ("weechat::config_is_set_plugin", XS_weechat_api_config_is_set_plugin, "weechat");
newXS ("weechat::config_set_plugin", XS_weechat_api_config_set_plugin, "weechat");
newXS ("weechat::config_set_desc_plugin", XS_weechat_api_config_set_desc_plugin, "weechat");
newXS ("weechat::config_unset_plugin", XS_weechat_api_config_unset_plugin, "weechat");
newXS ("weechat::prefix", XS_weechat_api_prefix, "weechat");
newXS ("weechat::color", XS_weechat_api_color, "weechat");

View File

@ -2759,6 +2759,41 @@ weechat_python_api_config_set_plugin (PyObject *self, PyObject *args)
PYTHON_RETURN_INT(rc);
}
/*
* weechat_python_api_config_set_desc_plugin: set description of a plugin option
*/
static PyObject *
weechat_python_api_config_set_desc_plugin (PyObject *self, PyObject *args)
{
char *option, *description;
/* make C compiler happy */
(void) self;
if (!python_current_script || !python_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PYTHON_RETURN_ERROR;
}
option = NULL;
description = NULL;
if (!PyArg_ParseTuple (args, "ss", &option, &description))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PYTHON_RETURN_ERROR;
}
script_api_config_set_desc_plugin (weechat_python_plugin,
python_current_script,
option,
description);
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_config_unset_plugin: unset plugin option
*/
@ -7066,6 +7101,7 @@ PyMethodDef weechat_python_funcs[] =
{ "config_get_plugin", &weechat_python_api_config_get_plugin, METH_VARARGS, "" },
{ "config_is_set_plugin", &weechat_python_api_config_is_set_plugin, METH_VARARGS, "" },
{ "config_set_plugin", &weechat_python_api_config_set_plugin, METH_VARARGS, "" },
{ "config_set_desc_plugin", &weechat_python_api_config_set_desc_plugin, METH_VARARGS, "" },
{ "config_unset_plugin", &weechat_python_api_config_unset_plugin, METH_VARARGS, "" },
{ "prefix", &weechat_python_api_prefix, METH_VARARGS, "" },
{ "color", &weechat_python_api_color, METH_VARARGS, "" },

View File

@ -2992,6 +2992,45 @@ weechat_ruby_api_config_set_plugin (VALUE class, VALUE option, VALUE value)
RUBY_RETURN_INT(rc);
}
/*
* weechat_ruby_api_config_set_desc_plugin: set description of a plugin option
*/
static VALUE
weechat_ruby_api_config_set_desc_plugin (VALUE class, VALUE option,
VALUE description)
{
char *c_option, *c_description;
/* make C compiler happy */
(void) class;
if (!ruby_current_script || !ruby_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
RUBY_RETURN_ERROR;
}
if (NIL_P (option) || NIL_P (description))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
RUBY_RETURN_ERROR;
}
Check_Type (option, T_STRING);
Check_Type (description, T_STRING);
c_option = StringValuePtr (option);
c_description = StringValuePtr (description);
script_api_config_set_desc_plugin (weechat_ruby_plugin,
ruby_current_script,
c_option,
c_description);
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_config_unset_plugin: unset plugin option
*/
@ -7737,6 +7776,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "config_get_plugin", &weechat_ruby_api_config_get_plugin, 1);
rb_define_module_function (ruby_mWeechat, "config_is_set_plugin", &weechat_ruby_api_config_is_set_plugin, 1);
rb_define_module_function (ruby_mWeechat, "config_set_plugin", &weechat_ruby_api_config_set_plugin, 2);
rb_define_module_function (ruby_mWeechat, "config_set_desc_plugin", &weechat_ruby_api_config_set_desc_plugin, 2);
rb_define_module_function (ruby_mWeechat, "config_unset_plugin", &weechat_ruby_api_config_unset_plugin, 1);
rb_define_module_function (ruby_mWeechat, "prefix", &weechat_ruby_api_prefix, 1);
rb_define_module_function (ruby_mWeechat, "color", &weechat_ruby_api_color, 1);

View File

@ -1680,6 +1680,31 @@ script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
return return_code;
}
/*
* script_api_config_set_plugin: set value of a script config option
* format in file is "plugin.script.option"
*/
void
script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option, const char *description)
{
char *option_fullname;
option_fullname = malloc ((strlen (script->name) +
strlen (option) + 2));
if (!option_fullname)
return;
strcpy (option_fullname, script->name);
strcat (option_fullname, ".");
strcat (option_fullname, option);
weechat_config_set_desc_plugin (option_fullname, description);
free (option_fullname);
}
/*
* script_api_config_unset_plugin: unset script config option
* format in file is "plugin.script.option"

View File

@ -317,6 +317,10 @@ extern int script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plu
extern int script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option, const char *value);
extern void script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option,
const char *description);
extern int script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option);

View File

@ -2984,6 +2984,44 @@ weechat_tcl_api_config_set_plugin (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_INT(rc);
}
/*
* weechat_tcl_api_config_set_desc_plugin: set description of a plugin option
*/
static int
weechat_tcl_api_config_set_desc_plugin (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *option, *description;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script || !tcl_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
TCL_RETURN_ERROR;
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
TCL_RETURN_ERROR;
}
option = Tcl_GetStringFromObj (objv[1], &i);
description = Tcl_GetStringFromObj (objv[2], &i);
script_api_config_set_desc_plugin (weechat_tcl_plugin,
tcl_current_script,
option,
description);
TCL_RETURN_OK;
}
/*
* weechat_tcl_api_config_set_plugin: unset plugin option
*/
@ -7639,6 +7677,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_config_is_set_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::config_set_plugin",
weechat_tcl_api_config_set_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::config_set_desc_plugin",
weechat_tcl_api_config_set_desc_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::config_unset_plugin",
weechat_tcl_api_config_unset_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::prefix",

View File

@ -45,7 +45,7 @@ struct timeval;
*/
/* API version (used to check that plugin has same API and can be loaded) */
#define WEECHAT_PLUGIN_API_VERSION "20110413-01"
#define WEECHAT_PLUGIN_API_VERSION "20110426-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -407,6 +407,9 @@ struct t_weechat_plugin
const char *option_name);
int (*config_set_plugin) (struct t_weechat_plugin *plugin,
const char *option_name, const char *value);
void (*config_set_desc_plugin) (struct t_weechat_plugin *plugin,
const char *option_name,
const char *description);
int (*config_unset_plugin) (struct t_weechat_plugin *plugin,
const char *option_name);
@ -1101,6 +1104,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_config_set_plugin(__option, __value) \
weechat_plugin->config_set_plugin(weechat_plugin, __option, \
__value)
#define weechat_config_set_desc_plugin(__option, __description) \
weechat_plugin->config_set_desc_plugin(weechat_plugin, __option, \
__description)
#define weechat_config_unset_plugin(__option) \
weechat_plugin->config_unset_plugin(weechat_plugin, __option)