gtk_init_check

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gtk_init_check

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


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: gtk_init_check

Paolo Bonzini-3

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

Yes, by moving it into gst_initModule.

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

Definitely, as it would allow to drop the "Gtk gstGtkInit part".

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: gtk_init_check

Paolo Bonzini-3
In reply to this post by Stefan Schmiedl

> 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

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

gst-gtk-init-check.patch (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gtk_init_check

Stefan Schmiedl
On Wed, 01 Jul 2009 19:48:41 +0200
Paolo Bonzini <[hidden email]> wrote:

>
> > 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? :-)

looking good ... now compiling gst for the umpteenth time today :-)

s.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk