Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 1 | /* |
Guillaume Roguez | 2a6150d | 2017-07-19 18:24:47 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015-2017 Savoir-faire Linux Inc. |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 3 | * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include "currentcallview.h" |
| 21 | |
| 22 | #include <gtk/gtk.h> |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 23 | #include <glib/gi18n.h> |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 24 | #include <call.h> |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 25 | #include <callmodel.h> |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 26 | #include "utils/drawing.h" |
| 27 | #include "video/video_widget.h" |
Stepan Salenikovich | 4ac89f1 | 2015-03-10 16:48:47 -0400 | [diff] [blame] | 28 | #include <video/previewmanager.h> |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 29 | #include <contactmethod.h> |
| 30 | #include <person.h> |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 31 | #include <globalinstances.h> |
| 32 | #include "native/pixbufmanipulator.h" |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 33 | #include <media/media.h> |
| 34 | #include <media/text.h> |
| 35 | #include <media/textrecording.h> |
| 36 | #include "models/gtkqtreemodel.h" |
Stepan Salenikovich | 67112d1 | 2015-06-16 16:57:06 -0400 | [diff] [blame] | 37 | #include "ringnotify.h" |
Edric Milaret | 58e7107 | 2016-03-21 12:16:37 -0400 | [diff] [blame] | 38 | #include <codecmodel.h> |
Stepan Salenikovich | f6f4265 | 2015-07-15 12:46:14 -0400 | [diff] [blame] | 39 | #include <account.h> |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 40 | #include "utils/files.h" |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 41 | #include <clutter-gtk/clutter-gtk.h> |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 42 | #include "chatview.h" |
Stepan Salenikovich | 07107e9 | 2016-05-06 10:35:17 -0400 | [diff] [blame] | 43 | #include <itemdataroles.h> |
| 44 | #include <numbercategory.h> |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 45 | #include <smartinfohub.h> |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 46 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 47 | static constexpr int CONTROLS_FADE_TIMEOUT = 3000000; /* microseconds */ |
| 48 | static constexpr int FADE_DURATION = 500; /* miliseconds */ |
| 49 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 50 | struct _CurrentCallView |
| 51 | { |
| 52 | GtkBox parent; |
| 53 | }; |
| 54 | |
| 55 | struct _CurrentCallViewClass |
| 56 | { |
| 57 | GtkBoxClass parent_class; |
| 58 | }; |
| 59 | |
| 60 | typedef struct _CurrentCallViewPrivate CurrentCallViewPrivate; |
| 61 | |
| 62 | struct _CurrentCallViewPrivate |
| 63 | { |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 64 | GtkWidget *hbox_call_info; |
| 65 | GtkWidget *hbox_call_controls; |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 66 | GtkWidget *vbox_call_smartInfo; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 67 | GtkWidget *image_peer; |
Stepan Salenikovich | 07107e9 | 2016-05-06 10:35:17 -0400 | [diff] [blame] | 68 | GtkWidget *label_name; |
Nicolas Jager | 2e467c3 | 2017-01-18 08:52:23 -0500 | [diff] [blame] | 69 | GtkWidget *label_bestId; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 70 | GtkWidget *label_status; |
| 71 | GtkWidget *label_duration; |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 72 | GtkWidget *label_smartinfo_description; |
| 73 | GtkWidget *label_smartinfo_value; |
| 74 | GtkWidget *label_smartinfo_general_information; |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 75 | GtkWidget *paned_call; |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 76 | GtkWidget *frame_video; |
| 77 | GtkWidget *video_widget; |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 78 | GtkWidget *frame_chat; |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 79 | GtkWidget *togglebutton_chat; |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 80 | GtkWidget *togglebutton_muteaudio; |
| 81 | GtkWidget *togglebutton_mutevideo; |
| 82 | GtkWidget *togglebutton_hold; |
Stepan Salenikovich | 77baa52 | 2015-07-07 15:29:14 -0400 | [diff] [blame] | 83 | GtkWidget *button_hangup; |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 84 | GtkWidget *scalebutton_quality; |
| 85 | GtkWidget *checkbutton_autoquality; |
| 86 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 87 | /* The webkit_chat_container is created once, then reused for all chat |
| 88 | * views */ |
| 89 | GtkWidget *webkit_chat_container; |
| 90 | |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 91 | /* flag used to keep track of the video quality scale pressed state; |
| 92 | * we do not want to update the codec bitrate until the user releases the |
| 93 | * scale button */ |
| 94 | gboolean quality_scale_pressed; |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 95 | |
| 96 | Call *call; |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 97 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 98 | QMetaObject::Connection state_change_connection; |
| 99 | QMetaObject::Connection call_details_connection; |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 100 | QMetaObject::Connection cm_changed_connection; |
| 101 | QMetaObject::Connection person_changed_connection; |
| 102 | QMetaObject::Connection cm_person_changed_connection; |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 103 | QMetaObject::Connection local_renderer_connection; |
| 104 | QMetaObject::Connection remote_renderer_connection; |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 105 | |
| 106 | GSettings *settings; |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 107 | |
| 108 | // for clutter animations and to know when to fade in/out the overlays |
| 109 | ClutterTransition *fade_info; |
| 110 | ClutterTransition *fade_controls; |
| 111 | gint64 time_last_mouse_motion; |
| 112 | guint timer_fade; |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 113 | |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 114 | gulong insert_controls_id; |
| 115 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 116 | // smart info |
| 117 | QMetaObject::Connection smartinfo_refresh_connection; |
| 118 | guint smartinfo_action; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX); |
| 122 | |
| 123 | #define CURRENT_CALL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CURRENT_CALL_VIEW_TYPE, CurrentCallViewPrivate)) |
| 124 | |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 125 | enum { |
| 126 | VIDEO_DOUBLE_CLICKED, |
| 127 | LAST_SIGNAL |
| 128 | }; |
| 129 | |
| 130 | static guint current_call_view_signals[LAST_SIGNAL] = { 0 }; |
| 131 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 132 | static void |
| 133 | current_call_view_dispose(GObject *object) |
| 134 | { |
| 135 | CurrentCallView *view; |
| 136 | CurrentCallViewPrivate *priv; |
| 137 | |
| 138 | view = CURRENT_CALL_VIEW(object); |
| 139 | priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 140 | |
| 141 | QObject::disconnect(priv->state_change_connection); |
| 142 | QObject::disconnect(priv->call_details_connection); |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 143 | QObject::disconnect(priv->cm_changed_connection); |
| 144 | QObject::disconnect(priv->person_changed_connection); |
| 145 | QObject::disconnect(priv->cm_person_changed_connection); |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 146 | QObject::disconnect(priv->local_renderer_connection); |
| 147 | QObject::disconnect(priv->remote_renderer_connection); |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 148 | QObject::disconnect(priv->smartinfo_refresh_connection); |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 149 | g_clear_object(&priv->settings); |
| 150 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 151 | g_source_remove(priv->timer_fade); |
| 152 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 153 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo"); |
| 154 | g_signal_handler_disconnect(display_smartinfo, priv->smartinfo_action); |
| 155 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 156 | G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object); |
| 157 | } |
| 158 | |
| 159 | static void |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 160 | show_chat_view(CurrentCallView *self) |
| 161 | { |
| 162 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 163 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 164 | |
| 165 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE); |
| 166 | } |
| 167 | |
| 168 | static void |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 169 | muteaudio_toggled(GtkToggleButton *togglebutton, CurrentCallView *self) |
| 170 | { |
| 171 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 172 | |
| 173 | if (gtk_toggle_button_get_active(togglebutton)) { |
| 174 | auto image_down = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio"); |
| 175 | gtk_button_set_image(GTK_BUTTON(togglebutton), image_down); |
| 176 | } else { |
| 177 | auto image_up = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio"); |
| 178 | gtk_button_set_image(GTK_BUTTON(togglebutton), image_up); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | static void |
| 183 | mutevideo_toggled(GtkToggleButton *togglebutton, CurrentCallView *self) |
| 184 | { |
| 185 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 186 | |
| 187 | if (gtk_toggle_button_get_active(togglebutton)) { |
| 188 | auto image_down = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video"); |
| 189 | gtk_button_set_image(GTK_BUTTON(togglebutton), image_down); |
| 190 | } else { |
| 191 | auto image_up = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video"); |
| 192 | gtk_button_set_image(GTK_BUTTON(togglebutton), image_up); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | static void |
| 197 | hold_toggled(GtkToggleButton *togglebutton, CurrentCallView *self) |
| 198 | { |
| 199 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 200 | |
| 201 | if (gtk_toggle_button_get_active(togglebutton)) { |
| 202 | auto image_down = gtk_image_new_from_resource ("/cx/ring/RingGnome/play"); |
| 203 | gtk_button_set_image(GTK_BUTTON(togglebutton), image_down); |
| 204 | } else { |
| 205 | auto image_up = gtk_image_new_from_resource ("/cx/ring/RingGnome/pause"); |
| 206 | gtk_button_set_image(GTK_BUTTON(togglebutton), image_up); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | static void |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 211 | chat_toggled(GtkToggleButton *togglebutton, CurrentCallView *self) |
| 212 | { |
| 213 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 214 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 215 | |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 216 | if (gtk_toggle_button_get_active(togglebutton)) { |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 217 | gtk_widget_show_all(priv->frame_chat); |
| 218 | gtk_widget_grab_focus(priv->frame_chat); |
Stepan Salenikovich | a5129f6 | 2015-11-05 15:10:59 -0500 | [diff] [blame] | 219 | } else { |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 220 | gtk_widget_hide(priv->frame_chat); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | |
Stepan Salenikovich | daf3cb3 | 2016-10-12 16:39:42 -0400 | [diff] [blame] | 224 | static gboolean |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 225 | map_boolean_to_orientation(GValue *value, GVariant *variant, G_GNUC_UNUSED gpointer user_data) |
| 226 | { |
| 227 | if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) { |
| 228 | if (g_variant_get_boolean(variant)) { |
| 229 | // true, chat should be horizontal (to the right) |
| 230 | g_value_set_enum(value, GTK_ORIENTATION_HORIZONTAL); |
| 231 | } else { |
| 232 | // false, chat should be vertical (at the bottom) |
| 233 | g_value_set_enum(value, GTK_ORIENTATION_VERTICAL); |
| 234 | } |
| 235 | return TRUE; |
| 236 | } |
| 237 | return FALSE; |
| 238 | } |
| 239 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 240 | static gboolean |
| 241 | timeout_check_last_motion_event(CurrentCallView *self) |
| 242 | { |
| 243 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), G_SOURCE_REMOVE); |
| 244 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 245 | |
| 246 | auto current_time = g_get_monotonic_time(); |
| 247 | if (current_time - priv->time_last_mouse_motion >= CONTROLS_FADE_TIMEOUT) { |
| 248 | // timeout has passed, hide the controls |
| 249 | if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->fade_info)) == CLUTTER_TIMELINE_BACKWARD) { |
| 250 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_FORWARD); |
| 251 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_FORWARD); |
| 252 | if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->fade_info))) { |
| 253 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_info)); |
| 254 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_controls)); |
| 255 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_info)); |
| 256 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_controls)); |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | return G_SOURCE_CONTINUE; |
| 262 | } |
| 263 | |
| 264 | static gboolean |
| 265 | mouse_moved(CurrentCallView *self) |
| 266 | { |
| 267 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 268 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 269 | |
| 270 | priv->time_last_mouse_motion = g_get_monotonic_time(); |
| 271 | |
| 272 | // since the mouse moved, make sure the controls are shown |
| 273 | if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->fade_info)) == CLUTTER_TIMELINE_FORWARD) { |
| 274 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_BACKWARD); |
| 275 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_BACKWARD); |
| 276 | if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->fade_info))) { |
| 277 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_info)); |
| 278 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_controls)); |
| 279 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_info)); |
| 280 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_controls)); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return FALSE; // propogate event |
| 285 | } |
| 286 | |
| 287 | static ClutterTransition * |
| 288 | create_fade_out_transition() |
| 289 | { |
| 290 | auto transition = clutter_property_transition_new("opacity"); |
| 291 | clutter_transition_set_from(transition, G_TYPE_UINT, 255); |
| 292 | clutter_transition_set_to(transition, G_TYPE_UINT, 0); |
| 293 | clutter_timeline_set_duration(CLUTTER_TIMELINE(transition), FADE_DURATION); |
| 294 | clutter_timeline_set_repeat_count(CLUTTER_TIMELINE(transition), 0); |
| 295 | clutter_timeline_set_progress_mode(CLUTTER_TIMELINE(transition), CLUTTER_EASE_IN_OUT_CUBIC); |
| 296 | return transition; |
| 297 | } |
| 298 | |
Stepan Salenikovich | 5ed1b49 | 2015-11-13 14:03:31 -0500 | [diff] [blame] | 299 | static gboolean |
| 300 | video_widget_focus(GtkWidget *widget, GtkDirectionType direction, CurrentCallView *self) |
| 301 | { |
| 302 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 303 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 304 | |
| 305 | // if this widget already has focus, we want the focus to move to the next widget, otherwise we |
| 306 | // will get stuck in a focus loop on the buttons |
| 307 | if (gtk_widget_has_focus(widget)) |
| 308 | return FALSE; |
| 309 | |
| 310 | // otherwise we want the focus to go to and change between the call control buttons |
| 311 | if (gtk_widget_child_focus(GTK_WIDGET(priv->hbox_call_controls), direction)) { |
| 312 | // selected a child, make sure call controls are shown |
| 313 | mouse_moved(self); |
| 314 | return TRUE; |
| 315 | } |
| 316 | |
| 317 | // did not select the next child, propogate the event |
| 318 | return FALSE; |
| 319 | } |
| 320 | |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 321 | static GtkBox * |
| 322 | gtk_scale_button_get_box(GtkScaleButton *button) |
| 323 | { |
| 324 | GtkWidget *box = NULL; |
| 325 | if (auto dock = gtk_scale_button_get_popup(button)) { |
| 326 | // the dock is a popover which contains the box |
| 327 | box = gtk_bin_get_child(GTK_BIN(dock)); |
| 328 | if (box) { |
| 329 | if (GTK_IS_FRAME(box)) { |
| 330 | // support older versions of gtk; the box used to be in a frame |
| 331 | box = gtk_bin_get_child(GTK_BIN(box)); |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | return GTK_BOX(box); |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * This gets the GtkScaleButtonScale widget (which is a GtkScale) from the |
| 341 | * given GtkScaleButton in order to be able to modify its properties and connect |
| 342 | * to its signals |
| 343 | */ |
| 344 | static GtkScale * |
| 345 | gtk_scale_button_get_scale(GtkScaleButton *button) |
| 346 | { |
| 347 | GtkScale *scale = NULL; |
| 348 | |
| 349 | if (auto box = gtk_scale_button_get_box(button)) { |
| 350 | GList *children = gtk_container_get_children(GTK_CONTAINER(box)); |
| 351 | for (GList *c = children; c && !scale; c = c->next) { |
| 352 | if (GTK_IS_SCALE(c->data)) |
| 353 | scale = GTK_SCALE(c->data); |
| 354 | } |
| 355 | g_list_free(children); |
| 356 | } |
| 357 | |
| 358 | return scale; |
| 359 | } |
| 360 | |
| 361 | static void |
| 362 | set_quality(Call *call, gboolean auto_quality_on, double desired_quality) |
| 363 | { |
| 364 | /* set auto quality true or false, also set the bitrate and quality values; |
| 365 | * the slider is from 0 to 100, use the min and max vals to scale each value accordingly */ |
| 366 | if (const auto& codecModel = call->account()->codecModel()) { |
| 367 | const auto& videoCodecs = codecModel->videoCodecs(); |
| 368 | |
| 369 | for (int i=0; i < videoCodecs->rowCount();i++) { |
| 370 | const auto& idx = videoCodecs->index(i,0); |
| 371 | |
| 372 | if (auto_quality_on) { |
| 373 | // g_debug("enable auto quality"); |
| 374 | videoCodecs->setData(idx, "true", CodecModel::Role::AUTO_QUALITY_ENABLED); |
| 375 | } else { |
| 376 | auto min_bitrate = idx.data(static_cast<int>(CodecModel::Role::MIN_BITRATE)).toInt(); |
| 377 | auto max_bitrate = idx.data(static_cast<int>(CodecModel::Role::MAX_BITRATE)).toInt(); |
| 378 | auto min_quality = idx.data(static_cast<int>(CodecModel::Role::MIN_QUALITY)).toInt(); |
| 379 | auto max_quality = idx.data(static_cast<int>(CodecModel::Role::MAX_QUALITY)).toInt(); |
| 380 | |
| 381 | // g_debug("bitrate min: %d, max: %d, quality min: %d, max: %d", min_bitrate, max_bitrate, min_quality, max_quality); |
| 382 | |
| 383 | double bitrate; |
| 384 | bitrate = min_bitrate + (double)(max_bitrate - min_bitrate)*(desired_quality/100.0); |
| 385 | if (bitrate < 0) bitrate = 0; |
| 386 | |
| 387 | double quality; |
| 388 | // note: a lower value means higher quality |
| 389 | quality = (double)min_quality - (min_quality - max_quality)*(desired_quality/100.0); |
| 390 | if (quality < 0) quality = 0; |
| 391 | |
| 392 | // g_debug("disable auto quality; %% quality: %d; bitrate: %d; quality: %d", (int)desired_quality, (int)bitrate, (int)quality); |
| 393 | videoCodecs->setData(idx, "false", CodecModel::Role::AUTO_QUALITY_ENABLED); |
| 394 | videoCodecs->setData(idx, QString::number((int)bitrate), CodecModel::Role::BITRATE); |
| 395 | videoCodecs->setData(idx, QString::number((int)quality), CodecModel::Role::QUALITY); |
| 396 | } |
| 397 | } |
| 398 | codecModel << CodecModel::EditAction::SAVE; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | static void |
| 403 | autoquality_toggled(GtkToggleButton *button, CurrentCallView *self) |
| 404 | { |
| 405 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 406 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 407 | |
| 408 | gboolean auto_quality_on = gtk_toggle_button_get_active(button); |
| 409 | |
| 410 | auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 411 | auto plus_button = gtk_scale_button_get_plus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 412 | auto minus_button = gtk_scale_button_get_minus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 413 | |
| 414 | gtk_widget_set_sensitive(GTK_WIDGET(scale), !auto_quality_on); |
| 415 | gtk_widget_set_sensitive(plus_button, !auto_quality_on); |
| 416 | gtk_widget_set_sensitive(minus_button, !auto_quality_on); |
| 417 | |
| 418 | double desired_quality = gtk_scale_button_get_value(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 419 | |
| 420 | if (priv->call) |
| 421 | set_quality(priv->call, auto_quality_on, desired_quality); |
| 422 | } |
| 423 | |
| 424 | static void |
| 425 | quality_changed(GtkScaleButton *button, G_GNUC_UNUSED gdouble value, CurrentCallView *self) |
| 426 | { |
| 427 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 428 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 429 | |
| 430 | /* no need to upate quality if auto quality is enabled */ |
| 431 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality))) return; |
| 432 | |
| 433 | /* only update if the scale button is released, to reduce the number of updates */ |
| 434 | if (priv->quality_scale_pressed) return; |
| 435 | |
| 436 | /* we get the value directly from the widget, in case this function is not |
| 437 | * called from the event */ |
| 438 | if (priv->call) |
| 439 | set_quality(priv->call, FALSE, gtk_scale_button_get_value(button)); |
| 440 | } |
| 441 | |
| 442 | static gboolean |
| 443 | quality_button_pressed(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, CurrentCallView *self) |
| 444 | { |
| 445 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 446 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 447 | |
| 448 | priv->quality_scale_pressed = TRUE; |
| 449 | |
| 450 | return GDK_EVENT_PROPAGATE; |
| 451 | } |
| 452 | |
| 453 | static gboolean |
| 454 | quality_button_released(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, CurrentCallView *self) |
| 455 | { |
| 456 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 457 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 458 | |
| 459 | priv->quality_scale_pressed = FALSE; |
| 460 | |
| 461 | /* now make sure the quality gets updated */ |
| 462 | quality_changed(GTK_SCALE_BUTTON(priv->scalebutton_quality), 0, self); |
| 463 | |
| 464 | return GDK_EVENT_PROPAGATE; |
| 465 | } |
| 466 | |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 467 | static void |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 468 | insert_controls(CurrentCallView *view) |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 469 | { |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 470 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 471 | |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 472 | /* only add the controls once */ |
| 473 | g_signal_handler_disconnect(view, priv->insert_controls_id); |
| 474 | priv->insert_controls_id = 0; |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 475 | |
| 476 | auto stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->video_widget)); |
| 477 | auto actor_info = gtk_clutter_actor_new_with_contents(priv->hbox_call_info); |
| 478 | auto actor_controls = gtk_clutter_actor_new_with_contents(priv->hbox_call_controls); |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 479 | auto actor_smartInfo = gtk_clutter_actor_new_with_contents(priv->vbox_call_smartInfo); |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 480 | |
| 481 | clutter_actor_add_child(stage, actor_info); |
| 482 | clutter_actor_set_x_align(actor_info, CLUTTER_ACTOR_ALIGN_FILL); |
| 483 | clutter_actor_set_y_align(actor_info, CLUTTER_ACTOR_ALIGN_START); |
| 484 | |
| 485 | clutter_actor_add_child(stage, actor_controls); |
| 486 | clutter_actor_set_x_align(actor_controls, CLUTTER_ACTOR_ALIGN_CENTER); |
| 487 | clutter_actor_set_y_align(actor_controls, CLUTTER_ACTOR_ALIGN_END); |
| 488 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 489 | clutter_actor_add_child(stage, actor_smartInfo); |
| 490 | clutter_actor_set_x_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_END); |
| 491 | clutter_actor_set_y_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_START); |
| 492 | ClutterMargin clutter_margin_smartInfo; |
| 493 | clutter_margin_smartInfo.top = 50; |
| 494 | clutter_margin_smartInfo.right = 10; |
philippegorley | a733794 | 2017-07-04 15:29:42 -0400 | [diff] [blame] | 495 | clutter_margin_smartInfo.left = 10; |
| 496 | clutter_margin_smartInfo.bottom = 10; |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 497 | clutter_actor_set_margin (actor_smartInfo, &clutter_margin_smartInfo); |
| 498 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 499 | /* add fade in and out states to the info and controls */ |
| 500 | priv->time_last_mouse_motion = g_get_monotonic_time(); |
| 501 | priv->fade_info = create_fade_out_transition(); |
| 502 | priv->fade_controls = create_fade_out_transition(); |
| 503 | clutter_actor_add_transition(actor_info, "fade_info", priv->fade_info); |
| 504 | clutter_actor_add_transition(actor_controls, "fade_controls", priv->fade_controls); |
| 505 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_BACKWARD); |
| 506 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_BACKWARD); |
| 507 | clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_info)); |
| 508 | clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_controls)); |
| 509 | |
| 510 | /* have a timer check every 1 second if the controls should fade out */ |
| 511 | priv->timer_fade = g_timeout_add(1000, (GSourceFunc)timeout_check_last_motion_event, view); |
| 512 | |
| 513 | /* connect to the mouse motion event to reset the last moved time */ |
| 514 | g_signal_connect_swapped(priv->video_widget, "motion-notify-event", G_CALLBACK(mouse_moved), view); |
| 515 | g_signal_connect_swapped(priv->video_widget, "button-press-event", G_CALLBACK(mouse_moved), view); |
| 516 | g_signal_connect_swapped(priv->video_widget, "button-release-event", G_CALLBACK(mouse_moved), view); |
| 517 | |
Stepan Salenikovich | 5ed1b49 | 2015-11-13 14:03:31 -0500 | [diff] [blame] | 518 | /* manually handle the focus of the video widget to be able to focus on the call controls */ |
| 519 | g_signal_connect(priv->video_widget, "focus", G_CALLBACK(video_widget_focus), view); |
| 520 | |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 521 | /* toggle whether or not the chat is displayed */ |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 522 | g_signal_connect(priv->togglebutton_chat, "toggled", G_CALLBACK(chat_toggled), view); |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 523 | g_signal_connect(priv->togglebutton_hold, "toggled", G_CALLBACK(hold_toggled), view); |
| 524 | g_signal_connect(priv->togglebutton_mutevideo, "toggled", G_CALLBACK(mutevideo_toggled), view); |
| 525 | g_signal_connect(priv->togglebutton_muteaudio, "toggled", G_CALLBACK(muteaudio_toggled), view); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 526 | |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 527 | /* bind the chat orientation to the gsetting */ |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 528 | priv->settings = g_settings_new_full(get_ring_schema(), NULL, NULL); |
| 529 | g_settings_bind_with_mapping(priv->settings, "chat-pane-horizontal", |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 530 | priv->paned_call, "orientation", |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 531 | G_SETTINGS_BIND_GET, |
| 532 | map_boolean_to_orientation, |
| 533 | nullptr, nullptr, nullptr); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 534 | |
| 535 | g_signal_connect(priv->scalebutton_quality, "value-changed", G_CALLBACK(quality_changed), view); |
| 536 | /* customize the quality button scale */ |
| 537 | if (auto scale_box = gtk_scale_button_get_box(GTK_SCALE_BUTTON(priv->scalebutton_quality))) { |
| 538 | priv->checkbutton_autoquality = gtk_check_button_new_with_label(C_("Enable automatic video quality", "Auto")); |
| 539 | gtk_widget_show(priv->checkbutton_autoquality); |
| 540 | gtk_box_pack_start(GTK_BOX(scale_box), priv->checkbutton_autoquality, FALSE, TRUE, 0); |
| 541 | g_signal_connect(priv->checkbutton_autoquality, "toggled", G_CALLBACK(autoquality_toggled), view); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 542 | } |
| 543 | if (auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality))) { |
| 544 | g_signal_connect(scale, "button-press-event", G_CALLBACK(quality_button_pressed), view); |
| 545 | g_signal_connect(scale, "button-release-event", G_CALLBACK(quality_button_released), view); |
| 546 | } |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 547 | |
| 548 | /* by this time we should have the call already set, but we check to make sure */ |
| 549 | if (priv->call) { |
| 550 | /* check if auto quality is enabled or not */ |
| 551 | if (const auto& codecModel = priv->call->account()->codecModel()) { |
| 552 | const auto& videoCodecs = codecModel->videoCodecs(); |
| 553 | if (videoCodecs->rowCount() > 0) { |
| 554 | /* we only need to check the first codec since by default it is ON for all, and the |
| 555 | * gnome client sets its ON or OFF for all codecs as well */ |
| 556 | const auto& idx = videoCodecs->index(0,0); |
| 557 | auto auto_quality_enabled = idx.data(static_cast<int>(CodecModel::Role::AUTO_QUALITY_ENABLED)).toString() == "true"; |
| 558 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality), auto_quality_enabled); |
| 559 | |
| 560 | // TODO: save the manual quality setting in the client and set the slider to that value here; |
| 561 | // the daemon resets the bitrate/quality between each call, and the default may be |
| 562 | // different for each codec, so there is no reason to check it here |
| 563 | } |
| 564 | } |
Guillaume Roguez | 567a97b | 2017-05-23 14:10:05 -0400 | [diff] [blame] | 565 | } else { |
| 566 | /* Auto-quality is off by default */ |
| 567 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality), FALSE); |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 568 | } |
Sébastien Blin | 4514eeb | 2017-07-25 14:17:01 -0400 | [diff] [blame] | 569 | |
| 570 | // Get if the user wants to show the smartInfo box |
| 571 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo"); |
| 572 | if (g_variant_get_boolean(g_action_get_state(G_ACTION(display_smartinfo)))) { |
| 573 | gtk_widget_show(priv->vbox_call_smartInfo); |
| 574 | } else { |
| 575 | gtk_widget_hide(priv->vbox_call_smartInfo); |
| 576 | } |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | static void |
| 580 | current_call_view_init(CurrentCallView *view) |
| 581 | { |
| 582 | gtk_widget_init_template(GTK_WIDGET(view)); |
| 583 | |
| 584 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 585 | |
| 586 | // CSS styles |
| 587 | auto provider = gtk_css_provider_new(); |
| 588 | gtk_css_provider_load_from_data(provider, |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 589 | ".smartinfo-block-style { color: #8ae234; background-color: rgba(1, 1, 1, 0.33); } \ |
| 590 | @keyframes blink { 0% {opacity: 1;} 49% {opacity: 1;} 50% {opacity: 0;} 100% {opacity: 0;} } \ |
| 591 | .record-button { background: rgba(0, 0, 0, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 592 | .record-button:checked { animation: blink 1s; animation-iteration-count: infinite; } \ |
| 593 | .call-button { background: rgba(0, 0, 0, 0); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 594 | .call-button:hover { background: rgba(200, 200, 200, 0.15); } \ |
| 595 | .call-button:disabled { opacity: 0.2; } \ |
| 596 | .can-be-disabled:checked { background: rgba(219, 58, 55, 1); } \ |
| 597 | .hangup-button-style { background: rgba(219, 58, 55, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 598 | .hangup-button-style:hover { background: rgba(219, 39, 25, 1); }", |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 599 | -1, nullptr |
| 600 | ); |
| 601 | gtk_style_context_add_provider_for_screen(gdk_display_get_default_screen(gdk_display_get_default()), |
| 602 | GTK_STYLE_PROVIDER(provider), |
| 603 | GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
| 604 | |
| 605 | priv->video_widget = video_widget_new(); |
| 606 | gtk_container_add(GTK_CONTAINER(priv->frame_video), priv->video_widget); |
| 607 | gtk_widget_show_all(priv->frame_video); |
| 608 | |
| 609 | /* add the overlay controls only once the view has been allocated a size to prevent size |
| 610 | * allocation warnings in the log */ |
| 611 | priv->insert_controls_id = g_signal_connect(view, "size-allocate", G_CALLBACK(insert_controls), nullptr); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | static void |
| 615 | current_call_view_class_init(CurrentCallViewClass *klass) |
| 616 | { |
| 617 | G_OBJECT_CLASS(klass)->dispose = current_call_view_dispose; |
| 618 | |
| 619 | gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass), |
| 620 | "/cx/ring/RingGnome/currentcallview.ui"); |
| 621 | |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 622 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_info); |
| 623 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_controls); |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 624 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, vbox_call_smartInfo); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 625 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, image_peer); |
Stepan Salenikovich | 07107e9 | 2016-05-06 10:35:17 -0400 | [diff] [blame] | 626 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_name); |
Nicolas Jager | 2e467c3 | 2017-01-18 08:52:23 -0500 | [diff] [blame] | 627 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_bestId); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 628 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status); |
| 629 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_duration); |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 630 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_description); |
| 631 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_value); |
| 632 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_general_information); |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 633 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, paned_call); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 634 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_video); |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 635 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_chat); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 636 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_chat); |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 637 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_hold); |
| 638 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_muteaudio); |
| 639 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_mutevideo); |
Stepan Salenikovich | 77baa52 | 2015-07-07 15:29:14 -0400 | [diff] [blame] | 640 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, button_hangup); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 641 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, scalebutton_quality); |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 642 | |
| 643 | current_call_view_signals[VIDEO_DOUBLE_CLICKED] = g_signal_new ( |
| 644 | "video-double-clicked", |
| 645 | G_TYPE_FROM_CLASS(klass), |
| 646 | (GSignalFlags) (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), |
| 647 | 0, |
| 648 | nullptr, |
| 649 | nullptr, |
| 650 | g_cclosure_marshal_VOID__VOID, |
| 651 | G_TYPE_NONE, 0); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 652 | } |
| 653 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 654 | static void |
| 655 | update_state(CurrentCallView *view, Call *call) |
| 656 | { |
| 657 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 658 | |
Stepan Salenikovich | 7ec8fe8 | 2015-06-02 18:26:39 -0400 | [diff] [blame] | 659 | gchar *status = g_strdup_printf("%s", call->toHumanStateName().toUtf8().constData()); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 660 | |
Stepan Salenikovich | 7ec8fe8 | 2015-06-02 18:26:39 -0400 | [diff] [blame] | 661 | gtk_label_set_text(GTK_LABEL(priv->label_status), status); |
| 662 | |
| 663 | g_free(status); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | static void |
| 667 | update_details(CurrentCallView *view, Call *call) |
| 668 | { |
| 669 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 670 | |
| 671 | /* update call duration */ |
| 672 | QByteArray ba_length = call->length().toLocal8Bit(); |
| 673 | gtk_label_set_text(GTK_LABEL(priv->label_duration), ba_length.constData()); |
| 674 | } |
| 675 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 676 | static void |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 677 | update_name_and_photo(CurrentCallView *view) |
| 678 | { |
| 679 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 680 | |
| 681 | /* get call image */ |
| 682 | QVariant var_i = GlobalInstances::pixmapManipulator().callPhoto(priv->call, QSize(60, 60), false); |
| 683 | std::shared_ptr<GdkPixbuf> image = var_i.value<std::shared_ptr<GdkPixbuf>>(); |
| 684 | gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_peer), image.get()); |
| 685 | |
| 686 | /* get name */ |
| 687 | auto name = priv->call->formattedName(); |
| 688 | gtk_label_set_text(GTK_LABEL(priv->label_name), name.toUtf8().constData()); |
| 689 | |
| 690 | /* get contact best id, if different from name */ |
| 691 | auto contactId = priv->call->peerContactMethod()->bestId(); |
| 692 | if (name != contactId) { |
Sébastien Blin | c2d5769 | 2017-07-26 09:39:50 -0400 | [diff] [blame] | 693 | gtk_label_set_text(GTK_LABEL(priv->label_bestId), contactId.toUtf8().constData()); |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 694 | gtk_widget_show(priv->label_bestId); |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | static void |
| 699 | update_person(CurrentCallView *view, Person *new_person) |
| 700 | { |
| 701 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 702 | |
| 703 | update_name_and_photo(view); |
| 704 | |
| 705 | QObject::disconnect(priv->person_changed_connection); |
| 706 | if (new_person) { |
| 707 | priv->person_changed_connection = QObject::connect( |
| 708 | new_person, |
| 709 | &Person::changed, |
| 710 | [view]() { update_name_and_photo(view); } |
| 711 | ); |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | static void |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 716 | update_smartInfo(CurrentCallView *view) |
| 717 | { |
| 718 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 719 | |
| 720 | if (!SmartInfoHub::instance().isConference()) { |
| 721 | gchar* general_information = g_strdup_printf("Call ID: %s", SmartInfoHub::instance().callID().toStdString().c_str()); |
| 722 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_general_information), general_information); |
| 723 | g_free(general_information); |
| 724 | |
| 725 | gchar* description = g_strdup_printf("You\n" |
| 726 | "Framerate:\n" |
| 727 | "Video codec:\n" |
| 728 | "Audio codec:\n" |
| 729 | "Resolution:\n\n" |
| 730 | "Peer\n" |
| 731 | "Framerate:\n" |
| 732 | "Video codec:\n" |
| 733 | "Audio codec:\n" |
| 734 | "Resolution:"); |
| 735 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_description),description); |
| 736 | g_free(description); |
| 737 | |
| 738 | gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d\n\n\n%f\n%s\n%s\n%dx%d", |
| 739 | (double)SmartInfoHub::instance().localFps(), |
| 740 | SmartInfoHub::instance().localVideoCodec().toStdString().c_str(), |
| 741 | SmartInfoHub::instance().localAudioCodec().toStdString().c_str(), |
| 742 | SmartInfoHub::instance().localWidth(), |
| 743 | SmartInfoHub::instance().localHeight(), |
| 744 | (double)SmartInfoHub::instance().remoteFps(), |
| 745 | SmartInfoHub::instance().remoteVideoCodec().toStdString().c_str(), |
| 746 | SmartInfoHub::instance().remoteAudioCodec().toStdString().c_str(), |
| 747 | SmartInfoHub::instance().remoteWidth(), |
| 748 | SmartInfoHub::instance().remoteHeight()); |
| 749 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_value),value); |
| 750 | g_free(value); |
| 751 | } else { |
| 752 | gchar* general_information = g_strdup_printf("Conference ID: %s", SmartInfoHub::instance().callID().toStdString().c_str()); |
| 753 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_general_information), general_information); |
| 754 | g_free(general_information); |
| 755 | |
| 756 | gchar* description = g_strdup_printf("You\n" |
| 757 | "Framerate:\n" |
| 758 | "Video codec:\n" |
| 759 | "Audio codec:\n" |
| 760 | "Resolution:"); |
| 761 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_description),description); |
| 762 | g_free(description); |
| 763 | |
| 764 | gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d", |
| 765 | (double)SmartInfoHub::instance().localFps(), |
| 766 | SmartInfoHub::instance().localVideoCodec().toStdString().c_str(), |
| 767 | SmartInfoHub::instance().localAudioCodec().toStdString().c_str(), |
| 768 | SmartInfoHub::instance().localWidth(), |
| 769 | SmartInfoHub::instance().localHeight()); |
| 770 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_value),value); |
| 771 | g_free(value); |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 776 | static gboolean |
| 777 | on_button_press_in_video_event(GtkWidget *self, GdkEventButton *event, CurrentCallView *view) |
| 778 | { |
| 779 | g_return_val_if_fail(IS_VIDEO_WIDGET(self), FALSE); |
| 780 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 781 | |
| 782 | /* on double click */ |
| 783 | if (event->type == GDK_2BUTTON_PRESS) { |
| 784 | g_debug("double click in video"); |
| 785 | g_signal_emit(G_OBJECT(view), current_call_view_signals[VIDEO_DOUBLE_CLICKED], 0); |
| 786 | } |
| 787 | |
| 788 | return GDK_EVENT_PROPAGATE; |
| 789 | } |
| 790 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 791 | static void |
| 792 | toggle_smartinfo(GSimpleAction* action, G_GNUC_UNUSED GVariant* state, GtkWidget* vbox_call_smartInfo) |
| 793 | { |
| 794 | if (g_variant_get_boolean(g_action_get_state(G_ACTION(action)))) { |
| 795 | gtk_widget_show(vbox_call_smartInfo); |
| 796 | } else { |
| 797 | gtk_widget_hide(vbox_call_smartInfo); |
| 798 | } |
| 799 | } |
| 800 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 801 | static void |
| 802 | set_call_info(CurrentCallView *view, Call *call) { |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 803 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 804 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 805 | priv->call = call; |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 806 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 807 | |
| 808 | /* change some things depending on call state */ |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 809 | update_state(view, priv->call); |
| 810 | update_details(view, priv->call); |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 811 | update_person(view, priv->call->peerContactMethod()->contact()); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 812 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 813 | priv->smartinfo_refresh_connection = QObject::connect( |
| 814 | &SmartInfoHub::instance(), |
| 815 | &SmartInfoHub::changed, |
| 816 | [view, priv]() { update_smartInfo(view); } |
| 817 | ); |
| 818 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 819 | priv->state_change_connection = QObject::connect( |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 820 | priv->call, |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 821 | &Call::stateChanged, |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 822 | [view, priv]() { update_state(view, priv->call); } |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 823 | ); |
| 824 | |
| 825 | priv->call_details_connection = QObject::connect( |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 826 | priv->call, |
Stepan Salenikovich | 6dbaf26 | 2017-05-19 15:42:24 -0400 | [diff] [blame] | 827 | &Call::changed, |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 828 | [view, priv]() { update_details(view, priv->call); } |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 829 | ); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 830 | |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 831 | priv->cm_changed_connection = QObject::connect( |
| 832 | priv->call->peerContactMethod(), |
| 833 | &ContactMethod::changed, |
| 834 | [view]() { update_name_and_photo(view); } |
| 835 | ); |
| 836 | |
| 837 | priv->cm_person_changed_connection = QObject::connect( |
| 838 | priv->call->peerContactMethod(), |
| 839 | &ContactMethod::contactChanged, |
| 840 | [view] (Person* newPerson, Person*) { update_person(view, newPerson); } |
| 841 | ); |
| 842 | |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 843 | /* check if we already have a renderer */ |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 844 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 845 | priv->call->videoRenderer(), |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 846 | VIDEO_RENDERER_REMOTE); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 847 | |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 848 | /* callback for remote renderer */ |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 849 | priv->remote_renderer_connection = QObject::connect( |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 850 | priv->call, |
Stepan Salenikovich | 9c1f668 | 2015-03-09 16:21:28 -0400 | [diff] [blame] | 851 | &Call::videoStarted, |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 852 | [priv](Video::Renderer *renderer) { |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 853 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
| 854 | renderer, |
| 855 | VIDEO_RENDERER_REMOTE); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 856 | } |
| 857 | ); |
Stepan Salenikovich | 4ac89f1 | 2015-03-10 16:48:47 -0400 | [diff] [blame] | 858 | |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 859 | /* local renderer */ |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 860 | if (Video::PreviewManager::instance().isPreviewing()) |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 861 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 862 | Video::PreviewManager::instance().previewRenderer(), |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 863 | VIDEO_RENDERER_LOCAL); |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 864 | |
| 865 | /* callback for local renderer */ |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 866 | priv->local_renderer_connection = QObject::connect( |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 867 | &Video::PreviewManager::instance(), |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 868 | &Video::PreviewManager::previewStarted, |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 869 | [priv](Video::Renderer *renderer) { |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 870 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
| 871 | renderer, |
| 872 | VIDEO_RENDERER_LOCAL); |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 873 | } |
| 874 | ); |
Stepan Salenikovich | bfe9ac6 | 2015-03-11 12:49:20 -0400 | [diff] [blame] | 875 | |
Julien Grossholtz | a0d4f10 | 2015-10-22 14:24:17 -0400 | [diff] [blame] | 876 | /* handle video widget button click event */ |
| 877 | g_signal_connect(priv->video_widget, "button-press-event", G_CALLBACK(video_widget_on_button_press_in_screen_event), priv->call); |
| 878 | |
| 879 | /* handle video widget drag and drop*/ |
| 880 | g_signal_connect(priv->video_widget, "drag-data-received", G_CALLBACK(video_widget_on_drag_data_received), priv->call); |
| 881 | |
Stepan Salenikovich | bfe9ac6 | 2015-03-11 12:49:20 -0400 | [diff] [blame] | 882 | /* catch double click to make full screen */ |
| 883 | g_signal_connect(priv->video_widget, "button-press-event", |
| 884 | G_CALLBACK(on_button_press_in_video_event), |
| 885 | view); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 886 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 887 | /* handle smartinfo in right click menu */ |
| 888 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo"); |
| 889 | priv->smartinfo_action = g_signal_connect(display_smartinfo, |
| 890 | "notify::state", |
| 891 | G_CALLBACK(toggle_smartinfo), |
| 892 | priv->vbox_call_smartInfo); |
| 893 | |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 894 | /* init chat view */ |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 895 | auto chat_view = chat_view_new_call(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container), priv->call); |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 896 | gtk_container_add(GTK_CONTAINER(priv->frame_chat), chat_view); |
| 897 | |
| 898 | /* check if there were any chat notifications and open the chat view if so */ |
Stepan Salenikovich | 26cd160 | 2016-01-20 13:43:17 -0500 | [diff] [blame] | 899 | if (ring_notify_close_chat_notification(priv->call->peerContactMethod())) |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 900 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE); |
| 901 | |
| 902 | /* show chat view on any new incoming messages */ |
| 903 | g_signal_connect_swapped(chat_view, "new-messages-displayed", G_CALLBACK(show_chat_view), view); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 904 | } |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 905 | |
| 906 | GtkWidget * |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 907 | current_call_view_new(Call *call, WebKitChatContainer *webkit_chat_container) |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 908 | { |
| 909 | auto self = g_object_new(CURRENT_CALL_VIEW_TYPE, NULL); |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 910 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 911 | priv->webkit_chat_container = GTK_WIDGET(webkit_chat_container); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 912 | set_call_info(CURRENT_CALL_VIEW(self), call); |
| 913 | |
| 914 | return GTK_WIDGET(self); |
| 915 | } |
| 916 | |
| 917 | Call* |
| 918 | current_call_view_get_call(CurrentCallView *self) |
| 919 | { |
| 920 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), nullptr); |
| 921 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 922 | |
| 923 | return priv->call; |
| 924 | } |