File: bonobo-generic-factory.h

package info (click to toggle)
bonobo 1.0.22-2.2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,412 kB
  • ctags: 5,445
  • sloc: ansic: 51,714; sh: 7,733; makefile: 1,425; yacc: 318; xml: 266; sed: 16
file content (140 lines) | stat: -rw-r--r-- 6,228 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * bonobo-generic-factory.h: a GenericFactory object.
 *
 * Author:
 *   Miguel de Icaza (miguel@kernel.org)
 *
 * Copyright 1999 Helix Code, Inc.
 */
#ifndef _BONOBO_GENERIC_FACTORY_H_
#define _BONOBO_GENERIC_FACTORY_H_

#include <libgnome/gnome-defs.h>
#include <gtk/gtkobject.h>
#include <bonobo/Bonobo.h>
#include <bonobo/bonobo-object.h>
#include <gnome.h>
#include <liboaf/oaf.h>
#include <liboaf/liboaf.h>

BEGIN_GNOME_DECLS
 
#define BONOBO_GENERIC_FACTORY_TYPE        (bonobo_generic_factory_get_type ())
#define BONOBO_GENERIC_FACTORY(o)          (GTK_CHECK_CAST ((o), BONOBO_GENERIC_FACTORY_TYPE, BonoboGenericFactory))
#define BONOBO_GENERIC_FACTORY_CLASS(k)    (GTK_CHECK_CLASS_CAST((k), BONOBO_GENERIC_FACTORY_TYPE, BonoboGenericFactoryClass))
#define BONOBO_IS_GENERIC_FACTORY(o)       (GTK_CHECK_TYPE ((o), BONOBO_GENERIC_FACTORY_TYPE))
#define BONOBO_IS_GENERIC_FACTORY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), BONOBO_GENERIC_FACTORY_TYPE))

typedef struct _BonoboGenericFactoryPrivate BonoboGenericFactoryPrivate;
typedef struct _BonoboGenericFactory        BonoboGenericFactory;

typedef BonoboObject * (*BonoboGenericFactoryFn)(BonoboGenericFactory *Factory, void *closure);
typedef BonoboObject * (*GnomeFactoryCallback)(BonoboGenericFactory *factory, const char *component_id, gpointer closure);
					
struct _BonoboGenericFactory {
	BonoboObject base;

	/* The function factory */
	BonoboGenericFactoryFn factory; /* compat reasons only */
	GnomeFactoryCallback   factory_cb;
	gpointer               factory_closure;

	/* The component_id for this generic factory */
	char *oaf_iid;
};

typedef struct {
	BonoboObjectClass parent_class;

	/* Virtual methods */
	BonoboObject *(*new_generic) (BonoboGenericFactory *c_factory,
				      const char           *component_id);
} BonoboGenericFactoryClass;

GtkType               bonobo_generic_factory_get_type  (void);

CORBA_Object          bonobo_generic_factory_corba_object_create (
	BonoboObject *object,
	gpointer      shlib_id);

BonoboGenericFactory *bonobo_generic_factory_new (
	const char            *oaf_iid,
	BonoboGenericFactoryFn factory,
	gpointer               user_data);

BonoboGenericFactory *bonobo_generic_factory_new_multi (
	const char            *oaf_iid,
	GnomeFactoryCallback   factory_cb,
	gpointer               data);

BonoboGenericFactory *bonobo_generic_factory_construct (
	const char            *oaf_iid,
	BonoboGenericFactory  *c_factory,
	CORBA_Object           corba_factory,
	BonoboGenericFactoryFn factory,
	GnomeFactoryCallback   factory_cb,
	gpointer               user_data);

BonoboGenericFactory *bonobo_generic_factory_construct_noregister (
	const char             *oaf_iid,
	BonoboGenericFactory   *c_factory,
	CORBA_Object            corba_factory,
	BonoboGenericFactoryFn  factory,
	GnomeFactoryCallback    factory_cb,
	gpointer                user_data);

void bonobo_generic_factory_set (
	BonoboGenericFactory  *c_factory,
	BonoboGenericFactoryFn factory,
	void                  *data);

POA_GNOME_ObjectFactory__epv *bonobo_generic_factory_get_epv (void);

#define BONOBO_OAF_FACTORY(oafiid, descr, version, fn, data)                  \
int main (int argc, char *argv [])                                            \
{                                                                             \
	BonoboGenericFactory *factory;                                        \
	CORBA_ORB orb;                                                        \
                                                                              \
	gnome_init_with_popt_table (descr, version, argc, argv,               \
				    oaf_popt_options, 0, NULL);               \
        orb = oaf_init (argc, argv);                                          \
	if (!bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL))           \
		g_error (_("Could not initialize Bonobo"));                   \
	factory = bonobo_generic_factory_new (oafiid, fn, data);              \
	if (factory) {                                                        \
		bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));   \
		bonobo_main ();                                               \
		return 0;                                                     \
	}                                                                     \
	else {                                                                \
		return 1;                                                     \
	}                                                                     \
}                                                                             

#define BONOBO_OAF_FACTORY_MULTI(oafiid, descr, version, fn, data)            \
int main (int argc, char *argv [])                                            \
{                                                                             \
	BonoboGenericFactory *factory;                                        \
	CORBA_ORB orb;                                                        \
                                                                              \
	gnome_init_with_popt_table (descr, version, argc, argv,               \
				    oaf_popt_options, 0, NULL);               \
        orb = oaf_init (argc, argv);                                          \
	if (!bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL))           \
		g_error (_("Could not initialize Bonobo"));                   \
	factory = bonobo_generic_factory_new_multi (oafiid, fn, data);        \
	if (factory) {                                                        \
		bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));   \
		bonobo_main ();                                               \
		return 0;                                                     \
	}                                                                     \
	else {                                                                \
		return 1;                                                     \
	}                                                                     \
}                                                                             

END_GNOME_DECLS

#endif