Add new signal: "geany-startup-complete" which is sent once all initialization and startup tasks has been done.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4527 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-01-17 15:17:30 +00:00
parent 9f8d16340f
commit cc19e09d83
6 changed files with 44 additions and 1 deletions

View File

@ -4,6 +4,10 @@
Add a little test program which can load and test Geany plugins to Add a little test program which can load and test Geany plugins to
verify it is loadable at runtime and all necessary symbols are verify it is loadable at runtime and all necessary symbols are
defined. defined.
* doc/plugins.dox, src/geanyobject.c, src/geanyobject.h, src/main.c,
src/plugindata.h:
Add new signal: "geany-startup-complete" which is sent once all
initialization and startup tasks has been done.
2010-01-16 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> 2010-01-16 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>

View File

@ -225,6 +225,19 @@ PluginCallback plugin_callbacks[] =
* @param user_data user data. * @param user_data user data.
* @endsignaldef * @endsignaldef
* *
* @signaldef geany-startup-complete
* @signalproto
* void user_function(GObject *obj, gpointer user_data);
* @endsignalproto
* @signaldesc
* 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.
*
* @param obj a GeanyObject instance, should be ignored.
* @param user_data user data.
* @endsignaldef
*
* @signaldef update-editor-menu * @signaldef update-editor-menu
* @signalproto * @signalproto
* void user_function(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, * void user_function(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc,

View File

@ -286,6 +286,16 @@ static void create_signals(GObjectClass *g_object_class)
G_TYPE_BOOLEAN, 2, G_TYPE_BOOLEAN, 2,
G_TYPE_POINTER, G_TYPE_POINTER); G_TYPE_POINTER, G_TYPE_POINTER);
/* General signals */
geany_object_signals[GCB_GEANY_STARTUP_COMPLETE] = g_signal_new (
"geany-startup-complete",
G_OBJECT_CLASS_TYPE (g_object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeanyObjectClass, geany_startup_complete),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/* Core-only signals */ /* Core-only signals */
geany_object_signals[GCB_SAVE_SETTINGS] = g_signal_new ( geany_object_signals[GCB_SAVE_SETTINGS] = g_signal_new (
"save-settings", "save-settings",

View File

@ -44,6 +44,7 @@ typedef enum
GCB_PROJECT_CLOSE, GCB_PROJECT_CLOSE,
GCB_UPDATE_EDITOR_MENU, GCB_UPDATE_EDITOR_MENU,
GCB_EDITOR_NOTIFY, GCB_EDITOR_NOTIFY,
GCB_GEANY_STARTUP_COMPLETE,
GCB_SAVE_SETTINGS, GCB_SAVE_SETTINGS,
GCB_LOAD_SETTINGS, GCB_LOAD_SETTINGS,
GCB_MAX GCB_MAX
@ -88,6 +89,7 @@ struct _GeanyObjectClass
void (*project_close)(void); void (*project_close)(void);
void (*update_editor_menu)(const gchar *word, gint click_pos, GeanyDocument *doc); void (*update_editor_menu)(const gchar *word, gint click_pos, GeanyDocument *doc);
gboolean (*editor_notify)(GeanyEditor *editor, gpointer scnt); gboolean (*editor_notify)(GeanyEditor *editor, gpointer scnt);
void (*geany_startup_complete)(void);
void (*save_settings)(GKeyFile *keyfile); void (*save_settings)(GKeyFile *keyfile);
void (*load_settings)(GKeyFile *keyfile); void (*load_settings)(GKeyFile *keyfile);
}; };

View File

@ -392,6 +392,9 @@ static void setup_paths(void)
* This is because the main window is realized (i.e. actually drawn on the screen) at the * This is because the main window is realized (i.e. actually drawn on the screen) at the
* end of the startup process. * end of the startup process.
* *
* @note Maybe you want to use the @ref geany-startup-complete signal to get notified about
* the completed startup process.
*
* @return @c TRUE if the Geany main window has been realized or @c FALSE otherwise. * @return @c TRUE if the Geany main window has been realized or @c FALSE otherwise.
* *
* @since 0.19 * @since 0.19
@ -888,6 +891,13 @@ static void load_startup_files(gint argc, gchar **argv)
} }
static gboolean send_startup_complete(gpointer data)
{
g_signal_emit_by_name(geany_object, "geany-startup-complete");
return FALSE;
}
gint main(gint argc, gchar **argv) gint main(gint argc, gchar **argv)
{ {
GeanyDocument *doc; GeanyDocument *doc;
@ -1079,6 +1089,10 @@ gint main(gint argc, gchar **argv)
} }
#endif #endif
/* when we are really done with setting everything up and the main event loop is running,
* tell other components, mainly plugins, that startup is complete */
g_idle_add_full(G_PRIORITY_LOW, send_startup_complete, NULL, NULL);
gtk_main(); gtk_main();
return 0; return 0;
} }

View File

@ -50,7 +50,7 @@
enum { enum {
/** The Application Programming Interface (API) version, incremented /** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */ * whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 169, GEANY_API_VERSION = 170,
/** The Application Binary Interface (ABI) version, incremented whenever /** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */ * existing fields in the plugin data types have to be changed or reordered. */