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

account-overview: Show notification on account message

Accounts implement the CallsMessageSource interface and emit messages when
there are state changes of which the user should be informed.

Closes #340
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-12-15 14:06:03 +01:00
parent 695839a2d9
commit 2a9791a9a3
2 changed files with 37 additions and 0 deletions

View file

@ -29,6 +29,7 @@
#include "calls-account-row.h"
#include "calls-account-provider.h"
#include "calls-manager.h"
#include "calls-in-app-notification.h"
/**
@ -64,6 +65,7 @@ struct _CallsAccountOverview {
/* misc */
CallsAccountOverviewState state;
GList *providers;
CallsInAppNotification *in_app_notification;
};
G_DEFINE_TYPE (CallsAccountOverview, calls_account_overview, HDY_TYPE_WINDOW)
@ -167,6 +169,24 @@ on_edit_account_clicked (CallsAccountRow *row,
}
static void
on_account_message (CallsAccount *account,
const char *message,
GtkMessageType message_type,
CallsAccountOverview *self)
{
g_autofree char* notification = NULL;
g_assert (CALLS_IS_ACCOUNT (account));
g_assert (CALLS_IS_ACCOUNT_OVERVIEW (self));
notification = g_strdup_printf ("%s: %s",
calls_account_get_address (account),
message);
calls_in_app_notification_show (self->in_app_notification, notification);
}
static void
update_account_list (CallsAccountOverview *self)
{
@ -197,6 +217,11 @@ update_account_list (CallsAccountOverview *self)
g_autoptr (CallsAccount) account = CALLS_ACCOUNT (g_list_model_get_item (model, i));
CallsAccountRow *account_row = calls_account_row_new (provider, account);
g_signal_handlers_disconnect_by_data (account, self);
g_signal_connect (account, "message",
G_CALLBACK (on_account_message),
self);
g_signal_connect (account_row, "edit-clicked",
G_CALLBACK (on_edit_account_clicked),
self);
@ -258,6 +283,8 @@ calls_account_overview_class_init (CallsAccountOverviewClass *klass)
gtk_widget_class_bind_template_child (widget_class, CallsAccountOverview, account_window);
gtk_widget_class_bind_template_child (widget_class, CallsAccountOverview, in_app_notification);
gtk_widget_class_bind_template_callback (widget_class, on_add_account_clicked);
}

View file

@ -28,6 +28,14 @@
</object>
</child>
<child>
<object class="GtkOverlay">
<property name="visible">True</property>
<child type="overlay">
<object class="CallsInAppNotification" id="in_app_notification">
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
@ -79,6 +87,8 @@
</object>
</child>
</object>
</child>
</template>
<object class="HdyActionRow" id="add_row">