Plugin utility functions.
More...
|
void | plugin_add_toolbar_item (struct GeanyPlugin *plugin, GtkToolItem *item) |
| Inserts a toolbar item before the Quit button, or after the previous plugin toolbar item. More...
|
|
void | plugin_builder_connect_signals (struct GeanyPlugin *plugin, GtkBuilder *builder, gpointer user_data) |
| Allows auto-connecting Glade/GtkBuilder signals in plugins. More...
|
|
guint | plugin_idle_add (struct GeanyPlugin *plugin, GSourceFunc function, gpointer data) |
| Adds a GLib main loop IDLE callback that will be removed when unloading the plugin, preventing it to run after the plugin has been unloaded (which may lead to a segfault). More...
|
|
void | plugin_module_make_resident (struct GeanyPlugin *plugin) |
| Ensures that a plugin's module (*.so) will never be unloaded. More...
|
|
struct GeanyKeyGroup * | plugin_set_key_group (struct GeanyPlugin *plugin, const gchar *section_name, gsize count, GeanyKeyGroupCallback callback) |
| Sets up or resizes a keybinding group for the plugin. More...
|
|
void | plugin_show_configure (struct GeanyPlugin *plugin) |
| Shows the plugin's configure dialog. More...
|
|
void | plugin_signal_connect (struct GeanyPlugin *plugin, GObject *object, const gchar *signal_name, gboolean after, GCallback callback, gpointer user_data) |
| Connects a signal which will be disconnected on unloading the plugin, to prevent a possible segfault. More...
|
|
guint | plugin_timeout_add (struct GeanyPlugin *plugin, guint interval, GSourceFunc function, gpointer data) |
| Adds a GLib main loop timeout callback that will be removed when unloading the plugin, preventing it to run after the plugin has been unloaded (which may lead to a segfault). More...
|
|
guint | plugin_timeout_add_seconds (struct GeanyPlugin *plugin, guint interval, GSourceFunc function, gpointer data) |
| Adds a GLib main loop timeout callback that will be removed when unloading the plugin, preventing it to run after the plugin has been unloaded (which may lead to a segfault). More...
|
|
Plugin utility functions.
These functions all take the geany_plugin symbol as their first argument.
void plugin_add_toolbar_item |
( |
GeanyPlugin * |
plugin, |
|
|
GtkToolItem * |
item |
|
) |
| |
Inserts a toolbar item before the Quit button, or after the previous plugin toolbar item.
A separator is added on the first call to this function, and will be shown when item is shown; hidden when item is hidden.
- Note
- You should still destroy item yourself, usually in plugin_cleanup().
- Parameters
-
void plugin_builder_connect_signals |
( |
GeanyPlugin * |
plugin, |
|
|
GtkBuilder * |
builder, |
|
|
gpointer |
user_data |
|
) |
| |
Allows auto-connecting Glade/GtkBuilder signals in plugins.
When a plugin uses GtkBuilder to load some UI from file/string, the gtk_builder_connect_signals() function is unable to automatically connect to the plugin's signal handlers. A plugin could itself use the gtk_builder_connect_signals_full() function to automatically connect to the signal handler functions by loading it's GModule and retrieving pointers to the handler functions, but rather than each plugin having to do that, this function handles it automatically.
2 GeanyPlugin *geany_plugin;
5 myplugin_button_clicked(GtkButton *button, gpointer user_data)
7 g_print("Button pressed\n");
10 void plugin_init(GeanyData *data)
12 GtkBuilder *builder = gtk_builder_new();
13 gtk_builder_add_from_file(builder, "gui.glade", NULL);
14 plugin_builder_connect_signals(geany_plugin, builder, NULL);
- Note
- It's important that you prefix your callback handlers with a plugin-specific prefix to avoid clashing with other plugins since the function symbols will be exported process-wide.
- Parameters
-
plugin | Must be geany_plugin. |
builder | The GtkBuilder to connect signals with. |
user_data | User data to pass to the connected signal handlers. |
- Since
- 1.24, plugin API 217.
guint plugin_idle_add |
( |
GeanyPlugin * |
plugin, |
|
|
GSourceFunc |
function, |
|
|
gpointer |
data |
|
) |
| |
Adds a GLib main loop IDLE callback that will be removed when unloading the plugin, preventing it to run after the plugin has been unloaded (which may lead to a segfault).
- Parameters
-
plugin | Must be geany_plugin. |
function | The function to call in IDLE time. |
data | The user data passed to the function. |
- Returns
- the ID of the event source (you generally won't need it, or better use g_idle_add() directly if you want to manage this event source manually).
- See also
- g_idle_add()
- Since
- 0.21, plugin API 205.
void plugin_module_make_resident |
( |
GeanyPlugin * |
plugin | ) |
|
Ensures that a plugin's module (*.so) will never be unloaded.
This is necessary if you register new GTypes in your plugin, e.g. when using own classes using the GObject system.
- Parameters
-
- Since
- 0.16
Sets up or resizes a keybinding group for the plugin.
You should then call keybindings_set_item() for each keybinding in the group.
- Parameters
-
plugin | Must be geany_plugin. |
section_name | Name used in the configuration file, such as "html_chars" . |
count | Number of keybindings for the group. |
callback | Group callback, or NULL if you only want individual keybinding callbacks. |
- Returns
- The plugin's keybinding group.
- Since
- 0.19.
void plugin_signal_connect |
( |
GeanyPlugin * |
plugin, |
|
|
GObject * |
object, |
|
|
const gchar * |
signal_name, |
|
|
gboolean |
after, |
|
|
GCallback |
callback, |
|
|
gpointer |
user_data |
|
) |
| |
Connects a signal which will be disconnected on unloading the plugin, to prevent a possible segfault.
- Parameters
-
plugin | Must be geany_plugin. |
object | Object to connect to, or NULL when using Geany signals . |
signal_name | The name of the signal. For a list of available signals, please see the Signal documentation . |
after | Set to TRUE to call your handler after the main signal handlers have been called (if supported by signal_name). |
callback | The function to call when the signal is emitted. |
user_data | The user data passed to the signal handler. |
- See also
- plugin_callbacks.
- Warning
- This should only be used on objects that outlive the plugin, never on objects that will get destroyed before the plugin is unloaded. For objects created and destroyed by the plugin, you can simply use
g_signal_connect()
, since all handlers are disconnected when the object is destroyed anyway. For objects that may or may not outlive the plugin (like a document's ScintillaObject
, which is destroyed when the document is closed), you currently have to manually handle both situations, when the plugin is unloaded before the object is destroyed (and then, you have to disconnect the signal on plugin_cleanup()
), and when the object is destroyed during the plugin's lifetime (in which case you cannot and should not disconnect manually in plugin_cleanup()
since it already has been disconnected and the object has been destroyed), and disconnect yourself or not as appropriate.
guint plugin_timeout_add |
( |
GeanyPlugin * |
plugin, |
|
|
guint |
interval, |
|
|
GSourceFunc |
function, |
|
|
gpointer |
data |
|
) |
| |
Adds a GLib main loop timeout callback that will be removed when unloading the plugin, preventing it to run after the plugin has been unloaded (which may lead to a segfault).
- Parameters
-
plugin | Must be geany_plugin. |
interval | The time between calls to the function, in milliseconds. |
function | The function to call after the given timeout. |
data | The user data passed to the function. |
- Returns
- the ID of the event source (you generally won't need it, or better use g_timeout_add() directly if you want to manage this event source manually).
- See also
- g_timeout_add()
- Since
- 0.21, plugin API 205.
guint plugin_timeout_add_seconds |
( |
GeanyPlugin * |
plugin, |
|
|
guint |
interval, |
|
|
GSourceFunc |
function, |
|
|
gpointer |
data |
|
) |
| |
Adds a GLib main loop timeout callback that will be removed when unloading the plugin, preventing it to run after the plugin has been unloaded (which may lead to a segfault).
- Parameters
-
plugin | Must be geany_plugin. |
interval | The time between calls to the function, in seconds. |
function | The function to call after the given timeout. |
data | The user data passed to the function. |
- Returns
- the ID of the event source (you generally won't need it, or better use g_timeout_add_seconds() directly if you want to manage this event source manually).
- See also
- g_timeout_add_seconds()
- Since
- 0.21, plugin API 205.