2018-09-16 18:52:06 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2018 Benjamin Otte
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: Benjamin Otte <otte@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gtklistview.h"
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
#include "gtkadjustment.h"
|
2018-09-16 18:52:06 +00:00
|
|
|
#include "gtkintl.h"
|
2018-09-18 02:56:19 +00:00
|
|
|
#include "gtkrbtreeprivate.h"
|
2018-09-17 05:29:50 +00:00
|
|
|
#include "gtklistitemfactoryprivate.h"
|
2018-09-20 03:18:34 +00:00
|
|
|
#include "gtklistitemmanagerprivate.h"
|
2018-09-18 17:58:19 +00:00
|
|
|
#include "gtkscrollable.h"
|
2018-10-03 16:53:06 +00:00
|
|
|
#include "gtkselectionmodel.h"
|
|
|
|
#include "gtksingleselection.h"
|
2018-09-18 17:58:19 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2018-09-16 18:52:06 +00:00
|
|
|
|
2018-09-25 23:37:38 +00:00
|
|
|
/* Maximum number of list items created by the listview.
|
|
|
|
* For debugging, you can set this to G_MAXUINT to ensure
|
|
|
|
* there's always a list item for every row.
|
|
|
|
*/
|
|
|
|
#define GTK_LIST_VIEW_MAX_LIST_ITEMS 200
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtklistview
|
|
|
|
* @title: GtkListView
|
|
|
|
* @short_description: A widget for displaying lists
|
|
|
|
* @see_also: #GListModel
|
|
|
|
*
|
|
|
|
* GtkListView is a widget to present a view into a large dynamic list of items.
|
|
|
|
*/
|
|
|
|
|
2018-09-18 02:56:19 +00:00
|
|
|
typedef struct _ListRow ListRow;
|
|
|
|
typedef struct _ListRowAugment ListRowAugment;
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
struct _GtkListView
|
|
|
|
{
|
|
|
|
GtkWidget parent_instance;
|
|
|
|
|
|
|
|
GListModel *model;
|
2018-09-20 03:18:34 +00:00
|
|
|
GtkListItemManager *item_manager;
|
2018-09-18 17:58:19 +00:00
|
|
|
GtkAdjustment *adjustment[2];
|
|
|
|
GtkScrollablePolicy scroll_policy[2];
|
2018-09-18 02:56:19 +00:00
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
int list_width;
|
2018-09-18 02:56:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _ListRow
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
GtkListItemManagerItem parent;
|
2018-09-25 23:37:38 +00:00
|
|
|
guint height; /* per row */
|
2018-09-18 02:56:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _ListRowAugment
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
GtkListItemManagerItemAugment parent;
|
2018-09-25 23:37:38 +00:00
|
|
|
guint height; /* total */
|
2018-09-16 18:52:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2018-09-18 17:58:19 +00:00
|
|
|
PROP_HADJUSTMENT,
|
|
|
|
PROP_HSCROLL_POLICY,
|
2018-09-16 18:52:06 +00:00
|
|
|
PROP_MODEL,
|
2018-09-18 17:58:19 +00:00
|
|
|
PROP_VADJUSTMENT,
|
|
|
|
PROP_VSCROLL_POLICY,
|
2018-09-16 18:52:06 +00:00
|
|
|
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkListView, gtk_list_view, GTK_TYPE_WIDGET,
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
|
2018-09-16 18:52:06 +00:00
|
|
|
|
|
|
|
static GParamSpec *properties[N_PROPS] = { NULL, };
|
|
|
|
|
2018-09-25 23:37:38 +00:00
|
|
|
static void G_GNUC_UNUSED
|
|
|
|
dump (GtkListView *self)
|
|
|
|
{
|
|
|
|
ListRow *row;
|
|
|
|
guint n_widgets, n_list_rows;
|
|
|
|
|
|
|
|
n_widgets = 0;
|
|
|
|
n_list_rows = 0;
|
2019-02-06 19:48:08 +00:00
|
|
|
//g_print ("ANCHOR: %u - %u\n", self->anchor_start, self->anchor_end);
|
|
|
|
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
2018-09-25 23:37:38 +00:00
|
|
|
row;
|
|
|
|
row = gtk_rb_tree_node_get_next (row))
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
if (row->parent.widget)
|
2018-09-25 23:37:38 +00:00
|
|
|
n_widgets++;
|
|
|
|
n_list_rows++;
|
2019-02-06 19:48:08 +00:00
|
|
|
g_print (" %4u%s (%upx)\n", row->parent.n_items, row->parent.widget ? " (widget)" : "", row->height);
|
2018-09-25 23:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_print (" => %u widgets in %u list rows\n", n_widgets, n_list_rows);
|
|
|
|
}
|
|
|
|
|
2018-09-18 02:56:19 +00:00
|
|
|
static void
|
|
|
|
list_row_augment (GtkRbTree *tree,
|
|
|
|
gpointer node_augment,
|
|
|
|
gpointer node,
|
|
|
|
gpointer left,
|
|
|
|
gpointer right)
|
2018-09-16 18:52:06 +00:00
|
|
|
{
|
2018-09-18 02:56:19 +00:00
|
|
|
ListRow *row = node;
|
|
|
|
ListRowAugment *aug = node_augment;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
gtk_list_item_manager_augment_node (tree, node_augment, node, left, right);
|
|
|
|
|
|
|
|
aug->height = row->height * row->parent.n_items;
|
2018-09-18 02:56:19 +00:00
|
|
|
|
|
|
|
if (left)
|
|
|
|
{
|
|
|
|
ListRowAugment *left_aug = gtk_rb_tree_get_augment (tree, left);
|
|
|
|
|
|
|
|
aug->height += left_aug->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (right)
|
|
|
|
{
|
|
|
|
ListRowAugment *right_aug = gtk_rb_tree_get_augment (tree, right);
|
|
|
|
|
|
|
|
aug->height += right_aug->height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-19 05:08:30 +00:00
|
|
|
static ListRow *
|
|
|
|
gtk_list_view_get_row_at_y (GtkListView *self,
|
|
|
|
int y,
|
|
|
|
int *offset)
|
|
|
|
{
|
|
|
|
ListRow *row, *tmp;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
row = gtk_list_item_manager_get_root (self->item_manager);
|
2018-09-19 05:08:30 +00:00
|
|
|
|
|
|
|
while (row)
|
|
|
|
{
|
|
|
|
tmp = gtk_rb_tree_node_get_left (row);
|
|
|
|
if (tmp)
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
ListRowAugment *aug = gtk_list_item_manager_get_item_augment (self->item_manager, tmp);
|
2018-09-19 05:08:30 +00:00
|
|
|
if (y < aug->height)
|
|
|
|
{
|
|
|
|
row = tmp;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
y -= aug->height;
|
|
|
|
}
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
if (y < row->height * row->parent.n_items)
|
2018-09-19 05:08:30 +00:00
|
|
|
break;
|
2019-02-06 19:48:08 +00:00
|
|
|
y -= row->height * row->parent.n_items;
|
2018-09-19 05:08:30 +00:00
|
|
|
|
|
|
|
row = gtk_rb_tree_node_get_right (row);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offset)
|
|
|
|
*offset = row ? y : 0;
|
|
|
|
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
list_row_get_y (GtkListView *self,
|
|
|
|
ListRow *row)
|
|
|
|
{
|
2018-09-25 23:37:38 +00:00
|
|
|
ListRow *parent, *left;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
left = gtk_rb_tree_node_get_left (row);
|
|
|
|
if (left)
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
ListRowAugment *aug = gtk_list_item_manager_get_item_augment (self->item_manager, left);
|
2018-09-25 23:37:38 +00:00
|
|
|
y = aug->height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
y = 0;
|
2018-09-19 05:08:30 +00:00
|
|
|
|
|
|
|
for (parent = gtk_rb_tree_node_get_parent (row);
|
|
|
|
parent != NULL;
|
|
|
|
parent = gtk_rb_tree_node_get_parent (row))
|
|
|
|
{
|
2018-09-25 23:37:38 +00:00
|
|
|
left = gtk_rb_tree_node_get_left (parent);
|
2018-09-19 05:08:30 +00:00
|
|
|
|
|
|
|
if (left != row)
|
|
|
|
{
|
|
|
|
if (left)
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
ListRowAugment *aug = gtk_list_item_manager_get_item_augment (self->item_manager, left);
|
2018-09-19 05:08:30 +00:00
|
|
|
y += aug->height;
|
|
|
|
}
|
2019-02-06 19:48:08 +00:00
|
|
|
y += parent->height * parent->parent.n_items;
|
2018-09-19 05:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
row = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return y ;
|
|
|
|
}
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
static int
|
|
|
|
gtk_list_view_get_list_height (GtkListView *self)
|
|
|
|
{
|
|
|
|
ListRow *row;
|
|
|
|
ListRowAugment *aug;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
row = gtk_list_item_manager_get_root (self->item_manager);
|
2018-09-18 17:58:19 +00:00
|
|
|
if (row == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
aug = gtk_list_item_manager_get_item_augment (self->item_manager, row);
|
2018-09-18 17:58:19 +00:00
|
|
|
return aug->height;
|
|
|
|
}
|
|
|
|
|
2018-09-24 22:16:27 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_adjustment_value_changed_cb (GtkAdjustment *adjustment,
|
|
|
|
GtkListView *self)
|
|
|
|
{
|
|
|
|
if (adjustment == self->adjustment[GTK_ORIENTATION_VERTICAL])
|
|
|
|
{
|
|
|
|
ListRow *row;
|
|
|
|
guint pos;
|
|
|
|
int dy;
|
|
|
|
|
|
|
|
row = gtk_list_view_get_row_at_y (self, gtk_adjustment_get_value (adjustment), &dy);
|
|
|
|
if (row)
|
2018-09-25 23:37:38 +00:00
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
pos = gtk_list_item_manager_get_item_position (self->item_manager, row) + dy / row->height;
|
2018-09-25 23:37:38 +00:00
|
|
|
}
|
2018-09-24 22:16:27 +00:00
|
|
|
else
|
|
|
|
pos = 0;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
gtk_list_item_manager_set_anchor (self->item_manager, pos, 0, NULL, (guint) -1);
|
2018-09-24 22:16:27 +00:00
|
|
|
}
|
2019-02-06 19:48:08 +00:00
|
|
|
|
|
|
|
gtk_widget_queue_allocate (GTK_WIDGET (self));
|
2018-09-24 22:16:27 +00:00
|
|
|
}
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_update_adjustments (GtkListView *self,
|
|
|
|
GtkOrientation orientation)
|
|
|
|
{
|
|
|
|
double upper, page_size, value;
|
|
|
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
{
|
|
|
|
page_size = gtk_widget_get_width (GTK_WIDGET (self));
|
|
|
|
upper = self->list_width;
|
|
|
|
value = 0;
|
|
|
|
if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL)
|
|
|
|
value = upper - page_size - value;
|
2018-09-19 05:08:30 +00:00
|
|
|
value = gtk_adjustment_get_value (self->adjustment[orientation]);
|
2018-09-18 17:58:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-19 05:08:30 +00:00
|
|
|
ListRow *row;
|
2019-02-06 19:48:08 +00:00
|
|
|
guint anchor;
|
|
|
|
double anchor_align;
|
2018-09-19 05:08:30 +00:00
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
page_size = gtk_widget_get_height (GTK_WIDGET (self));
|
|
|
|
upper = gtk_list_view_get_list_height (self);
|
2018-09-19 05:08:30 +00:00
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
anchor = gtk_list_item_manager_get_anchor (self->item_manager, &anchor_align);
|
|
|
|
row = gtk_list_item_manager_get_nth (self->item_manager, anchor, NULL);
|
2018-09-19 05:08:30 +00:00
|
|
|
if (row)
|
|
|
|
value = list_row_get_y (self, row);
|
|
|
|
else
|
|
|
|
value = 0;
|
2019-02-06 19:48:08 +00:00
|
|
|
value -= anchor_align * (page_size - (row ? row->height : 0));
|
2018-09-18 17:58:19 +00:00
|
|
|
}
|
|
|
|
upper = MAX (upper, page_size);
|
|
|
|
|
2018-09-24 22:16:27 +00:00
|
|
|
g_signal_handlers_block_by_func (self->adjustment[orientation],
|
|
|
|
gtk_list_view_adjustment_value_changed_cb,
|
|
|
|
self);
|
2018-09-18 17:58:19 +00:00
|
|
|
gtk_adjustment_configure (self->adjustment[orientation],
|
|
|
|
value,
|
|
|
|
0,
|
|
|
|
upper,
|
|
|
|
page_size * 0.1,
|
|
|
|
page_size * 0.9,
|
|
|
|
page_size);
|
2018-09-24 22:16:27 +00:00
|
|
|
g_signal_handlers_unblock_by_func (self->adjustment[orientation],
|
|
|
|
gtk_list_view_adjustment_value_changed_cb,
|
|
|
|
self);
|
2018-09-18 17:58:19 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 23:37:38 +00:00
|
|
|
static int
|
|
|
|
compare_ints (gconstpointer first,
|
|
|
|
gconstpointer second)
|
|
|
|
{
|
|
|
|
return *(int *) first - *(int *) second;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
gtk_list_view_get_unknown_row_height (GtkListView *self,
|
|
|
|
GArray *heights)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (heights->len > 0, 0);
|
|
|
|
|
|
|
|
/* return the median and hope rows are generally uniform with few outliers */
|
|
|
|
g_array_sort (heights, compare_ints);
|
|
|
|
|
|
|
|
return g_array_index (heights, int, heights->len / 2);
|
|
|
|
}
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
static void
|
2018-09-25 23:37:38 +00:00
|
|
|
gtk_list_view_measure_across (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural)
|
2018-09-16 18:52:06 +00:00
|
|
|
{
|
|
|
|
GtkListView *self = GTK_LIST_VIEW (widget);
|
2018-09-18 02:56:19 +00:00
|
|
|
ListRow *row;
|
|
|
|
int min, nat, child_min, child_nat;
|
|
|
|
/* XXX: Figure out how to split a given height into per-row heights.
|
|
|
|
* Good luck! */
|
2018-09-25 23:37:38 +00:00
|
|
|
for_size = -1;
|
2018-09-16 18:52:06 +00:00
|
|
|
|
2018-09-18 02:56:19 +00:00
|
|
|
min = 0;
|
|
|
|
nat = 0;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
2018-09-18 02:56:19 +00:00
|
|
|
row != NULL;
|
|
|
|
row = gtk_rb_tree_node_get_next (row))
|
2018-09-16 18:52:06 +00:00
|
|
|
{
|
2018-09-25 23:37:38 +00:00
|
|
|
/* ignore unavailable rows */
|
2019-02-06 19:48:08 +00:00
|
|
|
if (row->parent.widget == NULL)
|
2018-09-25 23:37:38 +00:00
|
|
|
continue;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
gtk_widget_measure (row->parent.widget,
|
2018-09-18 02:56:19 +00:00
|
|
|
orientation, for_size,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
2018-09-25 23:37:38 +00:00
|
|
|
min = MAX (min, child_min);
|
|
|
|
nat = MAX (nat, child_nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
*minimum = min;
|
|
|
|
*natural = nat;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_list_view_measure_list (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural)
|
|
|
|
{
|
|
|
|
GtkListView *self = GTK_LIST_VIEW (widget);
|
|
|
|
ListRow *row;
|
|
|
|
int min, nat, child_min, child_nat;
|
|
|
|
GArray *min_heights, *nat_heights;
|
|
|
|
guint n_unknown;
|
|
|
|
|
|
|
|
min_heights = g_array_new (FALSE, FALSE, sizeof (int));
|
|
|
|
nat_heights = g_array_new (FALSE, FALSE, sizeof (int));
|
|
|
|
n_unknown = 0;
|
|
|
|
min = 0;
|
|
|
|
nat = 0;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
2018-09-25 23:37:38 +00:00
|
|
|
row != NULL;
|
|
|
|
row = gtk_rb_tree_node_get_next (row))
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
if (row->parent.widget)
|
2018-09-18 02:56:19 +00:00
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
gtk_widget_measure (row->parent.widget,
|
2018-09-25 23:37:38 +00:00
|
|
|
orientation, for_size,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
|
|
|
g_array_append_val (min_heights, child_min);
|
|
|
|
g_array_append_val (nat_heights, child_nat);
|
|
|
|
min += child_min;
|
|
|
|
nat += child_nat;
|
2018-09-18 02:56:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
n_unknown += row->parent.n_items;
|
2018-09-18 02:56:19 +00:00
|
|
|
}
|
2018-09-16 18:52:06 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 23:37:38 +00:00
|
|
|
if (n_unknown)
|
|
|
|
{
|
|
|
|
min += n_unknown * gtk_list_view_get_unknown_row_height (self, min_heights);
|
|
|
|
nat += n_unknown * gtk_list_view_get_unknown_row_height (self, nat_heights);
|
|
|
|
}
|
|
|
|
g_array_free (min_heights, TRUE);
|
|
|
|
g_array_free (nat_heights, TRUE);
|
|
|
|
|
2018-09-18 02:56:19 +00:00
|
|
|
*minimum = min;
|
|
|
|
*natural = nat;
|
2018-09-16 18:52:06 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 23:37:38 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_measure (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural,
|
|
|
|
int *minimum_baseline,
|
|
|
|
int *natural_baseline)
|
|
|
|
{
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
gtk_list_view_measure_across (widget, orientation, for_size, minimum, natural);
|
|
|
|
else
|
|
|
|
gtk_list_view_measure_list (widget, orientation, for_size, minimum, natural);
|
|
|
|
}
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_size_allocate (GtkWidget *widget,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int baseline)
|
|
|
|
{
|
2018-09-18 02:56:19 +00:00
|
|
|
GtkListView *self = GTK_LIST_VIEW (widget);
|
|
|
|
GtkAllocation child_allocation = { 0, 0, 0, 0 };
|
|
|
|
ListRow *row;
|
2018-09-25 23:37:38 +00:00
|
|
|
GArray *heights;
|
2018-09-18 17:58:19 +00:00
|
|
|
int min, nat, row_height;
|
|
|
|
|
2018-09-25 23:37:38 +00:00
|
|
|
/* step 0: exit early if list is empty */
|
2019-02-06 19:48:08 +00:00
|
|
|
if (gtk_list_item_manager_get_root (self->item_manager) == NULL)
|
2018-09-25 23:37:38 +00:00
|
|
|
return;
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
/* step 1: determine width of the list */
|
|
|
|
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
-1,
|
|
|
|
&min, &nat, NULL, NULL);
|
|
|
|
if (self->scroll_policy[GTK_ORIENTATION_HORIZONTAL] == GTK_SCROLL_MINIMUM)
|
|
|
|
self->list_width = MAX (min, width);
|
|
|
|
else
|
|
|
|
self->list_width = MAX (nat, width);
|
|
|
|
|
2018-09-25 23:37:38 +00:00
|
|
|
/* step 2: determine height of known list items */
|
|
|
|
heights = g_array_new (FALSE, FALSE, sizeof (int));
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
2018-09-18 02:56:19 +00:00
|
|
|
row != NULL;
|
|
|
|
row = gtk_rb_tree_node_get_next (row))
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
if (row->parent.widget == NULL)
|
2018-09-25 23:37:38 +00:00
|
|
|
continue;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
gtk_widget_measure (row->parent.widget, GTK_ORIENTATION_VERTICAL,
|
2018-09-18 17:58:19 +00:00
|
|
|
self->list_width,
|
|
|
|
&min, &nat, NULL, NULL);
|
|
|
|
if (self->scroll_policy[GTK_ORIENTATION_VERTICAL] == GTK_SCROLL_MINIMUM)
|
|
|
|
row_height = min;
|
|
|
|
else
|
|
|
|
row_height = nat;
|
|
|
|
if (row->height != row_height)
|
2018-09-18 02:56:19 +00:00
|
|
|
{
|
2018-09-18 17:58:19 +00:00
|
|
|
row->height = row_height;
|
2018-09-18 02:56:19 +00:00
|
|
|
gtk_rb_tree_node_mark_dirty (row);
|
|
|
|
}
|
2018-09-25 23:37:38 +00:00
|
|
|
g_array_append_val (heights, row_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* step 3: determine height of unknown items */
|
|
|
|
row_height = gtk_list_view_get_unknown_row_height (self, heights);
|
|
|
|
g_array_free (heights, TRUE);
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
2018-09-25 23:37:38 +00:00
|
|
|
row != NULL;
|
|
|
|
row = gtk_rb_tree_node_get_next (row))
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
if (row->parent.widget)
|
2018-09-25 23:37:38 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (row->height != row_height)
|
|
|
|
{
|
|
|
|
row->height = row_height;
|
|
|
|
gtk_rb_tree_node_mark_dirty (row);
|
|
|
|
}
|
2018-09-18 17:58:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* step 3: update the adjustments */
|
|
|
|
gtk_list_view_update_adjustments (self, GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_list_view_update_adjustments (self, GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
|
|
|
/* step 4: actually allocate the widgets */
|
|
|
|
child_allocation.x = - gtk_adjustment_get_value (self->adjustment[GTK_ORIENTATION_HORIZONTAL]);
|
2018-09-24 22:16:27 +00:00
|
|
|
child_allocation.y = - round (gtk_adjustment_get_value (self->adjustment[GTK_ORIENTATION_VERTICAL]));
|
2018-09-18 17:58:19 +00:00
|
|
|
child_allocation.width = self->list_width;
|
2019-02-06 19:48:08 +00:00
|
|
|
for (row = gtk_list_item_manager_get_first (self->item_manager);
|
2018-09-18 17:58:19 +00:00
|
|
|
row != NULL;
|
|
|
|
row = gtk_rb_tree_node_get_next (row))
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
if (row->parent.widget)
|
2018-09-25 23:37:38 +00:00
|
|
|
{
|
|
|
|
child_allocation.height = row->height;
|
2019-02-06 19:48:08 +00:00
|
|
|
gtk_widget_size_allocate (row->parent.widget, &child_allocation, -1);
|
2018-09-25 23:37:38 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
child_allocation.y += row->height * row->parent.n_items;
|
2018-09-18 02:56:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_clear_adjustment (GtkListView *self,
|
|
|
|
GtkOrientation orientation)
|
|
|
|
{
|
|
|
|
if (self->adjustment[orientation] == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (self->adjustment[orientation],
|
|
|
|
gtk_list_view_adjustment_value_changed_cb,
|
|
|
|
self);
|
|
|
|
g_clear_object (&self->adjustment[orientation]);
|
|
|
|
}
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkListView *self = GTK_LIST_VIEW (object);
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
g_clear_object (&self->model);
|
2018-09-16 18:52:06 +00:00
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
gtk_list_view_clear_adjustment (self, GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_list_view_clear_adjustment (self, GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
2018-09-20 03:18:34 +00:00
|
|
|
g_clear_object (&self->item_manager);
|
2018-09-17 05:29:50 +00:00
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
G_OBJECT_CLASS (gtk_list_view_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2018-09-18 02:56:19 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkListView *self = GTK_LIST_VIEW (object);
|
|
|
|
|
2018-09-20 03:18:34 +00:00
|
|
|
g_clear_object (&self->item_manager);
|
2018-09-18 02:56:19 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_list_view_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkListView *self = GTK_LIST_VIEW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2018-09-18 17:58:19 +00:00
|
|
|
case PROP_HADJUSTMENT:
|
|
|
|
g_value_set_object (value, self->adjustment[GTK_ORIENTATION_HORIZONTAL]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_HSCROLL_POLICY:
|
|
|
|
g_value_set_enum (value, self->scroll_policy[GTK_ORIENTATION_HORIZONTAL]);
|
|
|
|
break;
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
case PROP_MODEL:
|
|
|
|
g_value_set_object (value, self->model);
|
|
|
|
break;
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
case PROP_VADJUSTMENT:
|
|
|
|
g_value_set_object (value, self->adjustment[GTK_ORIENTATION_VERTICAL]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_VSCROLL_POLICY:
|
|
|
|
g_value_set_enum (value, self->scroll_policy[GTK_ORIENTATION_VERTICAL]);
|
|
|
|
break;
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_set_adjustment (GtkListView *self,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
GtkAdjustment *adjustment)
|
|
|
|
{
|
|
|
|
if (self->adjustment[orientation] == adjustment)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (adjustment == NULL)
|
|
|
|
adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
|
|
g_object_ref_sink (adjustment);
|
|
|
|
|
|
|
|
gtk_list_view_clear_adjustment (self, orientation);
|
|
|
|
|
|
|
|
self->adjustment[orientation] = adjustment;
|
|
|
|
|
|
|
|
g_signal_connect (adjustment, "value-changed",
|
|
|
|
G_CALLBACK (gtk_list_view_adjustment_value_changed_cb),
|
|
|
|
self);
|
|
|
|
|
|
|
|
gtk_widget_queue_allocate (GTK_WIDGET (self));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_list_view_set_scroll_policy (GtkListView *self,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
GtkScrollablePolicy scroll_policy)
|
|
|
|
{
|
|
|
|
if (self->scroll_policy[orientation] == scroll_policy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->scroll_policy[orientation] = scroll_policy;
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self),
|
|
|
|
orientation == GTK_ORIENTATION_HORIZONTAL
|
|
|
|
? properties[PROP_HSCROLL_POLICY]
|
|
|
|
: properties[PROP_VSCROLL_POLICY]);
|
|
|
|
}
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkListView *self = GTK_LIST_VIEW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2018-09-18 17:58:19 +00:00
|
|
|
case PROP_HADJUSTMENT:
|
|
|
|
gtk_list_view_set_adjustment (self, GTK_ORIENTATION_HORIZONTAL, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_HSCROLL_POLICY:
|
|
|
|
gtk_list_view_set_scroll_policy (self, GTK_ORIENTATION_HORIZONTAL, g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
case PROP_MODEL:
|
|
|
|
gtk_list_view_set_model (self, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
case PROP_VADJUSTMENT:
|
|
|
|
gtk_list_view_set_adjustment (self, GTK_ORIENTATION_VERTICAL, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_VSCROLL_POLICY:
|
|
|
|
gtk_list_view_set_scroll_policy (self, GTK_ORIENTATION_VERTICAL, g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 21:24:18 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_select_item (GtkWidget *widget,
|
|
|
|
const char *action_name,
|
|
|
|
GVariant *parameter)
|
|
|
|
{
|
|
|
|
GtkListView *self = GTK_LIST_VIEW (widget);
|
|
|
|
GtkSelectionModel *selection_model;
|
|
|
|
guint pos;
|
|
|
|
gboolean modify, extend;
|
|
|
|
|
|
|
|
selection_model = gtk_list_item_manager_get_model (self->item_manager);
|
|
|
|
g_variant_get (parameter, "(ubb)", &pos, &modify, &extend);
|
|
|
|
|
|
|
|
/* XXX: handle extend by tracking the item to extend from */
|
|
|
|
|
|
|
|
if (modify)
|
|
|
|
{
|
|
|
|
if (gtk_selection_model_is_selected (selection_model, pos))
|
|
|
|
gtk_selection_model_unselect_item (selection_model, pos);
|
|
|
|
else
|
|
|
|
gtk_selection_model_select_item (selection_model, pos, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_selection_model_select_item (selection_model, pos, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
static void
|
|
|
|
gtk_list_view_class_init (GtkListViewClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2018-09-18 17:58:19 +00:00
|
|
|
gpointer iface;
|
2018-09-16 18:52:06 +00:00
|
|
|
|
|
|
|
widget_class->measure = gtk_list_view_measure;
|
|
|
|
widget_class->size_allocate = gtk_list_view_size_allocate;
|
|
|
|
|
|
|
|
gobject_class->dispose = gtk_list_view_dispose;
|
2018-09-18 02:56:19 +00:00
|
|
|
gobject_class->finalize = gtk_list_view_finalize;
|
2018-09-16 18:52:06 +00:00
|
|
|
gobject_class->get_property = gtk_list_view_get_property;
|
|
|
|
gobject_class->set_property = gtk_list_view_set_property;
|
|
|
|
|
2018-09-18 17:58:19 +00:00
|
|
|
/* GtkScrollable implementation */
|
|
|
|
iface = g_type_default_interface_peek (GTK_TYPE_SCROLLABLE);
|
|
|
|
properties[PROP_HADJUSTMENT] =
|
|
|
|
g_param_spec_override ("hadjustment",
|
|
|
|
g_object_interface_find_property (iface, "hadjustment"));
|
|
|
|
properties[PROP_HSCROLL_POLICY] =
|
|
|
|
g_param_spec_override ("hscroll-policy",
|
|
|
|
g_object_interface_find_property (iface, "hscroll-policy"));
|
|
|
|
properties[PROP_VADJUSTMENT] =
|
|
|
|
g_param_spec_override ("vadjustment",
|
|
|
|
g_object_interface_find_property (iface, "vadjustment"));
|
|
|
|
properties[PROP_VSCROLL_POLICY] =
|
|
|
|
g_param_spec_override ("vscroll-policy",
|
|
|
|
g_object_interface_find_property (iface, "vscroll-policy"));
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
/**
|
|
|
|
* GtkListView:model:
|
|
|
|
*
|
|
|
|
* Model for the items displayed
|
|
|
|
*/
|
|
|
|
properties[PROP_MODEL] =
|
|
|
|
g_param_spec_object ("model",
|
|
|
|
P_("Model"),
|
|
|
|
P_("Model for the items displayed"),
|
|
|
|
G_TYPE_LIST_MODEL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
|
|
|
|
2018-10-05 21:24:18 +00:00
|
|
|
/**
|
|
|
|
* GtkListView|list.select-item:
|
|
|
|
* @position: position of item to select
|
|
|
|
* @modify: %TRUE to toggle the existing selection, %FALSE to select
|
|
|
|
* @extend: %TRUE to extend the selection
|
|
|
|
*
|
|
|
|
* Changes selection.
|
|
|
|
*
|
|
|
|
* If @extend is %TRUE and the model supports selecting ranges, the
|
|
|
|
* affected items are all items from the last selected item to the item
|
|
|
|
* in @position.
|
|
|
|
* If @extend is %FALSE or selecting ranges is not supported, only the
|
|
|
|
* item in @position is affected.
|
|
|
|
*
|
|
|
|
* If @modify is %TRUE, the affected items will be set to the same state.
|
|
|
|
* If @modify is %FALSE, the affected items will be selected and
|
|
|
|
* all other items will be deselected.
|
|
|
|
*/
|
|
|
|
gtk_widget_class_install_action (widget_class,
|
|
|
|
"list.select-item",
|
|
|
|
"(ubb)",
|
|
|
|
gtk_list_view_select_item);
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("list"));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_list_view_init (GtkListView *self)
|
|
|
|
{
|
2019-02-06 19:48:08 +00:00
|
|
|
self->item_manager = gtk_list_item_manager_new (GTK_WIDGET (self), ListRow, ListRowAugment, list_row_augment);
|
2018-09-18 17:58:19 +00:00
|
|
|
|
|
|
|
self->adjustment[GTK_ORIENTATION_HORIZONTAL] = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
|
|
self->adjustment[GTK_ORIENTATION_VERTICAL] = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
|
2018-09-16 18:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_list_view_new:
|
|
|
|
*
|
|
|
|
* Creates a new empty #GtkListView.
|
|
|
|
*
|
|
|
|
* You most likely want to call gtk_list_view_set_model() to set
|
|
|
|
* a model and then set up a way to map its items to widgets next.
|
|
|
|
*
|
|
|
|
* Returns: a new #GtkListView
|
|
|
|
**/
|
|
|
|
GtkWidget *
|
|
|
|
gtk_list_view_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (GTK_TYPE_LIST_VIEW, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_list_view_get_model:
|
|
|
|
* @self: a #GtkListView
|
|
|
|
*
|
|
|
|
* Gets the model that's currently used to read the items displayed.
|
|
|
|
*
|
|
|
|
* Returns: (nullable) (transfer none): The model in use
|
|
|
|
**/
|
|
|
|
GListModel *
|
|
|
|
gtk_list_view_get_model (GtkListView *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_LIST_VIEW (self), NULL);
|
|
|
|
|
|
|
|
return self->model;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_list_view_set_model:
|
|
|
|
* @self: a #GtkListView
|
2018-10-03 16:53:06 +00:00
|
|
|
* @model: (allow-none) (transfer none): the model to use or %NULL for none
|
|
|
|
*
|
|
|
|
* Sets the #GListModel to use.
|
2018-09-16 18:52:06 +00:00
|
|
|
*
|
2018-10-03 16:53:06 +00:00
|
|
|
* If the @model is a #GtkSelectionModel, it is used for managing the selection.
|
|
|
|
* Otherwise, @self creates a #GtkSingleSelection for the selection.
|
2018-09-16 18:52:06 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_list_view_set_model (GtkListView *self,
|
|
|
|
GListModel *model)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_LIST_VIEW (self));
|
|
|
|
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
|
|
|
|
|
|
|
|
if (self->model == model)
|
|
|
|
return;
|
|
|
|
|
2019-02-06 19:48:08 +00:00
|
|
|
g_clear_object (&self->model);
|
2018-09-16 18:52:06 +00:00
|
|
|
|
|
|
|
if (model)
|
|
|
|
{
|
2018-10-03 16:53:06 +00:00
|
|
|
GtkSelectionModel *selection_model;
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
self->model = g_object_ref (model);
|
|
|
|
|
2018-10-03 16:53:06 +00:00
|
|
|
if (GTK_IS_SELECTION_MODEL (model))
|
|
|
|
selection_model = GTK_SELECTION_MODEL (g_object_ref (model));
|
|
|
|
else
|
|
|
|
selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
|
|
|
|
|
|
|
|
gtk_list_item_manager_set_model (self->item_manager, selection_model);
|
|
|
|
|
|
|
|
g_object_unref (selection_model);
|
2018-09-16 18:52:06 +00:00
|
|
|
}
|
2018-10-03 16:53:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_list_item_manager_set_model (self->item_manager, NULL);
|
|
|
|
}
|
|
|
|
|
2018-09-16 18:52:06 +00:00
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
|
|
|
|
}
|
|
|
|
|
2018-09-17 05:29:50 +00:00
|
|
|
void
|
2018-09-24 02:42:15 +00:00
|
|
|
gtk_list_view_set_functions (GtkListView *self,
|
|
|
|
GtkListItemSetupFunc setup_func,
|
|
|
|
GtkListItemBindFunc bind_func,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify user_destroy)
|
2018-09-17 05:29:50 +00:00
|
|
|
{
|
2018-09-20 03:18:34 +00:00
|
|
|
GtkListItemFactory *factory;
|
2018-09-18 02:56:19 +00:00
|
|
|
|
2018-09-17 05:29:50 +00:00
|
|
|
g_return_if_fail (GTK_IS_LIST_VIEW (self));
|
2018-09-24 02:42:15 +00:00
|
|
|
g_return_if_fail (setup_func || bind_func);
|
2018-09-17 05:29:50 +00:00
|
|
|
g_return_if_fail (user_data != NULL || user_destroy == NULL);
|
|
|
|
|
2018-09-24 02:42:15 +00:00
|
|
|
factory = gtk_list_item_factory_new (setup_func, bind_func, user_data, user_destroy);
|
2018-09-20 03:18:34 +00:00
|
|
|
gtk_list_item_manager_set_factory (self->item_manager, factory);
|
|
|
|
g_object_unref (factory);
|
2018-09-17 05:29:50 +00:00
|
|
|
}
|
|
|
|
|