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

history-box: Cap size of slice at number of call records

This helps avoiding some log spam when scrolling to the bottom:

16:29:17.1053      CallsHistoryBox[2798409]:   DEBUG: Increasing history slice from 1825 to 1875
16:29:17.1215      CallsHistoryBox[2798409]:   DEBUG: Increasing history slice from 1875 to 1925
16:29:20.6739      CallsHistoryBox[2798409]:   DEBUG: Increasing history slice from 1925 to 1975
16:29:23.1919      CallsHistoryBox[2798409]:   DEBUG: Increasing history slice from 1975 to 2025
16:29:24.2533      CallsHistoryBox[2798409]:   DEBUG: Increasing history slice from 2025 to 2075

for a history of ~1400 records.
This commit is contained in:
Evangelos Ribeiro Tzaras 2022-07-27 16:54:26 +02:00
parent 9209a7801c
commit b81b216cf0

View file

@ -48,6 +48,8 @@ struct _CallsHistoryBox {
GListModel *model;
GtkSliceListModel *slice_model;
gsize n_items;
gulong model_changed_handler_id;
};
@ -64,12 +66,16 @@ static GParamSpec *props[PROP_LAST_PROP];
static void
update (CallsHistoryBox *self)
on_model_changed (GListModel *model,
guint position,
guint removed,
guint added,
CallsHistoryBox *self)
{
gchar *child_name;
if (g_list_model_get_n_items (self->model) == 0) {
if (g_list_model_get_n_items (self->model) == 0)
self->n_items = self->n_items + added - removed;
if (self->n_items == 0)
child_name = "empty";
else
child_name = "history";
@ -153,6 +159,11 @@ on_adjustment_position_changed (GtkAdjustment *adjustment,
if (position > upper_limit - CALLS_HISTORY_INCREASE_N_PAGES_THRESHOLD * page_size) {
guint new_size = old_size + CALLS_HISTORY_SIZE_INCREMENTS;
new_size = MIN (new_size, self->n_items);
if (old_size == new_size)
return;
g_debug ("Increasing history slice from %u to %u",
old_size, new_size);
gtk_slice_list_model_set_size (self->slice_model, new_size);
@ -195,8 +206,10 @@ constructed (GObject *object)
CALLS_HISTORY_SIZE_INITIAL);
self->model_changed_handler_id =
g_signal_connect_swapped
(self->model, "items-changed", G_CALLBACK (update), self);
g_signal_connect (self->model,
"items-changed",
G_CALLBACK (on_model_changed),
self);
g_assert (self->model_changed_handler_id != 0);
gtk_list_box_bind_model (self->history,
@ -205,7 +218,7 @@ constructed (GObject *object)
self,
NULL);
update (self);
on_model_changed (self->model, 0, 0, g_list_model_get_n_items (self->model), self);
}