geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pluginsignals.c
Go to the documentation of this file.
1/*
2 * pluginsignals.c - this file is part of Geany, a fast and lightweight IDE
3 *
4 * Copyright 2008 The Geany contributors
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21/* Note: this file is for Doxygen only. */
22
23/**
24 * @file pluginsignals.c
25 * Plugin Signals
26 *
27 *
28 * @section Usage
29 *
30 * To use plugin signals in Geany, you have two options:
31 *
32 * -# Create a PluginCallback array with the @ref plugin_callbacks symbol. List the signals
33 * you want to listen to and create the appropriate signal callbacks for each signal.
34 * The callback array is read @a after plugin_init() has been called.
35 * -# Use plugin_signal_connect(), which can be called at any time and can also connect
36 * to non-Geany signals (such as GTK widget signals).
37 *
38 * This page lists the signal prototypes, but you connect to them using the
39 * string name (which by convention uses @c - hyphens instead of @c _ underscores).
40 *
41 * E.g. @c "document-open" for @ref document_open.
42 *
43 * The following code demonstrates how to use signals in Geany plugins. The code can be inserted
44 * in your plugin code at any desired position.
45 *
46 * @code
47static void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data)
48{
49 printf("Example: %s was opened\n", DOC_FILENAME(doc));
50}
51
52PluginCallback plugin_callbacks[] =
53{
54 { "document-open", (GCallback) &on_document_open, FALSE, NULL },
55 { NULL, NULL, FALSE, NULL }
56};
57 * @endcode
58 * @note The PluginCallback array has to be ended with a final @c NULL entry.
59 */
60
61/** Sent when a new document is created.
62 *
63 * @param obj a GeanyObject instance, should be ignored.
64 * @param doc the new document.
65 * @param user_data user data.
66 */
67signal void (*document_new)(GObject *obj, GeanyDocument *doc, gpointer user_data);
68
69/** Sent when a new document is opened.
70 *
71 * @param obj a GeanyObject instance, should be ignored.
72 * @param doc the opened document.
73 * @param user_data user data.
74 */
75signal void (*document_open)(GObject *obj, GeanyDocument *doc, gpointer user_data);
76
77/** Sent when an existing document is reloaded.
78 *
79 * @param obj a GeanyObject instance, should be ignored.
80 * @param doc the re-opened document.
81 * @param user_data user data.
82 *
83 * @since 0.21
84 */
85signal void (*document_reload)(GObject *obj, GeanyDocument *doc, gpointer user_data);
86
87/** Sent before a document is saved.
88 *
89 * @param obj a GeanyObject instance, should be ignored.
90 * @param doc the document to be saved.
91 * @param user_data user data.
92 */
93signal void (*document_before_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
94
95/** Sent when a new document is saved.
96 *
97 * @param obj a GeanyObject instance, should be ignored.
98 * @param doc the saved document.
99 * @param user_data user data.
100 */
101signal void (*document_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
102
103
104/** Sent after the filetype of a document has been changed.
105 *
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
110 *
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.
115 */
116signal void (*document_filetype_set)(GObject *obj, GeanyDocument *doc, GeanyFiletype *filetype_old, gpointer user_data);
117
118/** Sent when switching notebook pages.
119 *
120 * @param obj a GeanyObject instance, should be ignored.
121 * @param doc the current document.
122 * @param user_data user data.
123 */
124signal void (*document_activate)(GObject *obj, GeanyDocument *doc, gpointer user_data);
125
126/** Sent before closing a document.
127 *
128 * @param obj a GeanyObject instance, should be ignored.
129 * @param doc the document about to be closed.
130 * @param user_data user data.
131 */
132signal void (*document_close)(GObject *obj, GeanyDocument *doc, gpointer user_data);
133
134/** Sent after a project is opened but before session files are loaded.
135 *
136 * @param obj a GeanyObject instance, should be ignored.
137 * @param config an existing GKeyFile object which can be used to read and write data.
138 * It must not be closed or freed.
139 * @param user_data user data.
140 */
141signal void (*project_open)(GObject *obj, GKeyFile *config, gpointer user_data);
142
143/** Sent when a project is saved (happens when the project is created, the properties
144 * dialog is closed, before the project is closed, when Geany automatically
145 * saves its configuration by opening/closing documents or when Geany is exited).
146 * This signal is emitted shortly before Geany will write the contents of the
147 * GKeyFile to the disc.
148 *
149 * @param obj a GeanyObject instance, should be ignored.
150 * @param config an existing GKeyFile object which can be used to read and write data.
151 * It must not be closed or freed.
152 * @param user_data user data.
153 */
154signal void (*project_save)(GObject *obj, GKeyFile *config, gpointer user_data);
155
156/** Sent after a project is closed.
157 *
158 * @param obj a GeanyObject instance, should be ignored.
159 * @param user_data user data.
160 */
161signal void (*project_close)(GObject *obj, gpointer user_data);
162
163/** Sent before a project is closed.
164 *
165 * @param obj a GeanyObject instance, should be ignored.
166 * @param user_data user data.
167 *
168 * @since 1.29 (API 230)
169 */
170signal void (*project_before_close)(GObject *obj, gpointer user_data);
171
172/** Sent after a project dialog is opened but before it is displayed. Plugins
173 * can append their own project settings tabs by using this signal.
174 *
175 * @param obj a GeanyObject instance, should be ignored.
176 * @param notebook a GtkNotebook instance that can be used by plugins to append their
177 * settings tabs.
178 * @param user_data user data.
179 */
180signal void (*project_dialog_open)(GObject *obj, GtkWidget *notebook, gpointer user_data);
181
182/** Sent when the settings dialog is confirmed by the user. Plugins can use
183 * this signal to read the settings widgets previously added by using the
184 * @c project-dialog-open signal.
185 *
186 * @warning The dialog will still be running afterwards if the user chose 'Apply'.
187 * @param obj a GeanyObject instance, should be ignored.
188 * @param notebook a GtkNotebook instance that can be used by plugins to read their
189 * settings widgets.
190 * @param user_data user data.
191 */
192signal void (*project_dialog_confirmed)(GObject *obj, GtkWidget *notebook, gpointer user_data);
193
194/** Sent before project dialog is closed. By using this signal, plugins can remove
195 * tabs previously added in project-dialog-open signal handler.
196 *
197 * @param obj a GeanyObject instance, should be ignored.
198 * @param notebook a GtkNotebook instance that can be used by plugins to remove
199 * settings tabs previously added in the project-dialog-open signal handler.
200 * @param user_data user data.
201 */
202signal void (*project_dialog_close)(GObject *obj, GtkWidget *notebook, gpointer user_data);
203
204/** Sent once Geany has finished all initialization and startup tasks and the GUI has been
205 * realized. This signal is the very last step in the startup process and is sent once
206 * the GTK main event loop has been entered.
207 *
208 * @param obj a GeanyObject instance, should be ignored.
209 * @param user_data user data.
210 */
211signal void (*geany_startup_complete)(GObject *obj, gpointer user_data);
212
213/** Sent before build is started. A plugin could use this signal e.g. to save all unsaved documents
214 * before the build starts.
215 *
216 * @param obj a GeanyObject instance, should be ignored.
217 * @param user_data user data.
218 */
219signal void (*build_start)(GObject *obj, gpointer user_data);
220
221/** Sent before the popup menu of the editing widget is shown. This can be used to modify or extend
222 * the popup menu.
223 *
224 * @note You can add menu items from @c plugin_init() using @c geany->main_widgets->editor_menu,
225 * remembering to destroy them in @c plugin_cleanup().
226 *
227 * @param obj a GeanyObject instance, should be ignored.
228 * @param word the current word (in UTF-8 encoding) below the cursor position
229 * where the popup menu will be opened.
230 * @param pos the cursor position where the popup will be opened.
231 * @param doc the current document.
232 * @param user_data user data.
233 */
234signal void (*update_editor_menu)(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc,
235 gpointer user_data);
236
237/** Sent whenever something in the editor widget changes.
238 *
239 * E.g. Character added, fold level changes, clicks to the line number margin.
240 * A detailed description of possible notifications and the SCNotification can be found at
241 * http://www.scintilla.org/ScintillaDoc.html#Notifications.
242 *
243 * If you connect to this signal, you must check @c nt->nmhdr.code for the notification type
244 * to prevent handling unwanted notifications. This is important because for instance SCN_UPDATEUI
245 * is sent very often whereas you probably don't want to handle this notification.
246 *
247 * By default, the signal is sent before Geany's default handler is processing the event.
248 * Your callback function should return FALSE to allow Geany processing the event as well. If you
249 * want to prevent this for some reason, return TRUE.
250 * Please use this with care as it can break basic functionality of Geany.
251 *
252 * The signal can be sent after Geany's default handler has been run when you set
253 * PluginCallback::after field to TRUE.
254 *
255 * An example callback implementation of this signal can be found in the Demo plugin.
256 *
257 * @warning This signal has much power and should be used carefully. You should especially
258 * care about the return value; make sure to return TRUE only if it is necessary
259 * and in the correct situations.
260 *
261 * @param obj a GeanyObject instance, should be ignored.
262 * @param editor The current GeanyEditor.
263 * @param nt A pointer to the SCNotification struct which holds additional information for
264 * the event.
265 * @param user_data user data.
266 * @return @c TRUE to stop other handlers from being invoked for the event.
267 * @c FALSE to propagate the event further.
268 *
269 * @since 0.16
270 */
271signal gboolean (*editor_notify)(GObject *obj, GeanyEditor *editor, SCNotification *nt,
272 gpointer user_data);
273
274/** Sent whenever a key is pressed.
275 *
276 * This signal allows plugins to receive key press events before they are processed
277 * by Geany. Plugins can then process key presses before Geany and decide,
278 * whether Geany should receive the key press event or not.
279 *
280 * @warning This signal should be used carefully. If multiple plugins use this
281 * signal, the result could be unpredictble depending on which plugin
282 * receives the signal first.
283 *
284 * @param obj a GeanyObject instance, should be ignored.
285 * @param key The GdkEventKey corresponding to the key press.
286 * @param user_data user data.
287 * @return @c TRUE to stop other handlers from being invoked for the event.
288 * @c FALSE to propagate the event further.
289 *
290 * @since 1.34
291 */
292signal gboolean (*key_press)(GObject *obj, GdkEventKey *key, gpointer user_data);
gint pos
Definition: editor.c:87
signal void(* document_open)(GObject *obj, GeanyDocument *doc, gpointer user_data)
Sent when a new document is opened.
Definition: pluginsignals.c:75
signal void(* document_new)(GObject *obj, GeanyDocument *doc, gpointer user_data)
Sent when a new document is created.
Definition: pluginsignals.c:67
signal void(* project_open)(GObject *obj, GKeyFile *config, gpointer user_data)
Sent after a project is opened but before session files are loaded.
signal void(* project_before_close)(GObject *obj, gpointer user_data)
Sent before a project is closed.
signal void(* document_save)(GObject *obj, GeanyDocument *doc, gpointer user_data)
Sent when a new document is saved.
signal gboolean(* editor_notify)(GObject *obj, GeanyEditor *editor, SCNotification *nt, gpointer user_data)
Sent whenever something in the editor widget changes.
signal void(* project_close)(GObject *obj, gpointer user_data)
Sent after a project is closed.
signal void(* build_start)(GObject *obj, gpointer user_data)
Sent before build is started.
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.
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.
signal void(* project_dialog_open)(GObject *obj, GtkWidget *notebook, gpointer user_data)
Sent after a project dialog is opened but before it is displayed.
signal void(* document_reload)(GObject *obj, GeanyDocument *doc, gpointer user_data)
Sent when an existing document is reloaded.
Definition: pluginsignals.c:85
signal void(* project_dialog_confirmed)(GObject *obj, GtkWidget *notebook, gpointer user_data)
Sent when the settings dialog is confirmed by the user.
signal void(* project_dialog_close)(GObject *obj, GtkWidget *notebook, gpointer user_data)
Sent before project dialog is closed.
signal void(* document_before_save)(GObject *obj, GeanyDocument *doc, gpointer user_data)
Sent before a document is saved.
Definition: pluginsignals.c:93
signal void(* document_close)(GObject *obj, GeanyDocument *doc, gpointer user_data)
Sent before closing a document.
signal void(* document_activate)(GObject *obj, GeanyDocument *doc, gpointer user_data)
Sent when switching notebook pages.
signal gboolean(* key_press)(GObject *obj, GdkEventKey *key, gpointer user_data)
Sent whenever a key is pressed.
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.
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,...
Structure for representing an open tab with all its properties.
Definition: document.h:81
Editor-owned fields for each document.
Definition: editor.h:150
Represents a filetype.
Definition: filetypes.h:144