From 7e2a1f376af44f7d86e1aa8d4031f1badb12e2bc Mon Sep 17 00:00:00 2001 From: Adrien Plazas Date: Wed, 1 Aug 2018 12:57:40 +0200 Subject: [PATCH] main-window: Add the 'call-added' and 'call-removed' signals These will be used in the next commit to notify of added and removed, which will be needed to display the calls in a secondary window. --- src/calls-main-window.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/calls-main-window.c b/src/calls-main-window.c index ee1de9a..8bebe25 100644 --- a/src/calls-main-window.c +++ b/src/calls-main-window.c @@ -71,6 +71,14 @@ enum { static GParamSpec *props[PROP_LAST_PROP]; +enum { + SIGNAL_CALL_ADDED, + SIGNAL_CALL_REMOVED, + SIGNAL_LAST_SIGNAL, +}; +static guint signals [SIGNAL_LAST_SIGNAL]; + + CallsMainWindow * calls_main_window_new (GtkApplication *application, CallsProvider *provider) { @@ -262,6 +270,8 @@ add_call (CallsMainWindow *self, CallsCall *call) CallsCallHolder *holder; CallsCallDisplay *display; + g_signal_emit (self, signals[SIGNAL_CALL_ADDED], 0, call); + g_signal_connect_swapped (call, "message", G_CALLBACK (show_message), self); @@ -309,6 +319,8 @@ remove_call (CallsMainWindow *self, CallsCall *call, const gchar *reason) g_return_if_fail (CALLS_IS_MAIN_WINDOW (self)); g_return_if_fail (CALLS_IS_CALL (call)); + g_signal_emit (self, signals[SIGNAL_CALL_REMOVED], 0, call, reason); + found = find_call_holder (self, &n_items, &position, &holder, find_call_holder_by_call, call); g_return_if_fail (found); @@ -566,6 +578,28 @@ calls_main_window_class_init (CallsMainWindowClass *klass) g_object_class_install_properties (object_class, PROP_LAST_PROP, props); + signals[SIGNAL_CALL_ADDED] = + g_signal_new ("call-added", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, + 1, + CALLS_TYPE_CALL); + + signals[SIGNAL_CALL_REMOVED] = + g_signal_new ("call-removed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, + 2, + CALLS_TYPE_CALL, + G_TYPE_STRING); + + 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); gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, info_label);