1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-05-21 12:39:29 +00:00

call-record-row: Improve event handling

Part-of: <https://gitlab.gnome.org/GNOME/calls/-/merge_requests/714>
This commit is contained in:
Anton Lazarev 2024-01-12 16:38:25 -08:00
parent caecf10cc1
commit eef5b33ad4
2 changed files with 67 additions and 58 deletions

View file

@ -46,7 +46,6 @@ struct _CallsCallRecordRow {
GtkLabel *time;
GtkButton *button;
GtkPopover *popover;
GtkBox *event_box;
GMenu *context_menu;
@ -508,6 +507,19 @@ dispose (GObject *object)
}
static void
finalize (GObject *object)
{
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
GtkWidget *popover = GTK_WIDGET (self->popover);
g_clear_pointer (&popover, gtk_widget_unparent);
G_OBJECT_CLASS (calls_call_record_row_parent_class)->dispose (object);
}
static void
calls_call_record_row_class_init (CallsCallRecordRowClass *klass)
{
@ -518,6 +530,7 @@ calls_call_record_row_class_init (CallsCallRecordRowClass *klass)
object_class->constructed = constructed;
object_class->get_property = get_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
props[PROP_RECORD] =
g_param_spec_object ("record",
@ -536,7 +549,6 @@ calls_call_record_row_class_init (CallsCallRecordRowClass *klass)
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, time);
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, context_menu);
}
@ -616,10 +628,10 @@ new_sms_activated (GSimpleAction *action,
static GActionEntry entries[] =
{
{ "delete-call", delete_call_activated, NULL, NULL, NULL},
{ "copy-number", copy_number_activated, NULL, NULL, NULL},
{ "new-contact", new_contact_activated, NULL, NULL, NULL},
{ "new-sms", new_sms_activated, NULL, NULL, NULL},
{ "delete-call", delete_call_activated },
{ "copy-number", copy_number_activated },
{ "new-contact", new_contact_activated },
{ "new-sms", new_sms_activated },
};
@ -644,13 +656,14 @@ calls_call_record_row_init (CallsCallRecordRow *self)
g_simple_action_set_enabled (G_SIMPLE_ACTION (act), TRUE);
gesture = gtk_gesture_click_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (gesture, "pressed", G_CALLBACK (calls_call_record_row_button_press_event), self);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
gesture = gtk_gesture_long_press_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE);
g_signal_connect (gesture, "pressed", G_CALLBACK (on_long_pressed), self);
gtk_widget_add_controller (GTK_WIDGET (self->event_box), GTK_EVENT_CONTROLLER (gesture));
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
}

View file

@ -5,54 +5,50 @@
<property name="activatable">False</property>
<property name="selectable">False</property>
<property name="child">
<object class="GtkBox" id="event_box">
<object class="GtkBox">
<child>
<object class="GtkBox">
<child>
<object class="AdwAvatar" id="avatar">
<property name="margin-start">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="size">48</property>
<property name="text" bind-source="target" bind-property="label" bind-flags="sync-create"/>
<property name="show-initials">True</property>
</object>
</child>
<child>
<object class="GtkImage" id="type">
<property name="margin-start">8</property>
</object>
</child>
<child>
<object class="GtkLabel" id="target">
<property name="margin-start">10</property>
<property name="ellipsize">middle</property>
</object>
</child>
<child>
<object class="GtkButton" id="button">
<property name="margin-start">12</property>
<property name="margin-end">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="tooltip-text">Call</property>
<property name="icon-name">call-start-symbolic</property>
</object>
</child>
<child>
<object class="GtkLabel" id="time">
<property name="margin-start">8</property>
<property name="justify">right</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="scale" value="0.7"></attribute>
</attributes>
</object>
</child>
<object class="AdwAvatar" id="avatar">
<property name="margin-start">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="size">48</property>
<property name="text" bind-source="target" bind-property="label" bind-flags="sync-create"/>
<property name="show-initials">True</property>
</object>
</child>
<child>
<object class="GtkImage" id="type">
<property name="margin-start">8</property>
</object>
</child>
<child>
<object class="GtkLabel" id="target">
<property name="margin-start">10</property>
<property name="ellipsize">middle</property>
</object>
</child>
<child>
<object class="GtkButton" id="button">
<property name="margin-start">12</property>
<property name="margin-end">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="tooltip-text">Call</property>
<property name="icon-name">call-start-symbolic</property>
</object>
</child>
<child>
<object class="GtkLabel" id="time">
<property name="margin-start">8</property>
<property name="justify">right</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="scale" value="0.7"></attribute>
</attributes>
</object>
</child>
</object>
@ -62,21 +58,21 @@
<section>
<item>
<attribute name="label" translatable="yes">_Delete Call</attribute>
<attribute name="action">delete-call</attribute>
<attribute name="action">row-history.delete-call</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Copy number</attribute>
<attribute name="action">copy-number</attribute>
<attribute name="action">row-history.copy-number</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Add contact</attribute>
<attribute name="action">new-contact</attribute>
<attribute name="action">row-history.new-contact</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Send SMS</attribute>
<attribute name="action">new-sms</attribute>
<attribute name="action">row-history.new-sms</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
</section>