And then you might be able to end up with a gst image
that would run a GUI if gtk is available and run headless
if not ...

Like this? :-)

Paolo
diff --git a/packages/gtk/ChangeLog b/packages/gtk/ChangeLog
index ea81c8b..e6ffca0 100644
--- a/packages/gtk/ChangeLog
+++ b/packages/gtk/ChangeLog
@@ -1,3 +1,17 @@
+2009-07-01  Paolo Bonzini  <[email protected]>
+
+       * MoreFuncs.st: Add gtkInitialized.  Stub gstGtkInit.
+       * example_arrow.st: Remove gstGtkInit.
+       * example_aspectframe.st: Remove gstGtkInit.
+       * example_buttonbox.st: Remove gstGtkInit.
+       * example_entry.st: Remove gstGtkInit.
+       * example_eventbox.st: Remove gstGtkInit.
+       * example_hello.st: Remove gstGtkInit.
+       * example_tictactoe.st: Remove gstGtkInit.
+       * example_tree.st: Remove gstGtkInit.
+       * gst-gtk.c: Add gtkInitialized, use gtk_init_check instead of
+       gtk_init moving it to gst_initModule.
+
 2009-07-01  Gwenael Casaccio  <[email protected]>
 
        * gst-gtk.c: Call g_thread_init.
diff --git a/packages/gtk/MoreFuncs.st b/packages/gtk/MoreFuncs.st
index 2431bce..f396793 100644
--- a/packages/gtk/MoreFuncs.st
+++ b/packages/gtk/MoreFuncs.st
@@ -25,9 +25,12 @@ Gtk class extend [
     ]
 
     gstGtkInit [
+       "For backwards compatibility."
+    ]
+
+    gtkInitialized [
        <category: 'C call-outs'>
-       <cCall: 'gstGtkInit' returning: #void args: #()>
-       
+       <cCall: 'gtkInitialized' returning: #boolean args: #()>
     ]
 
 ]
diff --git a/packages/gtk/example_arrow.st b/packages/gtk/example_arrow.st
index c214f7d..b161bad 100644
--- a/packages/gtk/example_arrow.st
+++ b/packages/gtk/example_arrow.st
@@ -111,7 +111,6 @@ GTK.GtkButton class extend [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     ArrowExample new open.
     Gtk main
 ]
diff --git a/packages/gtk/example_aspectframe.st 
b/packages/gtk/example_aspectframe.st
index c7b3c85..4119047 100644
--- a/packages/gtk/example_aspectframe.st
+++ b/packages/gtk/example_aspectframe.st
@@ -77,7 +77,6 @@ Object subclass: AspectFrameExample [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     AspectFrameExample new open.
     Gtk main
 ]
diff --git a/packages/gtk/example_buttonbox.st 
b/packages/gtk/example_buttonbox.st
index 7f7ef33..a8d440b 100644
--- a/packages/gtk/example_buttonbox.st
+++ b/packages/gtk/example_buttonbox.st
@@ -174,7 +174,6 @@ GtkButtonBox class extend [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     ButtonBoxExample new open.
     Gtk main
 ]
diff --git a/packages/gtk/example_entry.st b/packages/gtk/example_entry.st
index 3728896..bc4d951 100644
--- a/packages/gtk/example_entry.st
+++ b/packages/gtk/example_entry.st
@@ -155,7 +155,6 @@ Object subclass: EntryExample [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     EntryExample new open.
     Gtk main
 ]
diff --git a/packages/gtk/example_eventbox.st b/packages/gtk/example_eventbox.st
index e697566..6264b41 100644
--- a/packages/gtk/example_eventbox.st
+++ b/packages/gtk/example_eventbox.st
@@ -82,7 +82,6 @@ Object subclass: EventBoxExample [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     EventBoxExample new open.
     Gtk main
 ]
diff --git a/packages/gtk/example_hello.st b/packages/gtk/example_hello.st
index 300684c..8e60624 100644
--- a/packages/gtk/example_hello.st
+++ b/packages/gtk/example_hello.st
@@ -80,7 +80,6 @@ Object subclass: HelloWorldExample [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     HelloWorldExample new open.
     Gtk main
 ]
diff --git a/packages/gtk/example_tictactoe.st 
b/packages/gtk/example_tictactoe.st
index b4c4a19..c33dd56 100644
--- a/packages/gtk/example_tictactoe.st
+++ b/packages/gtk/example_tictactoe.st
@@ -177,7 +177,6 @@ Object subclass: TicTacToe [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     TicTacToe new open.
     Gtk main
 ]
diff --git a/packages/gtk/example_tree.st b/packages/gtk/example_tree.st
index 94ff42b..8d9842e 100644
--- a/packages/gtk/example_tree.st
+++ b/packages/gtk/example_tree.st
@@ -208,7 +208,6 @@ Object subclass: TreeExample [
 
 
 Namespace current: GTK [
-    Gtk gstGtkInit.
     TreeExample new open buildTree defaultExpand.
     Gtk main
 ]
diff --git a/packages/gtk/gst-gtk.c b/packages/gtk/gst-gtk.c
index c987e0f..124dbf0 100644
--- a/packages/gtk/gst-gtk.c
+++ b/packages/gtk/gst-gtk.c
@@ -83,8 +83,6 @@ VMProxy *_gst_vm_proxy;
 static GQuark q_gst_object = 0;
 static int pending_quit_count = 0;
 
-static void gst_gtk_init ();
-
 /* Start the main event loop and then signal OOP.  */
 static void my_gtk_main (OOP semaphore);
 
@@ -924,27 +922,26 @@ void my_log_handler (const gchar * log_domain,
 
 /* Initialization.  */
  
+static int initialized = 0;
+
+int
+gst_gtk_initialized ()
+{
+  return initialized;
+}
+
 void
-gst_gtk_init ()
+gst_initModule (proxy)
+     VMProxy *proxy;
 {
-  static int init = 0;
   int argc = 1;
   gchar *argvArray[] = { (char *) "gst", NULL };
   gchar **argv = argvArray;
 
-  if (init)
-    return;
-
-  init++;
-  gtk_init (&argc, &argv);
-  if (!g_thread_supported ())
+  initialized = gtk_init_check (&argc, &argv);
+  if (initialized && !g_thread_supported ())
     g_thread_init (NULL);
-}
 
-void
-gst_initModule (proxy)
-     VMProxy *proxy;
-{
   q_gst_object = g_quark_from_string ("gst_object");
   g_type_init ();
   g_log_set_handler (NULL,
@@ -964,7 +961,7 @@ gst_initModule (proxy)
                     my_log_handler, NULL);
 
   _gst_vm_proxy = proxy;
-  _gst_vm_proxy->defineCFunc ("gstGtkInit", gst_gtk_init);
+  _gst_vm_proxy->defineCFunc ("gtkInitialized", gst_gtk_initialized);
   _gst_vm_proxy->defineCFunc ("gstGtkRegisterForType", register_for_type);
   _gst_vm_proxy->defineCFunc ("gstGtkFreeGObjectOOP", free_oop_for_g_object);
   _gst_vm_proxy->defineCFunc ("gstGtkNarrowGObjectOOP", 
narrow_oop_for_g_object);
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to