[gimp] app: Add gimp_set/get_show_gui()



commit b61c971f22019a0adbc003eafff5160b2b0a1430
Author: Martin Nordholts <martinn src gnome org>
Date:   Tue Sep 8 19:26:57 2009 +0200

    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.

 app/core/gimp.c |   32 ++++++++++++++++++++++++++++++++
 app/core/gimp.h |    4 ++++
 app/gui/gui.c   |   22 ++++++++++++++--------
 3 files changed, 50 insertions(+), 8 deletions(-)
---
diff --git a/app/core/gimp.c b/app/core/gimp.c
index 50d60e5..d7f1036 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -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,
diff --git a/app/core/gimp.h b/app/core/gimp.h
index 1a78f22..1f743b9 100644
--- a/app/core/gimp.h
+++ b/app/core/gimp.h
@@ -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,
diff --git a/app/gui/gui.c b/app/gui/gui.c
index 5a3971e..0407c37 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -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 ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]