[calls] record-row: Use per protocol dial action
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] record-row: Use per protocol dial action
- Date: Mon, 31 Jan 2022 17:39:21 +0000 (UTC)
commit b00deccdcb6f601c202efb9f59330cb381faa174
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Tue Jan 25 10:14:42 2022 +0100
record-row: Use per protocol dial action
This allows us to deactivate actions if there is no origin that can handle them.
Closes #293
src/calls-call-record-row.c | 38 +++++++++++++++-----------------------
src/ui/call-record-row.ui | 1 -
2 files changed, 15 insertions(+), 24 deletions(-)
---
diff --git a/src/calls-call-record-row.c b/src/calls-call-record-row.c
index 0b8ae522..a5eef695 100644
--- a/src/calls-call-record-row.c
+++ b/src/calls-call-record-row.c
@@ -73,19 +73,6 @@ enum {
static GParamSpec *props[PROP_LAST_PROP];
-static gboolean
-string_to_variant (GBinding *binding,
- const GValue *from_value,
- GValue *to_value)
-{
- const gchar *target = g_value_get_string (from_value);
- GVariant *variant = g_variant_new_string (target);
-
- g_value_take_variant (to_value, variant);
- return TRUE;
-}
-
-
static void
nice_time (GDateTime *t,
gchar **nice,
@@ -359,7 +346,6 @@ setup_contact (CallsCallRecordRow *self)
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), NULL);
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), FALSE);
} else {
- gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), "app.dial");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), TRUE);
}
}
@@ -445,22 +431,28 @@ constructed (GObject *object)
gboolean inbound;
GDateTime *answered;
GDateTime *end;
+ g_autofree char *target_name = NULL;
+ g_autofree char *protocol = NULL;
+ g_autofree char *action_name = NULL;
g_object_get (G_OBJECT (self->record),
"inbound", &inbound,
"answered", &answered,
"end", &end,
+ "protocol", &protocol,
NULL);
- g_object_bind_property_full (self->record,
- "target",
- self->button,
- "action-target",
- G_BINDING_SYNC_CREATE,
- (GBindingTransformFunc) string_to_variant,
- NULL,
- NULL,
- NULL);
+ /* Fall back to "app.dial-tel" action if no protocol was given */
+ if (protocol)
+ action_name = g_strdup_printf ("app.dial-%s", protocol);
+ else
+ action_name = g_strdup ("app.dial-tel");
+
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), action_name);
+
+ /* TODO add origin ID to action target */
+ gtk_actionable_set_action_target (GTK_ACTIONABLE (self->button),
+ "(ss)", self->target, "");
setup_time (self, inbound, answered, end);
calls_date_time_unref (answered);
diff --git a/src/ui/call-record-row.ui b/src/ui/call-record-row.ui
index b55aa898..94433850 100644
--- a/src/ui/call-record-row.ui
+++ b/src/ui/call-record-row.ui
@@ -54,7 +54,6 @@
<property name="margin_bottom">8</property>
<property name="halign">center</property>
<property name="valign">center</property>
- <property name="action-name">app.dial</property>
<style>
<class name="image-button"/>
</style>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]