On Wed, 16 Feb 2005 11:04:19 +0100, Michal Kepien
<[EMAIL PROTECTED]> wrote:
> function is connected to the "clicked" event of a button. The problem is, the
> button stays "pushed" until the sound playing function finishes its work. I 
> want
> the button to pop out immediately after it has been clicked (and of course, 
> the
> callback function to play the sound anyway). Is there any way to achieve that?

Your callback needs to start the sound playing and return immediately.
If you wait for the sound to finish, your GUI will lock up for the
duration of the sample, since callbacks execute in the same thread as
the widgets.

There are lots of ways to do this: one of the simplest (on linux) is
just to play the sound with system( "&" ). For example (ahem,
untested):

void
my_button_click( GtkWIdget *button, const char *filename )
{
  char buf[256];

  snprintf( buf, 256, "mpg123 %s &", filename );
  system( buf );
}

  g_signal_connect( button, "clicked",
    G_CALLBACK( my_button_click ), "sample.mp3" );

John
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to