summaryrefslogtreecommitdiff
path: root/gtk/gtkconstraintguide.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-06-28 22:53:43 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2019-07-01 00:10:11 +0100
commitb39a5fe5dcb2002f352d15d09624318282185816 (patch)
treeac91dfc72df2de9eac792963bbd331ef8eb6168f /gtk/gtkconstraintguide.c
parentc7ef8411bd28cc9b5cebc67b1aa14f7a421e4904 (diff)
downloadgtk+-b39a5fe5dcb2002f352d15d09624318282185816.tar.gz
constraint guide: Add a name property
We need to be able to print meaningful debug messages regarding these objects, and eventually present them in the inspector too.
Diffstat (limited to 'gtk/gtkconstraintguide.c')
-rw-r--r--gtk/gtkconstraintguide.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gtk/gtkconstraintguide.c b/gtk/gtkconstraintguide.c
index b6de3288a1..02b0a6c660 100644
--- a/gtk/gtkconstraintguide.c
+++ b/gtk/gtkconstraintguide.c
@@ -45,6 +45,8 @@ struct _GtkConstraintGuide
{
GObject parent_instance;
+ char *name;
+
int values[LAST_VALUE];
GtkConstraintLayout *layout;
@@ -71,6 +73,7 @@ enum {
PROP_NAT_HEIGHT,
PROP_MAX_WIDTH,
PROP_MAX_HEIGHT,
+ PROP_NAME,
LAST_PROP
};
@@ -226,6 +229,10 @@ gtk_constraint_guide_set_property (GObject *gobject,
}
break;
+ case PROP_NAME:
+ gtk_constraint_guide_set_name (self, g_value_get_string (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -251,6 +258,10 @@ gtk_constraint_guide_get_property (GObject *gobject,
g_value_set_int (value, self->values[prop_id - 1]);
break;
+ case PROP_NAME:
+ g_value_set_string (value, self->name);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -262,6 +273,8 @@ gtk_constraint_guide_finalize (GObject *object)
{
GtkConstraintGuide *self = GTK_CONSTRAINT_GUIDE (object);
+ g_free (self->name);
+
g_clear_pointer (&self->bound_attributes, g_hash_table_unref);
G_OBJECT_CLASS (gtk_constraint_guide_parent_class)->finalize (object);
@@ -319,6 +332,13 @@ gtk_constraint_guide_class_init (GtkConstraintGuideClass *class)
G_PARAM_READWRITE|
G_PARAM_EXPLICIT_NOTIFY);
+ guide_props[PROP_NAME] =
+ g_param_spec_string ("name",
+ "Name",
+ "A name to use in debug message",
+ NULL,
+ G_PARAM_READWRITE);
+
g_object_class_install_properties (object_class, LAST_PROP, guide_props);
}
@@ -496,3 +516,22 @@ gtk_constraint_guide_get_max_size (GtkConstraintGuide *guide,
if (height)
*height = guide->values[MAX_HEIGHT];
}
+
+const char *
+gtk_constraint_guide_get_name (GtkConstraintGuide *guide)
+{
+ g_return_val_if_fail (GTK_IS_CONSTRAINT_GUIDE (guide), NULL);
+
+ return guide->name;
+}
+
+void
+gtk_constraint_guide_set_name (GtkConstraintGuide *guide,
+ const char *name)
+{
+ g_return_if_fail (GTK_IS_CONSTRAINT_GUIDE (guide));
+
+ g_free (guide->name);
+ guide->name = g_strdup (name);
+ g_object_notify_by_pspec (G_OBJECT (guide), guide_props[PROP_NAME]);
+}