Geany dev
Variables
pluginsignals.c File Reference

Plugin Signals. More...

Variables

signal void(* build_start )(GObject *obj, gpointer user_data)
 Sent before build is started. More...
 
signal void(* document_activate )(GObject *obj, GeanyDocument *doc, gpointer user_data)
 Sent when switching notebook pages. More...
 
signal void(* document_before_save )(GObject *obj, GeanyDocument *doc, gpointer user_data)
 Sent before a document is saved. More...
 
signal void(* document_close )(GObject *obj, GeanyDocument *doc, gpointer user_data)
 Sent before closing a document. More...
 
signal void(* document_filetype_set )(GObject *obj, GeanyDocument *doc, GeanyFiletype *filetype_old, gpointer user_data)
 Sent after the filetype of a document has been changed. More...
 
signal void(* document_new )(GObject *obj, GeanyDocument *doc, gpointer user_data)
 Sent when a new document is created. More...
 
signal void(* document_open )(GObject *obj, GeanyDocument *doc, gpointer user_data)
 Sent when a new document is opened. More...
 
signal void(* document_reload )(GObject *obj, GeanyDocument *doc, gpointer user_data)
 Sent when an existing document is reloaded. More...
 
signal void(* document_save )(GObject *obj, GeanyDocument *doc, gpointer user_data)
 Sent when a new document is saved. More...
 
signal gboolean(* editor_notify )(GObject *obj, GeanyEditor *editor, SCNotification *nt, gpointer user_data)
 Sent whenever something in the editor widget changes. More...
 
signal void(* geany_startup_complete )(GObject *obj, gpointer user_data)
 Sent once Geany has finished all initialization and startup tasks and the GUI has been realized. More...
 
signal gboolean(* key_press )(GObject *obj, GdkEventKey *key, gpointer user_data)
 Sent whenever a key is pressed. More...
 
signal void(* project_before_close )(GObject *obj, gpointer user_data)
 Sent before a project is closed. More...
 
signal void(* project_close )(GObject *obj, gpointer user_data)
 Sent after a project is closed. More...
 
signal void(* project_dialog_close )(GObject *obj, GtkWidget *notebook, gpointer user_data)
 Sent before project dialog is closed. More...
 
signal void(* project_dialog_confirmed )(GObject *obj, GtkWidget *notebook, gpointer user_data)
 Sent when the settings dialog is confirmed by the user. More...
 
signal void(* project_dialog_open )(GObject *obj, GtkWidget *notebook, gpointer user_data)
 Sent after a project dialog is opened but before it is displayed. More...
 
signal void(* project_open )(GObject *obj, GKeyFile *config, gpointer user_data)
 Sent after a project is opened but before session files are loaded. More...
 
signal void(* project_save )(GObject *obj, GKeyFile *config, gpointer user_data)
 Sent when a project is saved (happens when the project is created, the properties dialog is closed, before the project is closed, when Geany automatically saves its configuration by opening/closing documents or when Geany is exited). More...
 
signal void(* update_editor_menu )(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, gpointer user_data)
 Sent before the popup menu of the editing widget is shown. More...
 

Detailed Description

Plugin Signals.

Usage

To use plugin signals in Geany, you have two options:

  1. Create a PluginCallback array with the plugin_callbacks symbol. List the signals you want to listen to and create the appropriate signal callbacks for each signal. The callback array is read after plugin_init() has been called.
  2. Use plugin_signal_connect(), which can be called at any time and can also connect to non-Geany signals (such as GTK widget signals).

This page lists the signal prototypes, but you connect to them using the string name (which by convention uses - hyphens instead of _ underscores).

E.g. "document-open" for document_open.

The following code demonstrates how to use signals in Geany plugins. The code can be inserted in your plugin code at any desired position.

static void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data)
{
printf("Example: %s was opened\n", DOC_FILENAME(doc));
}
{
{ "document-open", (GCallback) &on_document_open, FALSE, NULL },
{ NULL, NULL, FALSE, NULL }
};
#define DOC_FILENAME(doc)
Returns the filename of the document passed or GEANY_STRING_UNTITLED (e.g.
Definition: document.h:162
PluginCallback plugin_callbacks[]
An array for connecting GeanyObject events, which should be terminated with {NULL,...
Definition: pluginsymbols.c:75
Structure for representing an open tab with all its properties.
Definition: document.h:81
Callback array entry type used with the plugin_callbacks symbol.
Definition: plugindata.h:147
Note
The PluginCallback array has to be ended with a final NULL entry.

Variable Documentation

◆ build_start

signal void(* build_start) (GObject *obj, gpointer user_data) ( GObject *  obj,
gpointer  user_data 
)

Sent before build is started.

A plugin could use this signal e.g. to save all unsaved documents before the build starts.

Parameters
obja GeanyObject instance, should be ignored.
user_datauser data.

◆ document_activate

signal void(* document_activate) (GObject *obj, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
gpointer  user_data 
)

Sent when switching notebook pages.

Parameters
obja GeanyObject instance, should be ignored.
docthe current document.
user_datauser data.

◆ document_before_save

signal void(* document_before_save) (GObject *obj, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
gpointer  user_data 
)

Sent before a document is saved.

Parameters
obja GeanyObject instance, should be ignored.
docthe document to be saved.
user_datauser data.

◆ document_close

signal void(* document_close) (GObject *obj, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
gpointer  user_data 
)

Sent before closing a document.

Parameters
obja GeanyObject instance, should be ignored.
docthe document about to be closed.
user_datauser data.

◆ document_filetype_set

signal void(* document_filetype_set) (GObject *obj, GeanyDocument *doc, GeanyFiletype *filetype_old, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
GeanyFiletype filetype_old,
gpointer  user_data 
)

Sent after the filetype of a document has been changed.

The previous filetype object is passed but it can be NULL (e.g. at startup). The new filetype can be read with:

GeanyFiletype *ft = doc->file_type;
Represents a filetype.
Definition: filetypes.h:142
Parameters
obja GeanyObject instance, should be ignored.
docthe saved document.
filetype_oldthe previous filetype of the document.
user_datauser data.

◆ document_new

signal void(* document_new) (GObject *obj, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
gpointer  user_data 
)

Sent when a new document is created.

Parameters
obja GeanyObject instance, should be ignored.
docthe new document.
user_datauser data.

◆ document_open

signal void(* document_open) (GObject *obj, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
gpointer  user_data 
)

Sent when a new document is opened.

Parameters
obja GeanyObject instance, should be ignored.
docthe opened document.
user_datauser data.

◆ document_reload

signal void(* document_reload) (GObject *obj, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
gpointer  user_data 
)

Sent when an existing document is reloaded.

Parameters
obja GeanyObject instance, should be ignored.
docthe re-opened document.
user_datauser data.
Since
0.21

◆ document_save

signal void(* document_save) (GObject *obj, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
GeanyDocument doc,
gpointer  user_data 
)

Sent when a new document is saved.

Parameters
obja GeanyObject instance, should be ignored.
docthe saved document.
user_datauser data.

◆ editor_notify

signal gboolean(* editor_notify) (GObject *obj, GeanyEditor *editor, SCNotification *nt, gpointer user_data) ( GObject *  obj,
GeanyEditor editor,
SCNotification *  nt,
gpointer  user_data 
)

Sent whenever something in the editor widget changes.

E.g. Character added, fold level changes, clicks to the line number margin. A detailed description of possible notifications and the SCNotification can be found at https://www.scintilla.org/ScintillaDoc.html#Notifications.

If you connect to this signal, you must check nt->nmhdr.code for the notification type to prevent handling unwanted notifications. This is important because for instance SCN_UPDATEUI is sent very often whereas you probably don't want to handle this notification.

By default, the signal is sent before Geany's default handler is processing the event. Your callback function should return FALSE to allow Geany processing the event as well. If you want to prevent this for some reason, return TRUE. Please use this with care as it can break basic functionality of Geany.

The signal can be sent after Geany's default handler has been run when you set PluginCallback::after field to TRUE.

An example callback implementation of this signal can be found in the Demo plugin.

Warning
This signal has much power and should be used carefully. You should especially care about the return value; make sure to return TRUE only if it is necessary and in the correct situations.
Parameters
obja GeanyObject instance, should be ignored.
editorThe current GeanyEditor.
ntA pointer to the SCNotification struct which holds additional information for the event.
user_datauser data.
Returns
TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.
Since
0.16

◆ geany_startup_complete

signal void(* geany_startup_complete) (GObject *obj, gpointer user_data) ( GObject *  obj,
gpointer  user_data 
)

Sent once Geany has finished all initialization and startup tasks and the GUI has been realized.

This signal is the very last step in the startup process and is sent once the GTK main event loop has been entered.

Parameters
obja GeanyObject instance, should be ignored.
user_datauser data.

◆ key_press

signal gboolean(* key_press) (GObject *obj, GdkEventKey *key, gpointer user_data) ( GObject *  obj,
GdkEventKey *  key,
gpointer  user_data 
)

Sent whenever a key is pressed.

This signal allows plugins to receive key press events before they are processed by Geany. Plugins can then process key presses before Geany and decide, whether Geany should receive the key press event or not.

Warning
This signal should be used carefully. If multiple plugins use this signal, the result could be unpredictble depending on which plugin receives the signal first.
Parameters
obja GeanyObject instance, should be ignored.
keyThe GdkEventKey corresponding to the key press.
user_datauser data.
Returns
TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.
Since
1.34

◆ project_before_close

signal void(* project_before_close) (GObject *obj, gpointer user_data) ( GObject *  obj,
gpointer  user_data 
)

Sent before a project is closed.

Parameters
obja GeanyObject instance, should be ignored.
user_datauser data.
Since
1.29 (API 230)

◆ project_close

signal void(* project_close) (GObject *obj, gpointer user_data) ( GObject *  obj,
gpointer  user_data 
)

Sent after a project is closed.

Parameters
obja GeanyObject instance, should be ignored.
user_datauser data.

◆ project_dialog_close

signal void(* project_dialog_close) (GObject *obj, GtkWidget *notebook, gpointer user_data) ( GObject *  obj,
GtkWidget *  notebook,
gpointer  user_data 
)

Sent before project dialog is closed.

By using this signal, plugins can remove tabs previously added in project-dialog-open signal handler.

Parameters
obja GeanyObject instance, should be ignored.
notebooka GtkNotebook instance that can be used by plugins to remove settings tabs previously added in the project-dialog-open signal handler.
user_datauser data.

◆ project_dialog_confirmed

signal void(* project_dialog_confirmed) (GObject *obj, GtkWidget *notebook, gpointer user_data) ( GObject *  obj,
GtkWidget *  notebook,
gpointer  user_data 
)

Sent when the settings dialog is confirmed by the user.

Plugins can use this signal to read the settings widgets previously added by using the project-dialog-open signal.

Warning
The dialog will still be running afterwards if the user chose 'Apply'.
Parameters
obja GeanyObject instance, should be ignored.
notebooka GtkNotebook instance that can be used by plugins to read their settings widgets.
user_datauser data.

◆ project_dialog_open

signal void(* project_dialog_open) (GObject *obj, GtkWidget *notebook, gpointer user_data) ( GObject *  obj,
GtkWidget *  notebook,
gpointer  user_data 
)

Sent after a project dialog is opened but before it is displayed.

Plugins can append their own project settings tabs by using this signal.

Parameters
obja GeanyObject instance, should be ignored.
notebooka GtkNotebook instance that can be used by plugins to append their settings tabs.
user_datauser data.

◆ project_open

signal void(* project_open) (GObject *obj, GKeyFile *config, gpointer user_data) ( GObject *  obj,
GKeyFile *  config,
gpointer  user_data 
)

Sent after a project is opened but before session files are loaded.

Parameters
obja GeanyObject instance, should be ignored.
configan existing GKeyFile object which can be used to read and write data. It must not be closed or freed.
user_datauser data.

◆ project_save

signal void(* project_save) (GObject *obj, GKeyFile *config, gpointer user_data) ( GObject *  obj,
GKeyFile *  config,
gpointer  user_data 
)

Sent when a project is saved (happens when the project is created, the properties dialog is closed, before the project is closed, when Geany automatically saves its configuration by opening/closing documents or when Geany is exited).

This signal is emitted shortly before Geany will write the contents of the GKeyFile to the disc.

Parameters
obja GeanyObject instance, should be ignored.
configan existing GKeyFile object which can be used to read and write data. It must not be closed or freed.
user_datauser data.

◆ update_editor_menu

signal void(* update_editor_menu) (GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, gpointer user_data) ( GObject *  obj,
const gchar *  word,
gint  pos,
GeanyDocument doc,
gpointer  user_data 
)

Sent before the popup menu of the editing widget is shown.

This can be used to modify or extend the popup menu.

Note
You can add menu items from plugin_init() using geany->main_widgets->editor_menu, remembering to destroy them in plugin_cleanup().
Parameters
obja GeanyObject instance, should be ignored.
wordthe current word (in UTF-8 encoding) below the cursor position where the popup menu will be opened.
posthe cursor position where the popup will be opened.
docthe current document.
user_datauser data.