[gtk/wip/ebassi/constraint-layout: 35/69] Remove GtkConstraintVariable.set_prefix()



commit 92d3d551648f96b5f629f0f280ac37cd1b9631cb
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Jun 29 17:21:55 2019 +0100

    Remove GtkConstraintVariable.set_prefix()
    
    The prefix and name are set at construction time.

 gtk/gtkconstraintexpression.c        | 35 +++++++++++------------------------
 gtk/gtkconstraintexpressionprivate.h |  7 ++-----
 gtk/gtkconstraintsolver.c            |  3 +--
 3 files changed, 14 insertions(+), 31 deletions(-)
---
diff --git a/gtk/gtkconstraintexpression.c b/gtk/gtkconstraintexpression.c
index 6cd7dfcbaf..eff63679ec 100644
--- a/gtk/gtkconstraintexpression.c
+++ b/gtk/gtkconstraintexpression.c
@@ -55,9 +55,12 @@ static guint64 gtk_constraint_variable_next_id;
 
 static void
 gtk_constraint_variable_init (GtkConstraintVariable *variable,
+                              const char *prefix,
                               const char *name)
 {
   variable->_id = gtk_constraint_variable_next_id++;
+
+  variable->prefix = g_intern_string (prefix);
   variable->name = g_intern_string (name);
   variable->prefix = NULL;
   variable->value = 0.0;
@@ -81,7 +84,7 @@ gtk_constraint_variable_new_dummy (const char *name)
 {
   GtkConstraintVariable *res = g_rc_box_new (GtkConstraintVariable);
 
-  gtk_constraint_variable_init (res, name);
+  gtk_constraint_variable_init (res, NULL, name);
 
   res->_type = GTK_CONSTRAINT_SYMBOL_DUMMY;
   res->is_external = FALSE;
@@ -108,7 +111,7 @@ gtk_constraint_variable_new_objective (const char *name)
 {
   GtkConstraintVariable *res = g_rc_box_new (GtkConstraintVariable);
 
-  gtk_constraint_variable_init (res, name);
+  gtk_constraint_variable_init (res, NULL, name);
 
   res->_type = GTK_CONSTRAINT_SYMBOL_OBJECTIVE;
   res->is_external = FALSE;
@@ -145,7 +148,7 @@ gtk_constraint_variable_new_slack (const char *name)
 {
   GtkConstraintVariable *res = g_rc_box_new (GtkConstraintVariable);
 
-  gtk_constraint_variable_init (res, name);
+  gtk_constraint_variable_init (res, NULL, name);
 
   res->_type = GTK_CONSTRAINT_SYMBOL_SLACK;
   res->is_external = FALSE;
@@ -157,7 +160,8 @@ gtk_constraint_variable_new_slack (const char *name)
 
 /*< private >
  * gtk_constraint_variable_new:
- * @name: the name of the variable
+ * @prefix: (nullable): an optional prefix string for @name
+ * @name: (nullable): an optional name for the variable
  *
  * Allocates and initializes a new #GtkConstraintVariable for a regular
  * symbol. All variables introduced by constraints are regular variables.
@@ -170,11 +174,12 @@ gtk_constraint_variable_new_slack (const char *name)
  * Returns: a newly allocated #GtkConstraintVariable
  */
 GtkConstraintVariable *
-gtk_constraint_variable_new (const char *name)
+gtk_constraint_variable_new (const char *prefix,
+                             const char *name)
 {
   GtkConstraintVariable *res = g_rc_box_new (GtkConstraintVariable);
 
-  gtk_constraint_variable_init (res, name);
+  gtk_constraint_variable_init (res, prefix, name);
 
   res->_type = GTK_CONSTRAINT_SYMBOL_REGULAR;
   res->is_external = TRUE;
@@ -184,24 +189,6 @@ gtk_constraint_variable_new (const char *name)
   return res;
 }
 
-/*< private >
- * gtk_constraint_variable_set_prefix:
- * @variable: a #GtkConstraintVariable
- * @prefix: a prefix string
- *
- * Sets the prefix to the @variable's name.
- *
- * This function is useful when debugging the variable contents.
- */
-void
-gtk_constraint_variable_set_prefix (GtkConstraintVariable *variable,
-                                    const char *prefix)
-{
-  g_return_if_fail (variable != NULL);
-
-  variable->prefix = g_intern_string (prefix);
-}
-
 /*< private >
  * gtk_constraint_variable_ref:
  * @variable: a #GtkConstraintVariable
diff --git a/gtk/gtkconstraintexpressionprivate.h b/gtk/gtkconstraintexpressionprivate.h
index 1d42d26883..b498f88594 100644
--- a/gtk/gtkconstraintexpressionprivate.h
+++ b/gtk/gtkconstraintexpressionprivate.h
@@ -26,7 +26,8 @@
 G_BEGIN_DECLS
 
 GtkConstraintVariable *
-gtk_constraint_variable_new (const char *name);
+gtk_constraint_variable_new (const char *prefix,
+                             const char *name);
 
 GtkConstraintVariable *
 gtk_constraint_variable_new_dummy (const char *name);
@@ -50,10 +51,6 @@ gtk_constraint_variable_set_value (GtkConstraintVariable *variable,
 double
 gtk_constraint_variable_get_value (const GtkConstraintVariable *variable);
 
-void
-gtk_constraint_variable_set_prefix (GtkConstraintVariable *variable,
-                                    const char *prefix);
-
 char *
 gtk_constraint_variable_to_string (const GtkConstraintVariable *variable);
 
diff --git a/gtk/gtkconstraintsolver.c b/gtk/gtkconstraintsolver.c
index 22fa0111a4..3c3a5289f3 100644
--- a/gtk/gtkconstraintsolver.c
+++ b/gtk/gtkconstraintsolver.c
@@ -1482,8 +1482,7 @@ gtk_constraint_solver_create_variable (GtkConstraintSolver *self,
 {
   GtkConstraintVariable *res;
 
-  res = gtk_constraint_variable_new (name);
-  gtk_constraint_variable_set_prefix (res, prefix);
+  res = gtk_constraint_variable_new (prefix, name);
   gtk_constraint_variable_set_value (res, value);
 
   return res;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]