Merge pull request #581 from techee/symbollist_sort
[geany-mirror.git] / doc / pluginsignals.c
blobec51914f400d13ca3f21f47bc5c24cfbfa60bb53
1 /*
2 * pluginsignals.c - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2008-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2008-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 /* Note: this file is for Doxygen only. */
24 /**
25 * @file pluginsignals.c
26 * Plugin Signals
29 * @section Usage
31 * To use plugin signals in Geany, you have two options:
33 * -# Create a PluginCallback array with the @ref plugin_callbacks symbol. List the signals
34 * you want to listen to and create the appropriate signal callbacks for each signal.
35 * The callback array is read @a after plugin_init() has been called.
36 * -# Use plugin_signal_connect(), which can be called at any time and can also connect
37 * to non-Geany signals (such as GTK widget signals).
39 * This page lists the signal prototypes, but you connect to them using the
40 * string name (which by convention uses @c - hyphens instead of @c _ underscores).
42 * E.g. @c "document-open" for @ref document_open.
44 * The following code demonstrates how to use signals in Geany plugins. The code can be inserted
45 * in your plugin code at any desired position.
47 * @code
48 static void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data)
50 printf("Example: %s was opened\n", DOC_FILENAME(doc));
53 PluginCallback plugin_callbacks[] =
55 { "document-open", (GCallback) &on_document_open, FALSE, NULL },
56 { NULL, NULL, FALSE, NULL }
58 * @endcode
59 * @note The PluginCallback array has to be ended with a final @c NULL entry.
62 /** Sent when a new document is created.
64 * @param obj a GeanyObject instance, should be ignored.
65 * @param doc the new document.
66 * @param user_data user data.
68 signal void (*document_new)(GObject *obj, GeanyDocument *doc, gpointer user_data);
70 /** Sent when a new document is opened.
72 * @param obj a GeanyObject instance, should be ignored.
73 * @param doc the opened document.
74 * @param user_data user data.
76 signal void (*document_open)(GObject *obj, GeanyDocument *doc, gpointer user_data);
78 /** Sent when an existing document is reloaded.
80 * @param obj a GeanyObject instance, should be ignored.
81 * @param doc the re-opened document.
82 * @param user_data user data.
84 * @since 0.21
86 signal void (*document_reload)(GObject *obj, GeanyDocument *doc, gpointer user_data);
88 /** Sent before a document is saved.
90 * @param obj a GeanyObject instance, should be ignored.
91 * @param doc the document to be saved.
92 * @param user_data user data.
94 signal void (*document_before_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
96 /** Sent when a new document is saved.
98 * @param obj a GeanyObject instance, should be ignored.
99 * @param doc the saved document.
100 * @param user_data user data.
102 signal void (*document_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
105 /** Sent after the filetype of a document has been changed.
107 * The previous filetype object is passed but it can be NULL (e.g. at startup).
108 * The new filetype can be read with: @code
109 * GeanyFiletype *ft = doc->file_type;
110 * @endcode
112 * @param obj a GeanyObject instance, should be ignored.
113 * @param doc the saved document.
114 * @param filetype_old the previous filetype of the document.
115 * @param user_data user data.
117 signal void (*document_filetype_set)(GObject *obj, GeanyDocument *doc, GeanyFiletype *filetype_old, gpointer user_data);
119 /** Sent when switching notebook pages.
121 * @param obj a GeanyObject instance, should be ignored.
122 * @param doc the current document.
123 * @param user_data user data.
125 signal void (*document_activate)(GObject *obj, GeanyDocument *doc, gpointer user_data);
127 /** Sent before closing a document.
129 * @param obj a GeanyObject instance, should be ignored.
130 * @param doc the document about to be closed.
131 * @param user_data user data.
133 signal void (*document_close)(GObject *obj, GeanyDocument *doc, gpointer user_data);
135 /** Sent after a project is opened but before session files are loaded.
137 * @param obj a GeanyObject instance, should be ignored.
138 * @param config an exising GKeyFile object which can be used to read and write data.
139 * It must not be closed or freed.
140 * @param user_data user data.
142 signal void (*project_open)(GObject *obj, GKeyFile *config, gpointer user_data);
144 /** Sent when a project is saved(happens when the project is created, the properties
145 * dialog is closed or Geany is exited). This signal is emitted shortly before Geany
146 * will write the contents of the GKeyFile to the disc.
148 * @param obj a GeanyObject instance, should be ignored.
149 * @param config an exising GKeyFile object which can be used to read and write data.
150 * It must not be closed or freed.
151 * @param user_data user data.
153 signal void (*project_save)(GObject *obj, GKeyFile *config, gpointer user_data);
155 /** Sent after a project is closed.
157 * @param obj a GeanyObject instance, should be ignored.
158 * @param user_data user data.
160 signal void (*project_close)(GObject *obj, gpointer user_data);
162 /** Sent after a project dialog is opened but before it is displayed. Plugins
163 * can append their own project settings tabs by using this signal.
165 * @param obj a GeanyObject instance, should be ignored.
166 * @param notebook a GtkNotebook instance that can be used by plugins to append their
167 * settings tabs.
168 * @param user_data user data.
170 signal void (*project_dialog_open)(GObject *obj, GtkWidget *notebook, gpointer user_data);
172 /** Sent when the settings dialog is confirmed by the user. Plugins can use
173 * this signal to read the settings widgets previously added by using the
174 * @c project-dialog-open signal.
176 * @warning The dialog will still be running afterwards if the user chose 'Apply'.
177 * @param obj a GeanyObject instance, should be ignored.
178 * @param notebook a GtkNotebook instance that can be used by plugins to read their
179 * settings widgets.
180 * @param user_data user data.
182 signal void (*project_dialog_confirmed)(GObject *obj, GtkWidget *notebook, gpointer user_data);
184 /** Sent before project dialog is closed. By using this signal, plugins can remove
185 * tabs previously added in project-dialog-open signal handler.
187 * @param obj a GeanyObject instance, should be ignored.
188 * @param notebook a GtkNotebook instance that can be used by plugins to remove
189 * settings tabs previously added in the project-dialog-open signal handler.
190 * @param user_data user data.
192 signal void (*project_dialog_close)(GObject *obj, GtkWidget *notebook, gpointer user_data);
194 /** Sent once Geany has finished all initialization and startup tasks and the GUI has been
195 * realized. This signal is the very last step in the startup process and is sent once
196 * the GTK main event loop has been entered.
198 * @param obj a GeanyObject instance, should be ignored.
199 * @param user_data user data.
201 signal void (*geany_startup_complete)(GObject *obj, gpointer user_data);
203 /** Sent before build is started. A plugin could use this signal e.g. to save all unsaved documents
204 * before the build starts.
206 * @param obj a GeanyObject instance, should be ignored.
207 * @param user_data user data.
209 signal void (*build_start)(GObject *obj, gpointer user_data);
211 /** Sent before the popup menu of the editing widget is shown. This can be used to modify or extend
212 * the popup menu.
214 * @note You can add menu items from @c plugin_init() using @c geany->main_widgets->editor_menu,
215 * remembering to destroy them in @c plugin_cleanup().
217 * @param obj a GeanyObject instance, should be ignored.
218 * @param word the current word (in UTF-8 encoding) below the cursor position
219 * where the popup menu will be opened.
220 * @param click_pos the cursor position where the popup will be opened.
221 * @param doc the current document.
222 * @param user_data user data.
224 signal void (*update_editor_menu)(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc,
225 gpointer user_data);
227 /** Sent whenever something in the editor widget changes.
229 * E.g. Character added, fold level changes, clicks to the line number margin.
230 * A detailed description of possible notifications and the SCNotification can be found at
231 * http://www.scintilla.org/ScintillaDoc.html#Notifications.
233 * If you connect to this signal, you must check @c nt->nmhdr.code for the notification type
234 * to prevent handling unwanted notifications. This is important because for instance SCN_UPDATEUI
235 * is sent very often whereas you probably don't want to handle this notification.
237 * By default, the signal is sent before Geany's default handler is processing the event.
238 * Your callback function should return FALSE to allow Geany processing the event as well. If you
239 * want to prevent this for some reason, return TRUE.
240 * Please use this with care as it can break basic functionality of Geany.
242 * The signal can be sent after Geany's default handler has been run when you set
243 * PluginCallback::after field to TRUE.
245 * An example callback implemention of this signal can be found in the Demo plugin.
247 * @warning This signal has much power and should be used carefully. You should especially
248 * care about the return value; make sure to return TRUE only if it is necessary
249 * and in the correct situations.
251 * @param obj a GeanyObject instance, should be ignored.
252 * @param editor The current GeanyEditor.
253 * @param nt A pointer to the SCNotification struct which holds additional information for
254 * the event.
255 * @param user_data user data.
256 * @return @c TRUE to stop other handlers from being invoked for the event.
257 * @c FALSE to propagate the event further.
259 * @since 0.16
261 signal gboolean (*editor_notify)(GObject *obj, GeanyEditor *editor, SCNotification *nt,
262 gpointer user_data);