File: //usr/share/gtk-doc/html/libbonobo/libbonobo-bonobo-event-source.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>bonobo-event-source</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="Libbonobo Reference Manual">
<link rel="up" href="property-bags.html" title="Property Bags, Events, Listeners">
<link rel="prev" href="properties.html" title="Properties">
<link rel="next" href="libbonobo-bonobo-listener.html" title="bonobo-listener">
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="general.html" title="General">
<link rel="chapter" href="factories.html" title="Objects, Factories, Reference Counting">
<link rel="chapter" href="property-bags.html" title="Property Bags, Events, Listeners">
<link rel="chapter" href="monikers.html" title="Monikers">
<link rel="chapter" href="streams.html" title="Storages and Streams">
<link rel="chapter" href="persist.html" title="Persistency">
<link rel="chapter" href="misc.html" title="Miscellaneous">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="properties.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="property-bags.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Libbonobo Reference Manual</th>
<td><a accesskey="n" href="libbonobo-bonobo-listener.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2714983" class="shortcut">Top</a>
 | 
<a href="#id2716072" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="libbonobo-bonobo-event-source"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2714983"></a><span class="refentrytitle">bonobo-event-source</span>
</h2>
<p>bonobo-event-source — An Event Source where clients can connect to listen to events.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">
BonoboEventSource* <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-new">bonobo_event_source_new</a> (void);
void <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-notify-listeners">bonobo_event_source_notify_listeners</a>
(BonoboEventSource *event_source,
const char *event_name,
const CORBA_any *opt_value,
CORBA_Environment *opt_ev);
void <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-notify-listeners-full">bonobo_event_source_notify_listeners_full</a>
(BonoboEventSource *event_source,
const char *path,
const char *type,
const char *subtype,
const CORBA_any *opt_value,
CORBA_Environment *opt_ev);
void <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-client-remove-listener">bonobo_event_source_client_remove_listener</a>
(Bonobo_Unknown object,
Bonobo_Listener listener,
CORBA_Environment *opt_ev);
void <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-client-add-listener">bonobo_event_source_client_add_listener</a>
(Bonobo_Unknown object,
<a href="libbonobo-bonobo-listener.html#BonoboListenerCallbackFn">BonoboListenerCallbackFn</a> event_callback,
const char *opt_mask,
CORBA_Environment *opt_ev,
<a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data);
<a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
>gboolean</a> <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-has-listener">bonobo_event_source_has_listener</a>
(BonoboEventSource *event_source,
const char *event_name);
void <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-client-add-listener-closure">bonobo_event_source_client_add_listener_closure</a>
(Bonobo_Unknown object,
<a
href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GClosure"
>GClosure</a> *callback,
const char *opt_mask,
CORBA_Environment *opt_ev);
Bonobo_Listener <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-client-add-listener-full">bonobo_event_source_client_add_listener_full</a>
(Bonobo_Unknown object,
<a
href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GClosure"
>GClosure</a> *callback,
const char *opt_mask,
CORBA_Environment *opt_ev);
void <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-ignore-listeners">bonobo_event_source_ignore_listeners</a>
(BonoboEventSource *event_source);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2716072"></a><h2>Description</h2>
<p>
An event source object is responsible for channeling the emission
of signals on an object to the appropriate attached listeners.
The API is extremely simple and allows implementations to notify
their listeners of a new event occuring.
</p>
<p>
To notify a listener, you need to construct a textual string,
this is done by the <code class="function">bonobo_event</code> functions
( see <a href="libbonobo-bonobo-listener.html#BonoboListener"><span class="type">BonoboListener</span></a> ) ':' delimiting the fields. It is reccommended
that the IDL module path of the interface be used as the first
part of the string. This is because many interfaces can be aggregated
together and need to share the same event namespace without conflicts.
So for example the bonobo property bag notification code
uses the IDL path "Bonobo/Property" the "change" kind and sets the
sub-type to the property name:
</p>
<div class="example">
<a name="id2716115"></a><p class="title"><b>Example 1. An example event source notification</b></p>
<pre class="programlisting">
static void
notify_listeners (BonoboPropertyBag *pb,
BonoboProperty *prop,
const BonoboArg *new_value,
CORBA_Environment *opt_ev)
{
if (prop->flags & BONOBO_PROPERTY_NO_LISTENING)
return;
bonobo_event_source_notify_listeners_full (pb->es,
"Bonobo/Property",
"change", prop->name,
new_value, opt_ev);
}
</pre>
</div>
<p>
Of course, you need to notify the listener with a valid
BonoboArg containing the event data, this could easily contain
a structure. eg.
</p>
<div class="example">
<a name="id2716148"></a><p class="title"><b>Example 2. Passing a structure in an event</b></p>
<pre class="programlisting">
module GNOME {
module Foo {
struct BaaEvent {
double a;
string b;
long c;
};
};
};
</pre>
<pre class="programlisting">
static void
fire_event (BonoboEventSource *on_source,
double a_double,
char *a_string,
long a_float,
CORBA_Environment *opt_ev)
{
CORBA_any any;
GNOME_Foo_BaaEvent e;
e.a = a_double;
e.b = a_string;
e.c = a_float;
any->_type = TC_GNOME_Foo_BaaEvent;
any->_data = &e;
bonobo_event_source_notify_listeners_full (
on_source, "GNOME/Foo", "event", NULL,
&any, opt_ev);
}
</pre>
</div>
<p>
NB. it is reccommended that you make it clear that the event
structure is intended for use with the <span class="type">BonoboEventSource</span> /
<a href="libbonobo-bonobo-listener.html#BonoboListener"><span class="type">BonoboListener</span></a> by naming it XYZEvent, ie. with the 'Event'
suffix.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2716201"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2716211"></a><h3>
<a name="bonobo-event-source-new"></a>bonobo_event_source_new ()</h3>
<a class="indexterm" name="id2716224"></a><pre class="programlisting">BonoboEventSource* bonobo_event_source_new (void);</pre>
<p>
Creates a new BonoboEventSource object. Typically this
object will be exposed to clients through CORBA and they
will register and unregister functions to be notified
of events that this EventSource generates.
</p>
<p>
To notify clients of an event, use the <a href="libbonobo-bonobo-event-source.html#bonobo-event-source-notify-listeners"><code class="function">bonobo_event_source_notify_listeners()</code></a>
function.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> A new <span class="type">BonoboEventSource</span> server object.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2716291"></a><h3>
<a name="bonobo-event-source-notify-listeners"></a>bonobo_event_source_notify_listeners ()</h3>
<a class="indexterm" name="id2716305"></a><pre class="programlisting">void bonobo_event_source_notify_listeners
(BonoboEventSource *event_source,
const char *event_name,
const CORBA_any *opt_value,
CORBA_Environment *opt_ev);</pre>
<p>
This will notify all clients that have registered with this EventSource
(through the addListener or addListenerWithMask methods) of the availability
of the event named <em class="parameter"><code>event_name</code></em>. The <em class="parameter"><code>value</code></em> CORBA::any value is passed to
all listeners.
</p>
<p>
<em class="parameter"><code>event_name</code></em> can not contain comma separators, as commas are used to
separate the various event names.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>event_source</code></em> :</span></td>
<td> the Event Source that will emit the event.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>event_name</code></em> :</span></td>
<td> Name of the event being emitted
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_value</code></em> :</span></td>
<td> A CORBA_any value that contains the data that is passed
to interested clients, or NULL for an empty value
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_ev</code></em> :</span></td>
<td> A CORBA_Environment where a failure code can be returned, can be NULL.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2716451"></a><h3>
<a name="bonobo-event-source-notify-listeners-full"></a>bonobo_event_source_notify_listeners_full ()</h3>
<a class="indexterm" name="id2716466"></a><pre class="programlisting">void bonobo_event_source_notify_listeners_full
(BonoboEventSource *event_source,
const char *path,
const char *type,
const char *subtype,
const CORBA_any *opt_value,
CORBA_Environment *opt_ev);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>event_source</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>path</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>type</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>subtype</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_value</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_ev</code></em> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2716620"></a><h3>
<a name="bonobo-event-source-client-remove-listener"></a>bonobo_event_source_client_remove_listener ()</h3>
<a class="indexterm" name="id2716635"></a><pre class="programlisting">void bonobo_event_source_client_remove_listener
(Bonobo_Unknown object,
Bonobo_Listener listener,
CORBA_Environment *opt_ev);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>object</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>listener</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_ev</code></em> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2716725"></a><h3>
<a name="bonobo-event-source-client-add-listener"></a>bonobo_event_source_client_add_listener ()</h3>
<a class="indexterm" name="id2716738"></a><pre class="programlisting">void bonobo_event_source_client_add_listener
(Bonobo_Unknown object,
<a href="libbonobo-bonobo-listener.html#BonoboListenerCallbackFn">BonoboListenerCallbackFn</a> event_callback,
const char *opt_mask,
CORBA_Environment *opt_ev,
<a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>object</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>event_callback</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_mask</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_ev</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>user_data</code></em> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2716872"></a><h3>
<a name="bonobo-event-source-has-listener"></a>bonobo_event_source_has_listener ()</h3>
<a class="indexterm" name="id2716886"></a><pre class="programlisting"><a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
>gboolean</a> bonobo_event_source_has_listener
(BonoboEventSource *event_source,
const char *event_name);</pre>
<p>
This method determines if there are any listeners for
the event to be broadcast. This can be used to detect
whether it is worth constructing a potentialy expensive
state update, before sending it to no-one.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>event_source</code></em> :</span></td>
<td> the Event Source that will emit the event.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>event_name</code></em> :</span></td>
<td> Name of the event being emitted
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> TRUE if it's worth sending, else FALSE
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2716974"></a><h3>
<a name="bonobo-event-source-client-add-listener-closure"></a>bonobo_event_source_client_add_listener_closure ()</h3>
<a class="indexterm" name="id2716988"></a><pre class="programlisting">void bonobo_event_source_client_add_listener_closure
(Bonobo_Unknown object,
<a
href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GClosure"
>GClosure</a> *callback,
const char *opt_mask,
CORBA_Environment *opt_ev);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>object</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>callback</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_mask</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_ev</code></em> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2717100"></a><h3>
<a name="bonobo-event-source-client-add-listener-full"></a>bonobo_event_source_client_add_listener_full ()</h3>
<a class="indexterm" name="id2717114"></a><pre class="programlisting">Bonobo_Listener bonobo_event_source_client_add_listener_full
(Bonobo_Unknown object,
<a
href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GClosure"
>GClosure</a> *callback,
const char *opt_mask,
CORBA_Environment *opt_ev);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>object</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>callback</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_mask</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>opt_ev</code></em> :</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2717236"></a><h3>
<a name="bonobo-event-source-ignore-listeners"></a>bonobo_event_source_ignore_listeners ()</h3>
<a class="indexterm" name="id2717250"></a><pre class="programlisting">void bonobo_event_source_ignore_listeners
(BonoboEventSource *event_source);</pre>
<p>
Instructs the event source to de-register any listeners
that are added from the global running context.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><em class="parameter"><code>event_source</code></em> :</span></td>
<td>
</td>
</tr></tbody>
</table></div>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2717304"></a><h2>See Also</h2>
<p>
<a href="libbonobo-bonobo-listener.html#BonoboListener"><span class="type">BonoboListener</span></a> <a href="libbonobo-bonobo-arg.html#BonoboArg"><span class="type">BonoboArg</span></a>
</p>
</div>
</div>
</body>
</html>