gobject.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /* GObject - GLib Type, Object, Parameter and Signal Library
  2. * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
  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
  15. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __G_OBJECT_H__
  18. #define __G_OBJECT_H__
  19. #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
  20. #error "Only <glib-object.h> can be included directly."
  21. #endif
  22. #include <gobject/gtype.h>
  23. #include <gobject/gvalue.h>
  24. #include <gobject/gparam.h>
  25. #include <gobject/gclosure.h>
  26. #include <gobject/gsignal.h>
  27. #include <gobject/gboxed.h>
  28. G_BEGIN_DECLS
  29. /* --- type macros --- */
  30. /**
  31. * G_TYPE_IS_OBJECT:
  32. * @type: Type id to check
  33. *
  34. * Check if the passed in type id is a %G_TYPE_OBJECT or derived from it.
  35. *
  36. * Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT.
  37. */
  38. #define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
  39. /**
  40. * G_OBJECT:
  41. * @object: Object which is subject to casting.
  42. *
  43. * Casts a #GObject or derived pointer into a (GObject*) pointer.
  44. * Depending on the current debugging level, this function may invoke
  45. * certain runtime checks to identify invalid casts.
  46. */
  47. #define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
  48. /**
  49. * G_OBJECT_CLASS:
  50. * @class: a valid #GObjectClass
  51. *
  52. * Casts a derived #GObjectClass structure into a #GObjectClass structure.
  53. */
  54. #define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
  55. /**
  56. * G_IS_OBJECT:
  57. * @object: Instance to check for being a %G_TYPE_OBJECT.
  58. *
  59. * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT.
  60. */
  61. #define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))
  62. /**
  63. * G_IS_OBJECT_CLASS:
  64. * @class: a #GObjectClass
  65. *
  66. * Checks whether @class "is a" valid #GObjectClass structure of type
  67. * %G_TYPE_OBJECT or derived.
  68. */
  69. #define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))
  70. /**
  71. * G_OBJECT_GET_CLASS:
  72. * @object: a #GObject instance.
  73. *
  74. * Get the class structure associated to a #GObject instance.
  75. *
  76. * Returns: pointer to object class structure.
  77. */
  78. #define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
  79. /**
  80. * G_OBJECT_TYPE:
  81. * @object: Object to return the type id for.
  82. *
  83. * Get the type id of an object.
  84. *
  85. * Returns: Type id of @object.
  86. */
  87. #define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
  88. /**
  89. * G_OBJECT_TYPE_NAME:
  90. * @object: Object to return the type name for.
  91. *
  92. * Get the name of an object's type.
  93. *
  94. * Returns: Type name of @object. The string is owned by the type system and
  95. * should not be freed.
  96. */
  97. #define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))
  98. /**
  99. * G_OBJECT_CLASS_TYPE:
  100. * @class: a valid #GObjectClass
  101. *
  102. * Get the type id of a class structure.
  103. *
  104. * Returns: Type id of @class.
  105. */
  106. #define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
  107. /**
  108. * G_OBJECT_CLASS_NAME:
  109. * @class: a valid #GObjectClass
  110. *
  111. * Return the name of a class structure's type.
  112. *
  113. * Returns: Type name of @class. The string is owned by the type system and
  114. * should not be freed.
  115. */
  116. #define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))
  117. /**
  118. * G_VALUE_HOLDS_OBJECT:
  119. * @value: a valid #GValue structure
  120. *
  121. * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT.
  122. *
  123. * Returns: %TRUE on success.
  124. */
  125. #define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))
  126. /* --- type macros --- */
  127. /**
  128. * G_TYPE_INITIALLY_UNOWNED:
  129. *
  130. * The type for #GInitiallyUnowned.
  131. */
  132. #define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type())
  133. /**
  134. * G_INITIALLY_UNOWNED:
  135. * @object: Object which is subject to casting.
  136. *
  137. * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*)
  138. * pointer. Depending on the current debugging level, this function may invoke
  139. * certain runtime checks to identify invalid casts.
  140. */
  141. #define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))
  142. /**
  143. * G_INITIALLY_UNOWNED_CLASS:
  144. * @class: a valid #GInitiallyUnownedClass
  145. *
  146. * Casts a derived #GInitiallyUnownedClass structure into a
  147. * #GInitiallyUnownedClass structure.
  148. */
  149. #define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
  150. /**
  151. * G_IS_INITIALLY_UNOWNED:
  152. * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED.
  153. *
  154. * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED.
  155. */
  156. #define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED))
  157. /**
  158. * G_IS_INITIALLY_UNOWNED_CLASS:
  159. * @class: a #GInitiallyUnownedClass
  160. *
  161. * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type
  162. * %G_TYPE_INITIALLY_UNOWNED or derived.
  163. */
  164. #define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED))
  165. /**
  166. * G_INITIALLY_UNOWNED_GET_CLASS:
  167. * @object: a #GInitiallyUnowned instance.
  168. *
  169. * Get the class structure associated to a #GInitiallyUnowned instance.
  170. *
  171. * Returns: pointer to object class structure.
  172. */
  173. #define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
  174. /* GInitiallyUnowned ia a GObject with initially floating reference count */
  175. /* --- typedefs & structures --- */
  176. typedef struct _GObject GObject;
  177. typedef struct _GObjectClass GObjectClass;
  178. typedef struct _GObject GInitiallyUnowned;
  179. typedef struct _GObjectClass GInitiallyUnownedClass;
  180. typedef struct _GObjectConstructParam GObjectConstructParam;
  181. /**
  182. * GObjectGetPropertyFunc:
  183. * @object: a #GObject
  184. * @property_id: the numeric id under which the property was registered with
  185. * g_object_class_install_property().
  186. * @value: a #GValue to return the property value in
  187. * @pspec: the #GParamSpec describing the property
  188. *
  189. * The type of the @get_property function of #GObjectClass.
  190. */
  191. typedef void (*GObjectGetPropertyFunc) (GObject *object,
  192. guint property_id,
  193. GValue *value,
  194. GParamSpec *pspec);
  195. /**
  196. * GObjectSetPropertyFunc:
  197. * @object: a #GObject
  198. * @property_id: the numeric id under which the property was registered with
  199. * g_object_class_install_property().
  200. * @value: the new value for the property
  201. * @pspec: the #GParamSpec describing the property
  202. *
  203. * The type of the @set_property function of #GObjectClass.
  204. */
  205. typedef void (*GObjectSetPropertyFunc) (GObject *object,
  206. guint property_id,
  207. const GValue *value,
  208. GParamSpec *pspec);
  209. /**
  210. * GObjectFinalizeFunc:
  211. * @object: the #GObject being finalized
  212. *
  213. * The type of the @finalize function of #GObjectClass.
  214. */
  215. typedef void (*GObjectFinalizeFunc) (GObject *object);
  216. /**
  217. * GWeakNotify:
  218. * @data: data that was provided when the weak reference was established
  219. * @where_the_object_was: the object being finalized
  220. *
  221. * A #GWeakNotify function can be added to an object as a callback that gets
  222. * triggered when the object is finalized. Since the object is already being
  223. * finalized when the #GWeakNotify is called, there's not much you could do
  224. * with the object, apart from e.g. using its address as hash-index or the like.
  225. */
  226. typedef void (*GWeakNotify) (gpointer data,
  227. GObject *where_the_object_was);
  228. /**
  229. * GObject:
  230. *
  231. * All the fields in the GObject structure are private
  232. * to the #GObject implementation and should never be accessed directly.
  233. */
  234. struct _GObject
  235. {
  236. GTypeInstance g_type_instance;
  237. /*< private >*/
  238. volatile guint ref_count;
  239. GData *qdata;
  240. };
  241. /**
  242. * GObjectClass:
  243. * @g_type_class: the parent class
  244. * @constructor: the @constructor function is called by g_object_new () to
  245. * complete the object initialization after all the construction properties are
  246. * set. The first thing a @constructor implementation must do is chain up to the
  247. * @constructor of the parent class. Overriding @constructor should be rarely
  248. * needed, e.g. to handle construct properties, or to implement singletons.
  249. * @set_property: the generic setter for all properties of this type. Should be
  250. * overridden for every type with properties. If implementations of
  251. * @set_property don't emit property change notification explicitly, this will
  252. * be done implicitly by the type system. However, if the notify signal is
  253. * emitted explicitly, the type system will not emit it a second time.
  254. * @get_property: the generic getter for all properties of this type. Should be
  255. * overridden for every type with properties.
  256. * @dispose: the @dispose function is supposed to drop all references to other
  257. * objects, but keep the instance otherwise intact, so that client method
  258. * invocations still work. It may be run multiple times (due to reference
  259. * loops). Before returning, @dispose should chain up to the @dispose method
  260. * of the parent class.
  261. * @finalize: instance finalization function, should finish the finalization of
  262. * the instance begun in @dispose and chain up to the @finalize method of the
  263. * parent class.
  264. * @dispatch_properties_changed: emits property change notification for a bunch
  265. * of properties. Overriding @dispatch_properties_changed should be rarely
  266. * needed.
  267. * @notify: the class closure for the notify signal
  268. * @constructed: the @constructed function is called by g_object_new() as the
  269. * final step of the object creation process. At the point of the call, all
  270. * construction properties have been set on the object. The purpose of this
  271. * call is to allow for object initialisation steps that can only be performed
  272. * after construction properties have been set. @constructed implementors
  273. * should chain up to the @constructed call of their parent class to allow it
  274. * to complete its initialisation.
  275. *
  276. * The class structure for the GObject type.
  277. *
  278. * <example>
  279. * <title>Implementing singletons using a constructor</title>
  280. * <programlisting>
  281. * static MySingleton *the_singleton = NULL;
  282. *
  283. * static GObject*
  284. * my_singleton_constructor (GType type,
  285. * guint n_construct_params,
  286. * GObjectConstructParam *construct_params)
  287. * {
  288. * GObject *object;
  289. *
  290. * if (!the_singleton)
  291. * {
  292. * object = G_OBJECT_CLASS (parent_class)->constructor (type,
  293. * n_construct_params,
  294. * construct_params);
  295. * the_singleton = MY_SINGLETON (object);
  296. * }
  297. * else
  298. * object = g_object_ref (G_OBJECT (the_singleton));
  299. *
  300. * return object;
  301. * }
  302. * </programlisting></example>
  303. */
  304. struct _GObjectClass
  305. {
  306. GTypeClass g_type_class;
  307. /*< private >*/
  308. GSList *construct_properties;
  309. /*< public >*/
  310. /* seldom overidden */
  311. GObject* (*constructor) (GType type,
  312. guint n_construct_properties,
  313. GObjectConstructParam *construct_properties);
  314. /* overridable methods */
  315. void (*set_property) (GObject *object,
  316. guint property_id,
  317. const GValue *value,
  318. GParamSpec *pspec);
  319. void (*get_property) (GObject *object,
  320. guint property_id,
  321. GValue *value,
  322. GParamSpec *pspec);
  323. void (*dispose) (GObject *object);
  324. void (*finalize) (GObject *object);
  325. /* seldom overidden */
  326. void (*dispatch_properties_changed) (GObject *object,
  327. guint n_pspecs,
  328. GParamSpec **pspecs);
  329. /* signals */
  330. void (*notify) (GObject *object,
  331. GParamSpec *pspec);
  332. /* called when done constructing */
  333. void (*constructed) (GObject *object);
  334. /*< private >*/
  335. gsize flags;
  336. /* padding */
  337. gpointer pdummy[6];
  338. };
  339. /**
  340. * GObjectConstructParam:
  341. * @pspec: the #GParamSpec of the construct parameter
  342. * @value: the value to set the parameter to
  343. *
  344. * The GObjectConstructParam struct is an auxiliary
  345. * structure used to hand #GParamSpec/#GValue pairs to the @constructor of
  346. * a #GObjectClass.
  347. */
  348. struct _GObjectConstructParam
  349. {
  350. GParamSpec *pspec;
  351. GValue *value;
  352. };
  353. /**
  354. * GInitiallyUnowned:
  355. *
  356. * All the fields in the GInitiallyUnowned structure
  357. * are private to the #GInitiallyUnowned implementation and should never be
  358. * accessed directly.
  359. */
  360. /**
  361. * GInitiallyUnownedClass:
  362. *
  363. * The class structure for the GInitiallyUnowned type.
  364. */
  365. /* --- prototypes --- */
  366. GLIB_AVAILABLE_IN_ALL
  367. GType g_initially_unowned_get_type (void);
  368. GLIB_AVAILABLE_IN_ALL
  369. void g_object_class_install_property (GObjectClass *oclass,
  370. guint property_id,
  371. GParamSpec *pspec);
  372. GLIB_AVAILABLE_IN_ALL
  373. GParamSpec* g_object_class_find_property (GObjectClass *oclass,
  374. const gchar *property_name);
  375. GLIB_AVAILABLE_IN_ALL
  376. GParamSpec**g_object_class_list_properties (GObjectClass *oclass,
  377. guint *n_properties);
  378. GLIB_AVAILABLE_IN_ALL
  379. void g_object_class_override_property (GObjectClass *oclass,
  380. guint property_id,
  381. const gchar *name);
  382. GLIB_AVAILABLE_IN_ALL
  383. void g_object_class_install_properties (GObjectClass *oclass,
  384. guint n_pspecs,
  385. GParamSpec **pspecs);
  386. GLIB_AVAILABLE_IN_ALL
  387. void g_object_interface_install_property (gpointer g_iface,
  388. GParamSpec *pspec);
  389. GLIB_AVAILABLE_IN_ALL
  390. GParamSpec* g_object_interface_find_property (gpointer g_iface,
  391. const gchar *property_name);
  392. GLIB_AVAILABLE_IN_ALL
  393. GParamSpec**g_object_interface_list_properties (gpointer g_iface,
  394. guint *n_properties_p);
  395. GLIB_AVAILABLE_IN_ALL
  396. GType g_object_get_type (void) G_GNUC_CONST;
  397. GLIB_AVAILABLE_IN_ALL
  398. gpointer g_object_new (GType object_type,
  399. const gchar *first_property_name,
  400. ...);
  401. GLIB_AVAILABLE_IN_ALL
  402. gpointer g_object_newv (GType object_type,
  403. guint n_parameters,
  404. GParameter *parameters);
  405. GLIB_AVAILABLE_IN_ALL
  406. GObject* g_object_new_valist (GType object_type,
  407. const gchar *first_property_name,
  408. va_list var_args);
  409. GLIB_AVAILABLE_IN_ALL
  410. void g_object_set (gpointer object,
  411. const gchar *first_property_name,
  412. ...) G_GNUC_NULL_TERMINATED;
  413. GLIB_AVAILABLE_IN_ALL
  414. void g_object_get (gpointer object,
  415. const gchar *first_property_name,
  416. ...) G_GNUC_NULL_TERMINATED;
  417. GLIB_AVAILABLE_IN_ALL
  418. gpointer g_object_connect (gpointer object,
  419. const gchar *signal_spec,
  420. ...) G_GNUC_NULL_TERMINATED;
  421. GLIB_AVAILABLE_IN_ALL
  422. void g_object_disconnect (gpointer object,
  423. const gchar *signal_spec,
  424. ...) G_GNUC_NULL_TERMINATED;
  425. GLIB_AVAILABLE_IN_ALL
  426. void g_object_set_valist (GObject *object,
  427. const gchar *first_property_name,
  428. va_list var_args);
  429. GLIB_AVAILABLE_IN_ALL
  430. void g_object_get_valist (GObject *object,
  431. const gchar *first_property_name,
  432. va_list var_args);
  433. GLIB_AVAILABLE_IN_ALL
  434. void g_object_set_property (GObject *object,
  435. const gchar *property_name,
  436. const GValue *value);
  437. GLIB_AVAILABLE_IN_ALL
  438. void g_object_get_property (GObject *object,
  439. const gchar *property_name,
  440. GValue *value);
  441. GLIB_AVAILABLE_IN_ALL
  442. void g_object_freeze_notify (GObject *object);
  443. GLIB_AVAILABLE_IN_ALL
  444. void g_object_notify (GObject *object,
  445. const gchar *property_name);
  446. GLIB_AVAILABLE_IN_ALL
  447. void g_object_notify_by_pspec (GObject *object,
  448. GParamSpec *pspec);
  449. GLIB_AVAILABLE_IN_ALL
  450. void g_object_thaw_notify (GObject *object);
  451. GLIB_AVAILABLE_IN_ALL
  452. gboolean g_object_is_floating (gpointer object);
  453. GLIB_AVAILABLE_IN_ALL
  454. gpointer g_object_ref_sink (gpointer object);
  455. GLIB_AVAILABLE_IN_ALL
  456. gpointer g_object_ref (gpointer object);
  457. GLIB_AVAILABLE_IN_ALL
  458. void g_object_unref (gpointer object);
  459. GLIB_AVAILABLE_IN_ALL
  460. void g_object_weak_ref (GObject *object,
  461. GWeakNotify notify,
  462. gpointer data);
  463. GLIB_AVAILABLE_IN_ALL
  464. void g_object_weak_unref (GObject *object,
  465. GWeakNotify notify,
  466. gpointer data);
  467. GLIB_AVAILABLE_IN_ALL
  468. void g_object_add_weak_pointer (GObject *object,
  469. gpointer *weak_pointer_location);
  470. GLIB_AVAILABLE_IN_ALL
  471. void g_object_remove_weak_pointer (GObject *object,
  472. gpointer *weak_pointer_location);
  473. /**
  474. * GToggleNotify:
  475. * @data: Callback data passed to g_object_add_toggle_ref()
  476. * @object: The object on which g_object_add_toggle_ref() was called.
  477. * @is_last_ref: %TRUE if the toggle reference is now the
  478. * last reference to the object. %FALSE if the toggle
  479. * reference was the last reference and there are now other
  480. * references.
  481. *
  482. * A callback function used for notification when the state
  483. * of a toggle reference changes. See g_object_add_toggle_ref().
  484. */
  485. typedef void (*GToggleNotify) (gpointer data,
  486. GObject *object,
  487. gboolean is_last_ref);
  488. GLIB_AVAILABLE_IN_ALL
  489. void g_object_add_toggle_ref (GObject *object,
  490. GToggleNotify notify,
  491. gpointer data);
  492. GLIB_AVAILABLE_IN_ALL
  493. void g_object_remove_toggle_ref (GObject *object,
  494. GToggleNotify notify,
  495. gpointer data);
  496. GLIB_AVAILABLE_IN_ALL
  497. gpointer g_object_get_qdata (GObject *object,
  498. GQuark quark);
  499. GLIB_AVAILABLE_IN_ALL
  500. void g_object_set_qdata (GObject *object,
  501. GQuark quark,
  502. gpointer data);
  503. GLIB_AVAILABLE_IN_ALL
  504. void g_object_set_qdata_full (GObject *object,
  505. GQuark quark,
  506. gpointer data,
  507. GDestroyNotify destroy);
  508. GLIB_AVAILABLE_IN_ALL
  509. gpointer g_object_steal_qdata (GObject *object,
  510. GQuark quark);
  511. GLIB_AVAILABLE_IN_2_34
  512. gpointer g_object_dup_qdata (GObject *object,
  513. GQuark quark,
  514. GDuplicateFunc dup_func,
  515. gpointer user_data);
  516. GLIB_AVAILABLE_IN_2_34
  517. gboolean g_object_replace_qdata (GObject *object,
  518. GQuark quark,
  519. gpointer oldval,
  520. gpointer newval,
  521. GDestroyNotify destroy,
  522. GDestroyNotify *old_destroy);
  523. GLIB_AVAILABLE_IN_ALL
  524. gpointer g_object_get_data (GObject *object,
  525. const gchar *key);
  526. GLIB_AVAILABLE_IN_ALL
  527. void g_object_set_data (GObject *object,
  528. const gchar *key,
  529. gpointer data);
  530. GLIB_AVAILABLE_IN_ALL
  531. void g_object_set_data_full (GObject *object,
  532. const gchar *key,
  533. gpointer data,
  534. GDestroyNotify destroy);
  535. GLIB_AVAILABLE_IN_ALL
  536. gpointer g_object_steal_data (GObject *object,
  537. const gchar *key);
  538. GLIB_AVAILABLE_IN_2_34
  539. gpointer g_object_dup_data (GObject *object,
  540. const gchar *key,
  541. GDuplicateFunc dup_func,
  542. gpointer user_data);
  543. GLIB_AVAILABLE_IN_2_34
  544. gboolean g_object_replace_data (GObject *object,
  545. const gchar *key,
  546. gpointer oldval,
  547. gpointer newval,
  548. GDestroyNotify destroy,
  549. GDestroyNotify *old_destroy);
  550. GLIB_AVAILABLE_IN_ALL
  551. void g_object_watch_closure (GObject *object,
  552. GClosure *closure);
  553. GLIB_AVAILABLE_IN_ALL
  554. GClosure* g_cclosure_new_object (GCallback callback_func,
  555. GObject *object);
  556. GLIB_AVAILABLE_IN_ALL
  557. GClosure* g_cclosure_new_object_swap (GCallback callback_func,
  558. GObject *object);
  559. GLIB_AVAILABLE_IN_ALL
  560. GClosure* g_closure_new_object (guint sizeof_closure,
  561. GObject *object);
  562. GLIB_AVAILABLE_IN_ALL
  563. void g_value_set_object (GValue *value,
  564. gpointer v_object);
  565. GLIB_AVAILABLE_IN_ALL
  566. gpointer g_value_get_object (const GValue *value);
  567. GLIB_AVAILABLE_IN_ALL
  568. gpointer g_value_dup_object (const GValue *value);
  569. GLIB_AVAILABLE_IN_ALL
  570. gulong g_signal_connect_object (gpointer instance,
  571. const gchar *detailed_signal,
  572. GCallback c_handler,
  573. gpointer gobject,
  574. GConnectFlags connect_flags);
  575. /*< protected >*/
  576. GLIB_AVAILABLE_IN_ALL
  577. void g_object_force_floating (GObject *object);
  578. GLIB_AVAILABLE_IN_ALL
  579. void g_object_run_dispose (GObject *object);
  580. GLIB_AVAILABLE_IN_ALL
  581. void g_value_take_object (GValue *value,
  582. gpointer v_object);
  583. GLIB_DEPRECATED_FOR(g_value_take_object)
  584. void g_value_set_object_take_ownership (GValue *value,
  585. gpointer v_object);
  586. GLIB_DEPRECATED
  587. gsize g_object_compat_control (gsize what,
  588. gpointer data);
  589. /* --- implementation macros --- */
  590. #define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \
  591. G_STMT_START { \
  592. GObject *_glib__object = (GObject*) (object); \
  593. GParamSpec *_glib__pspec = (GParamSpec*) (pspec); \
  594. guint _glib__property_id = (property_id); \
  595. g_warning ("%s: invalid %s id %u for \"%s\" of type '%s' in '%s'", \
  596. G_STRLOC, \
  597. (pname), \
  598. _glib__property_id, \
  599. _glib__pspec->name, \
  600. g_type_name (G_PARAM_SPEC_TYPE (_glib__pspec)), \
  601. G_OBJECT_TYPE_NAME (_glib__object)); \
  602. } G_STMT_END
  603. /**
  604. * G_OBJECT_WARN_INVALID_PROPERTY_ID:
  605. * @object: the #GObject on which set_property() or get_property() was called
  606. * @property_id: the numeric id of the property
  607. * @pspec: the #GParamSpec of the property
  608. *
  609. * This macro should be used to emit a standard warning about unexpected
  610. * properties in set_property() and get_property() implementations.
  611. */
  612. #define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \
  613. G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec))
  614. GLIB_AVAILABLE_IN_ALL
  615. void g_clear_object (volatile GObject **object_ptr);
  616. #define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref)
  617. typedef struct {
  618. /*<private>*/
  619. union { gpointer p; } priv;
  620. } GWeakRef;
  621. GLIB_AVAILABLE_IN_ALL
  622. void g_weak_ref_init (GWeakRef *weak_ref,
  623. gpointer object);
  624. GLIB_AVAILABLE_IN_ALL
  625. void g_weak_ref_clear (GWeakRef *weak_ref);
  626. GLIB_AVAILABLE_IN_ALL
  627. gpointer g_weak_ref_get (GWeakRef *weak_ref);
  628. GLIB_AVAILABLE_IN_ALL
  629. void g_weak_ref_set (GWeakRef *weak_ref,
  630. gpointer object);
  631. G_END_DECLS
  632. #endif /* __G_OBJECT_H__ */