Remove spurious colon
[geany-mirror.git] / src / geanyobject.c
blob10ba4244fd5302ed3121e3f110fa7ef7d747369e
1 /*
2 * geanyobject.c - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2007-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2007-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 /* A GObject used for connecting and emitting signals when certain events happen,
23 * e.g. opening a document.
24 * Mainly used for plugins - see the API docs.
26 * Core-only signals:
28 * signal void save_settings(GObject *obj, GKeyFile *keyfile, gpointer user_data);
29 * Emitted just before saving main keyfile settings.
31 * signal void load_settings(GObject *obj, GKeyFile *keyfile, gpointer user_data);
32 * Emitted just after loading main keyfile settings.
35 #ifdef HAVE_CONFIG_H
36 # include "config.h"
37 #endif
39 #include "geanyobject.h"
41 /* extern in geany.h */
42 GObject *geany_object;
44 static guint geany_object_signals[GCB_MAX] = { 0 };
47 typedef struct _GeanyObjectPrivate GeanyObjectPrivate;
49 struct _GeanyObjectPrivate
51 /* to avoid warnings (g_type_class_add_private: assertion `private_size > 0' failed) */
52 gchar dummy;
55 /** @gironly
56 * Get the GObject-derived GType for GeanyObject
58 * @return GeanyObject type */
59 GEANY_API_SYMBOL
60 GType geany_object_get_type(void);
62 G_DEFINE_TYPE(GeanyObject, geany_object, G_TYPE_OBJECT)
65 static gboolean boolean_handled_accumulator(GSignalInvocationHint *ihint, GValue *return_accu,
66 const GValue *handler_return, gpointer dummy)
68 gboolean continue_emission, signal_handled;
70 signal_handled = g_value_get_boolean(handler_return);
71 g_value_set_boolean(return_accu, signal_handled);
72 continue_emission = !signal_handled;
74 return continue_emission;
78 static void create_signals(GObjectClass *g_object_class)
80 /* Document signals */
81 geany_object_signals[GCB_DOCUMENT_NEW] = g_signal_new (
82 "document-new",
83 G_OBJECT_CLASS_TYPE (g_object_class),
84 G_SIGNAL_RUN_FIRST,
85 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
86 G_TYPE_NONE, 1,
87 GEANY_TYPE_DOCUMENT);
88 geany_object_signals[GCB_DOCUMENT_OPEN] = g_signal_new (
89 "document-open",
90 G_OBJECT_CLASS_TYPE (g_object_class),
91 G_SIGNAL_RUN_FIRST,
92 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
93 G_TYPE_NONE, 1,
94 GEANY_TYPE_DOCUMENT);
95 geany_object_signals[GCB_DOCUMENT_RELOAD] = g_signal_new (
96 "document-reload",
97 G_OBJECT_CLASS_TYPE (g_object_class),
98 G_SIGNAL_RUN_FIRST,
99 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
100 G_TYPE_NONE, 1,
101 GEANY_TYPE_DOCUMENT);
102 geany_object_signals[GCB_DOCUMENT_BEFORE_SAVE] = g_signal_new (
103 "document-before-save",
104 G_OBJECT_CLASS_TYPE (g_object_class),
105 G_SIGNAL_RUN_FIRST,
106 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
107 G_TYPE_NONE, 1,
108 GEANY_TYPE_DOCUMENT);
109 geany_object_signals[GCB_DOCUMENT_SAVE] = g_signal_new (
110 "document-save",
111 G_OBJECT_CLASS_TYPE (g_object_class),
112 G_SIGNAL_RUN_FIRST,
113 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
114 G_TYPE_NONE, 1,
115 GEANY_TYPE_DOCUMENT);
116 geany_object_signals[GCB_DOCUMENT_FILETYPE_SET] = g_signal_new (
117 "document-filetype-set",
118 G_OBJECT_CLASS_TYPE (g_object_class),
119 G_SIGNAL_RUN_FIRST,
120 0, NULL, NULL, NULL,
121 G_TYPE_NONE, 2,
122 GEANY_TYPE_DOCUMENT, GEANY_TYPE_FILETYPE);
123 geany_object_signals[GCB_DOCUMENT_ACTIVATE] = g_signal_new (
124 "document-activate",
125 G_OBJECT_CLASS_TYPE (g_object_class),
126 G_SIGNAL_RUN_FIRST,
127 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
128 G_TYPE_NONE, 1,
129 GEANY_TYPE_DOCUMENT);
130 geany_object_signals[GCB_DOCUMENT_CLOSE] = g_signal_new (
131 "document-close",
132 G_OBJECT_CLASS_TYPE (g_object_class),
133 G_SIGNAL_RUN_FIRST,
134 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
135 G_TYPE_NONE, 1,
136 GEANY_TYPE_DOCUMENT);
138 /* Project signals */
139 geany_object_signals[GCB_PROJECT_OPEN] = g_signal_new (
140 "project-open",
141 G_OBJECT_CLASS_TYPE (g_object_class),
142 G_SIGNAL_RUN_FIRST,
143 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
144 G_TYPE_NONE, 1,
145 G_TYPE_KEY_FILE);
146 geany_object_signals[GCB_PROJECT_SAVE] = g_signal_new (
147 "project-save",
148 G_OBJECT_CLASS_TYPE (g_object_class),
149 G_SIGNAL_RUN_FIRST,
150 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
151 G_TYPE_NONE, 1,
152 G_TYPE_KEY_FILE);
153 geany_object_signals[GCB_PROJECT_CLOSE] = g_signal_new (
154 "project-close",
155 G_OBJECT_CLASS_TYPE (g_object_class),
156 G_SIGNAL_RUN_FIRST,
157 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
158 G_TYPE_NONE, 0);
159 geany_object_signals[GCB_PROJECT_BEFORE_CLOSE] = g_signal_new (
160 "project-before-close",
161 G_OBJECT_CLASS_TYPE (g_object_class),
162 G_SIGNAL_RUN_FIRST,
163 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
164 G_TYPE_NONE, 0);
165 geany_object_signals[GCB_PROJECT_DIALOG_OPEN] = g_signal_new (
166 "project-dialog-open",
167 G_OBJECT_CLASS_TYPE (g_object_class),
168 G_SIGNAL_RUN_FIRST,
169 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
170 G_TYPE_NONE, 1,
171 GTK_TYPE_NOTEBOOK);
172 geany_object_signals[GCB_PROJECT_DIALOG_CONFIRMED] = g_signal_new (
173 "project-dialog-confirmed",
174 G_OBJECT_CLASS_TYPE (g_object_class),
175 G_SIGNAL_RUN_FIRST,
176 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
177 G_TYPE_NONE, 1,
178 GTK_TYPE_NOTEBOOK);
179 geany_object_signals[GCB_PROJECT_DIALOG_CLOSE] = g_signal_new (
180 "project-dialog-close",
181 G_OBJECT_CLASS_TYPE (g_object_class),
182 G_SIGNAL_RUN_FIRST,
183 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
184 G_TYPE_NONE, 1,
185 GTK_TYPE_NOTEBOOK);
187 /* Editor signals */
188 geany_object_signals[GCB_UPDATE_EDITOR_MENU] = g_signal_new (
189 "update-editor-menu",
190 G_OBJECT_CLASS_TYPE (g_object_class),
191 G_SIGNAL_RUN_FIRST,
192 0, NULL, NULL, NULL,
193 G_TYPE_NONE, 3,
194 G_TYPE_STRING, G_TYPE_INT, GEANY_TYPE_DOCUMENT);
195 geany_object_signals[GCB_EDITOR_NOTIFY] = g_signal_new (
196 "editor-notify",
197 G_OBJECT_CLASS_TYPE (g_object_class),
198 G_SIGNAL_RUN_LAST,
199 0, boolean_handled_accumulator, NULL, NULL,
200 G_TYPE_BOOLEAN, 2,
201 GEANY_TYPE_EDITOR, SCINTILLA_TYPE_NOTIFICATION);
203 /* General signals */
204 geany_object_signals[GCB_GEANY_STARTUP_COMPLETE] = g_signal_new (
205 "geany-startup-complete",
206 G_OBJECT_CLASS_TYPE (g_object_class),
207 G_SIGNAL_RUN_FIRST,
208 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
209 G_TYPE_NONE, 0);
210 geany_object_signals[GCB_BUILD_START] = g_signal_new (
211 "build-start",
212 G_OBJECT_CLASS_TYPE (g_object_class),
213 G_SIGNAL_RUN_FIRST,
214 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
215 G_TYPE_NONE, 0);
217 /* Core-only signals */
218 geany_object_signals[GCB_SAVE_SETTINGS] = g_signal_new (
219 "save-settings",
220 G_OBJECT_CLASS_TYPE (g_object_class),
221 G_SIGNAL_RUN_FIRST,
222 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
223 G_TYPE_NONE, 1,
224 G_TYPE_KEY_FILE);
225 geany_object_signals[GCB_LOAD_SETTINGS] = g_signal_new (
226 "load-settings",
227 G_OBJECT_CLASS_TYPE (g_object_class),
228 G_SIGNAL_RUN_FIRST,
229 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
230 G_TYPE_NONE, 1,
231 G_TYPE_KEY_FILE);
235 static void geany_object_class_init(GeanyObjectClass *klass)
237 GObjectClass *g_object_class;
238 g_object_class = G_OBJECT_CLASS(klass);
240 g_type_class_add_private(klass, sizeof(GeanyObjectPrivate));
242 create_signals(g_object_class);
246 static void geany_object_init(GeanyObject *self)
248 /* nothing to do */
252 GObject *geany_object_new(void)
254 return g_object_new(GEANY_OBJECT_TYPE, NULL);