added a 'restored' flag to the Gimp object and set it in

2008-09-25  Sven Neumann  <sven@gimp.org>

	* app/core/gimp.[ch]: added a 'restored' flag to the Gimp object
	and set it in gimp_real_restore(). Added method 
gimp_is_restored().

	* app/gui/gui.c: call gui_unique_init() in gui_init() instead of
	that later in gui_restore_after_callback(). By doing so we start
	our DBus service (or message proxy window on Win32) much earlier
	in the start process, thus reducing the time frame where two
	instances of gimp can be launched.

	* app/gui/gui-unique.c
	* app/gui/gimpdbusservice.c: wait handling the queued file-open
	requests until gimp is fully restored.

	* app/gui/splash.c (splash_update): only run one iteration of 
the
	main loop. Doing it in a while loop can cause us to get stuck if
	the gimp-unique service already added an idle handler.


svn path=/trunk/; revision=27049
This commit is contained in:
Sven Neumann 2008-09-25 08:56:58 +00:00 committed by Sven Neumann
parent 63ca4578b9
commit 95cd081d13
7 changed files with 70 additions and 9 deletions

View file

@ -1,3 +1,22 @@
2008-09-25 Sven Neumann <sven@gimp.org>
* app/core/gimp.[ch]: added a 'restored' flag to the Gimp object
and set it in gimp_real_restore(). Added method gimp_is_restored().
* app/gui/gui.c: call gui_unique_init() in gui_init() instead of
that later in gui_restore_after_callback(). By doing so we start
our DBus service (or message proxy window on Win32) much earlier
in the start process, thus reducing the time frame where two
instances of gimp can be launched.
* app/gui/gui-unique.c
* app/gui/gimpdbusservice.c: wait handling the queued file-open
requests until gimp is fully restored.
* app/gui/splash.c (splash_update): only run one iteration of the
main loop. Doing it in a while loop can cause us to get stuck if
the gimp-unique service already added an idle handler.
2008-09-24 Martin Nordholts <martinn@svn.gnome.org> 2008-09-24 Martin Nordholts <martinn@svn.gnome.org>
Bug 549925 incorrect math: adding/substracting empty selection Bug 549925 incorrect math: adding/substracting empty selection

View file

@ -186,6 +186,8 @@ gimp_init (Gimp *gimp)
gimp->stack_trace_mode = GIMP_STACK_TRACE_NEVER; gimp->stack_trace_mode = GIMP_STACK_TRACE_NEVER;
gimp->pdb_compat_mode = GIMP_PDB_COMPAT_OFF; gimp->pdb_compat_mode = GIMP_PDB_COMPAT_OFF;
gimp->restored = FALSE;
gimp_gui_init (gimp); gimp_gui_init (gimp);
gimp->busy = 0; gimp->busy = 0;
@ -621,6 +623,8 @@ gimp_real_restore (Gimp *gimp,
gimp_plug_in_manager_restore (gimp->plug_in_manager, gimp_plug_in_manager_restore (gimp->plug_in_manager,
gimp_get_user_context (gimp), status_callback); gimp_get_user_context (gimp), status_callback);
gimp->restored = TRUE;
} }
static gboolean static gboolean
@ -852,6 +856,21 @@ gimp_restore (Gimp *gimp,
g_signal_emit (gimp, gimp_signals[RESTORE], 0, status_callback); g_signal_emit (gimp, gimp_signals[RESTORE], 0, status_callback);
} }
/**
* gimp_is_restored:
* @gimp: a #Gimp object
*
* Return value: %TRUE if GIMP is completely started, %FALSE otherwise.
**/
gboolean
gimp_is_restored (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
return gimp->restored;
}
/** /**
* gimp_exit: * gimp_exit:
* @gimp: a #Gimp object * @gimp: a #Gimp object

View file

@ -53,7 +53,9 @@ struct _Gimp
GimpStackTraceMode stack_trace_mode; GimpStackTraceMode stack_trace_mode;
GimpPDBCompatMode pdb_compat_mode; GimpPDBCompatMode pdb_compat_mode;
GimpGui gui; /* gui vtable */ GimpGui gui; /* gui vtable */
gboolean restored; /* becomes TRUE in gimp_restore() */
gint busy; gint busy;
guint busy_idle_id; guint busy_idle_id;
@ -150,6 +152,7 @@ void gimp_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback); GimpInitStatusFunc status_callback);
void gimp_restore (Gimp *gimp, void gimp_restore (Gimp *gimp,
GimpInitStatusFunc status_callback); GimpInitStatusFunc status_callback);
gboolean gimp_is_restored (Gimp *gimp);
void gimp_exit (Gimp *gimp, void gimp_exit (Gimp *gimp,
gboolean force); gboolean force);

View file

@ -171,9 +171,16 @@ gimp_dbus_service_activate (GimpDBusService *service,
g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE); g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE);
/* We want to be called again later in case that GIMP is not fully
* started yet.
*/
if (! gimp_is_restored (service->gimp))
return TRUE;
display = gimp_container_get_first_child (service->gimp->displays); display = gimp_container_get_first_child (service->gimp->displays);
gtk_window_present (GTK_WINDOW (GIMP_DISPLAY (display)->shell)); if (display)
gtk_window_present (GTK_WINDOW (GIMP_DISPLAY (display)->shell));
return TRUE; return TRUE;
} }
@ -194,6 +201,7 @@ gimp_dbus_service_queue_open (GimpDBusService *service,
{ {
service->source = g_idle_source_new (); service->source = g_idle_source_new ();
g_source_set_priority (service->source, G_PRIORITY_LOW);
g_source_set_callback (service->source, g_source_set_callback (service->source,
(GSourceFunc) gimp_dbus_service_open_idle, service, (GSourceFunc) gimp_dbus_service_open_idle, service,
NULL); NULL);
@ -215,7 +223,12 @@ gimp_dbus_service_queue_open (GimpDBusService *service,
static gboolean static gboolean
gimp_dbus_service_open_idle (GimpDBusService *service) gimp_dbus_service_open_idle (GimpDBusService *service)
{ {
OpenData *data = g_queue_pop_tail (service->queue); OpenData *data;
if (! service->gimp->restored)
return TRUE;
data = g_queue_pop_tail (service->queue);
if (data) if (data)
{ {

View file

@ -55,7 +55,7 @@ static void gui_unique_win32_init (Gimp *gimp);
static void gui_unique_win32_exit (void); static void gui_unique_win32_exit (void);
static Gimp *unique_gimp = NULL; static Gimp *unique_gimp = NULL;
static HWND proxy_window = NULL; static HWND proxy_window = NULL;
#endif #endif
@ -157,6 +157,12 @@ idle_open_data_free (IdleOpenData *data)
static gboolean static gboolean
gui_unique_win32_idle_open (IdleOpenData *data) gui_unique_win32_idle_open (IdleOpenData *data)
{ {
/* We want to be called again later in case that GIMP is not fully
* started yet.
*/
if (! gimp_is_restored (unique_gimp))
return TRUE;
if (data->name) if (data->name)
{ {
file_open_from_command_line (unique_gimp, data->name, data->as_new); file_open_from_command_line (unique_gimp, data->name, data->as_new);
@ -202,6 +208,7 @@ gui_unique_win32_message_handler (HWND hWnd,
g_object_watch_closure (unique_gimp, closure); g_object_watch_closure (unique_gimp, closure);
source = g_idle_source_new (); source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_LOW);
g_source_set_closure (source, closure); g_source_set_closure (source, closure);
g_source_attach (source, NULL); g_source_attach (source, NULL);
g_source_unref (source); g_source_unref (source);

View file

@ -192,6 +192,10 @@ gui_init (Gimp *gimp,
if (abort_message) if (abort_message)
gui_abort (abort_message); gui_abort (abort_message);
the_gui_gimp = gimp;
gui_unique_init (gimp);
gimp_widgets_init (gui_help_func, gimp_widgets_init (gui_help_func,
gui_get_foreground_func, gui_get_foreground_func,
gui_get_background_func, gui_get_background_func,
@ -199,8 +203,6 @@ gui_init (Gimp *gimp,
g_type_class_ref (GIMP_TYPE_COLOR_SELECT); g_type_class_ref (GIMP_TYPE_COLOR_SELECT);
the_gui_gimp = gimp;
/* disable automatic startup notification */ /* disable automatic startup notification */
gtk_window_set_auto_startup_notification (FALSE); gtk_window_set_auto_startup_notification (FALSE);
@ -512,8 +514,6 @@ gui_restore_after_callback (Gimp *gimp,
display = GIMP_DISPLAY (gimp_create_display (gimp, display = GIMP_DISPLAY (gimp_create_display (gimp,
NULL, GIMP_UNIT_PIXEL, 1.0)); NULL, GIMP_UNIT_PIXEL, 1.0));
gui_unique_init (gimp);
if (gui_config->restore_session) if (gui_config->restore_session)
session_restore (gimp); session_restore (gimp);

View file

@ -252,7 +252,7 @@ splash_update (const gchar *text1,
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (splash->progress), gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (splash->progress),
percentage); percentage);
while (gtk_events_pending ()) if (gtk_events_pending ())
gtk_main_iteration (); gtk_main_iteration ();
} }