app: Add gimp_set/get_show_gui()

For test cases we typically don't want to present any windows, so
allow test cases to turn that off.
This commit is contained in:
Martin Nordholts 2009-09-08 19:26:57 +02:00
parent a8e5dea309
commit b61c971f22
3 changed files with 50 additions and 8 deletions

View File

@ -191,6 +191,7 @@ gimp_init (Gimp *gimp)
gimp->be_verbose = FALSE;
gimp->no_data = FALSE;
gimp->no_interface = FALSE;
gimp->show_gui = TRUE;
gimp->use_shm = FALSE;
gimp->message_handler = GIMP_CONSOLE;
gimp->stack_trace_mode = GIMP_STACK_TRACE_NEVER;
@ -711,6 +712,37 @@ gimp_new (const gchar *name,
return gimp;
}
/**
* gimp_set_show_gui:
* @gimp:
* @show:
*
* Test cases that tests the UI typically don't want any windows to be
* presented during the test run. Allow them to set this.
**/
void
gimp_set_show_gui (Gimp *gimp,
gboolean show_gui)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->show_gui = show_gui;
}
/**
* gimp_get_show_gui:
* @gimp:
*
* Returns: %TRUE if the GUI should be shown, %FALSE otherwise.
**/
gboolean
gimp_get_show_gui (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
return gimp->show_gui;
}
static void
gimp_global_config_notify (GObject *global_config,
GParamSpec *param_spec,

View File

@ -46,6 +46,7 @@ struct _Gimp
gboolean no_data;
gboolean no_fonts;
gboolean no_interface;
gboolean show_gui;
gboolean use_shm;
GimpMessageHandlerType message_handler;
gboolean console_messages;
@ -149,6 +150,9 @@ Gimp * gimp_new (const gchar *name,
gboolean console_messages,
GimpStackTraceMode stack_trace_mode,
GimpPDBCompatMode pdb_compat_mode);
void gimp_set_show_gui (Gimp *gimp,
gboolean show_gui);
gboolean gimp_get_show_gui (Gimp *gimp);
void gimp_load_config (Gimp *gimp,
const gchar *alternate_system_gimprc,

View File

@ -516,17 +516,23 @@ gui_restore_after_callback (Gimp *gimp,
color_history_restore (gimp);
/* create the empty display */
display = GIMP_DISPLAY (gimp_create_display (gimp,
NULL, GIMP_UNIT_PIXEL, 1.0));
if (gimp_get_show_gui (gimp))
{
/* create the empty display */
display = GIMP_DISPLAY (gimp_create_display (gimp,
NULL,
GIMP_UNIT_PIXEL,
1.0));
if (gui_config->restore_session)
session_restore (gimp);
if (gui_config->restore_session)
session_restore (gimp);
windows_show_toolbox ();
windows_show_toolbox ();
/* move keyboard focus to the display */
gtk_window_present (GTK_WINDOW (display->shell));
/* move keyboard focus to the display */
gtk_window_present (GTK_WINDOW (display->shell));
}
/* indicate that the application has finished loading */
gdk_notify_startup_complete ();