Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > 0c00422fba9a46710101d04f3f3175e7 > files > 114

geany-devel-1.24.1-3.mga5.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>Geany: Plugin HowTo</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Geany
   &#160;<span id="projectnumber">1.24.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.8 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Plugin HowTo </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="intro"></a>
Introduction</h1>
<pre class="fragment">Since Geany 0.12 there is a plugin interface to extend Geany's functionality and
add new features. This document gives a brief overview about how to add new
plugins by writing a simple "Hello World" plugin in C or C++.
</pre><h1><a class="anchor" id="buildenv"></a>
Build environment</h1>
<pre class="fragment">To be able to write plugins for Geany, you need the source code and some development
packages for GTK and its dependencies. The following will only describe the way to compile and
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.

First you need to have Geany installed. Then install the development files for GTK
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
</pre> <div class="fragment"><div class="line">apt-<span class="keyword">get</span> install libgtk2.0-dev intltool </div>
</div><!-- fragment --><p> This will install all necessary files to be able to compile plugins for Geany. On other distributions, the package names and commands to use may differ.</p>
<p>Basically, you are done at this point and could continue with writing the plugin code.</p>
<p>[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 Geany's website at <a href="http://www.geany.org/Support/BuildingOnWin32">http://www.geany.org/Support/BuildingOnWin32</a>.</p>
<h1><a class="anchor" id="helloworld"></a>
"Hello World"</h1>
<pre class="fragment">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.
</pre> <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="geanyplugin_8h.html">geanyplugin.h</a>&gt;</span></div>
</div><!-- fragment --><p><em><a class="el" href="geanyplugin_8h.html" title="Single include for plugins. ">geanyplugin.h</a></em> includes all of the Geany API and also the necessary GTK header files, so there is no need to include <em>gtk/gtk.h</em> yourself.</p>
<dl class="section note"><dt>Note</dt><dd><em><a class="el" href="plugindata_8h.html" title="This file defines the plugin API, the interface between Geany and its plugins. ">plugindata.h</a></em> contains the biggest part of the plugin API and provides some basic macros. <em><a class="el" href="geanyfunctions_8h.html" title="geany_functions wrappers. ">geanyfunctions.h</a></em> provides some macros for convenient access to plugin API functions.</dd></dl>
<p>Then you should define three basic variables which will give access to data fields and functions provided by the plugin API. </p><div class="fragment"><div class="line"><a class="code" href="structGeanyPlugin.html">GeanyPlugin</a>         *<a class="code" href="pluginsymbols_8c.html#a7b50f49a0e368449584d4ff547a64c47">geany_plugin</a>;</div>
<div class="line"><a class="code" href="structGeanyData.html">GeanyData</a>           *<a class="code" href="pluginsymbols_8c.html#afc005e8bf9cdd3d61185166b8626c9f1">geany_data</a>;</div>
<div class="line"><a class="code" href="structGeanyFunctions.html">GeanyFunctions</a>      *<a class="code" href="pluginsymbols_8c.html#ae6f07f482a1b6e6b09ef9b893c663bbd">geany_functions</a>;</div>
</div><!-- fragment --><p>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 <a class="el" href="plugindata_8h.html#a68c850fc7108c65909f4340da8c16df9" title="Defines a function to check the plugin is safe to load. ">PLUGIN_VERSION_CHECK()</a>.</p>
<p><a class="el" href="plugindata_8h.html#a68c850fc7108c65909f4340da8c16df9" title="Defines a function to check the plugin is safe to load. ">PLUGIN_VERSION_CHECK()</a> 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 <em><a class="el" href="plugindata_8h.html" title="This file defines the plugin API, the interface between Geany and its plugins. ">plugindata.h</a></em> by <em>GEANY_API_VERSION</em>. 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.</p>
<p>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.</p>
<p>To do this you should use the <a class="el" href="plugindata_8h.html#a38301c1368e7b8880da0a8b9850cd21c" title="Sets the plugin name and some other basic information about a plugin. ">PLUGIN_SET_INFO()</a> macro, which expects 4 parameters:</p><ul>
<li>Plugin name</li>
<li>Short description</li>
<li>Version</li>
<li>Author</li>
</ul>
<p>Based on this, the line could look like: </p><div class="fragment"><div class="line"><a class="code" href="plugindata_8h.html#a38301c1368e7b8880da0a8b9850cd21c">PLUGIN_SET_INFO</a>(<span class="stringliteral">&quot;HelloWorld&quot;</span>, <span class="stringliteral">&quot;Just another tool to say hello world&quot;</span>,</div>
<div class="line">                <span class="stringliteral">&quot;1.0&quot;</span>, <span class="stringliteral">&quot;John Doe &lt;john.doe@example.org&gt;&quot;</span>);</div>
</div><!-- fragment --><p>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 <a class="el" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612" title="Called after loading the plugin. ">plugin_init()</a> and <a class="el" href="pluginsymbols_8c.html#a597c40a2085ba1713107b6ff9a5e165a" title="Called before unloading the plugin. ">plugin_cleanup()</a>. Let's see what this looks like: </p><div class="fragment"><div class="line"><a class="code" href="plugindata_8h.html#a68c850fc7108c65909f4340da8c16df9">PLUGIN_VERSION_CHECK</a>(211)</div>
<div class="line"></div>
<div class="line"><a class="code" href="plugindata_8h.html#a38301c1368e7b8880da0a8b9850cd21c">PLUGIN_SET_INFO</a>(&quot;HelloWorld&quot;, &quot;Just another tool to say hello world&quot;,</div>
<div class="line">                &quot;1.0&quot;, &quot;Joe Doe &lt;joe.doe@example.org&gt;&quot;);</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612">plugin_init</a>(<a class="code" href="structGeanyData.html">GeanyData</a> *data)</div>
<div class="line">{</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#a597c40a2085ba1713107b6ff9a5e165a">plugin_cleanup</a>(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">}</div>
</div><!-- fragment --><p>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?</p>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>If you would rather write the plugin in C++, you can do that by marking the plugin functions that it implements as <code>extern</code> <code>"C"</code>, for example:</p>
<div class="fragment"><div class="line"><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> <span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612">plugin_init</a>(<a class="code" href="structGeanyData.html">GeanyData</a> *data)</div>
<div class="line">{</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> <span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#a597c40a2085ba1713107b6ff9a5e165a">plugin_cleanup</a>(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="building"></a>
Building</h1>
<pre class="fragment">First make plugin.o:
</pre><div class="fragment"><div class="line">gcc -c plugin.c -fPIC `pkg-config --cflags <a class="code" href="plugindata_8h.html#a69d30df92bfae95283506199fdd1ce7c">geany</a>` </div>
</div><!-- fragment --> <pre class="fragment">Then make the plugin library plugin.so (or plugin.dll on Windows):
</pre><div class="fragment"><div class="line">gcc plugin.o -o plugin.so -shared `pkg-config --libs <a class="code" href="plugindata_8h.html#a69d30df92bfae95283506199fdd1ce7c">geany</a>` </div>
</div><!-- fragment --> <pre class="fragment">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.

@note

If you are writing the plugin in C++, then you will need to use your C++
compiler here, for example @c g++.
</pre><h1><a class="anchor" id="realfunc"></a>
Adding functionality</h1>
<pre class="fragment">Let's go on and implement some real functionality.

As mentioned before, plugin_init() will be called when the plugin is loaded in Geany.
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".
</pre> <div class="fragment"><div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612">plugin_init</a>(<a class="code" href="structGeanyData.html">GeanyData</a> *data)</div>
<div class="line">{</div>
<div class="line">    GtkWidget *main_menu_item;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Create a new menu item and show it</span></div>
<div class="line">    main_menu_item = gtk_menu_item_new_with_mnemonic(<span class="stringliteral">&quot;Hello World&quot;</span>);</div>
<div class="line">    gtk_widget_show(main_menu_item);</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Attach the new menu item to the Tools menu</span></div>
<div class="line">    gtk_container_add(GTK_CONTAINER(<a class="code" href="plugindata_8h.html#a69d30df92bfae95283506199fdd1ce7c">geany</a>-&gt;main_widgets-&gt;tools_menu),</div>
<div class="line">        main_menu_item);</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Connect the menu item with a callback function</span></div>
<div class="line">    <span class="comment">// which is called when the item is clicked</span></div>
<div class="line">    g_signal_connect(main_menu_item, <span class="stringliteral">&quot;activate&quot;</span>,</div>
<div class="line">        G_CALLBACK(item_activate_cb), NULL);</div>
<div class="line">}</div>
</div><!-- fragment --><p>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 geany-&gt;main_widgets-&gt;tools_menu. The structure <em>main_widgets</em> contains pointers to the main GUI elements in Geany.</p>
<p>Geany has a simple API for showing message dialogs. So our function contains only a few lines: </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> item_activate_cb(GtkMenuItem *menuitem, gpointer user_data)</div>
<div class="line">{</div>
<div class="line">    <a class="code" href="dialogs_8h.html#af3027d1be28e78af2b8b4cd665171d69">dialogs_show_msgbox</a>(GTK_MESSAGE_INFO, <span class="stringliteral">&quot;Hello World&quot;</span>);</div>
<div class="line">}</div>
</div><!-- fragment --><p>For the moment you don't need to worry about the parameters of that function.</p>
<p>Now we need to clean up properly when the plugin is unloaded.</p>
<p>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.</p>
<p>First you should add gtk_widget_destroy() to your <a class="el" href="pluginsymbols_8c.html#a597c40a2085ba1713107b6ff9a5e165a" title="Called before unloading the plugin. ">plugin_cleanup()</a> function. The argument for gtk_widget_destroy() is the widget object you created earlier in <a class="el" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612" title="Called after loading the plugin. ">plugin_init()</a>. To be able to access this pointer in <a class="el" href="pluginsymbols_8c.html#a597c40a2085ba1713107b6ff9a5e165a" title="Called before unloading the plugin. ">plugin_cleanup()</a>, you need to move its definition from <a class="el" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612" title="Called after loading the plugin. ">plugin_init()</a> into the global context so its visibility will increase and it can be accessed in all functions. </p><div class="fragment"><div class="line"><span class="keyword">static</span> GtkWidget *main_menu_item = NULL;</div>
<div class="line"></div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612">plugin_init</a>(<a class="code" href="structGeanyData.html">GeanyData</a> *data)</div>
<div class="line">{</div>
<div class="line">    main_menu_item = gtk_menu_item_new_with_mnemonic(<span class="stringliteral">&quot;Hello World&quot;</span>);</div>
<div class="line">    gtk_widget_show(main_menu_item);</div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#a597c40a2085ba1713107b6ff9a5e165a">plugin_cleanup</a>(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">    gtk_widget_destroy(main_menu_item);</div>
<div class="line">}</div>
</div><!-- fragment --><p>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. Once this is done, your first plugin is ready. Congratulations!</p>
<h1><a class="anchor" id="listing"></a>
Complete listing (without comments)</h1>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="geanyplugin_8h.html">geanyplugin.h</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><a class="code" href="structGeanyPlugin.html">GeanyPlugin</a>     *<a class="code" href="pluginsymbols_8c.html#a7b50f49a0e368449584d4ff547a64c47">geany_plugin</a>;</div>
<div class="line"><a class="code" href="structGeanyData.html">GeanyData</a>       *<a class="code" href="pluginsymbols_8c.html#afc005e8bf9cdd3d61185166b8626c9f1">geany_data</a>;</div>
<div class="line"><a class="code" href="structGeanyFunctions.html">GeanyFunctions</a>  *<a class="code" href="pluginsymbols_8c.html#ae6f07f482a1b6e6b09ef9b893c663bbd">geany_functions</a>;</div>
<div class="line"></div>
<div class="line"><a class="code" href="plugindata_8h.html#a68c850fc7108c65909f4340da8c16df9">PLUGIN_VERSION_CHECK</a>(211)</div>
<div class="line"></div>
<div class="line"><a class="code" href="plugindata_8h.html#a38301c1368e7b8880da0a8b9850cd21c">PLUGIN_SET_INFO</a>(&quot;HelloWorld&quot;, &quot;Just another tool to say hello world&quot;,</div>
<div class="line">                &quot;1.0&quot;, &quot;John Doe &lt;john.doe@example.org&gt;&quot;);</div>
<div class="line"></div>
<div class="line"></div>
<div class="line">static GtkWidget *main_menu_item = NULL;</div>
<div class="line"></div>
<div class="line">static <span class="keywordtype">void</span> item_activate_cb(GtkMenuItem *menuitem, gpointer gdata)</div>
<div class="line">{</div>
<div class="line">    <a class="code" href="dialogs_8h.html#af3027d1be28e78af2b8b4cd665171d69">dialogs_show_msgbox</a>(GTK_MESSAGE_INFO, <span class="stringliteral">&quot;Hello World&quot;</span>);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612">plugin_init</a>(<a class="code" href="structGeanyData.html">GeanyData</a> *data)</div>
<div class="line">{</div>
<div class="line">    main_menu_item = gtk_menu_item_new_with_mnemonic(<span class="stringliteral">&quot;Hello World&quot;</span>);</div>
<div class="line">    gtk_widget_show(main_menu_item);</div>
<div class="line">    gtk_container_add(GTK_CONTAINER(<a class="code" href="plugindata_8h.html#a69d30df92bfae95283506199fdd1ce7c">geany</a>-&gt;main_widgets-&gt;tools_menu),</div>
<div class="line">        main_menu_item);</div>
<div class="line">    g_signal_connect(main_menu_item, <span class="stringliteral">&quot;activate&quot;</span>,</div>
<div class="line">        G_CALLBACK(item_activate_cb), NULL);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#a597c40a2085ba1713107b6ff9a5e165a">plugin_cleanup</a>(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">    gtk_widget_destroy(main_menu_item);</div>
<div class="line">}</div>
</div><!-- fragment --><p>Now you might like to look at Geany's source code for core plugins such as <em>plugins/demoplugin.c</em>.</p>
<h1><a class="anchor" id="furtherimprovements"></a>
Furter Improvements and next steps</h1>
<h2><a class="anchor" id="translatable_plugin_information"></a>
Translatable plugin information</h2>
<p>After having written our first plugin, there is still room for improvement.</p>
<p>By default, <a class="el" href="plugindata_8h.html#a38301c1368e7b8880da0a8b9850cd21c" title="Sets the plugin name and some other basic information about a plugin. ">PLUGIN_SET_INFO()</a> does not allow translation of the basic plugin information for plugins which are not shipped with Geany's core distribution. Since most plugins are not shipped with Geany's core, it makes sense to enable translation when the plugin is loaded so that it gets translated inside Geany's Plugin Manager. As of Geany 0.19, the plugin API contains the <a class="el" href="plugindata_8h.html#a743dd012631a99ec7dad6945fd6d66a7" title="Sets the plugin name and some other basic information about a plugin. ">PLUGIN_SET_TRANSLATABLE_INFO()</a> macro which enables translation of the basic plugin details passed to <a class="el" href="plugindata_8h.html#a38301c1368e7b8880da0a8b9850cd21c" title="Sets the plugin name and some other basic information about a plugin. ">PLUGIN_SET_INFO()</a> when the plugin is loaded.</p>
<p><a class="el" href="plugindata_8h.html#a743dd012631a99ec7dad6945fd6d66a7" title="Sets the plugin name and some other basic information about a plugin. ">PLUGIN_SET_TRANSLATABLE_INFO()</a> takes two more parameters than <a class="el" href="plugindata_8h.html#a38301c1368e7b8880da0a8b9850cd21c" title="Sets the plugin name and some other basic information about a plugin. ">PLUGIN_SET_INFO()</a>, for a total of six parameters.</p>
<ul>
<li>Localedir</li>
<li>Gettextpackage</li>
<li>Plugin name</li>
<li>Short description</li>
<li>Version</li>
<li>Author</li>
</ul>
<p>The <em>Localdir</em> and the <em>Gettextpackage</em> parameters are usually set inside the build system. If this has been done, the call for example HelloWorld plugin could look like:</p>
<div class="fragment"><div class="line"><a class="code" href="plugindata_8h.html#a743dd012631a99ec7dad6945fd6d66a7">PLUGIN_SET_TRANSLATABLE_INFO</a>(</div>
<div class="line">    LOCALEDIR, GETTEXT_PACKAGE, _(<span class="stringliteral">&quot;Hello World&quot;</span>),</div>
<div class="line">    _(<span class="stringliteral">&quot;Just another tool to say hello world&quot;</span>),</div>
<div class="line">    <span class="stringliteral">&quot;1.0&quot;</span>, <span class="stringliteral">&quot;John Doe &lt;john.doe@example.org&gt;&quot;</span>);</div>
</div><!-- fragment --><p>When using this macro, you should use the gettext macro <em>_()</em> to mark the strings like name and the short description as translatable as well. You can see how this is done in the above example.</p>
<p>As you can see the author's information is not marked as translatable in this example. The community has agreed that the best practice here is to use, if possible, the latin version of the author's name followed by the native spelling inside parenthesis, where applicable.</p>
<h2><a class="anchor" id="plugin_i18n"></a>
Using i18n/l10n inside Plugin</h2>
<p>You can (and should) also mark other strings beside the plugin's meta information as translatable. Strings used in menu entries, information boxes or configuration dialogs should also be translatable as well. Geany offers a way to enable this in the plugin's code using the <a class="el" href="main_8h.html#a8b772d8f4006401807e76d4f57e6a5fc" title="Initialises the gettext translation system. ">main_locale_init()</a> function provided by the plugin API. This function takes the same two parameters discussed in the previous section; <em>GETTEXT_PACKAGE</em> and <em>LOCALEDIR</em>.</p>
<p>The <a class="el" href="main_8h.html#a8b772d8f4006401807e76d4f57e6a5fc" title="Initialises the gettext translation system. ">main_locale_init()</a> function is best called during initialization in the plugin's <a class="el" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612" title="Called after loading the plugin. ">plugin_init()</a> function. Adding this to the HelloWorld example could look like: </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> <a class="code" href="pluginsymbols_8c.html#aa962b949eadd24aeaf003b1b290c6612">plugin_init</a>(<a class="code" href="structGeanyData.html">GeanyData</a> *data)</div>
<div class="line">{</div>
<div class="line">    <a class="code" href="main_8h.html#a8b772d8f4006401807e76d4f57e6a5fc">main_locale_init</a>(LOCALEDIR, GETTEXT_PACKAGE);</div>
<div class="line">    main_menu_item = gtk_menu_item_new_with_mnemonic(<span class="stringliteral">&quot;Hello World&quot;</span>);</div>
<div class="line">    gtk_widget_show(main_menu_item);</div>
<div class="line">    gtk_container_add(GTK_CONTAINER(<a class="code" href="plugindata_8h.html#a69d30df92bfae95283506199fdd1ce7c">geany</a>-&gt;main_widgets-&gt;tools_menu),</div>
<div class="line">        main_menu_item);</div>
<div class="line">    g_signal_connect(main_menu_item, <span class="stringliteral">&quot;activate&quot;</span>,</div>
<div class="line">        G_CALLBACK(item_activate_cb), NULL);</div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>If you've previously called the <a class="el" href="plugindata_8h.html#a743dd012631a99ec7dad6945fd6d66a7" title="Sets the plugin name and some other basic information about a plugin. ">PLUGIN_SET_TRANSLATABLE_INFO()</a> you do not need to call <a class="el" href="main_8h.html#a8b772d8f4006401807e76d4f57e6a5fc" title="Initialises the gettext translation system. ">main_locale_init()</a> yourself, as this has been already been done for you. </dd></dl>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Oct 17 2014 05:13:17 for Geany by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.8
</small></address>
</body>
</html>