2
2
* plugins.dox - this file is part of Geany, a fast and lightweight IDE
4
* Copyright 2008-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5
* Copyright 2008-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
6
* Copyright 2009-2010 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
4
* Copyright 2008-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5
* Copyright 2008-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
6
* Copyright 2009-2011 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
8
8
* This program is free software; you can redistribute it and/or modify
9
9
* it under the terms of the GNU General Public License as published by
231
231
* plugin is loaded. Part of that function could be adding and removing of an item to
232
232
* Geany's Tools menu, setting up keybindings or registering some callbacks. Also you will
233
233
* need to implement the function that is called when your plugin is unloaded.
234
* These functions are called plugin_init() and plugin_cleanup(). Let's see how it could look like:
234
* These functions are called plugin_init() and plugin_cleanup(). Let's see what this
236
PLUGIN_VERSION_CHECK(147)
237
PLUGIN_VERSION_CHECK(211)
238
239
PLUGIN_SET_INFO("HelloWorld", "Just another tool to say hello world",
239
240
"1.0", "Joe Doe <joe.doe@example.org>");
381
382
* Now you might like to look at Geany's source code for core plugins such as
382
383
* @a plugins/demoplugin.c.
385
* @section furtherimprovements Furter Improvements and next steps
386
* @subsection translatable_plugin_information Translatable plugin information
388
* After having written our first plugin, there is still room for improvement.
390
* By default, PLUGIN_SET_INFO() does not allow translation of the basic plugin
391
* information for plugins which are not shipped with Geany's core distribution.
392
* Since most plugins are not shipped with Geany's core, it makes sense to
393
* enable translation when the plugin is loaded so that it gets translated
394
* inside Geany's Plugin Manager. As of Geany 0.19, the plugin API contains
395
* the PLUGIN_SET_TRANSLATABLE_INFO() macro which enables translation of the
396
* basic plugin details passed to PLUGIN_SET_INFO() when the plugin is loaded.
398
* PLUGIN_SET_TRANSLATABLE_INFO() takes two more parameters than PLUGIN_SET_INFO(),
399
* for a total of six parameters.
404
* - Short description
408
* The @a Localdir and the @a Gettextpackage parameters are usually set inside
409
* the build system. If this has been done, the call for example HelloWorld
410
* plugin could look like:
413
PLUGIN_SET_TRANSLATABLE_INFO(
414
LOCALEDIR, GETTEXT_PACKAGE, _("Hello World"),
415
_("Just another tool to say hello world"),
416
"1.0", "John Doe <john.doe@example.org>");
419
* When using this macro, you should use the gettext macro @a _() to mark
420
* the strings like name and the short description as translatable as well. You
421
* can see how this is done in the above example.
423
* As you can see the author's information is not marked as translatable in
424
* this example. The community has agreed that the best practice here is to
425
* use, if possible, the latin version of the author's name followed by the
426
* native spelling inside parenthesis, where applicable.
428
* @subsection plugin_i18n Using i18n/l10n inside Plugin
431
* You can (and should) also mark other strings beside the plugin's meta
432
* information as translatable. Strings used in menu entries, information
433
* boxes or configuration dialogs should also be translatable as well. Geany
434
* offers a way to enable this in the plugin's code using the main_locale_init()
435
* function provided by the plugin API. This function takes the same two
436
* parameters discussed in the previous section; @a GETTEXT_PACKAGE and
439
* The main_locale_init() function is best called during initialization in the
440
* plugin's plugin_init() function. Adding this to the HelloWorld example could
443
void plugin_init(GeanyData *data)
445
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
446
main_menu_item = gtk_menu_item_new_with_mnemonic("Hello World");
447
gtk_widget_show(main_menu_item);
448
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu),
450
g_signal_connect(main_menu_item, "activate",
451
G_CALLBACK(item_activate_cb), NULL);
455
* @note If you've previously called the PLUGIN_SET_TRANSLATABLE_INFO() you do not
456
* need to call main_locale_init() yourself, as this has been already been