[gtk/wip/ebassi/constraint-layout] Return the list of constraints added via VFL description
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/constraint-layout] Return the list of constraints added via VFL description
- Date: Sun, 30 Jun 2019 09:37:32 +0000 (UTC)
commit d6fa7da1badb9e76747b0f699fb9a40b7a595600
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Jun 30 10:36:33 2019 +0100
Return the list of constraints added via VFL description
Otherwise it's impossible to remove them.
gtk/gtkconstraintlayout.c | 35 ++++++++++++++++++++---------------
gtk/gtkconstraintlayout.h | 4 ++--
2 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkconstraintlayout.c b/gtk/gtkconstraintlayout.c
index e90ac25cc3..82db0f210c 100644
--- a/gtk/gtkconstraintlayout.c
+++ b/gtk/gtkconstraintlayout.c
@@ -1719,9 +1719,10 @@ attribute_from_name (const char *name)
* [button1(==button2.height)]
* ]|
*
- * Returns: %TRUE if the constraints were added to the layout
+ * Returns: (transfer container) (element-type GtkConstraint): the list of
+ * #GtkConstraints that were added to the layout
*/
-gboolean
+GList *
gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout *layout,
const char * const lines[],
gsize n_lines,
@@ -1731,11 +1732,12 @@ gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout *la
GError **error)
{
GtkConstraintVflParser *parser;
+ GList *res = NULL;
- g_return_val_if_fail (GTK_IS_CONSTRAINT_LAYOUT (layout), FALSE);
- g_return_val_if_fail (lines != NULL, FALSE);
- g_return_val_if_fail (views != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_CONSTRAINT_LAYOUT (layout), NULL);
+ g_return_val_if_fail (lines != NULL, NULL);
+ g_return_val_if_fail (views != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
parser = gtk_constraint_vfl_parser_new ();
gtk_constraint_vfl_parser_set_default_spacing (parser, hspacing, vspacing);
@@ -1776,7 +1778,7 @@ gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout *la
g_free (squiggly);
g_error_free (internal_error);
gtk_constraint_vfl_parser_free (parser);
- return FALSE;
+ return res;
}
int n_constraints = 0;
@@ -1810,6 +1812,8 @@ gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout *la
layout_add_constraint (layout, constraint);
g_hash_table_add (layout->constraints, constraint);
+
+ res = g_list_prepend (res, constraint);
}
g_free (constraints);
@@ -1817,7 +1821,7 @@ gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout *la
gtk_constraint_vfl_parser_free (parser);
- return TRUE;
+ return res;
}
/**
@@ -1840,9 +1844,10 @@ gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout *la
* gtk_constraint_layout_add_constraints_from_descriptionv(), using
* variadic arguments to populate the view/target map.
*
- * Returns: %TRUE if the constraints were added to the layout
+ * Returns: (transfer container) (element-type GtkConstraint): the list of
+ * #GtkConstraints that were added to the layout
*/
-gboolean
+GList *
gtk_constraint_layout_add_constraints_from_description (GtkConstraintLayout *layout,
const char * const lines[],
gsize n_lines,
@@ -1855,13 +1860,13 @@ gtk_constraint_layout_add_constraints_from_description (GtkConstraintLayout *lay
GtkConstraintVflParser *parser;
GHashTable *views;
const char *view;
- gboolean res;
+ GList *res;
va_list args;
- g_return_val_if_fail (GTK_IS_CONSTRAINT_LAYOUT (layout), FALSE);
- g_return_val_if_fail (lines != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (first_view != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_CONSTRAINT_LAYOUT (layout), NULL);
+ g_return_val_if_fail (lines != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+ g_return_val_if_fail (first_view != NULL, NULL);
parser = gtk_constraint_vfl_parser_new ();
gtk_constraint_vfl_parser_set_default_spacing (parser, hspacing, vspacing);
diff --git a/gtk/gtkconstraintlayout.h b/gtk/gtkconstraintlayout.h
index 5294ec74a4..52a79ac93f 100644
--- a/gtk/gtkconstraintlayout.h
+++ b/gtk/gtkconstraintlayout.h
@@ -79,7 +79,7 @@ GDK_AVAILABLE_IN_ALL
void gtk_constraint_layout_remove_all_constraints (GtkConstraintLayout
*manager);
GDK_AVAILABLE_IN_ALL
-gboolean gtk_constraint_layout_add_constraints_from_description (GtkConstraintLayout
*manager,
+GList * gtk_constraint_layout_add_constraints_from_description (GtkConstraintLayout
*manager,
const char * const
lines[],
gsize
n_lines,
int
hspacing,
@@ -88,7 +88,7 @@ gboolean gtk_constraint_layout_add_constraints_from_description
const char
*first_view,
...) G_GNUC_NULL_TERMINATED;
GDK_AVAILABLE_IN_ALL
-gboolean gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout
*manager,
+GList * gtk_constraint_layout_add_constraints_from_descriptionv (GtkConstraintLayout
*manager,
const char * const
lines[],
gsize
n_lines,
int
hspacing,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]