Blame src/e-util/ea-factory.h

Packit 15f964
/*
Packit 15f964
 *
Packit 15f964
 * This program is free software; you can redistribute it and/or modify it
Packit 15f964
 * under the terms of the GNU Lesser General Public License as published by
Packit 15f964
 * the Free Software Foundation.
Packit 15f964
 *
Packit 15f964
 * This program is distributed in the hope that it will be useful, but
Packit 15f964
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 15f964
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 15f964
 * for more details.
Packit 15f964
 *
Packit 15f964
 * You should have received a copy of the GNU Lesser General Public License
Packit 15f964
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Packit 15f964
 *
Packit 15f964
 *
Packit 15f964
 * Authors:
Packit 15f964
 *		Bolian Yin <bolian.yin@sun.com>
Packit 15f964
 *
Packit 15f964
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
Packit 15f964
 *
Packit 15f964
 */
Packit 15f964
Packit 15f964
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
Packit 15f964
#error "Only <e-util/e-util.h> should be included directly."
Packit 15f964
#endif
Packit 15f964
Packit 15f964
/* Evolution Accessibility
Packit 15f964
*/
Packit 15f964
Packit 15f964
#ifndef _EA_FACTORY_H__
Packit 15f964
#define _EA_FACTORY_H__
Packit 15f964
Packit 15f964
#include <atk/atkobject.h>
Packit 15f964
Packit 15f964
#define EA_FACTORY_PARTA_GOBJECT(type, type_as_function, opt_create_accessible) \
Packit 15f964
static AtkObject * \
Packit 15f964
type_as_function ## _factory_create_accessible (GObject *obj) \
Packit 15f964
{ \
Packit 15f964
  AtkObject *accessible; \
Packit 15f964
  g_return_val_if_fail (G_IS_OBJECT (obj), NULL); \
Packit 15f964
  accessible = opt_create_accessible (G_OBJECT (obj)); \
Packit 15f964
  return accessible; \
Packit 15f964
}
Packit 15f964
Packit 15f964
#define EA_FACTORY_PARTA(type, type_as_function, opt_create_accessible) \
Packit 15f964
static AtkObject * \
Packit 15f964
type_as_function ## _factory_create_accessible (GObject *obj) \
Packit 15f964
{ \
Packit 15f964
  GtkWidget *widget; \
Packit 15f964
  AtkObject *accessible; \
Packit 15f964
 \
Packit 15f964
  g_return_val_if_fail (GTK_IS_WIDGET (obj), NULL); \
Packit 15f964
 \
Packit 15f964
  widget = GTK_WIDGET (obj); \
Packit 15f964
 \
Packit 15f964
  accessible = opt_create_accessible (widget); \
Packit 15f964
  return accessible; \
Packit 15f964
}
Packit 15f964
Packit 15f964
#define EA_FACTORY_PARTB(type, type_as_function, opt_create_accessible) \
Packit 15f964
 \
Packit 15f964
static GType \
Packit 15f964
type_as_function ## _factory_get_accessible_type (void) \
Packit 15f964
{ \
Packit 15f964
  return type; \
Packit 15f964
} \
Packit 15f964
 \
Packit 15f964
 \
Packit 15f964
static void \
Packit 15f964
type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass) \
Packit 15f964
{ \
Packit 15f964
  klass->create_accessible = type_as_function ## _factory_create_accessible; \
Packit 15f964
  klass->get_accessible_type = type_as_function ## _factory_get_accessible_type;\
Packit 15f964
} \
Packit 15f964
 \
Packit 15f964
static GType \
Packit 15f964
type_as_function ## _factory_get_type (void) \
Packit 15f964
{ \
Packit 15f964
  static GType t = 0; \
Packit 15f964
 \
Packit 15f964
  if (!t) \
Packit 15f964
  { \
Packit 15f964
    gchar *name; \
Packit 15f964
    static const GTypeInfo tinfo = \
Packit 15f964
    { \
Packit 15f964
      sizeof (AtkObjectFactoryClass), \
Packit 15f964
      NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init, \
Packit 15f964
      NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL \
Packit 15f964
    }; \
Packit 15f964
 \
Packit 15f964
    name = g_strconcat (g_type_name (type), "Factory", NULL); \
Packit 15f964
    t = g_type_register_static ( \
Packit 15f964
	    ATK_TYPE_OBJECT_FACTORY, name, &tinfo, 0); \
Packit 15f964
    g_free (name); \
Packit 15f964
  } \
Packit 15f964
 \
Packit 15f964
  return t; \
Packit 15f964
}
Packit 15f964
Packit 15f964
#define EA_FACTORY(type, type_as_function, opt_create_accessible) \
Packit 15f964
        EA_FACTORY_PARTA (type, type_as_function, opt_create_accessible) \
Packit 15f964
        EA_FACTORY_PARTB (type, type_as_function, opt_create_accessible)
Packit 15f964
Packit 15f964
#define EA_FACTORY_GOBJECT(type, type_as_function, opt_create_accessible) \
Packit 15f964
        EA_FACTORY_PARTA_GOBJECT (type, type_as_function, opt_create_accessible) \
Packit 15f964
        EA_FACTORY_PARTB (type, type_as_function, opt_create_accessible)
Packit 15f964
Packit 15f964
#define EA_SET_FACTORY(obj_type, type_as_function) \
Packit 15f964
{ \
Packit 15f964
	if (atk_get_root ()) { \
Packit 15f964
		atk_registry_set_factory_type (atk_get_default_registry (), \
Packit 15f964
				      obj_type, \
Packit 15f964
				      type_as_function ## _factory_get_type ());\
Packit 15f964
	} \
Packit 15f964
}
Packit 15f964
Packit 15f964
#endif /* _EA_FACTORY_H__ */