2008-02-17 18:00:42 +00:00
|
|
|
/*
|
|
|
|
* plugins.dox - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2011-01-19 19:39:09 +00:00
|
|
|
* Copyright 2008-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2008-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
|
|
|
* Copyright 2009-2011 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
* MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* This file contains additional plugin documentation like the signal system and a small howto.
|
|
|
|
* It is best viewed when filetype is set to C or C++.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2009-08-26 14:42:25 +00:00
|
|
|
* @mainpage Geany Plugin API Documentation
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-08-26 14:42:25 +00:00
|
|
|
* @author Enrico Tröger, Nick Treleaven, Frank Lanitz
|
2010-03-18 13:13:11 +00:00
|
|
|
* $Date$
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-08-26 14:42:25 +00:00
|
|
|
* @section Intro
|
2009-08-27 16:13:20 +00:00
|
|
|
* This is the Geany API documentation. It should be considered work in progress.
|
2009-08-26 14:42:25 +00:00
|
|
|
* We will try to document as many functions and structs as possible.
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2010-03-18 13:13:11 +00:00
|
|
|
* @warning Do not use any symbol not in the documentation - it may change.
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2010-03-18 13:13:11 +00:00
|
|
|
* @section pluginsupport Plugin Support
|
|
|
|
* - @link howto Plugin HowTo @endlink - get started
|
2009-08-26 14:42:25 +00:00
|
|
|
* - @link pluginsymbols.c Plugin Symbols @endlink
|
2010-06-18 15:04:07 +00:00
|
|
|
* - @link plugindata.h Plugin Datatypes and Macros @endlink
|
2010-06-25 16:50:27 +00:00
|
|
|
* - @link pluginsignals.c Plugin Signals @endlink
|
2010-03-18 13:13:11 +00:00
|
|
|
* - @link pluginutils.h Plugin Utility Functions @endlink
|
2009-08-26 14:42:25 +00:00
|
|
|
* - @link guidelines Plugin Writing Guidelines @endlink
|
2009-08-27 16:13:20 +00:00
|
|
|
* - <b>plugins/demoplugin.c</b> - in Geany's source, bigger than the howto example
|
2010-03-18 13:13:11 +00:00
|
|
|
*
|
|
|
|
* @section common Common API files
|
|
|
|
* - @link dialogs.h @endlink
|
|
|
|
* - @link document.h @endlink
|
|
|
|
* - @link editor.h @endlink
|
|
|
|
* - @link filetypes.h @endlink
|
2010-04-05 11:42:31 +00:00
|
|
|
* - @link keybindings.h @endlink
|
2010-03-18 13:13:11 +00:00
|
|
|
* - @link msgwindow.h @endlink
|
|
|
|
* - @link project.h @endlink
|
|
|
|
* - @link sciwrappers.h Scintilla Wrapper Functions @endlink
|
2010-03-30 16:29:38 +00:00
|
|
|
* - @link stash.h Stash Pref/Setting Functions @endlink
|
2010-03-18 13:13:11 +00:00
|
|
|
* - @link utils.h General Utility Functions @endlink
|
|
|
|
* - @link ui_utils.h Widget Utility Functions @endlink
|
|
|
|
|
|
|
|
* @section More
|
|
|
|
* - All API functions and types - see <b>Files</b> link at the top
|
2009-08-27 16:13:20 +00:00
|
|
|
* - Deprecated symbols - see <b>Related Pages</b> link at the top
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-08-27 16:13:20 +00:00
|
|
|
* @note See the HACKING file for information about developing the plugin API and
|
|
|
|
* other useful notes.
|
2008-03-20 12:46:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-01-30 18:10:27 +00:00
|
|
|
* @page guidelines Plugin Writing Guidelines
|
|
|
|
*
|
|
|
|
* @section intro Introduction
|
|
|
|
*
|
|
|
|
* The following hints and guidelines are only recommendations. Nobody is forced to follow
|
|
|
|
* them at all.
|
|
|
|
*
|
|
|
|
* @section general General notes
|
|
|
|
*
|
|
|
|
* @subsection ideas Getting a plugin idea
|
|
|
|
*
|
|
|
|
* If you want to write a plugin but don't know yet what it should do, have a look at
|
|
|
|
* http://www.geany.org/Support/PluginWishlist to get an idea about what users wish.
|
|
|
|
*
|
|
|
|
* @subsection code Managing the source code
|
|
|
|
*
|
|
|
|
* For authors of plugins for Geany, we created a dedicated @a geany-plugins project at
|
|
|
|
* Sourceforge to ease development of plugins and help new authors.
|
|
|
|
* Project website: http://sourceforge.net/projects/geany-plugins
|
|
|
|
*
|
|
|
|
* Each plugin author is welcome to use these services. To do so, you need an account at
|
|
|
|
* Sourceforge. You can easily register at (http://sourceforge.net/account/registration/).
|
|
|
|
* After you successfully created an account,
|
|
|
|
* tell your account name Enrico or Nick and you will write access to the SVN repository
|
|
|
|
* (http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/).
|
|
|
|
* Then you can use the repository for your own plugin.
|
|
|
|
*
|
|
|
|
* Authors using this service should subscribe to the
|
|
|
|
* geany-plugins-commits at uvena.de and geany-plugins-tracker at uvena.de
|
|
|
|
* mailing lists(see my previous post) to stay up to date with changes.
|
|
|
|
* General plugin discussion can happen on the normal geany at uvena.de or
|
|
|
|
* geany-devel at uvena.de lists.
|
|
|
|
*
|
|
|
|
* At time of writing, there are some plugins already available in the
|
|
|
|
* repository. Feel free to use any of these plugins as a start for your own,
|
|
|
|
* maybe by copying the directory structure and the autotools files
|
|
|
|
* (Makefile.am, configure.in, ...). Most of the available plugins are also ready for
|
|
|
|
* i18n support, just for reference.
|
|
|
|
*
|
|
|
|
* New plugins should be imported into a new directory inside the trunk/
|
|
|
|
* directory. There are also the common branches and tags directories, use
|
|
|
|
* them as needed, use always a subdirectory for your own plugin.
|
|
|
|
*
|
|
|
|
* We encourage authors using this service to only commit changes to their
|
|
|
|
* own plugin and not to others' plugins. Instead just send patches to
|
|
|
|
* geany-devel at uvena.de or the plugin author directly.
|
|
|
|
*
|
|
|
|
* (the full announcement of this service can be found at
|
|
|
|
* http://lists.uvena.de/geany/2008-April/003225.html)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @section paths Installation paths
|
|
|
|
*
|
|
|
|
* - The plugin binary (@c pluginname.so) should be installed in Geany's libdir. This is
|
|
|
|
* necessary so that Geany can find the plugin.
|
|
|
|
* An easy way to retrieve Geany's libdir is to use the pkg-config tool, e.g. @code
|
|
|
|
* `$PKG_CONFIG --variable=libdir geany`/ geany
|
|
|
|
* @endcode
|
|
|
|
* - If your plugin creates other binary files like helper programs or helper libraries,
|
|
|
|
* they should go into @c $prefix/bin (for programs, ideally prefixed with @a geany),
|
|
|
|
* additional libraries should be installed in Geany's libdir, maybe in a subdirectory.
|
|
|
|
* - Plugins should install their documentation files (README, NEWS, ChangeLog, licences and
|
|
|
|
* other documentation files) into the common documentation directory
|
|
|
|
* @c $prefix/share/doc/geany-plugins/$pluginname/
|
|
|
|
* - Translation files should be installed normally into @c $prefix/share/locale. There is no
|
|
|
|
* need to use Geany's translation directory. To set up translation support properly and
|
|
|
|
* for additional information, see main_locale_init().
|
|
|
|
* - Do @a never install anything into a user's home directory like installing
|
|
|
|
* the plugin binary in @c ~/.config/geany/plugins/.
|
|
|
|
*
|
|
|
|
*
|
2010-03-18 13:13:11 +00:00
|
|
|
* @page howto Plugin HowTo
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
|
|
|
* @section intro Introduction
|
|
|
|
*
|
|
|
|
* Since Geany 0.12 there is a plugin interface to extend Geany's functionality and
|
2009-08-09 20:31:03 +00:00
|
|
|
* add new features. This document gives a brief overview about how to add new
|
2008-02-17 18:00:42 +00:00
|
|
|
* plugins by writing a simple "Hello World" plugin in C.
|
|
|
|
*
|
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* @section buildenv Build environment
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
|
|
|
* To be able to write plugins for Geany, you need the source code and some development
|
2009-02-14 17:37:28 +00:00
|
|
|
* packages for GTK and its dependencies. The following will only describe the way to compile and
|
2008-02-17 18:00:42 +00:00
|
|
|
* build plugins on Unix-like systems [1].
|
|
|
|
* If you already have the Geany source code and compiled it from them, you can skip the
|
|
|
|
* following.
|
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* First you need to have Geany installed. Then install the development files for GTK
|
2008-02-17 18:00:42 +00:00
|
|
|
* and its dependencies. The easiest way to do this is to use your distribution's package
|
|
|
|
* management system, e.g. on Debian and Ubuntu systems you can use
|
|
|
|
* @code apt-get install libgtk2.0-dev intltool @endcode
|
2009-02-14 17:37:28 +00:00
|
|
|
* This will install all necessary files to be able to compile plugins for Geany. On other
|
2008-02-17 18:00:42 +00:00
|
|
|
* distributions, the package names and commands to use may differ.
|
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* Basically, you are done at this point and could continue with writing the plugin code.
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
|
|
|
* [1] For Windows, it is basically the same but you might have some more work on setting up
|
|
|
|
* the general build environment(compiler, GTK development files, ...). This is described on
|
2008-09-01 11:15:16 +00:00
|
|
|
* Geany's website at http://www.geany.org/Support/BuildingOnWin32.
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* @section helloworld "Hello World"
|
|
|
|
*
|
|
|
|
* When writing a plugin, you will find a couple of functions or macros which are mandatory
|
|
|
|
* and some which are free to use for implementing some useful feature once your plugin
|
|
|
|
* becomes more powerful like including a configuration or help dialog.
|
|
|
|
*
|
|
|
|
* You should start your plugin with including some of the needed C header files and defining
|
|
|
|
* some basic global variables which will help you to access all needed functions of the plugin
|
|
|
|
* API in a more comfortable way.
|
|
|
|
*
|
|
|
|
* Let's start with the very basic headers and add more later if necessary.
|
|
|
|
* @code
|
2009-07-14 15:06:20 +00:00
|
|
|
#include "geanyplugin.h"
|
2009-02-14 17:37:28 +00:00
|
|
|
* @endcode
|
|
|
|
*
|
2009-07-14 15:06:20 +00:00
|
|
|
* @a geanyplugin.h includes all of the Geany API and also the necessary GTK header files,
|
|
|
|
* so there is no need to include @a gtk/gtk.h yourself.
|
2009-02-14 17:37:28 +00:00
|
|
|
*
|
2009-07-14 15:06:20 +00:00
|
|
|
* @note
|
2009-02-14 17:37:28 +00:00
|
|
|
* @a plugindata.h contains the biggest part of the plugin API and provides some basic macros.
|
2009-07-14 15:06:20 +00:00
|
|
|
* @a geanyfunctions.h provides some macros for convenient access to plugin API functions.
|
2009-02-14 17:37:28 +00:00
|
|
|
*
|
|
|
|
* The you should define three basic variables which will give access to data fields and
|
|
|
|
* functions provided by the plugin API.
|
|
|
|
* @code
|
|
|
|
GeanyPlugin *geany_plugin;
|
|
|
|
GeanyData *geany_data;
|
|
|
|
GeanyFunctions *geany_functions;
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* Now you can go on and write your first lines for your new plugin. As mentioned before,
|
|
|
|
* you will need to implement and fill out a couple of functions/macros to make the plugin work.
|
|
|
|
* So let's start with PLUGIN_VERSION_CHECK().
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* PLUGIN_VERSION_CHECK() is a convenient way to tell Geany which version of Geany's plugin API
|
|
|
|
* is needed at minimum to run your plugin. The value is defined in
|
|
|
|
* @a plugindata.h by @a GEANY_API_VERSION. In most cases this should be your minimum.
|
|
|
|
* Nevertheless when setting this value, you should choose the lowest possible version here to
|
|
|
|
* make the plugin compatible with a bigger number of versions of Geany.
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-07-14 15:06:20 +00:00
|
|
|
* For the next step, you will need to tell Geany some basic information about your plugin
|
|
|
|
* which will be shown in the plugin manager dialog.
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* For doing this, you should use PLUGIN_SET_INFO() which expects 4 values:
|
2009-07-14 15:06:20 +00:00
|
|
|
* - Plugin name
|
|
|
|
* - Short description
|
|
|
|
* - Version
|
|
|
|
* - Author
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* Based on this, the line could look like:
|
|
|
|
* @code
|
|
|
|
PLUGIN_SET_INFO("HelloWorld", "Just another tool to say hello world",
|
|
|
|
"1.0", "John Doe <john.doe@example.org>");
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* Once this is done, you will need to implement the function which will be executed when the
|
|
|
|
* plugin is loaded. Part of that function could be adding and removing of an item to
|
|
|
|
* Geany's Tools menu, setting up keybindings or registering some callbacks. Also you will
|
|
|
|
* need to implement the function that is called when your plugin is unloaded.
|
|
|
|
* These functions are called plugin_init() and plugin_cleanup(). Let's see how it could look like:
|
|
|
|
* @code
|
2009-07-14 15:06:20 +00:00
|
|
|
PLUGIN_VERSION_CHECK(147)
|
2009-02-14 17:37:28 +00:00
|
|
|
|
|
|
|
PLUGIN_SET_INFO("HelloWorld", "Just another tool to say hello world",
|
|
|
|
"1.0", "Joe Doe <joe.doe@example.org>");
|
|
|
|
|
|
|
|
void plugin_init(GeanyData *data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_cleanup(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
* @endcode
|
|
|
|
*
|
2010-01-19 15:48:42 +00:00
|
|
|
* If you think this plugin seems not to implement any functionality right now and only wastes
|
|
|
|
* some memory, you are right. But it should compile and load/unload in Geany nicely.
|
|
|
|
* Now you have the very basic layout of a new plugin. Great, isn't it?
|
|
|
|
*
|
2010-01-18 17:17:34 +00:00
|
|
|
* @section building Building
|
2010-01-18 16:55:49 +00:00
|
|
|
*
|
2010-01-19 15:48:42 +00:00
|
|
|
* First make plugin.o:
|
|
|
|
*
|
2010-01-18 17:17:34 +00:00
|
|
|
* @code gcc -c plugin.c -fPIC `pkg-config --cflags geany` @endcode
|
2010-01-18 16:55:49 +00:00
|
|
|
*
|
2010-01-19 15:48:42 +00:00
|
|
|
* Then make the plugin library plugin.so (or plugin.dll on Windows):
|
2010-01-18 16:55:49 +00:00
|
|
|
*
|
2010-01-18 17:17:34 +00:00
|
|
|
* @code gcc plugin.o -o plugin.so -shared `pkg-config --libs geany` @endcode
|
2010-01-18 16:55:49 +00:00
|
|
|
*
|
2010-01-19 15:48:42 +00:00
|
|
|
* If all went OK, put the library into one of the paths Geany looks for plugins,
|
|
|
|
* e.g. $prefix/lib/geany. See @ref paths "Installation paths" for details.
|
2010-01-18 17:17:34 +00:00
|
|
|
*
|
2010-01-19 15:48:42 +00:00
|
|
|
* @section realfunc Adding functionality
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* Let's go on and implement some real functionality.
|
|
|
|
*
|
|
|
|
* As mentioned before, plugin_init() will be called when the plugin is loaded in Geany.
|
2009-07-14 15:06:20 +00:00
|
|
|
* So it should implement everything that needs to be done during startup. In this case,
|
|
|
|
* we'd like to add a menu item to Geany's Tools menu which runs a dialog printing "Hello World".
|
2009-02-14 17:37:28 +00:00
|
|
|
* @code
|
|
|
|
void plugin_init(GeanyData *data)
|
|
|
|
{
|
|
|
|
GtkWidget *main_menu_item;
|
|
|
|
|
|
|
|
// Create a new menu item and show it
|
|
|
|
main_menu_item = gtk_menu_item_new_with_mnemonic("Hello World");
|
|
|
|
gtk_widget_show(main_menu_item);
|
|
|
|
|
|
|
|
// Attach the new menu item to the Tools menu
|
|
|
|
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu),
|
|
|
|
main_menu_item);
|
|
|
|
|
|
|
|
// Connect the menu item with a callback function
|
|
|
|
// which is called when the item is clicked
|
|
|
|
g_signal_connect(main_menu_item, "activate",
|
|
|
|
G_CALLBACK(item_activate_cb), NULL);
|
|
|
|
}
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* This will add an item to the Tools menu and connect this item to a function which implements
|
|
|
|
* what should be done when the menu item is activated by the user.
|
|
|
|
* This is done by g_signal_connect(). The Tools menu can be accessed with
|
2009-07-14 15:06:20 +00:00
|
|
|
* geany->main_widgets->tools_menu. The structure @a main_widgets contains pointers to the
|
|
|
|
* main GUI elements in Geany.
|
2009-02-14 17:37:28 +00:00
|
|
|
*
|
2009-07-14 15:06:20 +00:00
|
|
|
* Geany has a simple API for showing message dialogs. So our function contains
|
|
|
|
* only a few lines:
|
2009-02-14 17:37:28 +00:00
|
|
|
* @code
|
|
|
|
void item_activate_cb(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
dialogs_show_msgbox(GTK_MESSAGE_INFO, "Hello World");
|
|
|
|
}
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* For the moment you don't need to worry about the parameters of that function.
|
|
|
|
*
|
2009-07-14 15:06:20 +00:00
|
|
|
* Now we need to clean up properly when the plugin is unloaded.
|
2009-02-14 17:37:28 +00:00
|
|
|
*
|
|
|
|
* To remove the menu item from the Tools menu, you can use gtk_widget_destroy().
|
|
|
|
* gtk_widget_destroy() expects a pointer to a GtkWidget object.
|
|
|
|
*
|
|
|
|
* First you should add gtk_widget_destroy() to your plugin_cleanup() function.
|
|
|
|
* The argument for gtk_widget_destroy() is the widget object you created earlier in
|
|
|
|
* plugin_init(). To be able to access this pointer in plugin_cleanup(), you need to move
|
|
|
|
* its definition from plugin_init() into the global context so its visibility will increase
|
|
|
|
* and it can be accessed in all functions.
|
|
|
|
* @code
|
|
|
|
static GtkWidget *main_menu_item = NULL;
|
|
|
|
|
|
|
|
// ...
|
|
|
|
void plugin_init(GeanyData *data)
|
|
|
|
{
|
|
|
|
main_menu_item = gtk_menu_item_new_with_mnemonic("Hello World");
|
|
|
|
gtk_widget_show(main_menu_item);
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_cleanup(void)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy(main_menu_item);
|
|
|
|
}
|
|
|
|
* @endcode
|
|
|
|
*
|
2009-07-14 15:06:20 +00:00
|
|
|
* This will ensure your menu item is removed from the Tools menu as well as from
|
|
|
|
* memory once your plugin is unloaded, so you don't leave any memory leaks.
|
2009-02-14 17:37:28 +00:00
|
|
|
* Once this is done, your first plugin is ready. Congratulations!
|
|
|
|
*
|
2010-01-19 15:48:42 +00:00
|
|
|
* @section listing Complete listing (without comments)
|
|
|
|
*
|
2009-02-14 17:37:28 +00:00
|
|
|
* @code
|
2009-07-14 15:06:20 +00:00
|
|
|
#include "geanyplugin.h"
|
2009-02-14 17:37:28 +00:00
|
|
|
|
|
|
|
GeanyPlugin *geany_plugin;
|
|
|
|
GeanyData *geany_data;
|
|
|
|
GeanyFunctions *geany_functions;
|
|
|
|
|
2009-07-14 15:06:20 +00:00
|
|
|
PLUGIN_VERSION_CHECK(147)
|
2009-02-14 17:37:28 +00:00
|
|
|
|
|
|
|
PLUGIN_SET_INFO("HelloWorld", "Just another tool to say hello world",
|
|
|
|
"1.0", "John Doe <john.doe@example.org>");
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *main_menu_item = NULL;
|
|
|
|
|
|
|
|
static void item_activate_cb(GtkMenuItem *menuitem, gpointer gdata)
|
|
|
|
{
|
|
|
|
dialogs_show_msgbox(GTK_MESSAGE_INFO, "Hello World");
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_init(GeanyData *data)
|
|
|
|
{
|
|
|
|
main_menu_item = gtk_menu_item_new_with_mnemonic("Hello World");
|
|
|
|
gtk_widget_show(main_menu_item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu),
|
|
|
|
main_menu_item);
|
|
|
|
g_signal_connect(main_menu_item, "activate",
|
|
|
|
G_CALLBACK(item_activate_cb), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_cleanup(void)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy(main_menu_item);
|
|
|
|
}
|
|
|
|
* @endcode
|
2008-02-17 18:00:42 +00:00
|
|
|
*
|
2009-07-14 15:06:20 +00:00
|
|
|
*
|
|
|
|
* Now you might like to look at Geany's source code for core plugins such as
|
|
|
|
* @a plugins/demoplugin.c.
|
2011-07-31 17:35:22 +00:00
|
|
|
*
|
2011-07-31 17:36:53 +00:00
|
|
|
* @section furtherimprovements Furter Improvements and next steps
|
|
|
|
* @subsection translatable_plugin_information Translatable plugin information
|
2011-07-31 17:35:22 +00:00
|
|
|
*
|
|
|
|
* After we have done our first plugin, there is still some place for improvements.
|
|
|
|
*
|
|
|
|
* Per default PLUGIN_SET_INFO() is not allowing to translate the basic plugin
|
|
|
|
* information for a plugin which is not shipped with Geany's core distribution.
|
|
|
|
* In most cases, a plugin is shipped as a standalone and so it might make sense
|
|
|
|
* to enable translation on loading time so it is localized also inside plugin manager.
|
|
|
|
* With Geany 0.19 the plugin API is shipping the PLUGIN_SET_TRANSLATABLE_INFO()
|
|
|
|
* macro which is enabling translation of the basic plugin details already on
|
|
|
|
* loading time.
|
|
|
|
*
|
|
|
|
* PLUGIN_SET_TRANSLATABLE_INFO() is taking in difference to
|
|
|
|
* PLUGIN_SET_INFO() two more parameters, which it makes to take 6 parameters.
|
|
|
|
*
|
|
|
|
* - Localedir
|
|
|
|
* - Gettextpackage
|
|
|
|
* - Plugin name
|
|
|
|
* - Short description
|
|
|
|
* - Version
|
|
|
|
* - Author
|
|
|
|
*
|
|
|
|
* Localdir and the gettext package shall be set inside the build system.
|
|
|
|
* If this has been done, the call for above mentioned HelloWorld-world
|
|
|
|
* plugin could look like:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
|
|
|
|
PLUGIN_SET_TRANSLATABLE_INFO(
|
|
|
|
LOCALEDIR, GETTEXT_PACKAGE, _("Hello World"),
|
|
|
|
_("Just another tool to say hello world"),
|
|
|
|
"1.0", "John Doe <john.doe@example.org>");
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* When using the macro, you should use the gettext macro _() to mark
|
|
|
|
* the strings like name and the short description as translatable as well. You
|
|
|
|
* can see the usage inside the little example listed above.
|
|
|
|
*
|
|
|
|
* As you can see the author's informations are not marked translatable inside
|
|
|
|
* this little example. This has been discussed onto mailing list where it has
|
|
|
|
* been agreed to use if possible latin version of author's name
|
|
|
|
* followed by in case of its apply able nativ spelling inside braces.
|
|
|
|
*
|
2011-07-31 17:37:12 +00:00
|
|
|
* @subsection plugin_i18n Using i18n/l10n inside Plugin
|
|
|
|
*
|
|
|
|
|
|
|
|
* Not only the meta information of a plugin shall be translateable,
|
|
|
|
* but also the text like menu entries, information boxes or strings
|
|
|
|
* inside configuration dialog should be translateable too. Geany is
|
|
|
|
* offering a way to enable this from code point of view by using a
|
|
|
|
* function provided by the Geany API -- main_locale_init().
|
|
|
|
|
|
|
|
* The function is taking over two parameters LOCALEDIR and
|
|
|
|
* GETTEXT_PACKAGE which we already know from previous sesction.
|
|
|
|
|
|
|
|
* As the function is called best on plugin initialization, it should be
|
|
|
|
* placed into plugin_init() so the hello world example could look like:
|
|
|
|
* @code
|
|
|
|
void plugin_init(GeanyData *data)
|
|
|
|
{
|
|
|
|
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
|
|
|
|
main_menu_item = gtk_menu_item_new_with_mnemonic("Hello World");
|
|
|
|
gtk_widget_show(main_menu_item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu),
|
|
|
|
main_menu_item);
|
|
|
|
g_signal_connect(main_menu_item, "activate",
|
|
|
|
G_CALLBACK(item_activate_cb), NULL);
|
|
|
|
}
|
|
|
|
* @endcode
|
2011-08-01 19:20:39 +00:00
|
|
|
*
|
|
|
|
* If you already did use PLUGIN_SET_TRANSLATABLE_INFO() you don't need
|
2011-08-01 19:31:56 +00:00
|
|
|
* to add main_locale_init() as it has already been called.
|
2008-02-17 18:00:42 +00:00
|
|
|
**/
|