[calls] account-overview: Show notification on account message
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] account-overview: Show notification on account message
- Date: Tue, 11 Jan 2022 12:27:24 +0000 (UTC)
commit 2a9791a9a31c51049c39eeb5192c182044f252a7
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Wed Dec 15 14:06:03 2021 +0100
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
src/calls-account-overview.c | 27 +++++++++++++++++++++++++++
src/ui/account-overview.ui | 10 ++++++++++
2 files changed, 37 insertions(+)
---
diff --git a/src/calls-account-overview.c b/src/calls-account-overview.c
index feb733d5..b7ee75c7 100644
--- a/src/calls-account-overview.c
+++ b/src/calls-account-overview.c
@@ -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);
}
diff --git a/src/ui/account-overview.ui b/src/ui/account-overview.ui
index 5361fb36..4c8645c3 100644
--- a/src/ui/account-overview.ui
+++ b/src/ui/account-overview.ui
@@ -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">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]