[gtk/constraint-editor: 2/5] Add gtk_constraint_layout_remove_all_constraints



commit c4dbf27f154b479c9b8e8943260e4127673c29ea
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 29 22:59:39 2019 +0000

    Add gtk_constraint_layout_remove_all_constraints
    
    Otherwise, there is no way of getting rid of
    vfl constraints.

 gtk/gtkconstraintlayout.c | 25 +++++++++++++++++++++++++
 gtk/gtkconstraintlayout.h |  3 +++
 2 files changed, 28 insertions(+)
---
diff --git a/gtk/gtkconstraintlayout.c b/gtk/gtkconstraintlayout.c
index 191a145b62..ad5df8f4ba 100644
--- a/gtk/gtkconstraintlayout.c
+++ b/gtk/gtkconstraintlayout.c
@@ -1881,3 +1881,28 @@ gtk_constraint_layout_add_constraints_from_description (GtkConstraintLayout *lay
 
   return res;
 }
+
+/**
+ * gtk_constraint_layout_remove_all_constraints:
+ * @manager: a #GtkConstraintLayout
+ *
+ * Removes all constraints from @manager.
+ */
+void
+gtk_constraint_layout_remove_all_constraints (GtkConstraintLayout *manager)
+{
+  GHashTableIter iter;
+  gpointer key;
+
+  g_return_if_fail (GTK_IS_CONSTRAINT_LAYOUT (manager));
+
+  g_hash_table_iter_init (&iter, manager->constraints);
+  while (g_hash_table_iter_next (&iter, &key, NULL))
+    {
+      GtkConstraint *constraint = key;
+      gtk_constraint_detach (constraint);
+      g_hash_table_iter_remove (&iter);
+    }
+
+  gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (manager));
+}
diff --git a/gtk/gtkconstraintlayout.h b/gtk/gtkconstraintlayout.h
index 227a8bfbc7..9ed38135ac 100644
--- a/gtk/gtkconstraintlayout.h
+++ b/gtk/gtkconstraintlayout.h
@@ -94,4 +94,7 @@ gboolean                gtk_constraint_layout_add_constraints_from_descriptionv
                                                                                  GHashTable          *views,
                                                                                  GError             **error);
 
+GDK_AVAILABLE_IN_ALL
+void                    gtk_constraint_layout_remove_all_constraints (GtkConstraintLayout *manager);
+
 G_END_DECLS


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