[gtk/wip/ebassi/constraint-layout: 40/69] Add method to remove all constraints from a layout



commit 3204347bb05defe7bd8986759260e27ee9a14356
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sun Jun 30 10:30:02 2019 +0100

    Add method to remove all constraints from a layout

 gtk/gtkconstraintlayout.c | 26 ++++++++++++++++++++++++++
 gtk/gtkconstraintlayout.h |  2 ++
 2 files changed, 28 insertions(+)
---
diff --git a/gtk/gtkconstraintlayout.c b/gtk/gtkconstraintlayout.c
index 44554f33f4..b5062f788c 100644
--- a/gtk/gtkconstraintlayout.c
+++ b/gtk/gtkconstraintlayout.c
@@ -1222,6 +1222,32 @@ gtk_constraint_layout_remove_constraint (GtkConstraintLayout *manager,
   gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (manager));
 }
 
+/**
+ * gtk_constraint_layout_remove_all_constraints:
+ * @manager: a #GtkConstraintLayout
+ *
+ * Removes all constraints from the layout 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));
+}
+
 static void
 gtk_constraint_guide_constraint_target_iface_init (GtkConstraintTargetInterface *iface)
 {
diff --git a/gtk/gtkconstraintlayout.h b/gtk/gtkconstraintlayout.h
index 227a8bfbc7..5294ec74a4 100644
--- a/gtk/gtkconstraintlayout.h
+++ b/gtk/gtkconstraintlayout.h
@@ -75,6 +75,8 @@ void                    gtk_constraint_layout_add_guide         (GtkConstraintLa
 GDK_AVAILABLE_IN_ALL
 void                    gtk_constraint_layout_remove_guide      (GtkConstraintLayout *manager,
                                                                  GtkConstraintGuide  *guide);
+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,


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