diff options
author | Peter Williams <peterw@src.gnome.org> | 2000-08-11 01:30:50 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2000-08-11 01:30:50 +0800 |
commit | 8cb514d6dd9497893a35a089d07a132d51263ee7 (patch) | |
tree | 9f4e5d1f929da7e0be900919753d419fe4c9c61a /camel/camel-object.h | |
parent | bcbb63c59f80eb4e684036c5ef58ab141fb01b03 (diff) | |
download | gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.gz gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.bz2 gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.lz gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.xz gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.zst gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.zip |
Merge with camel-async.
svn path=/trunk/; revision=4687
Diffstat (limited to 'camel/camel-object.h')
-rw-r--r-- | camel/camel-object.h | 138 |
1 files changed, 109 insertions, 29 deletions
diff --git a/camel/camel-object.h b/camel/camel-object.h index 2c6b4d0d5c..fdcf7b4a15 100644 --- a/camel/camel-object.h +++ b/camel/camel-object.h @@ -26,40 +26,120 @@ #ifndef CAMEL_OBJECT_H #define CAMEL_OBJECT_H 1 - #ifdef __cplusplus -extern "C" { +extern "C" +{ #pragma } -#endif /* __cplusplus }*/ +#endif /* __cplusplus } */ -#include <gtk/gtk.h> +#include <stdlib.h> /* size_t */ #include <camel/camel-types.h> - -#define CAMEL_OBJECT_TYPE (camel_object_get_type ()) -#define CAMEL_OBJECT(obj) (GTK_CHECK_CAST((obj), CAMEL_OBJECT_TYPE, CamelObject)) -#define CAMEL_OBJECT_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_OBJECT_TYPE, CamelObjectClass)) -#define CAMEL_IS_OBJECT(o) (GTK_CHECK_TYPE((o), CAMEL_OBJECT_TYPE)) - - -struct _CamelObject -{ - GtkObject parent_object; - -}; - - -typedef struct { - GtkObjectClass parent_class; - -} CamelObjectClass; - - -/* Standard Gtk function */ -GtkType camel_object_get_type (void); - +#include <glib.h> + +#ifdef G_DISABLE_CHECKS +#define CAMEL_CHECK_CAST( obj, ctype, ptype ) ((ptype *) obj) +#define CAMEL_CHECK_CLASS_CAST( class, ctype, ptype ) ((ptype *) class) +#define CAMEL_CHECK_TYPE( obj, ctype ) (TRUE) +#define CAMEL_CHECK_CLASS_TYPE( class, ctype ) (TRUE) +#else +#define CAMEL_CHECK_CAST( obj, ctype, ptype ) ((ptype *) camel_object_check_cast( (CamelObject *)(obj), (CamelType)(ctype) )) +#define CAMEL_CHECK_CLASS_CAST( class, ctype, ptype ) ((ptype *) camel_object_class_check_cast( (CamelObjectClass *)(class), (CamelType)(ctype) )) +#define CAMEL_CHECK_TYPE( obj, ctype ) (camel_object_is_of_type( (CamelObject *)(obj), (CamelType)(ctype) )) +#define CAMEL_CHECK_CLASS_TYPE( class, ctype ) (camel_object_class_is_of_type( (CamelObjectClass *)(class), (CamelType)(ctype) )) +#endif + +#define CAMEL_INVALID_TYPE ((CamelType)0) + +#define CAMEL_OBJECT_TYPE (camel_object_get_type ()) + +#define CAMEL_OBJECT(obj) (CAMEL_CHECK_CAST((obj), CAMEL_OBJECT_TYPE, CamelObject)) +#define CAMEL_OBJECT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_OBJECT_TYPE, CamelObjectClass)) +#define CAMEL_IS_OBJECT(o) (CAMEL_CHECK_TYPE((o), CAMEL_OBJECT_TYPE)) +#define CAMEL_IS_OBJECT_CLASS(k) (CAMEL_CHECK_CLASS_TYPE((k), CAMEL_OBJECT_TYPE)) + +#define CAMEL_OBJECT_GET_CLASS(o) ((CamelObjectClass *)(CAMEL_OBJECT(o))->classfuncs) +#define CAMEL_OBJECT_GET_TYPE(o) ((CamelType)(CAMEL_OBJECT(o))->s.type) + + typedef guint32 CamelType; + + typedef struct _CamelObjectShared + { + guint32 magic; + CamelType type; + } + CamelObjectShared; + + typedef struct _CamelObjectClass + { + CamelObjectShared s; + + GHashTable *event_to_preplist; + } + CamelObjectClass; + + typedef struct _CamelObject + { + CamelObjectShared s; + guint32 ref_count:31; + guint32 in_event:1; + CamelObjectClass *classfuncs; + GHashTable *event_to_hooklist; + } + CamelObject; + + typedef void (*CamelObjectClassInitFunc) (CamelObjectClass *); + typedef void (*CamelObjectClassFinalizeFunc) (CamelObjectClass *); + typedef void (*CamelObjectInitFunc) (CamelObject *); + typedef void (*CamelObjectFinalizeFunc) (CamelObject *); + + typedef gboolean (*CamelObjectEventPrepFunc) (CamelObject *, + gpointer); + typedef void (*CamelObjectEventHookFunc) (CamelObject *, gpointer, + gpointer); + +/* The type system .... it's pretty simple..... */ + + void camel_type_init (void); + CamelType camel_type_register (CamelType parent, const gchar * name, + size_t instance_size, + size_t classfuncs_size, + CamelObjectClassInitFunc class_init, + CamelObjectClassFinalizeFunc + class_finalize, + CamelObjectInitFunc instance_init, + CamelObjectFinalizeFunc + instance_finalize); + CamelObjectClass *camel_type_get_global_classfuncs (CamelType type); + const gchar *camel_type_to_name (CamelType type); + + CamelType camel_object_get_type (void); + CamelObject *camel_object_new (CamelType type); + void camel_object_ref (CamelObject * obj); + void camel_object_unref (CamelObject * obj); + CamelObject *camel_object_check_cast (CamelObject * obj, + CamelType ctype); + CamelObjectClass *camel_object_class_check_cast (CamelObjectClass * + class, + CamelType ctype); + gboolean camel_object_is_of_type (CamelObject * obj, CamelType ctype); + gboolean camel_object_class_is_of_type (CamelObjectClass * class, + CamelType ctype); + gchar *camel_object_describe (CamelObject * obj); + void camel_object_class_declare_event (CamelObjectClass * class, + const gchar * name, + CamelObjectEventPrepFunc prep); + void camel_object_hook_event (CamelObject * obj, const gchar * name, + CamelObjectEventHookFunc hook, + gpointer user_data); + void camel_object_unhook_event (CamelObject * obj, const gchar * name, + CamelObjectEventHookFunc hook, + gpointer user_data); + void camel_object_trigger_event (CamelObject * obj, + const gchar * name, + gpointer event_data); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* CAMEL_OBJECT_H */ +#endif /* CAMEL_OBJECT_H */ |