From 30cd9878e18a10cd6cfd17a35a9a7f5761cb604f Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Sun, 23 Jan 2011 00:19:18 -0800 Subject: [PATCH] Wait for eggsmclient to initialize before running scripts --- moo/medit-app/main.c | 10 ++++------ moo/mooapp/mooapp.c | 19 +++++++++++++++++++ moo/mooapp/mooapp.h | 2 ++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/moo/medit-app/main.c b/moo/medit-app/main.c index 5847e279..3f2802e7 100644 --- a/moo/medit-app/main.c +++ b/moo/medit-app/main.c @@ -514,7 +514,7 @@ hookup_synaptics_touchpad (void) #endif // GDK_WINDOWING_WIN32 -static gboolean +static void unit_test_func (void) { MooTestOptions opts = 0; @@ -526,16 +526,14 @@ unit_test_func (void) status = unit_tests_main (opts, medit_opts.ut_tests, medit_opts.ut_dir, medit_opts.ut_coverage_file); moo_app_set_exit_status (moo_app_instance (), status); moo_app_quit (moo_app_instance ()); - return FALSE; } -static gboolean +static void run_script_func (void) { char **p; for (p = medit_opts.run_script; p && *p; ++p) moo_app_run_script (moo_app_instance(), *p); - return FALSE; } static int @@ -685,9 +683,9 @@ medit_main (int argc, char *argv[]) g_option_context_free (ctx); if (medit_opts.ut) - gdk_threads_add_timeout (10, (GSourceFunc) unit_test_func, NULL); + g_signal_connect (app, "started", G_CALLBACK (unit_test_func), NULL); if (medit_opts.run_script) - gdk_threads_add_timeout (10, (GSourceFunc) run_script_func, NULL); + g_signal_connect (app, "started", G_CALLBACK (run_script_func), NULL); retval = moo_app_run (app); gdk_threads_leave (); diff --git a/moo/mooapp/mooapp.c b/moo/mooapp/mooapp.c index d1a5c491..1d4c27c8 100644 --- a/moo/mooapp/mooapp.c +++ b/moo/mooapp/mooapp.c @@ -204,6 +204,7 @@ enum { INIT, RUN, QUIT, + STARTED, TRY_QUIT, PREFS_DIALOG, LOAD_SESSION, @@ -299,6 +300,15 @@ moo_app_class_init (MooAppClass *klass) _moo_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0); + signals[STARTED] = + g_signal_new ("started", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MooAppClass, started), + NULL, NULL, + _moo_marshal_VOID__VOID, + G_TYPE_NONE, 0); + signals[PREFS_DIALOG] = g_signal_new ("prefs-dialog", G_OBJECT_CLASS_TYPE (klass), @@ -788,6 +798,13 @@ moo_app_try_quit (MooApp *app) } +static gboolean +emit_started (MooApp *app) +{ + g_signal_emit_by_name (app, "started"); + return FALSE; +} + static void sm_quit_requested (MooApp *app) { @@ -829,6 +846,8 @@ moo_app_run_real (MooApp *app) if (EGG_SM_CLIENT_GET_CLASS (app->priv->sm_client)->startup) EGG_SM_CLIENT_GET_CLASS (app->priv->sm_client)->startup (app->priv->sm_client, NULL); + gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE + 1, (GSourceFunc) emit_started, app, NULL); + gtk_main (); return app->priv->exit_status; diff --git a/moo/mooapp/mooapp.h b/moo/mooapp/mooapp.h index 838081d8..0101fcb7 100644 --- a/moo/mooapp/mooapp.h +++ b/moo/mooapp/mooapp.h @@ -47,6 +47,8 @@ struct _MooAppClass int (*run) (MooApp *app); void (*quit) (MooApp *app); + void (*started) (MooApp *app); + gboolean (*try_quit) (MooApp *app); GtkWidget* (*prefs_dialog) (MooApp *app);