Add a new section to the Windows installer to install header files
[geany-mirror.git] / doc / pluginsignals.c
blobcacdcff3ef92c5bcb120860be7f7467978d732d3
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 appropiate 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.
106 * The previous filetype object is passed but it can be NULL (e.g. at startup).
107 * The new filetype can be read with: @code
108 * GeanyFiletype *ft = doc->file_type;
109 * @endcode
111 * @param obj a GeanyObject instance, should be ignored.
112 * @param doc the saved document.
113 * @param filetype_old the previous filetype of the document.
114 * @param user_data user data.
116 signal void (*document_filetype_set)(GObject *obj, GeanyDocument *doc, GeanyFiletype *filetype_old, gpointer user_data);
118 /** Sent when switching notebook pages.
120 * @param obj a GeanyObject instance, should be ignored.
121 * @param doc the current document.
122 * @param user_data user data.
124 signal void (*document_activate)(GObject *obj, GeanyDocument *doc, gpointer user_data);
126 /** Sent before closing a document.
128 * @param obj a GeanyObject instance, should be ignored.
129 * @param doc the document about to be closed.
130 * @param user_data user data.
132 signal void (*document_close)(GObject *obj, GeanyDocument *doc, gpointer user_data);
134 /** Sent after a project is opened but before session files are loaded.
135 * @param obj a GeanyObject instance, should be ignored.
136 * @param config an exising GKeyFile object which can be used to read and write data.
137 * It must not be closed or freed.
138 * @param user_data user data.
140 signal void (*project_open)(GObject *obj, GKeyFile *config, gpointer user_data);
142 /** Sent when a project is saved(happens when the project is created, the properties
143 * dialog is closed or Geany is exited). This signal is emitted shortly before Geany
144 * will write the contents of the GKeyFile to the disc.
145 * @param obj a GeanyObject instance, should be ignored.
146 * @param config an exising GKeyFile object which can be used to read and write data.
147 * It must not be closed or freed.
148 * @param user_data user data.
150 signal void (*project_save)(GObject *obj, GKeyFile *config, gpointer user_data);
152 /** Sent after a project is closed.
153 * @param obj a GeanyObject instance, should be ignored.
154 * @param user_data user data.
156 signal void (*project_close)(GObject *obj, gpointer user_data);
158 /** Sent after a project dialog is opened but before it is displayed. Plugins
159 * can append their own project settings tabs by using this signal.
160 * @param obj a GeanyObject instance, should be ignored.
161 * @param notebook a GtkNotebook instance that can be used by plugins to append their
162 * settings tabs.
163 * @param user_data user data.
165 signal void (*project_dialog_open)(GObject *obj, GtkWidget *notebook, gpointer user_data);
167 /** Sent when the settings dialog is confirmed by the user. Plugins can use
168 * this signal to read the settings widgets previously added by using the
169 * @c project-dialog-open signal.
170 * @warning The dialog will still be running afterwards if the user chose 'Apply'.
171 * @param obj a GeanyObject instance, should be ignored.
172 * @param notebook a GtkNotebook instance that can be used by plugins to read their
173 * settings widgets.
174 * @param user_data user data.
176 signal void (*project_dialog_confirmed)(GObject *obj, GtkWidget *notebook, gpointer user_data);
178 /** Sent before project dialog is closed. By using this signal, plugins can remove
179 * tabs previously added in project-dialog-open signal handler.
180 * @param obj a GeanyObject instance, should be ignored.
181 * @param notebook a GtkNotebook instance that can be used by plugins to remove
182 * settings tabs previously added in the project-dialog-open signal handler.
183 * @param user_data user data.
185 signal void (*project_dialog_close)(GObject *obj, GtkWidget *notebook, gpointer user_data);
187 /** Sent once Geany has finished all initialization and startup tasks and the GUI has been
188 * realized. This signal is the very last step in the startup process and is sent once
189 * the GTK main event loop has been entered.
191 * @param obj a GeanyObject instance, should be ignored.
192 * @param user_data user data.
194 signal void (*geany_startup_complete)(GObject *obj, gpointer user_data);
196 /** Sent before build is started. A plugin could use this signal e.g. to save all unsaved documents
197 * before the build starts.
199 * @param obj a GeanyObject instance, should be ignored.
200 * @param user_data user data.
202 signal void (*build_start)(GObject *obj, gpointer user_data);
204 /** Sent before the popup menu of the editing widget is shown. This can be used to modify or extend
205 * the popup menu.
207 * @note You can add menu items from @c plugin_init() using @c geany->main_widgets->editor_menu,
208 * remembering to destroy them in @c plugin_cleanup().
210 * @param obj a GeanyObject instance, should be ignored.
211 * @param word the current word (in UTF-8 encoding) below the cursor position
212 where the popup menu will be opened.
213 * @param click_pos the cursor position where the popup will be opened.
214 * @param doc the current document.
215 * @param user_data user data.
217 signal void (*update_editor_menu)(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc,
218 gpointer user_data);
220 /** Sent whenever something in the editor widget changes.
221 * E.g. Character added, fold level changes, clicks to the line number margin.
222 * A detailed description of possible notifications and the SCNotification can be found at
223 * http://www.scintilla.org/ScintillaDoc.html#Notifications.
225 * If you connect to this signal, you must check @c nt->nmhdr.code for the notification type
226 * to prevent handling unwanted notifications. This is important because for instance SCN_UPDATEUI
227 * is sent very often whereas you probably don't want to handle this notification.
229 * By default, the signal is sent before Geany's default handler is processing the event.
230 * Your callback function should return FALSE to allow Geany processing the event as well. If you
231 * want to prevent this for some reason, return TRUE.
232 * Please use this with care as it can break basic functionality of Geany.
234 * The signal can be sent after Geany's default handler has been run when you set
235 * PluginCallback::after field to TRUE.
237 * An example callback implemention of this signal can be found in the Demo plugin.
239 * @warning This signal has much power and should be used carefully. You should especially
240 * care about the return value; make sure to return TRUE only if it is necessary
241 * and in the correct situations.
243 * @param obj a GeanyObject instance, should be ignored.
244 * @param editor The current GeanyEditor.
245 * @param nt A pointer to the SCNotification struct which holds additional information for
246 * the event.
247 * @param user_data user data.
248 * @return @c TRUE to stop other handlers from being invoked for the event.
249 * @c FALSE to propagate the event further.
251 * @since 0.16
253 signal gboolean (*editor_notify)(GObject *obj, GeanyEditor *editor, SCNotification *nt,
254 gpointer user_data);