1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-06-28 14:49:30 +00:00

MainWindow: use in-app notification for messages

This replaces the infobar with a in-app notification.
This commit is contained in:
Julian Sparber 2020-03-02 19:01:20 +01:00
parent e7e95efcfb
commit e7c248ea30
No known key found for this signature in database
GPG key ID: 7A0E81F405F35D6A
2 changed files with 11 additions and 102 deletions

View file

@ -28,6 +28,7 @@
#include "calls-call-selector-item.h"
#include "calls-new-call-box.h"
#include "calls-history-box.h"
#include "calls-in-app-notification.h"
#include "calls-enumerate.h"
#include "config.h"
#include "util.h"
@ -47,10 +48,7 @@ struct _CallsMainWindow
GListModel *record_store;
CallsContacts *contacts;
GtkRevealer *info_revealer;
guint info_timeout;
GtkInfoBar *info;
GtkLabel *info_label;
CallsInAppNotification *in_app_notification;
HdySqueezer *squeezer;
GtkLabel *title_label;
@ -124,58 +122,20 @@ static const GActionEntry window_entries [] =
};
static gboolean
show_message_timeout_cb (CallsMainWindow *self)
{
gtk_revealer_set_reveal_child (self->info_revealer, FALSE);
self->info_timeout = 0;
return FALSE;
}
static void
show_message (CallsMainWindow *self, const gchar *text, GtkMessageType type)
call_message_cb (CallsMainWindow *self, const gchar *reason)
{
gtk_info_bar_set_message_type (self->info, type);
gtk_label_set_text (self->info_label, text);
gtk_revealer_set_reveal_child (self->info_revealer, TRUE);
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
if (self->info_timeout)
{
g_source_remove (self->info_timeout);
}
self->info_timeout = g_timeout_add_seconds
(3,
(GSourceFunc)show_message_timeout_cb,
self);
calls_in_app_notification_show (self->in_app_notification, reason);
}
static inline void
stop_info_timeout (CallsMainWindow *self)
{
if (self->info_timeout)
{
g_source_remove (self->info_timeout);
self->info_timeout = 0;
}
}
static void
info_response_cb (GtkInfoBar *infobar,
gint response_id,
CallsMainWindow *self)
{
stop_info_timeout (self);
gtk_revealer_set_reveal_child (self->info_revealer, FALSE);
}
static void
call_removed_cb (CallsMainWindow *self, CallsCall *call, const gchar *reason)
{
show_message(self, reason, GTK_MESSAGE_INFO);
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
calls_in_app_notification_show (self->in_app_notification, reason);
}
@ -239,7 +199,7 @@ set_up_provider (CallsMainWindow *self)
for (i = 0; i < 3; ++i)
{
calls_enumerate_params_add
(params, msg_obj_types[i], "message", G_CALLBACK (show_message));
(params, msg_obj_types[i], "message", G_CALLBACK (call_message_cb));
}
calls_enumerate_params_add
@ -318,7 +278,6 @@ dispose (GObject *object)
{
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
stop_info_timeout (self);
g_clear_object (&self->contacts);
g_clear_object (&self->record_store);
g_clear_object (&self->provider);
@ -381,16 +340,13 @@ calls_main_window_class_init (CallsMainWindowClass *klass)
widget_class->size_allocate = size_allocate;
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/main-window.ui");
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, info_revealer);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, info);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, info_label);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, in_app_notification);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, squeezer);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, title_label);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, wide_switcher);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, narrow_switcher);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, switcher_bar);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, main_stack);
gtk_widget_class_bind_template_callback (widget_class, info_response_cb);
}

View file

@ -14,56 +14,9 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child type="overlay">
<object class="GtkRevealer" id="info_revealer">
<object class="CallsInAppNotification" id="in_app_notification">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="reveal-child">False</property>
<property name="transition-type">slide-down</property>
<child>
<object class="GtkInfoBar" id="info">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<signal name="response" handler="info_response_cb" swapped="no"/>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="info_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>