Add gtk_list_box_prepend
Add a convenience method for prepending rows to a list box without having to fiddle with a sort function. https://bugzilla.gnome.org/show_bug.cgi?id=705558
This commit is contained in:
@ -510,6 +510,7 @@ GtkListBoxSortFunc
|
|||||||
GtkListBoxUpdateHeaderFunc
|
GtkListBoxUpdateHeaderFunc
|
||||||
|
|
||||||
gtk_list_box_new
|
gtk_list_box_new
|
||||||
|
gtk_list_box_prepend
|
||||||
gtk_list_box_select_row
|
gtk_list_box_select_row
|
||||||
gtk_list_box_get_selected_row
|
gtk_list_box_get_selected_row
|
||||||
|
|
||||||
|
|||||||
@ -1672,10 +1672,10 @@ gtk_list_box_row_visibility_changed (GtkListBox *list_box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_list_box_real_add (GtkContainer *container,
|
gtk_list_box_add_row (GtkListBox *list_box,
|
||||||
GtkWidget *child)
|
GtkWidget *child,
|
||||||
|
gboolean prepend)
|
||||||
{
|
{
|
||||||
GtkListBox *list_box = GTK_LIST_BOX (container);
|
|
||||||
GtkListBoxPrivate *priv = gtk_list_box_get_instance_private (list_box);
|
GtkListBoxPrivate *priv = gtk_list_box_get_instance_private (list_box);
|
||||||
GtkListBoxRow *row;
|
GtkListBoxRow *row;
|
||||||
GSequenceIter* iter = NULL;
|
GSequenceIter* iter = NULL;
|
||||||
@ -1692,10 +1692,11 @@ gtk_list_box_real_add (GtkContainer *container,
|
|||||||
if (priv->sort_func != NULL)
|
if (priv->sort_func != NULL)
|
||||||
iter = g_sequence_insert_sorted (priv->children, row,
|
iter = g_sequence_insert_sorted (priv->children, row,
|
||||||
(GCompareDataFunc)do_sort, list_box);
|
(GCompareDataFunc)do_sort, list_box);
|
||||||
|
else if (prepend)
|
||||||
|
iter = g_sequence_prepend (priv->children, row);
|
||||||
else
|
else
|
||||||
iter = g_sequence_append (priv->children, row);
|
iter = g_sequence_append (priv->children, row);
|
||||||
|
|
||||||
|
|
||||||
ROW_PRIV (row)->iter = iter;
|
ROW_PRIV (row)->iter = iter;
|
||||||
gtk_widget_set_parent (GTK_WIDGET (row), GTK_WIDGET (list_box));
|
gtk_widget_set_parent (GTK_WIDGET (row), GTK_WIDGET (list_box));
|
||||||
gtk_widget_set_child_visible (GTK_WIDGET (row), TRUE);
|
gtk_widget_set_child_visible (GTK_WIDGET (row), TRUE);
|
||||||
@ -1711,6 +1712,13 @@ gtk_list_box_real_add (GtkContainer *container,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_list_box_real_add (GtkContainer *container,
|
||||||
|
GtkWidget *child)
|
||||||
|
{
|
||||||
|
gtk_list_box_add_row (GTK_LIST_BOX (container), child, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_list_box_real_remove (GtkContainer *container,
|
gtk_list_box_real_remove (GtkContainer *container,
|
||||||
GtkWidget *child)
|
GtkWidget *child)
|
||||||
@ -2046,6 +2054,24 @@ gtk_list_box_real_size_allocate (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_list_box_prepend:
|
||||||
|
* @list_box: a #GtkListBox.
|
||||||
|
* @child: the #GtkWidget to add
|
||||||
|
*
|
||||||
|
* Prepend a widget to the list. If a sort function is set, the widget will
|
||||||
|
* actually be inserted at the calculated position and this function has the
|
||||||
|
* same effect of gtk_container_add().
|
||||||
|
*
|
||||||
|
* Since: 3.10
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_list_box_prepend (GtkListBox *list_box,
|
||||||
|
GtkWidget *child)
|
||||||
|
{
|
||||||
|
gtk_list_box_add_row (list_box, child, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_list_box_drag_unhighlight_row:
|
* gtk_list_box_drag_unhighlight_row:
|
||||||
* @list_box: An #GtkListBox.
|
* @list_box: An #GtkListBox.
|
||||||
|
|||||||
@ -161,6 +161,9 @@ void gtk_list_box_row_changed (GtkListBoxRow *row);
|
|||||||
GDK_AVAILABLE_IN_3_10
|
GDK_AVAILABLE_IN_3_10
|
||||||
GType gtk_list_box_get_type (void) G_GNUC_CONST;
|
GType gtk_list_box_get_type (void) G_GNUC_CONST;
|
||||||
GDK_AVAILABLE_IN_3_10
|
GDK_AVAILABLE_IN_3_10
|
||||||
|
void gtk_list_box_prepend (GtkListBox *list_box,
|
||||||
|
GtkWidget *child);
|
||||||
|
GDK_AVAILABLE_IN_3_10
|
||||||
GtkListBoxRow* gtk_list_box_get_selected_row (GtkListBox *list_box);
|
GtkListBoxRow* gtk_list_box_get_selected_row (GtkListBox *list_box);
|
||||||
GDK_AVAILABLE_IN_3_10
|
GDK_AVAILABLE_IN_3_10
|
||||||
GtkListBoxRow* gtk_list_box_get_row_at_index (GtkListBox *list_box,
|
GtkListBoxRow* gtk_list_box_get_row_at_index (GtkListBox *list_box,
|
||||||
|
|||||||
Reference in New Issue
Block a user