From 3fd2af81847440fa221621572d6cf36eca910483 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 26 Apr 2011 17:47:49 +0200 Subject: [PATCH] api: add new function config_set_desc_plugin (task #10925) --- ChangeLog | 3 +- doc/en/weechat_plugin_api.en.txt | 45 +++++ doc/fr/weechat_plugin_api.fr.txt | 46 +++++ doc/it/weechat_plugin_api.it.txt | 46 +++++ po/cs.po | 6 +- po/de.po | 6 +- po/es.po | 6 +- po/fr.po | 7 +- po/hu.po | 5 +- po/it.po | 6 +- po/pl.po | 6 +- po/pt_BR.po | 5 +- po/ru.po | 5 +- po/weechat.pot | 5 +- src/plugins/plugin-api.c | 13 ++ src/plugins/plugin-api.h | 3 + src/plugins/plugin-config.c | 173 +++++++++++++++++- src/plugins/plugin-config.h | 3 + src/plugins/plugin.c | 1 + src/plugins/scripts/lua/weechat-lua-api.c | 39 ++++ src/plugins/scripts/perl/weechat-perl-api.c | 36 ++++ .../scripts/python/weechat-python-api.c | 36 ++++ src/plugins/scripts/ruby/weechat-ruby-api.c | 40 ++++ src/plugins/scripts/script-api.c | 25 +++ src/plugins/scripts/script-api.h | 4 + src/plugins/scripts/tcl/weechat-tcl-api.c | 40 ++++ src/plugins/weechat-plugin.h | 8 +- 27 files changed, 601 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62c4c67dd..1da37ee9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu -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) diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index a17887336..bfdecf907 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 96b7a3fa1..16aec43c5 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index 740bf89c4..b3e20b420 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/po/cs.po b/po/cs.po index bfff029d4..8c0e6218c 100644 --- a/po/cs.po +++ b/po/cs.po @@ -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 \n" "Language-Team: weechat-dev \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):" diff --git a/po/de.po b/po/de.po index cdc7276f3..c00ee7e70 100644 --- a/po/de.po +++ b/po/de.po @@ -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 \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):" diff --git a/po/es.po b/po/es.po index ec3f6f3a4..4346f9822 100644 --- a/po/es.po +++ b/po/es.po @@ -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 \n" "Language-Team: weechat-dev \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)" diff --git a/po/fr.po b/po/fr.po index e1b716276..bef863908 100644 --- a/po/fr.po +++ b/po/fr.po @@ -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 \n" "Language-Team: weechat-dev \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):" diff --git a/po/hu.po b/po/hu.po index ed481aff7..f5fa75a51 100644 --- a/po/hu.po +++ b/po/hu.po @@ -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 \n" "Language-Team: weechat-dev \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 "" diff --git a/po/it.po b/po/it.po index 8d4cd9ee7..7ee78dd12 100644 --- a/po/it.po +++ b/po/it.po @@ -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 \n" "Language-Team: weechat-dev \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)" diff --git a/po/pl.po b/po/pl.po index d13ad82c8..7de7ac52a 100644 --- a/po/pl.po +++ b/po/pl.po @@ -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 \n" "Language-Team: weechat-dev \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)" diff --git a/po/pt_BR.po b/po/pt_BR.po index 538b5987e..8371ccc2a 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -5901,6 +5901,9 @@ msgstr "" msgid "Plugins unloaded" msgstr "" +msgid "description of plugin option" +msgstr "" + msgid "Actions (letter+enter):" msgstr "" diff --git a/po/ru.po b/po/ru.po index 996f7e23a..49e36b813 100644 --- a/po/ru.po +++ b/po/ru.po @@ -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 \n" "Language-Team: weechat-dev \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 "" diff --git a/po/weechat.pot b/po/weechat.pot index 60543a3b3..ba04d19d5 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -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 \n" "Language-Team: LANGUAGE \n" @@ -5361,6 +5361,9 @@ msgstr "" msgid "Plugins unloaded" msgstr "" +msgid "description of plugin option" +msgstr "" + msgid "Actions (letter+enter):" msgstr "" diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index f67aca4ff..a5c467594 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -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 */ diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h index 003a4d1b3..4d9e70baa 100644 --- a/src/plugins/plugin-api.h +++ b/src/plugins/plugin-api.h @@ -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); diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c index d469b49f8..4a4f5f720 100644 --- a/src/plugins/plugin-config.c +++ b/src/plugins/plugin-config.c @@ -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); } diff --git a/src/plugins/plugin-config.h b/src/plugins/plugin-config.h index 2aa2e0dee..049c92ed8 100644 --- a/src/plugins/plugin-config.h +++ b/src/plugins/plugin-config.h @@ -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 (); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index a17088f96..cb0a95588 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -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; diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 286b4509b..c89ad16d0 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -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 }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 0219a8e08..97f54c8a6 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -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"); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 9a3924fc4..daf7d8b75 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -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, "" }, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index cfa82cf88..a9df9537a 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -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); diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index 4fb0cd09b..3aefdd446 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -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" diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index 73f419b34..a9bc5fe32 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -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); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index b36d72ad3..03e84c30f 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -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", diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index e580aa230..87669b9dd 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -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)