mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-06 03:25:31 +00:00
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
This commit is contained in:
parent
4353effa98
commit
4df3ea005d
2 changed files with 15 additions and 10 deletions
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue