| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- DEFINITION MODULE FOR "C" GObject ;
- (*
- m2-GTK4 - GObject: reference counting, properties and signals.
- Mapped onto <glib-object.h>.
- Signals
- -------
- C exposes the g_signal_connect() macro which expands to
- g_signal_connect_data(instance, name, handler, data, NULL, 0).
- Because macros have no symbol, this binding calls the real
- function g_signal_connect_data() directly; the pure-M2 helper
- GtkUtils.Connect wraps the common case.
- A signal handler is a normal C function pointer whose first
- argument is the emitting instance and whose second is the
- user data. Declare a top-level Modula-2 procedure with the
- right signature and pass it directly or via ADR(...):
- PROCEDURE OnClicked (button: ADDRESS; data: ADDRESS);
- ...
- Connect(button, "clicked", ADR(OnClicked), NIL);
- Because the arity and return type depend on the signal, the
- generic GCallback below is an ADDRESS, as in C.
- *)
- FROM SYSTEM IMPORT ADDRESS;
- EXPORT UNQUALIFIED
- GObject, GType, GCallback, GClosureNotify, GConnectFlags, GSignalHandlerID,
- GConnectDefault, GConnectAfter, GConnectSwapped,
- g_object_get_type, g_object_new, g_type_from_name,
- g_object_ref, g_object_unref,
- g_signal_connect_data, g_signal_handler_disconnect,
- g_signal_emit_by_name,
- g_object_set, g_object_get;
- TYPE
- GObject = ADDRESS;
- (* A GType is a gsize-wide run-time type identifier. *)
- GType = LONGCARD;
- (* generic function pointer - pass ADR(proc) *)
- GCallback = ADDRESS;
- GClosureNotify = ADDRESS;
- GConnectFlags = CARDINAL;
- GSignalHandlerID = LONGCARD;
- CONST
- GConnectDefault = 0;
- GConnectAfter = 1; (* call the handler after the default handler *)
- GConnectSwapped = 2; (* swap instance and user data *)
- (* GType g_object_get_type(void) *)
- PROCEDURE g_object_get_type () : GType;
- (* GType g_type_from_name(const gchar *name) *)
- PROCEDURE g_type_from_name (name: ARRAY OF CHAR) : GType;
- (* gpointer g_object_new(GType object_type, const gchar *first_property_name, ...) *)
- PROCEDURE g_object_new (object_type: GType;
- first_property_name: ARRAY OF CHAR; ...) : ADDRESS;
- (* gpointer g_object_ref(gpointer object) *)
- PROCEDURE g_object_ref (object: GObject) : GObject;
- (* void g_object_unref(gpointer object) *)
- PROCEDURE g_object_unref (object: GObject);
- (* gulong g_signal_connect_data(gpointer instance, const gchar *detailed_signal,
- GCallback c_handler, gpointer data, GClosureNotify destroy_data,
- GConnectFlags connect_flags) *)
- PROCEDURE g_signal_connect_data (instance: GObject;
- detailed_signal: ARRAY OF CHAR;
- c_handler: GCallback;
- data: ADDRESS;
- destroy_data: GClosureNotify;
- connect_flags: GConnectFlags) : [ GSignalHandlerID ];
- (* void g_signal_handler_disconnect(gpointer instance, gulong handler_id) *)
- PROCEDURE g_signal_handler_disconnect (instance: GObject;
- handler_id: GSignalHandlerID);
- (* void g_signal_emit_by_name(gpointer instance, const gchar *detailed_signal, ...) *)
- PROCEDURE g_signal_emit_by_name (instance: GObject;
- detailed_signal: ARRAY OF CHAR; ...);
- (* void g_object_set(gpointer object, const gchar *first_property_name, ...) *)
- PROCEDURE g_object_set (object: GObject;
- first_property_name: ARRAY OF CHAR; ...);
- (* void g_object_get(gpointer object, const gchar *first_property_name, ...) *)
- PROCEDURE g_object_get (object: GObject;
- first_property_name: ARRAY OF CHAR; ...);
- END GObject.
|