1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-12 15:47:35 +00:00

record-row: Allow copying number from context menu

This commit is contained in:
Evangelos Ribeiro Tzaras 2021-01-13 15:17:18 +01:00
parent 5eeacf3720
commit 78a47918be
2 changed files with 29 additions and 0 deletions

View file

@ -598,9 +598,30 @@ delete_call_activated (GSimpleAction *action,
} }
static void
copy_number_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (data);
g_autofree gchar *target = NULL;
g_object_get (G_OBJECT (self->record),
"target", &target,
NULL);
g_return_if_fail (target);
g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
"copy-number",
g_variant_new_string (target));
}
static GActionEntry entries[] = static GActionEntry entries[] =
{ {
{ "delete-call", delete_call_activated, NULL, NULL, NULL}, { "delete-call", delete_call_activated, NULL, NULL, NULL},
{ "copy-number", copy_number_activated, NULL, NULL, NULL},
}; };
@ -627,6 +648,9 @@ calls_call_record_row_init (CallsCallRecordRow *self)
act = g_action_map_lookup_action (self->action_map, "delete-call"); act = g_action_map_lookup_action (self->action_map, "delete-call");
g_simple_action_set_enabled (G_SIMPLE_ACTION (act), TRUE); g_simple_action_set_enabled (G_SIMPLE_ACTION (act), TRUE);
act = g_action_map_lookup_action (self->action_map, "copy-number");
g_simple_action_set_enabled (G_SIMPLE_ACTION (act), TRUE);
self->gesture = gtk_gesture_long_press_new (GTK_WIDGET (self->event_box)); self->gesture = gtk_gesture_long_press_new (GTK_WIDGET (self->event_box));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->gesture), TRUE); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->gesture), TRUE);
g_signal_connect (self->gesture, "pressed", G_CALLBACK (long_pressed), self); g_signal_connect (self->gesture, "pressed", G_CALLBACK (long_pressed), self);

View file

@ -112,6 +112,11 @@
<attribute name="label" translatable="yes">_Delete Call</attribute> <attribute name="label" translatable="yes">_Delete Call</attribute>
<attribute name="action">delete-call</attribute> <attribute name="action">delete-call</attribute>
</item> </item>
<item>
<!-- Translators: This is a phone number -->
<attribute name="label" translatable="yes">_Copy number</attribute>
<attribute name="action">copy-number</attribute>
</item>
</section> </section>
</menu> </menu>
</interface> </interface>