help-smalltalk
[Top][All Lists]
Advanced

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

[Help-smalltalk] gtk_init_check


From: Stefan Schmiedl
Subject: [Help-smalltalk] gtk_init_check
Date: Wed, 1 Jul 2009 17:58:48 +0200

Isn't it great that I can look at the code of GtkAssistant and
quickly locate and fix the path for the Gtk+ documentation?

An what interesting things you can find there. Take, for example,
the function gtk_init() that everybody seems to call once.

  Note
  This function will terminate your program if it was unable to
  initialize the GUI for some reason. If you want your program to
  fall back to a textual interface you want to call
  gtk_init_check() instead.  

So now I'm wondering if that bold fail-early strategy is somewhat
mollified by the surrounding gst environment or if would not
indeed be more flexible to change gst_gtk_init() to the
following:

gboolean
gst_gtk_init ()
{
  static int init = 0;
  int argc = 1;
  gboolean initialized;
  gchar *argvArray[] = { (char *) "gst", NULL };
  gchar **argv = argvArray;

  if (init)
    return;

  init++;
  initialized = gtk_init_check (&argc, &argv);
  if (!g_thread_supported ()) g_thread_init(NULL);
  return initialized;
}

I did not test it, but it might even make it possible to get rid
of the init-flag hack.

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 ... 

Giddy with possibilities,
s.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]