summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-11-28 14:36:26 -0500
committerMatthias Clasen <mclasen@redhat.com>2022-11-28 14:36:47 -0500
commita46bee12858093f2c86cb4b8802533523b0a90df (patch)
treefb83dc3ffc013c709e5b60628edfabd013944496
parent57ac4740b388db9fbbbfc02f7f71d9137d78da15 (diff)
downloadgtk+-a46bee12858093f2c86cb4b8802533523b0a90df.tar.gz
Revert "builder: Stop using GtkBuildable.get_id"
This reverts commit 92edd4c476917e83c5f50e5eab8aa5a0ad240793. This commit changed behavior that GNOME Builder relies on.
-rw-r--r--gtk/gtkbuilder.c10
-rw-r--r--gtk/gtkwidget.c22
2 files changed, 30 insertions, 2 deletions
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 8a53b9bcd7..36f3a1edcb 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -626,7 +626,10 @@ gtk_builder_get_parameters (GtkBuilder *builder,
static const char *
object_get_id (GObject *object)
{
- return g_object_get_data (object, "gtk-builder-id");
+ if (GTK_IS_BUILDABLE (object))
+ return gtk_buildable_get_buildable_id (GTK_BUILDABLE (object));
+ else
+ return g_object_get_data (object, "gtk-builder-id");
}
static GObject *
@@ -669,7 +672,10 @@ static inline void
object_set_id (GObject *object,
const char *id)
{
- g_object_set_data_full (object, "gtk-builder-id", g_strdup (id), g_free);
+ if (GTK_IS_BUILDABLE (object))
+ gtk_buildable_set_buildable_id (GTK_BUILDABLE (object), id);
+ else
+ g_object_set_data_full (object, "gtk-builder-id", g_strdup (id), g_free);
}
void
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index e96a4c6750..7f129a0d89 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -608,6 +608,9 @@ static gboolean gtk_widget_real_mnemonic_activate (GtkWidget
gboolean group_cycling);
static void gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface);
static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface);
+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);
@@ -649,6 +652,7 @@ static GQuark quark_size_groups = 0;
static GQuark quark_auto_children = 0;
static GQuark quark_font_options = 0;
static GQuark quark_font_map = 0;
+static GQuark quark_builder_set_id = 0;
GType
gtk_widget_get_type (void)
@@ -8492,6 +8496,10 @@ gtk_widget_buildable_add_child (GtkBuildable *buildable,
static void
gtk_widget_buildable_interface_init (GtkBuildableIface *iface)
{
+ quark_builder_set_id = g_quark_from_static_string ("gtk-builder-set-id");
+
+ 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->custom_tag_start = gtk_widget_buildable_custom_tag_start;
iface->custom_tag_end = gtk_widget_buildable_custom_tag_end;
@@ -8499,6 +8507,20 @@ gtk_widget_buildable_interface_init (GtkBuildableIface *iface)
iface->add_child = gtk_widget_buildable_add_child;
}
+static void
+gtk_widget_buildable_set_id (GtkBuildable *buildable,
+ const char *id)
+{
+ g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_id,
+ g_strdup (id), g_free);
+}
+
+static const char *
+gtk_widget_buildable_get_id (GtkBuildable *buildable)
+{
+ return g_object_get_qdata (G_OBJECT (buildable), quark_builder_set_id);
+}
+
static GObject *
gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,