[gtk/wip/cdavis/flowbox-add-functions: 109/109] gtkflowbox: Add prepend() and append()




commit 317278f544e59410f3602d463667573e67e0c9c8
Author: Christopher Davis <christopherdavis gnome org>
Date:   Wed Sep 29 19:45:45 2021 -0700

    gtkflowbox: Add prepend() and append()
    
    These functions are common across container implementations,
    but GtkFlowBox was missing them.
    
    Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4277

 gtk/gtkflowbox.c | 34 ++++++++++++++++++++++++++++++++++
 gtk/gtkflowbox.h |  6 ++++++
 2 files changed, 40 insertions(+)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 188b76c562..4207053837 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -4072,6 +4072,40 @@ gtk_flow_box_insert_widget (GtkFlowBox    *box,
   gtk_widget_insert_after (child, GTK_WIDGET (box), sibling);
 }
 
+/**
+ * gtk_flow_box_prepend:
+ * @box: a `GtkFlowBox
+ * @child: the `GtkWidget` to add
+ *
+ * Adds @child to the start of @box
+ *
+ * If a sort function is set, the widget will
+ * actually be inserted at the calculated position.
+ */
+void
+gtk_flow_box_prepend (GtkFlowBox *box,
+                      GtkWidget  *child)
+{
+  gtk_flow_box_insert (box, child, 0);
+}
+
+/**
+ * gtk_flow_box_append:
+ * @box: a `GtkFlowBox
+ * @child: the `GtkWidget` to add
+ *
+ * Adds @child to the end of @box
+ *
+ * If a sort function is set, the widget will
+ * actually be inserted at the calculated position.
+ */
+void
+gtk_flow_box_append (GtkFlowBox *box,
+                     GtkWidget  *child)
+{
+  gtk_flow_box_insert (box, child, -1);
+}
+
 /**
  * gtk_flow_box_insert:
  * @box: a `GtkFlowBox`
diff --git a/gtk/gtkflowbox.h b/gtk/gtkflowbox.h
index 3625d18ddf..1ccbca8a45 100644
--- a/gtk/gtkflowbox.h
+++ b/gtk/gtkflowbox.h
@@ -147,6 +147,12 @@ void                  gtk_flow_box_set_activate_on_single_click (GtkFlowBox
 GDK_AVAILABLE_IN_ALL
 gboolean              gtk_flow_box_get_activate_on_single_click (GtkFlowBox        *box);
 
+GDK_AVAILABLE_IN_4_6
+void                  gtk_flow_box_prepend                      (GtkFlowBox        *box,
+                                                                 GtkWidget         *child);
+GDK_AVAILABLE_IN_4_6
+void                  gtk_flow_box_append                       (GtkFlowBox        *box,
+                                                                 GtkWidget         *child);
 GDK_AVAILABLE_IN_ALL
 void                  gtk_flow_box_insert                       (GtkFlowBox        *box,
                                                                  GtkWidget         *widget,


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