gtkflowbox: Add prepend() and append()
authorChristopher Davis <christopherdavis@gnome.org>
Thu, 30 Sep 2021 02:45:45 +0000 (19:45 -0700)
committerChristopher Davis <christopherdavis@gnome.org>
Tue, 12 Oct 2021 18:07:17 +0000 (11:07 -0700)
These functions are common across container implementations,
but GtkFlowBox was missing them.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4277

gtk/gtkflowbox.c
gtk/gtkflowbox.h

index 188b76c562290dbee01c8473bbd1794147d64630..a3de9deaaa455b1fc7486676fb8dfc20cf4af8b5 100644 (file)
@@ -4072,6 +4072,54 @@ gtk_flow_box_insert_widget (GtkFlowBox    *box,
   gtk_widget_insert_after (child, GTK_WIDGET (box), sibling);
 }
 
+/**
+ * gtk_flow_box_prepend:
+ * @self: a `GtkFlowBox
+ * @child: the `GtkWidget` to add
+ *
+ * Adds @child to the start of @self.
+ *
+ * If a sort function is set, the widget will
+ * actually be inserted at the calculated position.
+ *
+ * See also: [method@Gtk.FlowBox.insert].
+ *
+ * Since: 4.6
+ */
+void
+gtk_flow_box_prepend (GtkFlowBox *self,
+                      GtkWidget  *child)
+{
+  g_return_if_fail (GTK_IS_FLOW_BOX (self));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+
+  gtk_flow_box_insert (self, child, 0);
+}
+
+/**
+ * gtk_flow_box_append:
+ * @self: a `GtkFlowBox
+ * @child: the `GtkWidget` to add
+ *
+ * Adds @child to the end of @self.
+ *
+ * If a sort function is set, the widget will
+ * actually be inserted at the calculated position.
+ *
+ * See also: [method@Gtk.FlowBox.insert].
+ *
+ * Since: 4.6
+ */
+void
+gtk_flow_box_append (GtkFlowBox *self,
+                     GtkWidget  *child)
+{
+  g_return_if_fail (GTK_IS_FLOW_BOX (self));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+
+  gtk_flow_box_insert (self, child, -1);
+}
+
 /**
  * gtk_flow_box_insert:
  * @box: a `GtkFlowBox`
index 3625d18ddf278c4cd3bd8a7f77c2f9ad9f6b9d77..a8f3da2eda1c75f1fef0347ff57591e2d7b73b13 100644 (file)
@@ -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        *self,
+                                                                 GtkWidget         *child);
+GDK_AVAILABLE_IN_4_6
+void                  gtk_flow_box_append                       (GtkFlowBox        *self,
+                                                                 GtkWidget         *child);
 GDK_AVAILABLE_IN_ALL
 void                  gtk_flow_box_insert                       (GtkFlowBox        *box,
                                                                  GtkWidget         *widget,