[calls] history-box: Switch to GtkSliceListModel



commit 8ae03a13210296a52ee99bf429b8bbe7698b6907
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Sat Jul 9 12:49:08 2022 +0200

    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

 src/calls-history-box.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/calls-history-box.c b/src/calls-history-box.c
index 092565f5..6c481164 100644
--- a/src/calls-history-box.c
+++ b/src/calls-history-box.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]