Re: Sound events in Gtk




"yiyus" <jg_yiyus@jet.es> writes:

> Hello,
> I am trying to put some sound events in Gtk, in
> the same way which enlightenment does it. I had a
> Gtk+ 1.0.4 working with some E code where buttons
> played .wav where they where pressed. Now, I have
> to remove the E stuff from some files to make it
> only for Gtk. My question is, which is the best
> place to put the function which play sounds?
> (please give me file and function name, since I
> don't know very well Gtk, thank you).
> And I would like to know your opinion about this
> (if you like to have sound, etc). Think it would
> be implemented as in enlightenment, the sound:
> - use ESD.
> - is an option at compile time.
> - is an option at run time.

The slick and clean way to do it (I should credit Raster for 
the basic concept), is to add a single function to GTK+:

 gtk_signal_snooper_install (GtkSignalSnooperFunc snooper,
	                     gpointer             func_data);

if there are snooper's installed, they get called on
every signal emission.

Then, you write your sound code in a dynamically loaded
module (a recent addition to GTK+, not in a released
version yet, but will be soon), and when your module
is initialized it adds a signal snooper, and parses
a configuration file like:

 "GtkWidget" "button-press-event" "my-mouse-isnt-load-enough.au"
 "GtkMenu"   "show"               "scraping-noise.au"

Then, on each signal, it does a lookup of against the
configuration file, and if it finds a matching sound,
plays it. There will be some performance penalty
when running with sound enabled, but it shouldn't be that
bad if you are clever enough about doing the lookups.

The user configures all GTK+ applications to use sound by
adding a line like:
 
 module "gtk-esound"

to their gtkrc.

> And I would like to know where I can obtain the
> latest Gtk via ftp (I can't use CVS, since I don't
> have modem in my Linux box).

Releases of the 1.1 development branch are now
available on ftp://ftp.gtk.org.

Regards,
                                        Owen



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