diff --git a/po/cs.po b/po/cs.po index c7f454cc2..bb02fd18e 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-27 16:41+0100\n" +"POT-Creation-Date: 2009-03-28 20:51+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -5144,6 +5144,11 @@ msgstr "" "\n" "Pokud nejsou uvedeny argumenty, jsou vypsány všechny načtené skripty." +#. TRANSLATORS: %s is language (for example "perl") +#, fuzzy, c-format +msgid "list of %s scripts" +msgstr "Seznam položek polí:" + #, c-format msgid "%s: error loading script \"%s\" (bad name, spaces are forbidden)" msgstr "%s: chyba načítání skriptu \"%s\" (špatné jméno, mezery jsou zakázány)" diff --git a/po/de.po b/po/de.po index f3b1a6986..c4205622e 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-27 16:41+0100\n" +"POT-Creation-Date: 2009-03-28 20:51+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -5083,6 +5083,11 @@ msgid "" "Without argument, this command lists all loaded scripts." msgstr "" +#. TRANSLATORS: %s is language (for example "perl") +#, fuzzy, c-format +msgid "list of %s scripts" +msgstr "Liste der Aliases:\n" + #, c-format msgid "%s: error loading script \"%s\" (bad name, spaces are forbidden)" msgstr "" diff --git a/po/es.po b/po/es.po index e98df89f3..c36c03e7e 100644 --- a/po/es.po +++ b/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-27 16:41+0100\n" +"POT-Creation-Date: 2009-03-28 20:51+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -5073,6 +5073,11 @@ msgid "" "Without argument, this command lists all loaded scripts." msgstr "" +#. TRANSLATORS: %s is language (for example "perl") +#, fuzzy, c-format +msgid "list of %s scripts" +msgstr "Lista de alias:\n" + #, c-format msgid "%s: error loading script \"%s\" (bad name, spaces are forbidden)" msgstr "" diff --git a/po/fr.po b/po/fr.po index 5f8630e46..15f2b35d2 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-27 16:41+0100\n" -"PO-Revision-Date: 2009-03-27 16:43+0100\n" +"POT-Creation-Date: 2009-03-28 20:51+0100\n" +"PO-Revision-Date: 2009-03-28 20:51+0100\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -5282,6 +5282,11 @@ msgstr "" "\n" "Sans argument, cette commande liste tous les scripts chargés." +#. TRANSLATORS: %s is language (for example "perl") +#, c-format +msgid "list of %s scripts" +msgstr "liste des scripts %s" + #, c-format msgid "%s: error loading script \"%s\" (bad name, spaces are forbidden)" msgstr "" diff --git a/po/hu.po b/po/hu.po index 2f5f9bf23..d72c8c2be 100644 --- a/po/hu.po +++ b/po/hu.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-27 16:41+0100\n" +"POT-Creation-Date: 2009-03-28 20:51+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -5140,6 +5140,11 @@ msgid "" "Without argument, this command lists all loaded scripts." msgstr "" +#. TRANSLATORS: %s is language (for example "perl") +#, fuzzy, c-format +msgid "list of %s scripts" +msgstr "Aliaszok listája:\n" + #, c-format msgid "%s: error loading script \"%s\" (bad name, spaces are forbidden)" msgstr "" diff --git a/po/ru.po b/po/ru.po index 4d9f70250..04917be67 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-27 16:41+0100\n" +"POT-Creation-Date: 2009-03-28 20:51+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -5116,6 +5116,11 @@ msgid "" "Without argument, this command lists all loaded scripts." msgstr "" +#. TRANSLATORS: %s is language (for example "perl") +#, fuzzy, c-format +msgid "list of %s scripts" +msgstr "Список сокращений:\n" + #, c-format msgid "%s: error loading script \"%s\" (bad name, spaces are forbidden)" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index ca77d3988..d690b2390 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: 2009-03-27 16:41+0100\n" +"POT-Creation-Date: 2009-03-28 20:51+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4426,6 +4426,11 @@ msgid "" "Without argument, this command lists all loaded scripts." msgstr "" +#. TRANSLATORS: %s is language (for example "perl") +#, c-format +msgid "list of %s scripts" +msgstr "" + #, c-format msgid "%s: error loading script \"%s\" (bad name, spaces are forbidden)" msgstr "" diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 2f8a918f6..943b4cf43 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -449,6 +449,30 @@ weechat_lua_completion_cb (void *data, const char *completion_item, return WEECHAT_RC_OK; } +/* + * weechat_lua_infolist_cb: callback for infolist + */ + +struct t_infolist * +weechat_lua_infolist_cb (void *data, const char *infolist_name, + void *pointer, const char *arguments) +{ + /* make C compiler happy */ + (void) data; + (void) arguments; + + if (!infolist_name || !infolist_name[0]) + return NULL; + + if (weechat_strcasecmp (infolist_name, "lua_script") == 0) + { + return script_infolist_list_scripts (weechat_lua_plugin, + lua_scripts, pointer); + } + + return NULL; +} + /* * weechat_lua_debug_dump_cb: dump Lua plugin data in WeeChat log file */ @@ -504,6 +528,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) script_init (weechat_lua_plugin, &weechat_lua_command_cb, &weechat_lua_completion_cb, + &weechat_lua_infolist_cb, &weechat_lua_debug_dump_cb, &weechat_lua_buffer_closed_cb, &weechat_lua_load_cb); diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 04c0437ad..50fcc8a83 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -594,6 +594,30 @@ weechat_perl_completion_cb (void *data, const char *completion_item, return WEECHAT_RC_OK; } +/* + * weechat_perl_infolist_cb: callback for infolist + */ + +struct t_infolist * +weechat_perl_infolist_cb (void *data, const char *infolist_name, + void *pointer, const char *arguments) +{ + /* make C compiler happy */ + (void) data; + (void) arguments; + + if (!infolist_name || !infolist_name[0]) + return NULL; + + if (weechat_strcasecmp (infolist_name, "perl_script") == 0) + { + return script_infolist_list_scripts (weechat_perl_plugin, + perl_scripts, pointer); + } + + return NULL; +} + /* * weechat_perl_debug_dump_cb: dump Perl plugin data in WeeChat log file */ @@ -680,6 +704,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) script_init (weechat_perl_plugin, &weechat_perl_command_cb, &weechat_perl_completion_cb, + &weechat_perl_infolist_cb, &weechat_perl_debug_dump_cb, &weechat_perl_buffer_closed_cb, &weechat_perl_load_cb); diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 2f4aa68e3..8fcb5b465 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -662,6 +662,30 @@ weechat_python_completion_cb (void *data, const char *completion_item, return WEECHAT_RC_OK; } +/* + * weechat_python_infolist_cb: callback for infolist + */ + +struct t_infolist * +weechat_python_infolist_cb (void *data, const char *infolist_name, + void *pointer, const char *arguments) +{ + /* make C compiler happy */ + (void) data; + (void) arguments; + + if (!infolist_name || !infolist_name[0]) + return NULL; + + if (weechat_strcasecmp (infolist_name, "python_script") == 0) + { + return script_infolist_list_scripts (weechat_python_plugin, + python_scripts, pointer); + } + + return NULL; +} + /* * weechat_python_debug_dump_cb: dump Python plugin data in WeeChat log file */ @@ -744,6 +768,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) script_init (weechat_python_plugin, &weechat_python_command_cb, &weechat_python_completion_cb, + &weechat_python_infolist_cb, &weechat_python_debug_dump_cb, &weechat_python_buffer_closed_cb, &weechat_python_load_cb); diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 18f1d5398..78a3965a4 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -648,6 +648,30 @@ weechat_ruby_completion_cb (void *data, const char *completion_item, return WEECHAT_RC_OK; } +/* + * weechat_ruby_infolist_cb: callback for infolist + */ + +struct t_infolist * +weechat_ruby_infolist_cb (void *data, const char *infolist_name, + void *pointer, const char *arguments) +{ + /* make C compiler happy */ + (void) data; + (void) arguments; + + if (!infolist_name || !infolist_name[0]) + return NULL; + + if (weechat_strcasecmp (infolist_name, "ruby_script") == 0) + { + return script_infolist_list_scripts (weechat_ruby_plugin, + ruby_scripts, pointer); + } + + return NULL; +} + /* * weechat_ruby_debug_dump_cb: dump Ruby plugin data in WeeChat log file */ @@ -785,6 +809,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) script_init (weechat_ruby_plugin, &weechat_ruby_command_cb, &weechat_ruby_completion_cb, + &weechat_ruby_infolist_cb, &weechat_ruby_debug_dump_cb, &weechat_ruby_buffer_closed_cb, &weechat_ruby_load_cb); diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index 9b633d371..ede725dcd 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -87,6 +87,10 @@ script_init (struct t_weechat_plugin *weechat_plugin, int (*callback_completion)(void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion), + struct t_infolist *(*callback_infolist)(void *data, + const char *infolist_name, + void *pointer, + const char *arguments), int (*callback_signal_debug_dump)(void *data, const char *signal, const char *type_data, void *signal_data), @@ -96,6 +100,7 @@ script_init (struct t_weechat_plugin *weechat_plugin, void (*callback_load_file)(void *data, const char *filename)) { char *string, *completion = "list|listfull|load|autoload|reload|unload %f"; + char infolist_description[512]; int length; /* read script configuration */ @@ -144,14 +149,19 @@ script_init (struct t_weechat_plugin *weechat_plugin, callback_command, NULL); if (string) free (string); - - /* add completion */ + + /* add completion and infolist */ length = strlen (weechat_plugin->name) + 16; string = malloc (length); if (string) { snprintf (string, length, "%s_script", weechat_plugin->name); weechat_hook_completion (string, callback_completion, NULL); + snprintf (infolist_description, sizeof (infolist_description), + /* TRANSLATORS: %s is language (for example "perl") */ + _("list of %s scripts"), weechat_plugin->name); + weechat_hook_infolist (string, infolist_description, + callback_infolist, NULL); free (string); } @@ -165,6 +175,32 @@ script_init (struct t_weechat_plugin *weechat_plugin, script_auto_load (weechat_plugin, callback_load_file); } +/* + * script_valid: check if a script pointer exists + * return 1 if script exists + * 0 if script is not found + */ + +int +script_valid (struct t_plugin_script *scripts, + struct t_plugin_script *script) +{ + struct t_plugin_script *ptr_script; + + if (!script) + return 0; + + for (ptr_script = scripts; ptr_script; + ptr_script = ptr_script->next_script) + { + if (ptr_script == script) + return 1; + } + + /* script not found */ + return 0; +} + /* * script_ptr2str: convert pointer to string for usage in a script * (any language) @@ -699,6 +735,98 @@ script_display_short_list (struct t_weechat_plugin *weechat_plugin, } } +/* + * script_add_to_infolist: add a script in an infolist + * return 1 if ok, 0 if error + */ + +int +script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, + struct t_infolist *infolist, + struct t_plugin_script *script) +{ + struct t_infolist_item *ptr_item; + + if (!infolist || !script) + return 0; + + ptr_item = weechat_infolist_new_item (infolist); + if (!ptr_item) + return 0; + + if (!weechat_infolist_new_var_pointer (ptr_item, "pointer", script)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "filename", script->filename)) + return 0; + if (!weechat_infolist_new_var_pointer (ptr_item, "interpreter", script->interpreter)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "name", script->name)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "author", script->author)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "version", script->version)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "license", script->license)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "description", script->description)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "shutdown_func", script->shutdown_func)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "charset", script->charset)) + return 0; + + return 1; +} + +/* + * script_infolist_list_scripts: build infolist with list of scripts + */ + +struct t_infolist * +script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + void *pointer) +{ + struct t_infolist *ptr_infolist; + struct t_plugin_script *ptr_script; + + if (pointer && !script_valid (scripts, pointer)) + return NULL; + + ptr_infolist = weechat_infolist_new (); + if (ptr_infolist) + { + if (pointer) + { + /* build list with only one script */ + if (!script_add_to_infolist (weechat_plugin, + ptr_infolist, pointer)) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } + return ptr_infolist; + } + else + { + /* build list with all scripts */ + for (ptr_script = scripts; ptr_script; + ptr_script = ptr_script->next_script) + { + if (!script_add_to_infolist (weechat_plugin, + ptr_infolist, ptr_script)) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } + } + return ptr_infolist; + } + } + + return NULL; +} + /* * script_print_log: print script infos in log (usually for crash dump) */ diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h index 8e05401a1..159519749 100644 --- a/src/plugins/scripts/script.h +++ b/src/plugins/scripts/script.h @@ -65,6 +65,10 @@ extern void script_init (struct t_weechat_plugin *weechat_plugin, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion), + struct t_infolist *(*callback_infolist)(void *data, + const char *infolist_name, + void *pointer, + const char *arguments), int (*callback_signal_debug_dump)(void *data, const char *signal, const char *type_data, @@ -74,6 +78,8 @@ extern void script_init (struct t_weechat_plugin *weechat_plugin, const char *type_data, void *signal_data), void (*callback_load_file)(void *data, const char *filename)); +extern int script_valid (struct t_plugin_script *scripts, + struct t_plugin_script *script); extern char *script_ptr2str (void *pointer); extern void *script_str2ptr (const char *pointer_str); extern void script_auto_load (struct t_weechat_plugin *weechat_plugin, @@ -104,6 +110,12 @@ extern void script_display_list (struct t_weechat_plugin *weechat_plugin, const char *name, int full); extern void script_display_short_list (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *scripts); +extern int script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, + struct t_infolist *infolist, + struct t_plugin_script *script); +extern struct t_infolist *script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + void *pointer); extern void script_print_log (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *scripts); diff --git a/src/plugins/scripts/tcl/weechat-tcl.c b/src/plugins/scripts/tcl/weechat-tcl.c index 910e20551..f1c9da394 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.c +++ b/src/plugins/scripts/tcl/weechat-tcl.c @@ -389,6 +389,30 @@ weechat_tcl_completion_cb (void *data, const char *completion_item, return WEECHAT_RC_OK; } +/* + * weechat_tcl_infolist_cb: callback for infolist + */ + +struct t_infolist * +weechat_tcl_infolist_cb (void *data, const char *infolist_name, + void *pointer, const char *arguments) +{ + /* make C compiler happy */ + (void) data; + (void) arguments; + + if (!infolist_name || !infolist_name[0]) + return NULL; + + if (weechat_strcasecmp (infolist_name, "tcl_script") == 0) + { + return script_infolist_list_scripts (weechat_tcl_plugin, + tcl_scripts, pointer); + } + + return NULL; +} + /* * weechat_tcl_debug_dump_cb: dump Tcl plugin data in WeeChat log file */ @@ -442,11 +466,12 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) tcl_quiet = 1; script_init (weechat_tcl_plugin, - weechat_tcl_command_cb, - weechat_tcl_completion_cb, - weechat_tcl_debug_dump_cb, - weechat_tcl_buffer_closed_cb, - weechat_tcl_load_cb); + &weechat_tcl_command_cb, + &weechat_tcl_completion_cb, + &weechat_tcl_infolist_cb, + &weechat_tcl_debug_dump_cb, + &weechat_tcl_buffer_closed_cb, + &weechat_tcl_load_cb); tcl_quiet = 0; script_display_short_list (weechat_tcl_plugin,