diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 5b5ff53cb1..c4313508b3 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -3983,6 +3983,7 @@ gtk_cell_view_new_with_context gtk_cell_view_new_with_text gtk_cell_view_new_with_markup gtk_cell_view_new_with_pixbuf +gtk_cell_view_new_with_texture gtk_cell_view_set_model gtk_cell_view_get_model gtk_cell_view_set_displayed_row diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c index 3ffffd50a4..a5482e39be 100644 --- a/gtk/gtkcellview.c +++ b/gtk/gtkcellview.c @@ -943,6 +943,38 @@ gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf) return GTK_WIDGET (cellview); } +/** + * gtk_cell_view_new_with_texture: + * @texture: the image to display in the cell view + * + * Creates a new #GtkCellView widget, adds a #GtkCellRendererPixbuf + * to it, and makes it show @texture. + * + * Returns: A newly created #GtkCellView widget. + * + * Since: 3.94 + */ +GtkWidget * +gtk_cell_view_new_with_texture (GdkTexture *texture) +{ + GtkCellView *cellview; + GtkCellRenderer *renderer; + GValue value = G_VALUE_INIT; + + cellview = GTK_CELL_VIEW (gtk_cell_view_new ()); + + renderer = gtk_cell_renderer_pixbuf_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview), + renderer, TRUE); + + g_value_init (&value, GDK_TYPE_TEXTURE); + g_value_set_object (&value, texture); + gtk_cell_view_set_value (cellview, renderer, "texture", &value); + g_value_unset (&value); + + return GTK_WIDGET (cellview); +} + /** * gtk_cell_view_set_value: * @cell_view: a #GtkCellView widget diff --git a/gtk/gtkcellview.h b/gtk/gtkcellview.h index e96bfe4594..4e6a0682bf 100644 --- a/gtk/gtkcellview.h +++ b/gtk/gtkcellview.h @@ -79,6 +79,8 @@ GDK_AVAILABLE_IN_ALL GtkWidget *gtk_cell_view_new_with_markup (const gchar *markup); GDK_AVAILABLE_IN_ALL GtkWidget *gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf); +GDK_AVAILABLE_IN_3_94 +GtkWidget *gtk_cell_view_new_with_texture (GdkTexture *texture); GDK_AVAILABLE_IN_ALL void gtk_cell_view_set_model (GtkCellView *cell_view, GtkTreeModel *model);