Remove GtkConstraintVariable.set_prefix()

The prefix and name are set at construction time.
This commit is contained in:
Emmanuele Bassi 2019-06-29 17:21:55 +01:00
parent ba2125d8e1
commit 92d3d55164
3 changed files with 14 additions and 31 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;