From 12189bc10f87fe6315565e38099aceff60583a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 25 Sep 2020 16:43:24 +0200 Subject: buildable: Rename set_name() to set_buildable_id() GtkBuildable's get_name()/set_name() methods may shadow GtkWidget's methods. Avoid that by renaming the API to get_buildable_id()/set_buildable_id(), which also reflects the name of the XML attribute the API refers to. https://gitlab.gnome.org/GNOME/gtk/-/issues/3191 --- demos/widget-factory/widget-factory.c | 8 ++++---- docs/reference/gtk/gtk4-sections.txt | 4 ++-- gtk/gtkbuildable.c | 34 +++++++++++++++++----------------- gtk/gtkbuildable.h | 20 ++++++++++---------- gtk/gtkbuilder.c | 24 ++++++++++++------------ gtk/gtkliststore.c | 2 +- gtk/gtktreestore.c | 2 +- gtk/gtkwidget.c | 26 +++++++++++++------------- gtk/inspector/misc-info.c | 2 +- gtk/inspector/object-tree.c | 2 +- gtk/tools/gtk-builder-tool-enumerate.c | 8 ++++---- gtk/tools/gtk-builder-tool-preview.c | 2 +- testsuite/gtk/builder.c | 6 +++--- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 48329d4018..021b69e640 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -1398,7 +1398,7 @@ handle_insert (GtkWidget *button, GtkWidget *textview) const char *id; const char *text; - id = gtk_buildable_get_name (GTK_BUILDABLE (button)); + id = gtk_buildable_get_buildable_id (GTK_BUILDABLE (button)); if (strcmp (id, "toolbutton1") == 0) text = "⌘"; @@ -1424,7 +1424,7 @@ handle_cutcopypaste (GtkWidget *button, GtkWidget *textview) clipboard = gtk_widget_get_clipboard (textview); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); - id = gtk_buildable_get_name (GTK_BUILDABLE (button)); + id = gtk_buildable_get_buildable_id (GTK_BUILDABLE (button)); if (strcmp (id, "cutbutton") == 0) gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE); @@ -1442,7 +1442,7 @@ clipboard_formats_notify (GdkClipboard *clipboard, GdkEvent *event, GtkWidget *b const char *id; gboolean has_text; - id = gtk_buildable_get_name (GTK_BUILDABLE (button)); + id = gtk_buildable_get_buildable_id (GTK_BUILDABLE (button)); has_text = gdk_content_formats_contain_gtype (gdk_clipboard_get_formats (clipboard), GTK_TYPE_TEXT_BUFFER); if (strcmp (id, "pastebutton") == 0) @@ -1455,7 +1455,7 @@ textbuffer_notify_selection (GObject *object, GParamSpec *pspec, GtkWidget *butt const char *id; gboolean has_selection; - id = gtk_buildable_get_name (GTK_BUILDABLE (button)); + id = gtk_buildable_get_buildable_id (GTK_BUILDABLE (button)); has_selection = gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (object)); if (strcmp (id, "cutbutton") == 0 || diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 72968d98a4..d93c23e297 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -617,8 +617,8 @@ gtk_grid_view_get_type GtkBuildable GtkBuildableIface GtkBuildableParser -gtk_buildable_set_name -gtk_buildable_get_name +gtk_buildable_set_buildable_id +gtk_buildable_get_buildable_id gtk_buildable_add_child gtk_buildable_set_buildable_property gtk_buildable_construct_child diff --git a/gtk/gtkbuildable.c b/gtk/gtkbuildable.c index f5b26325e2..8e73e20b4a 100644 --- a/gtk/gtkbuildable.c +++ b/gtk/gtkbuildable.c @@ -49,46 +49,46 @@ gtk_buildable_default_init (GtkBuildableInterface *iface) } /** - * gtk_buildable_set_name: + * gtk_buildable_set_buildable_id: * @buildable: a #GtkBuildable - * @name: name to set + * @id: name to set * - * Sets the name of the @buildable object. + * Sets the ID of the @buildable object. **/ void -gtk_buildable_set_name (GtkBuildable *buildable, - const char *name) +gtk_buildable_set_buildable_id (GtkBuildable *buildable, + const char *id) { GtkBuildableIface *iface; g_return_if_fail (GTK_IS_BUILDABLE (buildable)); - g_return_if_fail (name != NULL); + g_return_if_fail (id != NULL); iface = GTK_BUILDABLE_GET_IFACE (buildable); - if (iface->set_name) - (* iface->set_name) (buildable, name); + if (iface->set_id) + (* iface->set_id) (buildable, id); else g_object_set_data_full (G_OBJECT (buildable), - "gtk-builder-name", - g_strdup (name), + "gtk-builder-id", + g_strdup (id), g_free); } /** - * gtk_buildable_get_name: + * gtk_buildable_get_buildable_id: * @buildable: a #GtkBuildable * - * Gets the name of the @buildable object. + * Gets the ID of the @buildable object. * * #GtkBuilder sets the name based on the * [GtkBuilder UI definition][BUILDER-UI] * used to construct the @buildable. * - * Returns: the name set with gtk_buildable_set_name() + * Returns: the ID set with gtk_buildable_set_buildable_id() **/ const char * -gtk_buildable_get_name (GtkBuildable *buildable) +gtk_buildable_get_buildable_id (GtkBuildable *buildable) { GtkBuildableIface *iface; @@ -96,11 +96,11 @@ gtk_buildable_get_name (GtkBuildable *buildable) iface = GTK_BUILDABLE_GET_IFACE (buildable); - if (iface->get_name) - return (* iface->get_name) (buildable); + if (iface->get_id) + return (* iface->get_id) (buildable); else return (const char *)g_object_get_data (G_OBJECT (buildable), - "gtk-builder-name"); + "gtk-builder-id"); } /** diff --git a/gtk/gtkbuildable.h b/gtk/gtkbuildable.h index 7450103f57..9cb69dcaa3 100644 --- a/gtk/gtkbuildable.h +++ b/gtk/gtkbuildable.h @@ -76,12 +76,12 @@ struct _GtkBuildableParser /** * GtkBuildableIface: * @g_iface: the parent class - * @set_name: Stores the name attribute given in the GtkBuilder UI definition. + * @set_id: Stores the id attribute given in the GtkBuilder UI definition. * #GtkWidget stores the name as object data. Implement this method if your - * object has some notion of “name” and it makes sense to map the XML name + * object has some notion of “ID” and it makes sense to map the XML id * attribute to it. - * @get_name: The getter corresponding to @set_name. Implement this - * if you implement @set_name. + * @get_id: The getter corresponding to @set_id. Implement this + * if you implement @set_id. * @add_child: Adds a child. The @type parameter can be used to * differentiate the kind of child. #GtkWidget implements this * to add event controllers to the widget, #GtkNotebook uses @@ -126,9 +126,9 @@ struct _GtkBuildableIface GTypeInterface g_iface; /* virtual table */ - void (* set_name) (GtkBuildable *buildable, - const char *name); - const char * (* get_name) (GtkBuildable *buildable); + void (* set_id) (GtkBuildable *buildable, + const char *id); + const char * (* get_id) (GtkBuildable *buildable); void (* add_child) (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, @@ -169,10 +169,10 @@ GDK_AVAILABLE_IN_ALL GType gtk_buildable_get_type (void) G_GNUC_CONST; GDK_AVAILABLE_IN_ALL -void gtk_buildable_set_name (GtkBuildable *buildable, - const char *name); +void gtk_buildable_set_buildable_id (GtkBuildable *buildable, + const char *id); GDK_AVAILABLE_IN_ALL -const char * gtk_buildable_get_name (GtkBuildable *buildable); +const char * gtk_buildable_get_buildable_id (GtkBuildable *buildable); GDK_AVAILABLE_IN_ALL void gtk_buildable_add_child (GtkBuildable *buildable, GtkBuilder *builder, diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 02541a4b84..1e079c2ccc 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -623,12 +623,12 @@ gtk_builder_get_parameters (GtkBuilder *builder, } static const char * -object_get_name (GObject *object) +object_get_id (GObject *object) { if (GTK_IS_BUILDABLE (object)) - return gtk_buildable_get_name (GTK_BUILDABLE (object)); + return gtk_buildable_get_buildable_id (GTK_BUILDABLE (object)); else - return g_object_get_data (object, "gtk-builder-name"); + return g_object_get_data (object, "gtk-builder-id"); } static GObject * @@ -650,7 +650,7 @@ gtk_builder_get_internal_child (GtkBuilder *builder, GTK_NOTE (BUILDER, g_message ("Trying to get internal child %s from %s", - childname, object_get_name (info->object))); + childname, object_get_id (info->object))); if (GTK_IS_BUILDABLE (info->object)) obj = gtk_buildable_get_internal_child (GTK_BUILDABLE (info->object), @@ -669,13 +669,13 @@ gtk_builder_get_internal_child (GtkBuilder *builder, } static inline void -object_set_name (GObject *object, - const char *name) +object_set_id (GObject *object, + const char *id) { if (GTK_IS_BUILDABLE (object)) - gtk_buildable_set_name (GTK_BUILDABLE (object), name); + gtk_buildable_set_buildable_id (GTK_BUILDABLE (object), id); else - g_object_set_data_full (object, "gtk-builder-name", g_strdup (name), g_free); + g_object_set_data_full (object, "gtk-builder-id", g_strdup (id), g_free); } void @@ -685,7 +685,7 @@ _gtk_builder_add_object (GtkBuilder *builder, { GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder); - object_set_name (object, id); + object_set_id (object, id); g_hash_table_insert (priv->objects, g_strdup (id), g_object_ref (object)); } @@ -984,7 +984,7 @@ _gtk_builder_add (GtkBuilder *builder, if (!child_info->parent) { - g_warning ("%s: Not adding, No parent", object_get_name (object)); + g_warning ("%s: Not adding, No parent", object_get_id (object)); return; } @@ -993,7 +993,7 @@ _gtk_builder_add (GtkBuilder *builder, parent = ((ObjectInfo*)child_info->parent)->object; GTK_NOTE (BUILDER, - g_message ("adding %s to %s", object_get_name (object), object_get_name (parent))); + g_message ("adding %s to %s", object_get_id (object), object_get_id (parent))); if (G_IS_LIST_STORE (parent)) { @@ -1735,7 +1735,7 @@ gtk_builder_expose_object (GtkBuilder *builder, g_return_if_fail (name && name[0]); g_return_if_fail (!g_hash_table_contains (priv->objects, name)); - object_set_name (object, name); + object_set_id (object, name); g_hash_table_insert (priv->objects, g_strdup (name), g_object_ref (object)); diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c index f5b1347fbe..b1fa81e777 100644 --- a/gtk/gtkliststore.c +++ b/gtk/gtkliststore.c @@ -2511,7 +2511,7 @@ list_store_end_element (GtkBuildableParseContext *context, { g_warning ("Unknown type %s specified in treemodel %s", (const char *)l->data, - gtk_buildable_get_name (GTK_BUILDABLE (data->object))); + gtk_buildable_get_buildable_id (GTK_BUILDABLE (data->object))); continue; } column_types[i] = type; diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index aac3ae5ad3..27cc237a49 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -3389,7 +3389,7 @@ tree_model_end_element (GtkBuildableParseContext *context, { g_warning ("Unknown type %s specified in treemodel %s", (const char *)l->data, - gtk_buildable_get_name (GTK_BUILDABLE (data->object))); + gtk_buildable_get_buildable_id (GTK_BUILDABLE (data->object))); continue; } types[i] = type; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index f9d5f079f9..2978107266 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -604,9 +604,9 @@ static void gtk_widget_real_state_flags_changed (GtkWidget static void gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface); static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface); -static void gtk_widget_buildable_set_name (GtkBuildable *buildable, - const char *name); -static const char * gtk_widget_buildable_get_name (GtkBuildable *buildable); +static void gtk_widget_buildable_set_id (GtkBuildable *buildable, + const char *id); +static const char * gtk_widget_buildable_get_id (GtkBuildable *buildable); static GObject * gtk_widget_buildable_get_internal_child (GtkBuildable *buildable, GtkBuilder *builder, const char *childname); @@ -8113,7 +8113,7 @@ gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface) /* * GtkBuildable implementation */ -static GQuark quark_builder_set_name = 0; +static GQuark quark_builder_set_id = 0; static void gtk_widget_buildable_add_child (GtkBuildable *buildable, @@ -8143,10 +8143,10 @@ gtk_widget_buildable_add_child (GtkBuildable *buildable, static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface) { - quark_builder_set_name = g_quark_from_static_string ("gtk-builder-set-name"); + quark_builder_set_id = g_quark_from_static_string ("gtk-builder-set-id"); - iface->set_name = gtk_widget_buildable_set_name; - iface->get_name = gtk_widget_buildable_get_name; + iface->set_id = gtk_widget_buildable_set_id; + iface->get_id = gtk_widget_buildable_get_id; iface->get_internal_child = gtk_widget_buildable_get_internal_child; iface->parser_finished = gtk_widget_buildable_parser_finished; iface->custom_tag_start = gtk_widget_buildable_custom_tag_start; @@ -8156,17 +8156,17 @@ gtk_widget_buildable_interface_init (GtkBuildableIface *iface) } static void -gtk_widget_buildable_set_name (GtkBuildable *buildable, - const char *name) +gtk_widget_buildable_set_id (GtkBuildable *buildable, + const char *id) { - g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_name, - g_strdup (name), g_free); + g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_id, + g_strdup (id), g_free); } static const char * -gtk_widget_buildable_get_name (GtkBuildable *buildable) +gtk_widget_buildable_get_id (GtkBuildable *buildable) { - return g_object_get_qdata (G_OBJECT (buildable), quark_builder_set_name); + return g_object_get_qdata (G_OBJECT (buildable), quark_builder_set_id); } static GObject * diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c index d2bb6d9503..8d969d996f 100644 --- a/gtk/inspector/misc-info.c +++ b/gtk/inspector/misc-info.c @@ -353,7 +353,7 @@ update_info (gpointer data) if (GTK_IS_BUILDABLE (sl->object)) { gtk_label_set_text (GTK_LABEL (sl->buildable_id), - gtk_buildable_get_name (GTK_BUILDABLE (sl->object))); + gtk_buildable_get_buildable_id (GTK_BUILDABLE (sl->object))); } if (GDK_IS_FRAME_CLOCK (sl->object)) diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c index 664ad30742..5f8c036380 100644 --- a/gtk/inspector/object-tree.c +++ b/gtk/inspector/object-tree.c @@ -633,7 +633,7 @@ gtk_inspector_get_object_name (GObject *object) { const char *id; - id = gtk_buildable_get_name (GTK_BUILDABLE (object)); + id = gtk_buildable_get_buildable_id (GTK_BUILDABLE (object)); if (id != NULL && !g_str_has_prefix (id, "___object_")) return id; } diff --git a/gtk/tools/gtk-builder-tool-enumerate.c b/gtk/tools/gtk-builder-tool-enumerate.c index 382ad93929..feb3758cc5 100644 --- a/gtk/tools/gtk-builder-tool-enumerate.c +++ b/gtk/tools/gtk-builder-tool-enumerate.c @@ -29,12 +29,12 @@ #include "gtk-builder-tool.h" static const char * -object_get_name (GObject *object) +object_get_id (GObject *object) { if (GTK_IS_BUILDABLE (object)) - return gtk_buildable_get_name (GTK_BUILDABLE (object)); + return gtk_buildable_get_buildable_id (GTK_BUILDABLE (object)); else - return g_object_get_data (object, "gtk-builder-name"); + return g_object_get_data (object, "gtk-builder-id"); } void @@ -63,7 +63,7 @@ do_enumerate (int *argc, const char ***argv) for (l = list; l; l = l->next) { object = l->data; - name = object_get_name (object); + name = object_get_id (object); if (g_str_has_prefix (name, "___") && g_str_has_suffix (name, "___")) continue; diff --git a/gtk/tools/gtk-builder-tool-preview.c b/gtk/tools/gtk-builder-tool-preview.c index 3dbc3d1b5b..db345c7bca 100644 --- a/gtk/tools/gtk-builder-tool-preview.c +++ b/gtk/tools/gtk-builder-tool-preview.c @@ -144,7 +144,7 @@ preview_file (const char *filename, window = gtk_window_new (); if (GTK_IS_BUILDABLE (object)) - id = gtk_buildable_get_name (GTK_BUILDABLE (object)); + id = gtk_buildable_get_buildable_id (GTK_BUILDABLE (object)); set_window_title (GTK_WINDOW (window), filename, id); diff --git a/testsuite/gtk/builder.c b/testsuite/gtk/builder.c index 754d05c63e..78ff3c9b3a 100644 --- a/testsuite/gtk/builder.c +++ b/testsuite/gtk/builder.c @@ -944,7 +944,7 @@ test_children (void) g_assert (button != NULL); g_assert (GTK_IS_BUTTON (button)); g_assert (gtk_widget_get_parent (GTK_WIDGET(button)) != NULL); - g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (gtk_widget_get_parent (GTK_WIDGET (button)))), "window1") == 0); + g_assert (strcmp (gtk_buildable_get_buildable_id (GTK_BUILDABLE (gtk_widget_get_parent (GTK_WIDGET (button)))), "window1") == 0); gtk_window_destroy (GTK_WINDOW (window)); g_object_unref (builder); @@ -965,14 +965,14 @@ test_children (void) g_assert (vbox != NULL); g_assert (GTK_IS_BOX (vbox)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (vbox)) == GTK_ORIENTATION_VERTICAL); - g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (content_area)), "dialog1-vbox") == 0); + g_assert (strcmp (gtk_buildable_get_buildable_id (GTK_BUILDABLE (content_area)), "dialog1-vbox") == 0); action_area = gtk_builder_get_object (builder, "dialog1-action_area"); g_assert (action_area != NULL); g_assert (GTK_IS_BOX (action_area)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (action_area)) == GTK_ORIENTATION_HORIZONTAL); g_assert (gtk_widget_get_parent (GTK_WIDGET (action_area)) != NULL); - g_assert (gtk_buildable_get_name (GTK_BUILDABLE (action_area)) != NULL); + g_assert (gtk_buildable_get_buildable_id (GTK_BUILDABLE (action_area)) != NULL); gtk_window_destroy (GTK_WINDOW (dialog)); g_object_unref (builder); } -- cgit v1.2.1 From 2715b3ec31256ee1c3e0276fdc0154cd8a69fa8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 25 Sep 2020 14:27:26 +0200 Subject: buildable: Make vfunc accessor functions private With the exception of gtk_buildable_get_id(), those are only used to construct objects from XML descriptions, which is functionality internal to GTK. The API is therefore unlikely to be missed, and keeping it internal means they can no longer unintentionally shadow object methods in bindings with less namespacing; for example it's currently ambiguous whether `infoBar.add_child()` refers to gtk_info_bar_add_child() or gtk_buildable_add_child(). https://gitlab.gnome.org/GNOME/gtk/-/issues/3191 --- docs/reference/gtk/gtk4-sections.txt | 9 -------- gtk/gtkbuildable.c | 2 +- gtk/gtkbuildable.h | 43 ---------------------------------- gtk/gtkbuildableprivate.h | 45 ++++++++++++++++++++++++++++++++++++ gtk/gtkbuilder-menus.c | 1 + gtk/gtkbuilder.c | 2 +- gtk/gtkbuilderparser.c | 2 +- gtk/gtkbuilderprecompile.c | 2 +- 8 files changed, 50 insertions(+), 56 deletions(-) create mode 100644 gtk/gtkbuildableprivate.h diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index d93c23e297..b0bbd9cb1d 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -617,16 +617,7 @@ gtk_grid_view_get_type GtkBuildable GtkBuildableIface GtkBuildableParser -gtk_buildable_set_buildable_id gtk_buildable_get_buildable_id -gtk_buildable_add_child -gtk_buildable_set_buildable_property -gtk_buildable_construct_child -gtk_buildable_custom_tag_start -gtk_buildable_custom_tag_end -gtk_buildable_custom_finished -gtk_buildable_parser_finished -gtk_buildable_get_internal_child GTK_BUILDABLE GTK_IS_BUILDABLE diff --git a/gtk/gtkbuildable.c b/gtk/gtkbuildable.c index 8e73e20b4a..dd0e33040d 100644 --- a/gtk/gtkbuildable.c +++ b/gtk/gtkbuildable.c @@ -36,7 +36,7 @@ */ #include "config.h" -#include "gtkbuildable.h" +#include "gtkbuildableprivate.h" #include "gtkintl.h" diff --git a/gtk/gtkbuildable.h b/gtk/gtkbuildable.h index 9cb69dcaa3..ed0dbdd25a 100644 --- a/gtk/gtkbuildable.h +++ b/gtk/gtkbuildable.h @@ -168,51 +168,8 @@ struct _GtkBuildableIface GDK_AVAILABLE_IN_ALL GType gtk_buildable_get_type (void) G_GNUC_CONST; -GDK_AVAILABLE_IN_ALL -void gtk_buildable_set_buildable_id (GtkBuildable *buildable, - const char *id); GDK_AVAILABLE_IN_ALL const char * gtk_buildable_get_buildable_id (GtkBuildable *buildable); -GDK_AVAILABLE_IN_ALL -void gtk_buildable_add_child (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const char *type); -GDK_AVAILABLE_IN_ALL -void gtk_buildable_set_buildable_property (GtkBuildable *buildable, - GtkBuilder *builder, - const char *name, - const GValue *value); -GDK_AVAILABLE_IN_ALL -GObject * gtk_buildable_construct_child (GtkBuildable *buildable, - GtkBuilder *builder, - const char *name); -GDK_AVAILABLE_IN_ALL -gboolean gtk_buildable_custom_tag_start (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const char *tagname, - GtkBuildableParser *parser, - gpointer *data); -GDK_AVAILABLE_IN_ALL -void gtk_buildable_custom_tag_end (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const char *tagname, - gpointer data); -GDK_AVAILABLE_IN_ALL -void gtk_buildable_custom_finished (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const char *tagname, - gpointer data); -GDK_AVAILABLE_IN_ALL -void gtk_buildable_parser_finished (GtkBuildable *buildable, - GtkBuilder *builder); -GDK_AVAILABLE_IN_ALL -GObject * gtk_buildable_get_internal_child (GtkBuildable *buildable, - GtkBuilder *builder, - const char *childname); GDK_AVAILABLE_IN_ALL void gtk_buildable_parse_context_push (GtkBuildableParseContext *context, diff --git a/gtk/gtkbuildableprivate.h b/gtk/gtkbuildableprivate.h new file mode 100644 index 0000000000..305be21898 --- /dev/null +++ b/gtk/gtkbuildableprivate.h @@ -0,0 +1,45 @@ +#ifndef __GTK_BUILDABLE_PRIVATE_H__ +#define __GTK_BUILDABLE_PRIVATE_H__ + +#include "gtkbuildable.h" + +G_BEGIN_DECLS + +void gtk_buildable_set_buildable_id (GtkBuildable *buildable, + const char *id); +void gtk_buildable_add_child (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const char *type); +void gtk_buildable_set_buildable_property (GtkBuildable *buildable, + GtkBuilder *builder, + const char *name, + const GValue *value); +GObject * gtk_buildable_construct_child (GtkBuildable *buildable, + GtkBuilder *builder, + const char *name); +gboolean gtk_buildable_custom_tag_start (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const char *tagname, + GtkBuildableParser *parser, + gpointer *data); +void gtk_buildable_custom_tag_end (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const char *tagname, + gpointer data); +void gtk_buildable_custom_finished (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const char *tagname, + gpointer data); +void gtk_buildable_parser_finished (GtkBuildable *buildable, + GtkBuilder *builder); +GObject * gtk_buildable_get_internal_child (GtkBuildable *buildable, + GtkBuilder *builder, + const char *childname); + +G_END_DECLS + +#endif /* __GTK_BUILDABLE_PRIVATE_H__ */ diff --git a/gtk/gtkbuilder-menus.c b/gtk/gtkbuilder-menus.c index aca07e3f2e..0bc7c1ed78 100644 --- a/gtk/gtkbuilder-menus.c +++ b/gtk/gtkbuilder-menus.c @@ -20,6 +20,7 @@ #include "config.h" #include "gtkbuilderprivate.h" +#include "gtkbuildableprivate.h" #include "gtkintl.h" #include diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 1e079c2ccc..cb2bcf0236 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -206,7 +206,7 @@ #include "gtkbuilderprivate.h" #include "gdkpixbufutilsprivate.h" -#include "gtkbuildable.h" +#include "gtkbuildableprivate.h" #include "gtkbuilderlistitemfactory.h" #include "gtkbuilderscopeprivate.h" #include "gtkdebug.h" diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index 78385499a9..3ea04b941f 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -20,7 +20,7 @@ #include "gtkbuilderprivate.h" -#include "gtkbuildable.h" +#include "gtkbuildableprivate.h" #include "gtkbuilderscopeprivate.h" #include "gtkdebug.h" #include "gtkintl.h" diff --git a/gtk/gtkbuilderprecompile.c b/gtk/gtkbuilderprecompile.c index 9360dc1606..4a06a2393e 100644 --- a/gtk/gtkbuilderprecompile.c +++ b/gtk/gtkbuilderprecompile.c @@ -21,7 +21,7 @@ #include #include "gtkbuilderprivate.h" #include "gtkbuilder.h" -#include "gtkbuildable.h" +#include "gtkbuildableprivate.h" /***************************************** Record a GMarkup parser call ***************************/ -- cgit v1.2.1 From e4d4b50d6de6324f5566cad9061ac7470fa64125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 25 Sep 2020 22:54:52 +0200 Subject: docs: Document GtkBuildable changes in migration guide https://gitlab.gnome.org/GNOME/gtk/-/issues/3191 --- docs/reference/gtk/migrating-3to4.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/reference/gtk/migrating-3to4.md b/docs/reference/gtk/migrating-3to4.md index 59800003b5..bae17df96f 100644 --- a/docs/reference/gtk/migrating-3to4.md +++ b/docs/reference/gtk/migrating-3to4.md @@ -1041,6 +1041,13 @@ You can replace calls to gtk_dialog_run() by specifying that the %GTK_DIALOG_MODAL flag, and connecting to the #GtkDialog::response signal. +### Stop using GtkBuildable API + +All the GtkBuildable API was made private, except for the +getter function to retrieve the buildable ID. If you are +using gtk_buildable_get_name() you should replace it with +gtk_buildable_get_buildable_id(). + ## Changes to consider after the switch GTK 4 has a number of new features that you may want to take -- cgit v1.2.1