mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-12-14 00:17:35 +00:00
parent
5588bd934a
commit
827594dc2e
2 changed files with 55 additions and 3 deletions
|
@ -296,10 +296,30 @@ setup_time (CallsCallRecordRow *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_notify_can_add_contacts (CallsCallRecordRow *self)
|
||||||
|
{
|
||||||
|
CallsContactsProvider *contacts_provider;
|
||||||
|
GAction *action_new_contact = g_action_map_lookup_action (self->action_map, "new-contact");
|
||||||
|
|
||||||
|
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
||||||
|
|
||||||
|
if (!calls_contacts_provider_get_can_add_contacts (contacts_provider))
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_object_bind_property (self->contact, "has-individual",
|
||||||
|
action_new_contact, "enabled",
|
||||||
|
G_BINDING_SYNC_CREATE |
|
||||||
|
G_BINDING_INVERT_BOOLEAN);
|
||||||
|
g_signal_handlers_disconnect_by_data(contacts_provider, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_contact (CallsCallRecordRow *self)
|
setup_contact (CallsCallRecordRow *self)
|
||||||
{
|
{
|
||||||
GAction *act = g_action_map_lookup_action (self->action_map, "copy-number");
|
GAction *action_copy = g_action_map_lookup_action (self->action_map, "copy-number");
|
||||||
|
GAction *action_new_contact = g_action_map_lookup_action (self->action_map, "new-contact");
|
||||||
g_autofree gchar *target = NULL;
|
g_autofree gchar *target = NULL;
|
||||||
CallsContactsProvider *contacts_provider;
|
CallsContactsProvider *contacts_provider;
|
||||||
|
|
||||||
|
@ -324,12 +344,23 @@ setup_contact (CallsCallRecordRow *self)
|
||||||
self->avatar, "loadable-icon",
|
self->avatar, "loadable-icon",
|
||||||
G_BINDING_SYNC_CREATE);
|
G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
|
if (calls_contacts_provider_get_can_add_contacts (contacts_provider)) {
|
||||||
|
on_notify_can_add_contacts (self);
|
||||||
|
} else {
|
||||||
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_new_contact), FALSE);
|
||||||
|
g_signal_connect_swapped (contacts_provider,
|
||||||
|
"notify::can-add-contacts",
|
||||||
|
G_CALLBACK (on_notify_can_add_contacts),
|
||||||
|
self);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (target[0] == '\0') {
|
if (target[0] == '\0') {
|
||||||
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), NULL);
|
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), NULL);
|
||||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (act), FALSE);
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), FALSE);
|
||||||
} else {
|
} else {
|
||||||
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), "app.dial");
|
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), "app.dial");
|
||||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (act), TRUE);
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,10 +576,26 @@ copy_number_activated (GSimpleAction *action,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
new_contact_activated (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (data);
|
||||||
|
CallsContactsProvider *contacts_provider;
|
||||||
|
|
||||||
|
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
||||||
|
|
||||||
|
calls_contacts_provider_add_new_contact (contacts_provider,
|
||||||
|
calls_best_match_get_phone_number (self->contact));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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},
|
{ "copy-number", copy_number_activated, NULL, NULL, NULL},
|
||||||
|
{ "new-contact", new_contact_activated, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,11 @@
|
||||||
<attribute name="action">copy-number</attribute>
|
<attribute name="action">copy-number</attribute>
|
||||||
<attribute name="hidden-when">action-disabled</attribute>
|
<attribute name="hidden-when">action-disabled</attribute>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">_Add contact</attribute>
|
||||||
|
<attribute name="action">new-contact</attribute>
|
||||||
|
<attribute name="hidden-when">action-disabled</attribute>
|
||||||
|
</item>
|
||||||
</section>
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
Loading…
Reference in a new issue