mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-06 11:35:32 +00:00
CallWindow: use in-app notification
This commit is contained in:
parent
e7c248ea30
commit
19632e428b
2 changed files with 14 additions and 109 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "calls-call-holder.h"
|
||||
#include "calls-call-selector-item.h"
|
||||
#include "calls-new-call-box.h"
|
||||
#include "calls-in-app-notification.h"
|
||||
#include "calls-enumerate.h"
|
||||
#include "calls-wayland-config.h"
|
||||
#include "util.h"
|
||||
|
@ -51,10 +52,7 @@ struct _CallsCallWindow
|
|||
|
||||
GListStore *call_holders;
|
||||
|
||||
GtkRevealer *info_revealer;
|
||||
guint info_timeout;
|
||||
GtkInfoBar *info;
|
||||
GtkLabel *info_label;
|
||||
CallsInAppNotification *in_app_notification;
|
||||
|
||||
GtkStack *main_stack;
|
||||
GtkStack *header_bar_stack;
|
||||
|
@ -197,56 +195,6 @@ update_visibility (CallsCallWindow *self)
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
show_message_timeout_cb (CallsCallWindow *self)
|
||||
{
|
||||
gtk_revealer_set_reveal_child (self->info_revealer, FALSE);
|
||||
self->info_timeout = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
show_message (CallsCallWindow *self,
|
||||
const gchar *text,
|
||||
GtkMessageType type)
|
||||
{
|
||||
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);
|
||||
|
||||
if (self->info_timeout)
|
||||
{
|
||||
g_source_remove (self->info_timeout);
|
||||
}
|
||||
self->info_timeout = g_timeout_add_seconds
|
||||
(3,
|
||||
(GSourceFunc)show_message_timeout_cb,
|
||||
self);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
stop_info_timeout (CallsCallWindow *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,
|
||||
CallsCallWindow *self)
|
||||
{
|
||||
stop_info_timeout (self);
|
||||
gtk_revealer_set_reveal_child (self->info_revealer, FALSE);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
call_holders_create_widget_cb (CallsCallHolder *holder,
|
||||
CallsCallWindow *self)
|
||||
|
@ -415,7 +363,7 @@ remove_call (CallsCallWindow *self,
|
|||
|
||||
remove_call_holder (self, n_items, position, holder);
|
||||
|
||||
show_message(self, reason, GTK_MESSAGE_INFO);
|
||||
calls_in_app_notification_show (self->in_app_notification, reason);
|
||||
}
|
||||
|
||||
|
||||
|
@ -436,6 +384,14 @@ remove_calls (CallsCallWindow *self)
|
|||
update_visibility (self);
|
||||
}
|
||||
|
||||
static void
|
||||
call_message_cb (CallsCallWindow *self, gchar *reason)
|
||||
{
|
||||
g_return_if_fail (CALLS_IS_CALL_WINDOW (self));
|
||||
|
||||
calls_in_app_notification_show (self->in_app_notification, reason);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_provider (CallsCallWindow *self, CallsProvider *provider)
|
||||
|
@ -450,7 +406,7 @@ set_provider (CallsCallWindow *self, CallsProvider *provider)
|
|||
(params, CALLS_TYPE_ORIGIN, "call-removed", G_CALLBACK (remove_call));
|
||||
|
||||
calls_enumerate_params_add
|
||||
(params, CALLS_TYPE_CALL, "message", G_CALLBACK (show_message));
|
||||
(params, CALLS_TYPE_CALL, "message", G_CALLBACK (call_message_cb));
|
||||
|
||||
calls_enumerate (provider, params);
|
||||
|
||||
|
@ -672,7 +628,6 @@ dispose (GObject *object)
|
|||
}
|
||||
|
||||
g_clear_object (&self->call_holders);
|
||||
stop_info_timeout (self);
|
||||
|
||||
G_OBJECT_CLASS (calls_call_window_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -704,15 +659,12 @@ calls_call_window_class_init (CallsCallWindowClass *klass)
|
|||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/call-window.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, info_revealer);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, info);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, info_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, in_app_notification);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, main_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, header_bar_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, show_calls);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, call_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallWindow, call_selector);
|
||||
gtk_widget_class_bind_template_callback (widget_class, info_response_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, call_selector_child_activated_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, show_calls_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, new_call_submitted_cb);
|
||||
|
|
|
@ -15,56 +15,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>
|
||||
|
|
Loading…
Reference in a new issue