summaryrefslogtreecommitdiff
path: root/gtk/gtkobject.h
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-07-09 23:00:34 +0000
committerTim Janik <timj@src.gnome.org>1998-07-09 23:00:34 +0000
commit347efc33b8007f5d2fe625d7c0e6a51fbb3a3438 (patch)
treeb1a1837fb5431bd39c05edc94f792cf96dca8f04 /gtk/gtkobject.h
parent9b4d90465ef16ba56272cb91857dab0b2347d93c (diff)
downloadgtk+-347efc33b8007f5d2fe625d7c0e6a51fbb3a3438.tar.gz
deleted most of the argument handling code, since that is now implemented
Fri Jul 10 00:02:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: deleted most of the argument handling code, since that is now implemented in gtkarg.c. similar to gtk_object_args_collect, we now export a new function gtk_container_child_args_collect(). for consistency with the object arguments, a few functions got renamed: gtk_container_child_arg_get -> gtk_container_child_get, gtk_container_child_arg_set -> gtk_container_child_set, gtk_container_child_arg_getv -> gtk_container_child_getv, gtk_container_child_arg_setv -> gtk_container_child_setv, gtk_container_add_with_argv -> gtk_container_addv. note, gtk_container_add_with_args() remained, because its equivalent would be gtk_container_add(,, ...) which would break all existing code. (gtk_container_add_child_arg_type): similar to gtk_object_add_arg_type, we expect the `arg_name' argument to be a const static string now. (gtk_container_get_child_arg_type): function removed. Thu Jul 9 07:03:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkargcollector.c: new file which holds gtk_arg_collect_value(). this is a static inline function that collects command line arguments from a va_list. this file can just be included in all places that need this functionality. * gtk/gtkarg.h: * gtk/gtkarg.c: new files which implement most of the argument handling stuff from gtkobject.c. also collected a few more gtk_arg_* utility functions from else places. * gtk/gtkobject.h: * gtk/gtkobject.c: moved most of the argument handling code into gtkarg.c. we now export gtk_object_args_collect() as a non-public method with a blind va_list pointer. (gtk_object_add_arg_type): the `arg_name' argument is required to be a const static string now. (gtk_object_get_arg_type): function got removed. * gtk/gtkwidget.c: (gtk_widget_set): (gtk_widget_new): adaptions for gtk_object_args_collect(). * gtk/gtktypeutils.c (gtk_type_init_builtin_types): changed the internal fundamental type name so as to have a valid prefix, e.g. "bool"-> "gboolean", "string"->"GtkString" and somesuch, left "void" as is, though that should probably be something like GtkNone since the type itself is called GTK_TYPE_NONE. even the internal type names need to avoid name clashes and must live in their own namespace, several code portions rely on that. we should relly have typedefs such as typedef gchar* GtkString; so the fundamental type names can be used for code dumpers just like with all the Gtk/Gdk types.
Diffstat (limited to 'gtk/gtkobject.h')
-rw-r--r--gtk/gtkobject.h183
1 files changed, 99 insertions, 84 deletions
diff --git a/gtk/gtkobject.h b/gtk/gtkobject.h
index 945a1131c6..90382c42ad 100644
--- a/gtk/gtkobject.h
+++ b/gtk/gtkobject.h
@@ -20,6 +20,7 @@
#define __GTK_OBJECT_H__
+#include <gtk/gtkarg.h>
#include <gtk/gtkenums.h>
#include <gtk/gtktypeutils.h>
#include <gtk/gtkdebug.h>
@@ -32,6 +33,13 @@ extern "C" {
+#ifdef offsetof
+#define GTK_STRUCT_OFFSET(struct, field) ((gint) offsetof (struct, field))
+#else /* !offsetof */
+#define GTK_STRUCT_OFFSET(struct, field) ((gint) ((gchar*) &((struct*) 0)->field))
+#endif /* !offsetof */
+
+
/* The debugging versions of the casting macros make sure the cast is "ok"
* before proceeding, but they are definately slower than their less
* careful counterparts as they involve no less than 3 function calls.
@@ -127,8 +135,8 @@ typedef enum
GTK_ARG_WRITABLE = 1 << 1,
GTK_ARG_CONSTRUCT = 1 << 2,
GTK_ARG_CHILD_ARG = 1 << 3,
- GTK_ARG_MASK = 0x0f,
-
+ GTK_ARG_MASK = 0x0f,
+
/* aliases
*/
GTK_ARG_READWRITE = GTK_ARG_READABLE | GTK_ARG_WRITABLE
@@ -189,7 +197,7 @@ struct _GtkObjectClass
/* The number of arguments per class.
*/
guint n_args;
-
+
/* Non overridable class methods to set and get per class arguments */
void (*set_arg) (GtkObject *object,
GtkArg *arg,
@@ -225,18 +233,12 @@ typedef void (*GtkSignalMarshaller) (GtkObject *object,
GtkArg *args);
-/* Get the type identifier for GtkObject's.
- */
-GtkType gtk_object_get_type (void);
-/* Append "signals" to those already defined in "class".
- */
-void gtk_object_class_add_signals (GtkObjectClass *klass,
- guint *signals,
- guint nsignals);
+/* Application-level methods */
-/* Append a user defined signal without default handler to a class.
- */
+GtkType gtk_object_get_type (void);
+
+/* Append a user defined signal without default handler to a class. */
guint gtk_object_class_user_signal_new (GtkObjectClass *klass,
const gchar *name,
GtkSignalRunType signal_flags,
@@ -251,40 +253,29 @@ guint gtk_object_class_user_signal_newv (GtkObjectClass *klass,
GtkType return_val,
guint nparams,
GtkType *params);
-/* Outdated */
-guint gtk_object_class_add_user_signal (GtkObjectClass *klass,
- const gchar *name,
- GtkSignalMarshaller marshaller,
- GtkType return_val,
- guint nparams,
- ...);
-
-GtkObject* gtk_object_new (GtkType type,
- ...);
-
-GtkObject* gtk_object_newv (GtkType type,
- guint nargs,
- GtkArg *args);
+GtkObject* gtk_object_new (GtkType type,
+ ...);
+GtkObject* gtk_object_newv (GtkType object_type,
+ guint n_args,
+ GtkArg *args);
void gtk_object_sink (GtkObject *object);
void gtk_object_ref (GtkObject *object);
void gtk_object_unref (GtkObject *object);
-
void gtk_object_weakref (GtkObject *object,
GtkDestroyNotify notify,
gpointer data);
void gtk_object_weakunref (GtkObject *object,
GtkDestroyNotify notify,
gpointer data);
-
void gtk_object_destroy (GtkObject *object);
/* gtk_object_getv() sets an arguments type and value, or just
* its type to GTK_TYPE_INVALID.
- * if arg->type == GTK_TYPE_STRING, it's the callers response to
- * do a g_free (GTK_VALUE_STRING (arg));
+ * if GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_STRING, it's
+ * the callers response to do a g_free (GTK_VALUE_STRING (arg));
*/
void gtk_object_getv (GtkObject *object,
- guint nargs,
+ guint n_args,
GtkArg *args);
/* gtk_object_set() takes a variable argument list of the form:
@@ -294,9 +285,8 @@ void gtk_object_getv (GtkObject *object,
*/
void gtk_object_set (GtkObject *object,
...);
-
void gtk_object_setv (GtkObject *object,
- guint nargs,
+ guint n_args,
GtkArg *args);
/* Allocate a GtkArg array of size nargs that hold the
@@ -307,49 +297,67 @@ void gtk_object_setv (GtkObject *object,
* It is the callers response to do a
* g_free (returned_args); g_free (*arg_flags).
*/
-GtkArg* gtk_object_query_args (GtkType class_type,
+GtkArg* gtk_object_query_args (GtkType class_type,
guint32 **arg_flags,
- guint *nargs);
-
-void gtk_object_add_arg_type (const gchar *arg_name,
- GtkType arg_type,
- guint arg_flags,
- guint arg_id);
-
-GtkType gtk_object_get_arg_type (const gchar *arg_name);
+ guint *n_args);
/* Set 'data' to the "object_data" field of the object. The
* data is indexed by the "key". If there is already data
* associated with "key" then the new data will replace it.
* If 'data' is NULL then this call is equivalent to
* 'gtk_object_remove_data'.
+ * The gtk_object_set_data_full variant acts just the same,
+ * but takes an additional argument which is a function to
+ * be called when the data is removed.
+ * `gtk_object_remove_data' is equivalent to the above,
+ * where 'data' is NULL
+ * `gtk_object_get_data' gets the data associated with "key".
*/
-void gtk_object_set_data (GtkObject *object,
- const gchar *key,
- gpointer data);
-
-/* Like gtk_object_set_data, but takes an additional argument
- * which is a function to be called when the data is removed.
- */
-void gtk_object_set_data_full (GtkObject *object,
- const gchar *key,
- gpointer data,
+void gtk_object_set_data (GtkObject *object,
+ const gchar *key,
+ gpointer data);
+void gtk_object_set_data_full (GtkObject *object,
+ const gchar *key,
+ gpointer data,
GtkDestroyNotify destroy);
-
-/* Get the data associated with "key".
+void gtk_object_remove_data (GtkObject *object,
+ const gchar *key);
+gpointer gtk_object_get_data (GtkObject *object,
+ const gchar *key);
+
+/* Set/get the "user_data" object data field of "object". It should
+ * be noted that these functions are no different than calling
+ * `gtk_object_set_data'/`gtk_object_get_data' with a key of "user_data".
+ * They are merely provided as a convenience.
*/
-gpointer gtk_object_get_data (GtkObject *object,
- const gchar *key);
+void gtk_object_set_user_data (GtkObject *object,
+ gpointer data);
+gpointer gtk_object_get_user_data (GtkObject *object);
-/* Remove the data associated with "key". This call is
- * equivalent to 'gtk_object_set_data' where 'data' is NULL.
- */
-void gtk_object_remove_data (GtkObject *object,
- const gchar *key);
-/* Object data functions that operate on key ids.
- * These functions are meant for *internal* use only.
+/* Object-level methods */
+
+/* Append "signals" to those already defined in "class". */
+void gtk_object_class_add_signals (GtkObjectClass *klass,
+ guint *signals,
+ guint nsignals);
+/* the `arg_name' argument needs to be a const static string */
+void gtk_object_add_arg_type (const gchar *arg_name,
+ GtkType arg_type,
+ guint arg_flags,
+ guint arg_id);
+
+/* The next two functions are provided to check an object/class pointer
+ * for its validity. Appropriate warning messages will be put out if
+ * the object or class pointers are invalid.
*/
+GtkObject* gtk_object_check_cast (GtkObject *obj,
+ GtkType cast_type);
+
+GtkObjectClass* gtk_object_check_class_cast (GtkObjectClass *klass,
+ GtkType cast_type);
+
+/* Object data method variants that operate on key ids. */
void gtk_object_set_data_by_id (GtkObject *object,
GQuark data_id,
gpointer data);
@@ -364,35 +372,42 @@ void gtk_object_remove_data_by_id (GtkObject *object,
#define gtk_object_data_try_key g_quark_try_string
#define gtk_object_data_force_id g_quark_from_string
-/* Set the "user_data" object data field of "object". It should
- * be noted that this is no different than calling 'gtk_object_set_data'
- * with a key of "user_data". It is merely provided as a convenience.
- */
-void gtk_object_set_user_data (GtkObject *object,
- gpointer data);
-
-/* Get the "user_data" object data field of "object". It should
- * be noted that this is no different than calling 'gtk_object_get_data'
- * with a key of "user_data". It is merely provided as a convenience.
- */
-gpointer gtk_object_get_user_data (GtkObject *object);
-
-GtkObject* gtk_object_check_cast (GtkObject *obj,
- GtkType cast_type);
-GtkObjectClass* gtk_object_check_class_cast (GtkObjectClass *klass,
- GtkType cast_type);
+/* Non-public methods */
+void gtk_object_arg_set (GtkObject *object,
+ GtkArg *arg,
+ GtkArgInfo *info);
+void gtk_object_arg_get (GtkObject *object,
+ GtkArg *arg,
+ GtkArgInfo *info);
+gchar* gtk_object_args_collect (GtkType object_type,
+ GSList **arg_list_p,
+ GSList **info_list_p,
+ gpointer var_args_p);
void gtk_trace_referencing (GtkObject *object,
const gchar *func,
guint dummy,
guint line,
gboolean do_ref);
-
-#if G_ENABLE_DEBUG
+#if G_ENABLE_DEBUG
# define gtk_object_ref(o) G_STMT_START{gtk_trace_referencing((o),G_GNUC_PRETTY_FUNCTION,0,__LINE__,1);}G_STMT_END
# define gtk_object_unref(o) G_STMT_START{gtk_trace_referencing((o),G_GNUC_PRETTY_FUNCTION,0,__LINE__,0);}G_STMT_END
-#endif /* G_ENABLE_DEBUG && __GNUC__ */
+#endif /* G_ENABLE_DEBUG */
+
+
+/* Deprecated methods */
+
+/* Use gtk_object_class_user_signal_new() instead */
+guint gtk_object_class_add_user_signal (GtkObjectClass *klass,
+ const gchar *name,
+ GtkSignalMarshaller marshaller,
+ GtkType return_val,
+ guint nparams,
+ ...);
+
+
+