[libdazzle] listbox: allow tweaking the recycle max
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] listbox: allow tweaking the recycle max
- Date: Sun, 17 Dec 2017 11:19:31 +0000 (UTC)
commit a39a229bd4ca478e99f718bcdead80334e6e1791
Author: Christian Hergert <chergert redhat com>
Date: Sun Dec 17 03:17:39 2017 -0800
listbox: allow tweaking the recycle max
This allows you to set how many rows to cache by default.
src/widgets/dzl-list-box.c | 28 +++++++++++++++++++++++++++-
src/widgets/dzl-list-box.h | 3 +++
2 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/src/widgets/dzl-list-box.c b/src/widgets/dzl-list-box.c
index 425a284..af0a546 100644
--- a/src/widgets/dzl-list-box.c
+++ b/src/widgets/dzl-list-box.c
@@ -35,6 +35,8 @@
#include "dzl-list-box.h"
#include "dzl-list-box-row.h"
+#define RECYCLE_MAX_DEFAULT 25
+
typedef struct
{
GListModel *model;
@@ -294,7 +296,7 @@ dzl_list_box_init (DzlListBox *self)
DzlListBoxPrivate *priv = dzl_list_box_get_instance_private (self);
priv->row_type = G_TYPE_INVALID;
- priv->recycle_max = 25;
+ priv->recycle_max = RECYCLE_MAX_DEFAULT;
g_queue_init (&priv->trashed_rows);
}
@@ -369,3 +371,27 @@ dzl_list_box_set_model (DzlListBox *self,
self,
NULL);
}
+
+/**
+ * dzl_list_box_set_recycle_max:
+ * @self: a #DzlListBox
+ * @recycle_max: max number of rows to cache
+ *
+ * Sets the max number of rows to cache for reuse. Set to 0 to return
+ * to the default.
+ *
+ * Since: 3.28
+ */
+void
+dzl_list_box_set_recycle_max (DzlListBox *self,
+ guint recycle_max)
+{
+ DzlListBoxPrivate *priv = dzl_list_box_get_instance_private (self);
+
+ g_return_if_fail (DZL_IS_LIST_BOX (self));
+
+ if (recycle_max == 0)
+ priv->recycle_max = RECYCLE_MAX_DEFAULT;
+ else
+ priv->recycle_max = recycle_max;
+}
diff --git a/src/widgets/dzl-list-box.h b/src/widgets/dzl-list-box.h
index 34de62b..5a0fd2d 100644
--- a/src/widgets/dzl-list-box.h
+++ b/src/widgets/dzl-list-box.h
@@ -51,6 +51,9 @@ GListModel *dzl_list_box_get_model (DzlListBox *self);
DZL_AVAILABLE_IN_ALL
void dzl_list_box_set_model (DzlListBox *self,
GListModel *model);
+DZL_AVAILABLE_IN_3_28
+void dzl_list_box_set_recycle_max (DzlListBox *self,
+ guint recycle_max);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]