diff --git a/docs/reference/gobject/gobject-sections.txt b/docs/reference/gobject/gobject-sections.txt index 70f28329d..f52d95379 100644 --- a/docs/reference/gobject/gobject-sections.txt +++ b/docs/reference/gobject/gobject-sections.txt @@ -409,6 +409,7 @@ G_TYPE_POLLFD G_TYPE_THREAD G_TYPE_OPTION_GROUP G_TYPE_URI +G_TYPE_TREE G_TYPE_IS_BOXED @@ -443,6 +444,7 @@ g_markup_parse_context_get_type g_thread_get_type g_option_group_get_type g_uri_get_type +g_tree_get_type
diff --git a/gobject/gboxed.c b/gobject/gboxed.c index c7e9b75b6..30ba4e775 100644 --- a/gobject/gboxed.c +++ b/gobject/gboxed.c @@ -145,6 +145,7 @@ G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref) G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref) G_DEFINE_BOXED_TYPE (GByteArray, g_byte_array, g_byte_array_ref, g_byte_array_unref) G_DEFINE_BOXED_TYPE (GBytes, g_bytes, g_bytes_ref, g_bytes_unref) +G_DEFINE_BOXED_TYPE (GTree, g_tree, g_tree_ref, g_tree_unref) G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref) G_DEFINE_BOXED_TYPE (GMatchInfo, g_match_info, g_match_info_ref, g_match_info_unref) diff --git a/gobject/glib-types.h b/gobject/glib-types.h index b24e76bf1..cdccdaab4 100644 --- a/gobject/glib-types.h +++ b/gobject/glib-types.h @@ -306,6 +306,15 @@ typedef gsize GType; */ #define G_TYPE_URI (g_uri_get_type ()) +/** + * G_TYPE_TREE: + * + * The #GType for #GTree. + * + * Since: 2.68 + */ +#define G_TYPE_TREE (g_tree_get_type ()) + GLIB_AVAILABLE_IN_ALL GType g_date_get_type (void) G_GNUC_CONST; GLIB_AVAILABLE_IN_ALL @@ -364,6 +373,8 @@ GLIB_AVAILABLE_IN_2_44 GType g_option_group_get_type (void) G_GNUC_CONST; GLIB_AVAILABLE_IN_2_66 GType g_uri_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_68 +GType g_tree_get_type (void) G_GNUC_CONST; GLIB_DEPRECATED_FOR('G_TYPE_VARIANT') GType g_variant_get_gtype (void) G_GNUC_CONST; diff --git a/gobject/tests/boxed.c b/gobject/tests/boxed.c index 7f70d40c8..0c8872a82 100644 --- a/gobject/tests/boxed.c +++ b/gobject/tests/boxed.c @@ -617,6 +617,34 @@ test_boxed_checksum (void) g_value_unset (&value); } +static gint +treecmp (gconstpointer a, gconstpointer b) +{ + return (a < b) ? -1 : (a > b); +} + +static void +test_boxed_tree (void) +{ + GTree *t, *t2; + GValue value = G_VALUE_INIT; + + g_value_init (&value, G_TYPE_TREE); + g_assert_true (G_VALUE_HOLDS_BOXED (&value)); + + t = g_tree_new (treecmp); + g_value_take_boxed (&value, t); + + t2 = g_value_get_boxed (&value); + g_assert_true (t == t2); + + t2 = g_value_dup_boxed (&value); + g_assert_true (t == t2); /* trees use ref/unref for copy/free */ + g_tree_unref (t2); + + g_value_unset (&value); +} + int main (int argc, char *argv[]) { @@ -646,6 +674,7 @@ main (int argc, char *argv[]) g_test_add_func ("/boxed/markup", test_boxed_markup); g_test_add_func ("/boxed/thread", test_boxed_thread); g_test_add_func ("/boxed/checksum", test_boxed_checksum); + g_test_add_func ("/boxed/tree", test_boxed_tree); return g_test_run (); }