// -*- c++ -*-
/*  Generated by gensig from object.gen_h. DO NOT MODIFY!!! */
#ifndef GTKMM_OBJECT_HEADER
#define GTKMM_OBJECT_HEADER
/* $Id: object.gen_h,v 1.38.2.2 1999/07/08 19:43:54 kenelson Exp $ */

/* object.h
 * 
 * Copyright (C) 1998-1999 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* this file is critical for our compile times, no #includes to this
   header, please */
#include <gtk--/base.h>
#include <gtk/gtkobject.h>

class Gtk_Object_Class;
#line 27 "object.gen_h"


class Gtk_ArgBase;


// We need the reference to Gtk_Main::idle to be in the .cc file,
//  or the dependencies get all screwed up. Thus this class.
class Gtk_Trashcan_Helper {
protected:
  Gtk_Trashcan_Helper() {}
  virtual ~Gtk_Trashcan_Helper() {}
  static Signal0_r<gint> & idle_signal();
};

// The Gtk_Trashcan class should ideally be in the signal stuff
//  and usable without Gtk--, but for now it depends on the idle
//  callback system of Gtk_Main
//: Avoids the "delete this" problem, allowing an object to 
//:  free itself. Simply queues the thrown away objects for deletion as soon 
//:  as there are no events pending.
//: This is often needed if you want to delete the object in
//:  a callback attached to one of its signals.
template <class DeleteType>
class Gtk_Trashcan : public Gtk_Trashcan_Helper, public Gtk_Signal_Base {
public:
  Gtk_Trashcan() {}
  // essential that this is virtual
  virtual ~Gtk_Trashcan() {}
  
  void throw_away(DeleteType* dt);
  
private:
  gint delete_idle();  

  // GSList is simple and guaranteed to work with all systems.
  GSList* delete_list;
};

template <class DeleteType>
void
Gtk_Trashcan<DeleteType>::throw_away(DeleteType* dt)
{
  bool delete_idle_connected = (delete_list != 0);

  delete_list = g_slist_prepend(delete_list,dt);
  if (!delete_idle_connected) {
    connect_to_method(idle_signal(),
		      this,
		      &Gtk_Trashcan<DeleteType>::delete_idle);
  }
}

template <class DeleteType>
gint
Gtk_Trashcan<DeleteType>::delete_idle()
{
  GSList* first = delete_list;

  while (delete_list) {
    // Cast ensures we know it's a class and call
    //  destructors.
    DeleteType* dt = static_cast<DeleteType*>(delete_list->data);
    delete dt;
    delete_list = g_slist_next(delete_list);
  }
  if (first != 0) g_slist_free(first);

  g_assert(delete_list == 0);
  return FALSE; // causes disconnect? Doesn't seem to always work.
}

//: The base class of the whole hierarchy
class Gtk_Object : public Gtk_Base {
public:
	
#if 0
  // disabled this constructor because we can't pass the arguments
  // in ... to gtk_object_new
  // FIXME
  Gtk_Object(guint      type, 
	     ...);
#endif
  Gtk_Object(GtkObject *castitem);
  Gtk_Object(const Gtk_Object &obj);
  virtual ~Gtk_Object();

  void set_user_data(gpointer data);
  gpointer get_user_data();
	
  guint* signals() { return GTK_OBJECT_SIGNALS (gtkobj()); }
  gint nsignals() { return GTK_OBJECT_NSIGNALS (gtkobj()); } 
	
  guint type() { return GTK_OBJECT_TYPE (gtkobj()); }
	
  friend bool operator ==(Gtk_Object& a, 
			  Gtk_Object& b);
  friend bool operator !=(Gtk_Object& a, 
			  Gtk_Object& b);


	
protected:
  typedef Gtk_Object_Class    CppClassType;
  typedef GtkObject           BaseObjectType;
  typedef GtkObjectClass      BaseClassType;

  virtual void *get_parent_class();

private:
  friend CppClassType;
  static CppClassType object_class; 
  GtkType get_type(); 

public:

  Signal_proxy0<BaseObjectType> destroy;
protected:
  /* impl functions */
  virtual void destroy_impl();
public:
  GtkObject* gtkobj() { return GTK_OBJECT(gtkobject); }
  const GtkObject* gtkobj() const { return GTK_OBJECT(gtkobject); }
  static bool isGtkObject(Gtk_Object *checkcast);
#line 130 "object.gen_h"


  //: Chunks the Gtk_Object in the Global_Object_Trashcan,
  //:  which is safe to do from inside a callback 
  //:  (in effect, 'delete this')
  virtual void delete_self();
	
  // The second argument to signal_connect should be GtkSignalFunc
  // However, gcc/egcs interprets GtkSignalFunc different depending
  // on the -pedantic compiler option, so both possible versions are
  // provided here. When signal_connect is used, the second argument
  // should simply be cast to GtkSignalFunc.
  //: obsolete
  gint signal_connect     (const gchar *       name, 
			   void (*callback_func)(void),
			   gpointer      cbdata);
  gint signal_connect     (const gchar *       name, 
			   void (*callback_func)(...),
			   gpointer      cbdata);
  //: obsolete
  void signal_emit        (gint signal_type, 
			   ...);
  //: obsolete
  void signal_emit_by_name(const gchar *name, 
			   ...);
  //: obsolete
  void signal_disconnect  (gint id);

  void set_data(string const &key,
                gpointer     data);

  gpointer get_data(string const &key) const;

#line 164 "object.gen_h"

  vector<Gtk_ArgBase*>* getv(guint n_args);

  void setv                 (const vector<Gtk_ArgBase*> &args);

  static void add_arg_type  (const string &arg_name,
			     GtkType	 arg_type,
			     guint		 arg_flags,
			     guint		 arg_id);

  void set_data_full        (const string &key,
			     gpointer data,
			     GtkDestroyNotify destroy);

  void set_data_by_id       (GQuark data_id,
			     gpointer	  data);

  void set_data_by_id_full  (GQuark	  data_id,
			     gpointer	  data,
			     GtkDestroyNotify destroy);

  void remove_data                  (const string &key);
  void remove_no_notify             (const string &key);
  gpointer get_data_by_id           (GQuark data_id) const;
  void remove_data_by_id            (GQuark data_id);
  void remove_no_notify_by_id       (GQuark data_id);

#line 192 "object.gen_h"

protected:
  //: This gives full access to gtk.
  GtkObject *gtkobject;

  void ref();
  void unref();

#line 201 "object.gen_h"
  void weakref   (GtkDestroyNotify notify,
		  gpointer         data);
  void weakunref (GtkDestroyNotify notify,
		  gpointer         data);
#line 206 "object.gen_h"

  Gtk_Object();
  static void gtkmm_sigsegv(const char *name);
	
  friend class Gtk_MenuPath;
};

extern Gtk_Trashcan<Gtk_Object>* Global_Object_Trashcan;

#endif
