[calls] record-row: Only create popover when needed
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] record-row: Only create popover when needed
- Date: Fri, 10 Dec 2021 17:47:26 +0000 (UTC)
commit 4df3ea005dac748d42ff7aa84d30a78afd89a281
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Wed Dec 8 10:25:15 2021 +0100
record-row: Only create popover when needed
Creating a popover for each CallsCallRecordRow comes with a big performance
hit when scrolling the history, so we should avoid doing this.
Fixes #198
src/calls-call-record-row.c | 22 +++++++++++++++-------
src/ui/call-record-row.ui | 3 ---
2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/calls-call-record-row.c b/src/calls-call-record-row.c
index 7d51aa8f..d11d9bdf 100644
--- a/src/calls-call-record-row.c
+++ b/src/calls-call-record-row.c
@@ -335,10 +335,23 @@ setup_contact (CallsCallRecordRow *self)
static void
-context_menu (GtkWidget *self,
+context_menu (GtkWidget *widget,
GdkEvent *event)
{
- gtk_popover_popup (CALLS_CALL_RECORD_ROW (self)->popover);
+ CallsCallRecordRow *self;
+
+ g_assert (CALLS_IS_CALL_RECORD_ROW (widget));
+
+ self = CALLS_CALL_RECORD_ROW (widget);
+
+ if (!self->popover) {
+ self->popover = GTK_POPOVER (gtk_popover_new (widget));
+ gtk_popover_bind_model (self->popover,
+ G_MENU_MODEL (self->context_menu),
+ "row-history");
+ }
+
+ gtk_popover_popup (self->popover);
}
@@ -498,7 +511,6 @@ calls_call_record_row_class_init (CallsCallRecordRowClass *klass)
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, button);
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, event_box);
- gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, popover);
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, context_menu);
}
@@ -561,10 +573,6 @@ calls_call_record_row_init (CallsCallRecordRow *self)
self->gesture = gtk_gesture_long_press_new (GTK_WIDGET (self->event_box));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->gesture), TRUE);
g_signal_connect (self->gesture, "pressed", G_CALLBACK (long_pressed), self);
-
- gtk_popover_bind_model (self->popover,
- G_MENU_MODEL (self->context_menu),
- "row-history");
}
diff --git a/src/ui/call-record-row.ui b/src/ui/call-record-row.ui
index 15a28a16..99f4a1c8 100644
--- a/src/ui/call-record-row.ui
+++ b/src/ui/call-record-row.ui
@@ -97,9 +97,6 @@
</object>
</child>
</template>
- <object class="GtkPopover" id="popover">
- <property name="relative-to">CallsCallRecordRow</property>
- </object>
<menu id="context_menu">
<section>
<item>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]