/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAM_EVENT_H_
#define __GDAM_EVENT_H_

#include "gdamconnection.h"
#include <gtk/gtkobject.h>

/*
 * ``Events''
 *
 * Events in GDAM are messages delivered to the client
 * when something happens.
 *
 * These are the server-side hooks for adding events.
 *
 *
 * An implementor of an event, must register the event.
 * Then the caller must merely gdam_*_connect to it.
 *
 * There are two types of events:
 *    - signal events: those events tied to the emission of a particular
 *                     gtk signal.
 *    - timer events:  those events issuing status periodically.
 *
 * Then the events can be connected to a connection via the
 * gdam_*_connect functions-- these return a handle which
 * can later be used to disconnect the event. 
 * (The gdam_connection_destroy function will automatically
 *  disconnect all the events it has subscribed to.)
 */

/* The type of function to trigger when the event has occurred. */
typedef void (*GdamEventMarshal)(GdamConnection    *registered,
                                 GtkObject         *actor,
				 int                connection_id,
				 gpointer           event_type_data,
				 gpointer           connection_data);


/* Register function which will be gtk_signal_connect'd
 * by gdam_event_connect() and invoked when the signal is emitted. */

guint        gdam_event_register         (GtkType          object_type,
                                          const char      *signal_name,
                                          GdamEventMarshal marshal,
					  GDestroyNotify   destroyer,
					  gpointer         event_type_data);

guint        gdam_timer_register         (GtkType          object_type,
                                          GdamEventMarshal marshal,
					  GDestroyNotify   destroyer,
					  gpointer         event_type_data);

guint        gdam_event_connect          (GtkObject       *object,
                                          GdamConnection  *to_connect,
                                          guint            signal_type_id,
					  gpointer         connection_data);

guint        gdam_timer_connect          (GtkObject       *object,
                                          guint            event_type_id,
                                          GdamConnection  *to_connect,
                                          int              period,
					  gpointer         connection_data);

gboolean     gdam_event_disconnect       (guint            connection_id);

void         gdam_event_disconnect_all_from_connection
                                         (GdamConnection  *connection);
#endif
