Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

251 rinda
8.5 KiB

  1. /* GTK - The GIMP Toolkit
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. /*
  20. * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
  21. * file for a list of people on the GTK+ Team. See the ChangeLog
  22. * files for a list of changes. These files are distributed with
  23. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  24. */
  25. #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
  26. #error "Only <gtk/gtk.h> can be included directly."
  27. #endif
  28. #ifndef __GTK_OBJECT_H__
  29. #define __GTK_OBJECT_H__
  30. #include <gdkconfig.h>
  31. #include <gtk/gtkenums.h>
  32. #include <gtk/gtktypeutils.h>
  33. #include <gtk/gtkdebug.h>
  34. G_BEGIN_DECLS
  35. /* macros for casting a pointer to a GtkObject or GtkObjectClass pointer,
  36. * and to test whether `object' and `klass' are of type GTK_TYPE_OBJECT.
  37. * these are the standard macros for all GtkObject-derived classes.
  38. */
  39. #define GTK_TYPE_OBJECT (gtk_object_get_type ())
  40. #define GTK_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_OBJECT, GtkObject))
  41. #define GTK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_OBJECT, GtkObjectClass))
  42. #define GTK_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_OBJECT))
  43. #define GTK_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_OBJECT))
  44. #define GTK_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GTK_TYPE_OBJECT, GtkObjectClass))
  45. /* Macros for extracting various fields from GtkObject and GtkObjectClass.
  46. */
  47. #ifndef GTK_DISABLE_DEPRECATED
  48. /**
  49. * GTK_OBJECT_TYPE:
  50. * @object: a #GtkObject.
  51. *
  52. * Gets the type of an object.
  53. *
  54. * Deprecated: 2.20: Use G_OBJECT_TYPE() instead.
  55. */
  56. #define GTK_OBJECT_TYPE G_OBJECT_TYPE
  57. /**
  58. * GTK_OBJECT_TYPE_NAME:
  59. * @object: a #GtkObject.
  60. *
  61. * Gets the name of an object's type.
  62. *
  63. * Deprecated: 2.20: Use G_OBJECT_TYPE_NAME() instead.
  64. */
  65. #define GTK_OBJECT_TYPE_NAME G_OBJECT_TYPE_NAME
  66. #endif
  67. #if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
  68. /* GtkObject only uses the first 4 bits of the flags field.
  69. * Derived objects may use the remaining bits. Though this
  70. * is a kinda nasty break up, it does make the size of
  71. * derived objects smaller.
  72. */
  73. typedef enum
  74. {
  75. GTK_IN_DESTRUCTION = 1 << 0, /* Used internally during dispose */
  76. GTK_FLOATING = 1 << 1,
  77. GTK_RESERVED_1 = 1 << 2,
  78. GTK_RESERVED_2 = 1 << 3
  79. } GtkObjectFlags;
  80. /* Macros for extracting the object_flags from GtkObject.
  81. */
  82. #define GTK_OBJECT_FLAGS(obj) (GTK_OBJECT (obj)->flags)
  83. #ifndef GTK_DISABLE_DEPRECATED
  84. #define GTK_OBJECT_FLOATING(obj) (g_object_is_floating (obj))
  85. #endif
  86. /* Macros for setting and clearing bits in the object_flags field of GtkObject.
  87. */
  88. #define GTK_OBJECT_SET_FLAGS(obj,flag) G_STMT_START{ (GTK_OBJECT_FLAGS (obj) |= (flag)); }G_STMT_END
  89. #define GTK_OBJECT_UNSET_FLAGS(obj,flag) G_STMT_START{ (GTK_OBJECT_FLAGS (obj) &= ~(flag)); }G_STMT_END
  90. #endif
  91. typedef struct _GtkObjectClass GtkObjectClass;
  92. struct _GtkObject
  93. {
  94. GInitiallyUnowned parent_instance;
  95. /* 32 bits of flags. GtkObject only uses 4 of these bits and
  96. * GtkWidget uses the rest. This is done because structs are
  97. * aligned on 4 or 8 byte boundaries. If a new bitfield were
  98. * used in GtkWidget much space would be wasted.
  99. */
  100. guint32 GSEAL (flags);
  101. };
  102. struct _GtkObjectClass
  103. {
  104. GInitiallyUnownedClass parent_class;
  105. /* Non overridable class methods to set and get per class arguments */
  106. void (*set_arg) (GtkObject *object,
  107. GtkArg *arg,
  108. guint arg_id);
  109. void (*get_arg) (GtkObject *object,
  110. GtkArg *arg,
  111. guint arg_id);
  112. /* Default signal handler for the ::destroy signal, which is
  113. * invoked to request that references to the widget be dropped.
  114. * If an object class overrides destroy() in order to perform class
  115. * specific destruction then it must still invoke its superclass'
  116. * implementation of the method after it is finished with its
  117. * own cleanup. (See gtk_widget_real_destroy() for an example of
  118. * how to do this).
  119. */
  120. void (*destroy) (GtkObject *object);
  121. };
  122. /* Application-level methods */
  123. GType gtk_object_get_type (void) G_GNUC_CONST;
  124. #ifndef GTK_DISABLE_DEPRECATED
  125. void gtk_object_sink (GtkObject *object);
  126. #endif
  127. void gtk_object_destroy (GtkObject *object);
  128. /****************************************************************/
  129. #ifndef GTK_DISABLE_DEPRECATED
  130. GtkObject* gtk_object_new (GType type,
  131. const gchar *first_property_name,
  132. ...);
  133. GtkObject* gtk_object_ref (GtkObject *object);
  134. void gtk_object_unref (GtkObject *object);
  135. void gtk_object_weakref (GtkObject *object,
  136. GDestroyNotify notify,
  137. gpointer data);
  138. void gtk_object_weakunref (GtkObject *object,
  139. GDestroyNotify notify,
  140. gpointer data);
  141. /* Set 'data' to the "object_data" field of the object. The
  142. * data is indexed by the "key". If there is already data
  143. * associated with "key" then the new data will replace it.
  144. * If 'data' is NULL then this call is equivalent to
  145. * 'gtk_object_remove_data'.
  146. * The gtk_object_set_data_full variant acts just the same,
  147. * but takes an additional argument which is a function to
  148. * be called when the data is removed.
  149. * `gtk_object_remove_data' is equivalent to the above,
  150. * where 'data' is NULL
  151. * `gtk_object_get_data' gets the data associated with "key".
  152. */
  153. void gtk_object_set_data (GtkObject *object,
  154. const gchar *key,
  155. gpointer data);
  156. void gtk_object_set_data_full (GtkObject *object,
  157. const gchar *key,
  158. gpointer data,
  159. GDestroyNotify destroy);
  160. void gtk_object_remove_data (GtkObject *object,
  161. const gchar *key);
  162. gpointer gtk_object_get_data (GtkObject *object,
  163. const gchar *key);
  164. void gtk_object_remove_no_notify (GtkObject *object,
  165. const gchar *key);
  166. /* Set/get the "user_data" object data field of "object". It should
  167. * be noted that these functions are no different than calling
  168. * `gtk_object_set_data'/`gtk_object_get_data' with a key of "user_data".
  169. * They are merely provided as a convenience.
  170. */
  171. void gtk_object_set_user_data (GtkObject *object,
  172. gpointer data);
  173. gpointer gtk_object_get_user_data (GtkObject *object);
  174. /* Object-level methods */
  175. /* Object data method variants that operate on key ids. */
  176. void gtk_object_set_data_by_id (GtkObject *object,
  177. GQuark data_id,
  178. gpointer data);
  179. void gtk_object_set_data_by_id_full (GtkObject *object,
  180. GQuark data_id,
  181. gpointer data,
  182. GDestroyNotify destroy);
  183. gpointer gtk_object_get_data_by_id (GtkObject *object,
  184. GQuark data_id);
  185. void gtk_object_remove_data_by_id (GtkObject *object,
  186. GQuark data_id);
  187. void gtk_object_remove_no_notify_by_id (GtkObject *object,
  188. GQuark key_id);
  189. #define gtk_object_data_try_key g_quark_try_string
  190. #define gtk_object_data_force_id g_quark_from_string
  191. /* GtkArg flag bits for gtk_object_add_arg_type
  192. */
  193. typedef enum
  194. {
  195. GTK_ARG_READABLE = G_PARAM_READABLE,
  196. GTK_ARG_WRITABLE = G_PARAM_WRITABLE,
  197. GTK_ARG_CONSTRUCT = G_PARAM_CONSTRUCT,
  198. GTK_ARG_CONSTRUCT_ONLY = G_PARAM_CONSTRUCT_ONLY,
  199. GTK_ARG_CHILD_ARG = 1 << 4
  200. } GtkArgFlags;
  201. #define GTK_ARG_READWRITE (GTK_ARG_READABLE | GTK_ARG_WRITABLE)
  202. void gtk_object_get (GtkObject *object,
  203. const gchar *first_property_name,
  204. ...) G_GNUC_NULL_TERMINATED;
  205. void gtk_object_set (GtkObject *object,
  206. const gchar *first_property_name,
  207. ...) G_GNUC_NULL_TERMINATED;
  208. void gtk_object_add_arg_type (const gchar *arg_name,
  209. GType arg_type,
  210. guint arg_flags,
  211. guint arg_id);
  212. #endif /* GTK_DISABLE_DEPRECATED */
  213. G_END_DECLS
  214. #endif /* __GTK_OBJECT_H__ */