1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-13 16:07:36 +00:00

history-box: Switch to GtkSliceListModel

Having more than ~200 widgets in a GtkListBox comes with a very
performance impact. This is especially noticable during while the main
window is being realized (even if Calls already runs in daemon mode).

We can limit the amount of widgets by using a slice list model.

Fixes: #374
This commit is contained in:
Evangelos Ribeiro Tzaras 2022-07-09 12:49:08 +02:00
parent 3568af8553
commit 8ae03a1321

View file

@ -25,6 +25,7 @@
#include "calls-history-box.h"
#include "calls-call-record.h"
#include "calls-call-record-row.h"
#include "gtklistmodels/gtkmodels.h"
#include "util.h"
#include <glib/gi18n.h>
@ -37,6 +38,8 @@ struct _CallsHistoryBox {
GtkListBox *history;
GListModel *model;
GtkSliceListModel *slice_model;
gulong model_changed_handler_id;
};
@ -149,13 +152,15 @@ constructed (GObject *object)
G_OBJECT_CLASS (calls_history_box_parent_class)->constructed (object);
self->slice_model = gtk_slice_list_model_new (self->model, 0, 75);
self->model_changed_handler_id =
g_signal_connect_swapped
(self->model, "items-changed", G_CALLBACK (update), self);
g_assert (self->model_changed_handler_id != 0);
gtk_list_box_bind_model (self->history,
self->model,
G_LIST_MODEL (self->slice_model),
(GtkListBoxCreateWidgetFunc) create_row_cb,
self,
NULL);
@ -169,6 +174,7 @@ dispose (GObject *object)
{
CallsHistoryBox *self = CALLS_HISTORY_BOX (object);
g_clear_object (&self->slice_model);
g_clear_object (&self->model);
G_OBJECT_CLASS (calls_history_box_parent_class)->dispose (object);