[gtk/wip/ebassi/constraint-layout: 52/69] constraint guide: Add a name property
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/constraint-layout: 52/69] constraint guide: Add a name property
- Date: Sun, 30 Jun 2019 23:14:29 +0000 (UTC)
commit b39a5fe5dcb2002f352d15d09624318282185816
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 28 22:53:43 2019 +0000
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.
gtk/gtkconstraintguide.c | 39 +++++++++++++++++++++++++++++++++++++++
gtk/gtkconstraintguide.h | 5 +++++
2 files changed, 44 insertions(+)
---
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]);
+}
diff --git a/gtk/gtkconstraintguide.h b/gtk/gtkconstraintguide.h
index 415978f9ef..429085c1f9 100644
--- a/gtk/gtkconstraintguide.h
+++ b/gtk/gtkconstraintguide.h
@@ -67,5 +67,10 @@ GDK_AVAILABLE_IN_ALL
void gtk_constraint_guide_get_max_size (GtkConstraintGuide *guide,
int *width,
int *height);
+GDK_AVAILABLE_IN_ALL
+void gtk_constraint_guide_set_name (GtkConstraintGuide *guide,
+ const char *name);
+GDK_AVAILABLE_IN_ALL
+const char * gtk_constraint_guide_get_name (GtkConstraintGuide *guide);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]