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 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 22 | // Gtk |
| 23 | #include <clutter-gtk/clutter-gtk.h> |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 24 | #include <gtk/gtk.h> |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 25 | #include <glib/gi18n.h> |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 26 | |
| 27 | // Lrc |
Stepan Salenikovich | f6f4265 | 2015-07-15 12:46:14 -0400 | [diff] [blame] | 28 | #include <account.h> |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 29 | #include <api/conversationmodel.h> |
| 30 | #include <api/contact.h> |
| 31 | #include <api/contactmodel.h> |
| 32 | #include <api/newcallmodel.h> |
| 33 | #include <codecmodel.h> |
| 34 | #include <globalinstances.h> |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 35 | #include <smartinfohub.h> |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 36 | #include <video/previewmanager.h> |
| 37 | |
| 38 | // Client |
| 39 | #include "chatview.h" |
| 40 | #include "native/pixbufmanipulator.h" |
| 41 | #include "ringnotify.h" |
| 42 | #include "utils/drawing.h" |
| 43 | #include "utils/files.h" |
| 44 | #include "video/video_widget.h" |
| 45 | |
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; |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 83 | GtkWidget *togglebutton_record; |
Stepan Salenikovich | 77baa52 | 2015-07-07 15:29:14 -0400 | [diff] [blame] | 84 | GtkWidget *button_hangup; |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 85 | GtkWidget *scalebutton_quality; |
| 86 | GtkWidget *checkbutton_autoquality; |
Sébastien Blin | 366243f | 2017-11-03 14:14:54 -0400 | [diff] [blame] | 87 | GtkWidget *chat_view; |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 88 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 89 | /* The webkit_chat_container is created once, then reused for all chat |
| 90 | * views */ |
| 91 | GtkWidget *webkit_chat_container; |
| 92 | |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 93 | /* flag used to keep track of the video quality scale pressed state; |
| 94 | * we do not want to update the codec bitrate until the user releases the |
| 95 | * scale button */ |
| 96 | gboolean quality_scale_pressed; |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 97 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 98 | lrc::api::conversation::Info* conversation_; |
| 99 | AccountContainer* accountContainer_; |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 100 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 101 | QMetaObject::Connection state_change_connection; |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 102 | QMetaObject::Connection local_renderer_connection; |
| 103 | QMetaObject::Connection remote_renderer_connection; |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 104 | QMetaObject::Connection new_message_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); |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 142 | QObject::disconnect(priv->local_renderer_connection); |
| 143 | QObject::disconnect(priv->remote_renderer_connection); |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 144 | QObject::disconnect(priv->smartinfo_refresh_connection); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 145 | QObject::disconnect(priv->new_message_connection); |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 146 | g_clear_object(&priv->settings); |
| 147 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 148 | g_source_remove(priv->timer_fade); |
| 149 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 150 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo"); |
| 151 | g_signal_handler_disconnect(display_smartinfo, priv->smartinfo_action); |
| 152 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 153 | G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object); |
| 154 | } |
| 155 | |
| 156 | static void |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 157 | show_chat_view(CurrentCallView *self) |
| 158 | { |
| 159 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 160 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 161 | |
| 162 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE); |
| 163 | } |
| 164 | |
| 165 | static void |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 166 | chat_toggled(GtkToggleButton *togglebutton, CurrentCallView *self) |
| 167 | { |
| 168 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 169 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 170 | |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 171 | if (gtk_toggle_button_get_active(togglebutton)) { |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 172 | gtk_widget_show_all(priv->frame_chat); |
| 173 | gtk_widget_grab_focus(priv->frame_chat); |
Stepan Salenikovich | a5129f6 | 2015-11-05 15:10:59 -0500 | [diff] [blame] | 174 | } else { |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 175 | gtk_widget_hide(priv->frame_chat); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 176 | } |
| 177 | } |
| 178 | |
Stepan Salenikovich | daf3cb3 | 2016-10-12 16:39:42 -0400 | [diff] [blame] | 179 | static gboolean |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 180 | map_boolean_to_orientation(GValue *value, GVariant *variant, G_GNUC_UNUSED gpointer user_data) |
| 181 | { |
| 182 | if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) { |
| 183 | if (g_variant_get_boolean(variant)) { |
| 184 | // true, chat should be horizontal (to the right) |
| 185 | g_value_set_enum(value, GTK_ORIENTATION_HORIZONTAL); |
| 186 | } else { |
| 187 | // false, chat should be vertical (at the bottom) |
| 188 | g_value_set_enum(value, GTK_ORIENTATION_VERTICAL); |
| 189 | } |
| 190 | return TRUE; |
| 191 | } |
| 192 | return FALSE; |
| 193 | } |
| 194 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 195 | static void |
| 196 | update_details(CurrentCallView *view) |
| 197 | { |
| 198 | auto *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 199 | auto callRendered = priv->conversation_->callId; |
| 200 | |
| 201 | if (!priv->conversation_->confId.empty()) |
| 202 | callRendered = priv->conversation_->confId; |
| 203 | |
| 204 | gtk_label_set_text(GTK_LABEL(priv->label_duration), |
| 205 | priv->accountContainer_->info.callModel->getFormattedCallDuration(callRendered).c_str()); |
| 206 | |
| 207 | auto call = priv->accountContainer_->info.callModel->getCall(callRendered); |
| 208 | gtk_widget_set_sensitive(GTK_WIDGET(priv->togglebutton_muteaudio), (call.type != lrc::api::call::Type::CONFERENCE)); |
| 209 | gtk_widget_set_sensitive(GTK_WIDGET(priv->togglebutton_mutevideo), (call.type != lrc::api::call::Type::CONFERENCE)); |
| 210 | } |
| 211 | |
| 212 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 213 | static gboolean |
| 214 | timeout_check_last_motion_event(CurrentCallView *self) |
| 215 | { |
| 216 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), G_SOURCE_REMOVE); |
| 217 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 218 | |
| 219 | auto current_time = g_get_monotonic_time(); |
| 220 | if (current_time - priv->time_last_mouse_motion >= CONTROLS_FADE_TIMEOUT) { |
| 221 | // timeout has passed, hide the controls |
| 222 | if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->fade_info)) == CLUTTER_TIMELINE_BACKWARD) { |
| 223 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_FORWARD); |
| 224 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_FORWARD); |
| 225 | if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->fade_info))) { |
| 226 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_info)); |
| 227 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_controls)); |
| 228 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_info)); |
| 229 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_controls)); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 234 | update_details(self); |
| 235 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 236 | return G_SOURCE_CONTINUE; |
| 237 | } |
| 238 | |
| 239 | static gboolean |
| 240 | mouse_moved(CurrentCallView *self) |
| 241 | { |
| 242 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 243 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 244 | |
| 245 | priv->time_last_mouse_motion = g_get_monotonic_time(); |
| 246 | |
| 247 | // since the mouse moved, make sure the controls are shown |
| 248 | if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->fade_info)) == CLUTTER_TIMELINE_FORWARD) { |
| 249 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_BACKWARD); |
| 250 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_BACKWARD); |
| 251 | if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->fade_info))) { |
| 252 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_info)); |
| 253 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_controls)); |
| 254 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_info)); |
| 255 | clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_controls)); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | return FALSE; // propogate event |
| 260 | } |
| 261 | |
| 262 | static ClutterTransition * |
| 263 | create_fade_out_transition() |
| 264 | { |
| 265 | auto transition = clutter_property_transition_new("opacity"); |
| 266 | clutter_transition_set_from(transition, G_TYPE_UINT, 255); |
| 267 | clutter_transition_set_to(transition, G_TYPE_UINT, 0); |
| 268 | clutter_timeline_set_duration(CLUTTER_TIMELINE(transition), FADE_DURATION); |
| 269 | clutter_timeline_set_repeat_count(CLUTTER_TIMELINE(transition), 0); |
| 270 | clutter_timeline_set_progress_mode(CLUTTER_TIMELINE(transition), CLUTTER_EASE_IN_OUT_CUBIC); |
| 271 | return transition; |
| 272 | } |
| 273 | |
Stepan Salenikovich | 5ed1b49 | 2015-11-13 14:03:31 -0500 | [diff] [blame] | 274 | static gboolean |
| 275 | video_widget_focus(GtkWidget *widget, GtkDirectionType direction, CurrentCallView *self) |
| 276 | { |
| 277 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 278 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 279 | |
| 280 | // if this widget already has focus, we want the focus to move to the next widget, otherwise we |
| 281 | // will get stuck in a focus loop on the buttons |
| 282 | if (gtk_widget_has_focus(widget)) |
| 283 | return FALSE; |
| 284 | |
| 285 | // otherwise we want the focus to go to and change between the call control buttons |
| 286 | if (gtk_widget_child_focus(GTK_WIDGET(priv->hbox_call_controls), direction)) { |
| 287 | // selected a child, make sure call controls are shown |
| 288 | mouse_moved(self); |
| 289 | return TRUE; |
| 290 | } |
| 291 | |
| 292 | // did not select the next child, propogate the event |
| 293 | return FALSE; |
| 294 | } |
| 295 | |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 296 | static GtkBox * |
| 297 | gtk_scale_button_get_box(GtkScaleButton *button) |
| 298 | { |
| 299 | GtkWidget *box = NULL; |
| 300 | if (auto dock = gtk_scale_button_get_popup(button)) { |
| 301 | // the dock is a popover which contains the box |
| 302 | box = gtk_bin_get_child(GTK_BIN(dock)); |
| 303 | if (box) { |
| 304 | if (GTK_IS_FRAME(box)) { |
| 305 | // support older versions of gtk; the box used to be in a frame |
| 306 | box = gtk_bin_get_child(GTK_BIN(box)); |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | return GTK_BOX(box); |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * This gets the GtkScaleButtonScale widget (which is a GtkScale) from the |
| 316 | * given GtkScaleButton in order to be able to modify its properties and connect |
| 317 | * to its signals |
| 318 | */ |
| 319 | static GtkScale * |
| 320 | gtk_scale_button_get_scale(GtkScaleButton *button) |
| 321 | { |
| 322 | GtkScale *scale = NULL; |
| 323 | |
| 324 | if (auto box = gtk_scale_button_get_box(button)) { |
| 325 | GList *children = gtk_container_get_children(GTK_CONTAINER(box)); |
| 326 | for (GList *c = children; c && !scale; c = c->next) { |
| 327 | if (GTK_IS_SCALE(c->data)) |
| 328 | scale = GTK_SCALE(c->data); |
| 329 | } |
| 330 | g_list_free(children); |
| 331 | } |
| 332 | |
| 333 | return scale; |
| 334 | } |
| 335 | |
| 336 | static void |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 337 | autoquality_toggled(GtkToggleButton *button, CurrentCallView *self) |
| 338 | { |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 339 | // TODO |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 340 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 341 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 342 | |
| 343 | gboolean auto_quality_on = gtk_toggle_button_get_active(button); |
| 344 | |
| 345 | auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 346 | auto plus_button = gtk_scale_button_get_plus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 347 | auto minus_button = gtk_scale_button_get_minus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 348 | |
| 349 | gtk_widget_set_sensitive(GTK_WIDGET(scale), !auto_quality_on); |
| 350 | gtk_widget_set_sensitive(plus_button, !auto_quality_on); |
| 351 | gtk_widget_set_sensitive(minus_button, !auto_quality_on); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | static void |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 355 | quality_changed(G_GNUC_UNUSED GtkScaleButton *button, G_GNUC_UNUSED gdouble value, CurrentCallView *self) |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 356 | { |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 357 | // TODO |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 358 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 359 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 360 | |
| 361 | /* no need to upate quality if auto quality is enabled */ |
| 362 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality))) return; |
| 363 | |
| 364 | /* only update if the scale button is released, to reduce the number of updates */ |
| 365 | if (priv->quality_scale_pressed) return; |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | static gboolean |
| 369 | quality_button_pressed(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, CurrentCallView *self) |
| 370 | { |
| 371 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 372 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 373 | priv->quality_scale_pressed = TRUE; |
| 374 | |
| 375 | return GDK_EVENT_PROPAGATE; |
| 376 | } |
| 377 | |
| 378 | static gboolean |
| 379 | quality_button_released(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, CurrentCallView *self) |
| 380 | { |
| 381 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 382 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 383 | priv->quality_scale_pressed = FALSE; |
| 384 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 385 | // now make sure the quality gets updated |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 386 | quality_changed(GTK_SCALE_BUTTON(priv->scalebutton_quality), 0, self); |
| 387 | |
| 388 | return GDK_EVENT_PROPAGATE; |
| 389 | } |
| 390 | |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 391 | static void |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 392 | button_hangup_clicked(CurrentCallView *view) |
| 393 | { |
| 394 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 395 | auto callToHangUp = priv->conversation_->callId; |
| 396 | if (!priv->conversation_->confId.empty()) |
| 397 | callToHangUp = priv->conversation_->confId; |
| 398 | priv->accountContainer_->info.callModel->hangUp(callToHangUp); |
| 399 | } |
| 400 | |
| 401 | static void |
| 402 | togglebutton_hold_clicked(CurrentCallView *view) |
| 403 | { |
| 404 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 405 | auto callToHold = priv->conversation_->callId; |
| 406 | if (!priv->conversation_->confId.empty()) |
| 407 | callToHold = priv->conversation_->confId; |
| 408 | priv->accountContainer_->info.callModel->togglePause(callToHold); |
| 409 | } |
| 410 | |
| 411 | static void |
| 412 | togglebutton_record_clicked(CurrentCallView *view) |
| 413 | { |
| 414 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 415 | auto callToRecord = priv->conversation_->callId; |
| 416 | if (!priv->conversation_->confId.empty()) |
| 417 | callToRecord = priv->conversation_->confId; |
| 418 | priv->accountContainer_->info.callModel->toggleAudioRecord(callToRecord); |
| 419 | } |
| 420 | |
| 421 | static void |
| 422 | togglebutton_muteaudio_clicked(CurrentCallView *view) |
| 423 | { |
| 424 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 425 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 426 | auto callToMute = priv->conversation_->callId; |
| 427 | if (!priv->conversation_->confId.empty()) |
| 428 | callToMute = priv->conversation_->confId; |
| 429 | auto muteAudioBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio); |
| 430 | priv->accountContainer_->info.callModel->toggleMedia(callToMute, |
Sébastien Blin | 1ffd472 | 2017-11-06 15:38:08 -0500 | [diff] [blame] | 431 | lrc::api::NewCallModel::Media::AUDIO); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 432 | |
| 433 | auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio); |
| 434 | auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio"); |
| 435 | if (gtk_toggle_button_get_active(togglebutton)) |
| 436 | image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio"); |
| 437 | gtk_button_set_image(GTK_BUTTON(togglebutton), image); |
| 438 | } |
| 439 | |
| 440 | static void |
| 441 | togglebutton_mutevideo_clicked(CurrentCallView *view) |
| 442 | { |
| 443 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 444 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 445 | auto callToMute = priv->conversation_->callId; |
| 446 | if (!priv->conversation_->confId.empty()) |
| 447 | callToMute = priv->conversation_->confId; |
| 448 | auto muteVideoBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo); |
| 449 | priv->accountContainer_->info.callModel->toggleMedia(callToMute, |
Sébastien Blin | 1ffd472 | 2017-11-06 15:38:08 -0500 | [diff] [blame] | 450 | lrc::api::NewCallModel::Media::VIDEO); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 451 | |
| 452 | auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo); |
| 453 | auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video"); |
| 454 | if (gtk_toggle_button_get_active(togglebutton)) |
| 455 | image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video"); |
| 456 | gtk_button_set_image(GTK_BUTTON(togglebutton), image); |
| 457 | } |
| 458 | |
| 459 | static void |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 460 | insert_controls(CurrentCallView *view) |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 461 | { |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 462 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 463 | |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 464 | /* only add the controls once */ |
| 465 | g_signal_handler_disconnect(view, priv->insert_controls_id); |
| 466 | priv->insert_controls_id = 0; |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 467 | |
| 468 | auto stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->video_widget)); |
| 469 | auto actor_info = gtk_clutter_actor_new_with_contents(priv->hbox_call_info); |
| 470 | 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] | 471 | 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] | 472 | |
| 473 | clutter_actor_add_child(stage, actor_info); |
| 474 | clutter_actor_set_x_align(actor_info, CLUTTER_ACTOR_ALIGN_FILL); |
| 475 | clutter_actor_set_y_align(actor_info, CLUTTER_ACTOR_ALIGN_START); |
| 476 | |
| 477 | clutter_actor_add_child(stage, actor_controls); |
| 478 | clutter_actor_set_x_align(actor_controls, CLUTTER_ACTOR_ALIGN_CENTER); |
| 479 | clutter_actor_set_y_align(actor_controls, CLUTTER_ACTOR_ALIGN_END); |
| 480 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 481 | clutter_actor_add_child(stage, actor_smartInfo); |
| 482 | clutter_actor_set_x_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_END); |
| 483 | clutter_actor_set_y_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_START); |
| 484 | ClutterMargin clutter_margin_smartInfo; |
| 485 | clutter_margin_smartInfo.top = 50; |
| 486 | clutter_margin_smartInfo.right = 10; |
philippegorley | a733794 | 2017-07-04 15:29:42 -0400 | [diff] [blame] | 487 | clutter_margin_smartInfo.left = 10; |
| 488 | clutter_margin_smartInfo.bottom = 10; |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 489 | clutter_actor_set_margin (actor_smartInfo, &clutter_margin_smartInfo); |
| 490 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 491 | /* add fade in and out states to the info and controls */ |
| 492 | priv->time_last_mouse_motion = g_get_monotonic_time(); |
| 493 | priv->fade_info = create_fade_out_transition(); |
| 494 | priv->fade_controls = create_fade_out_transition(); |
| 495 | clutter_actor_add_transition(actor_info, "fade_info", priv->fade_info); |
| 496 | clutter_actor_add_transition(actor_controls, "fade_controls", priv->fade_controls); |
| 497 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_BACKWARD); |
| 498 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_BACKWARD); |
| 499 | clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_info)); |
| 500 | clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_controls)); |
| 501 | |
| 502 | /* have a timer check every 1 second if the controls should fade out */ |
| 503 | priv->timer_fade = g_timeout_add(1000, (GSourceFunc)timeout_check_last_motion_event, view); |
| 504 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 505 | /* connect the controllers (new model) */ |
| 506 | g_signal_connect_swapped(priv->button_hangup, "clicked", G_CALLBACK(button_hangup_clicked), view); |
| 507 | g_signal_connect_swapped(priv->togglebutton_hold, "clicked", G_CALLBACK(togglebutton_hold_clicked), view); |
| 508 | g_signal_connect_swapped(priv->togglebutton_muteaudio, "clicked", G_CALLBACK(togglebutton_muteaudio_clicked), view); |
| 509 | g_signal_connect_swapped(priv->togglebutton_record, "clicked", G_CALLBACK(togglebutton_record_clicked), view); |
| 510 | g_signal_connect_swapped(priv->togglebutton_mutevideo, "clicked", G_CALLBACK(togglebutton_mutevideo_clicked), view); |
| 511 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 512 | /* connect to the mouse motion event to reset the last moved time */ |
| 513 | g_signal_connect_swapped(priv->video_widget, "motion-notify-event", G_CALLBACK(mouse_moved), view); |
| 514 | g_signal_connect_swapped(priv->video_widget, "button-press-event", G_CALLBACK(mouse_moved), view); |
| 515 | g_signal_connect_swapped(priv->video_widget, "button-release-event", G_CALLBACK(mouse_moved), view); |
| 516 | |
Stepan Salenikovich | 5ed1b49 | 2015-11-13 14:03:31 -0500 | [diff] [blame] | 517 | /* manually handle the focus of the video widget to be able to focus on the call controls */ |
| 518 | g_signal_connect(priv->video_widget, "focus", G_CALLBACK(video_widget_focus), view); |
| 519 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 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); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 523 | |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 524 | /* bind the chat orientation to the gsetting */ |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 525 | priv->settings = g_settings_new_full(get_ring_schema(), NULL, NULL); |
| 526 | g_settings_bind_with_mapping(priv->settings, "chat-pane-horizontal", |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 527 | priv->paned_call, "orientation", |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 528 | G_SETTINGS_BIND_GET, |
| 529 | map_boolean_to_orientation, |
| 530 | nullptr, nullptr, nullptr); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 531 | |
| 532 | g_signal_connect(priv->scalebutton_quality, "value-changed", G_CALLBACK(quality_changed), view); |
| 533 | /* customize the quality button scale */ |
| 534 | if (auto scale_box = gtk_scale_button_get_box(GTK_SCALE_BUTTON(priv->scalebutton_quality))) { |
| 535 | priv->checkbutton_autoquality = gtk_check_button_new_with_label(C_("Enable automatic video quality", "Auto")); |
| 536 | gtk_widget_show(priv->checkbutton_autoquality); |
| 537 | gtk_box_pack_start(GTK_BOX(scale_box), priv->checkbutton_autoquality, FALSE, TRUE, 0); |
| 538 | g_signal_connect(priv->checkbutton_autoquality, "toggled", G_CALLBACK(autoquality_toggled), view); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 539 | } |
| 540 | if (auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality))) { |
| 541 | g_signal_connect(scale, "button-press-event", G_CALLBACK(quality_button_pressed), view); |
| 542 | g_signal_connect(scale, "button-release-event", G_CALLBACK(quality_button_released), view); |
| 543 | } |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 544 | |
Sébastien Blin | 4514eeb | 2017-07-25 14:17:01 -0400 | [diff] [blame] | 545 | // Get if the user wants to show the smartInfo box |
| 546 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo"); |
| 547 | if (g_variant_get_boolean(g_action_get_state(G_ACTION(display_smartinfo)))) { |
| 548 | gtk_widget_show(priv->vbox_call_smartInfo); |
| 549 | } else { |
| 550 | gtk_widget_hide(priv->vbox_call_smartInfo); |
| 551 | } |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | static void |
| 555 | current_call_view_init(CurrentCallView *view) |
| 556 | { |
| 557 | gtk_widget_init_template(GTK_WIDGET(view)); |
| 558 | |
| 559 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 560 | |
| 561 | // CSS styles |
| 562 | auto provider = gtk_css_provider_new(); |
| 563 | gtk_css_provider_load_from_data(provider, |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 564 | ".smartinfo-block-style { color: #8ae234; background-color: rgba(1, 1, 1, 0.33); } \ |
| 565 | @keyframes blink { 0% {opacity: 1;} 49% {opacity: 1;} 50% {opacity: 0;} 100% {opacity: 0;} } \ |
| 566 | .record-button { background: rgba(0, 0, 0, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 567 | .record-button:checked { animation: blink 1s; animation-iteration-count: infinite; } \ |
| 568 | .call-button { background: rgba(0, 0, 0, 0); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 569 | .call-button:hover { background: rgba(200, 200, 200, 0.15); } \ |
| 570 | .call-button:disabled { opacity: 0.2; } \ |
| 571 | .can-be-disabled:checked { background: rgba(219, 58, 55, 1); } \ |
| 572 | .hangup-button-style { background: rgba(219, 58, 55, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 573 | .hangup-button-style:hover { background: rgba(219, 39, 25, 1); }", |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 574 | -1, nullptr |
| 575 | ); |
| 576 | gtk_style_context_add_provider_for_screen(gdk_display_get_default_screen(gdk_display_get_default()), |
| 577 | GTK_STYLE_PROVIDER(provider), |
| 578 | GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
| 579 | |
| 580 | priv->video_widget = video_widget_new(); |
| 581 | gtk_container_add(GTK_CONTAINER(priv->frame_video), priv->video_widget); |
| 582 | gtk_widget_show_all(priv->frame_video); |
| 583 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 584 | // add the overlay controls only once the view has been allocated a size to prevent size |
| 585 | // allocation warnings in the log |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 586 | 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] | 587 | } |
| 588 | |
| 589 | static void |
| 590 | current_call_view_class_init(CurrentCallViewClass *klass) |
| 591 | { |
| 592 | G_OBJECT_CLASS(klass)->dispose = current_call_view_dispose; |
| 593 | |
| 594 | gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass), |
| 595 | "/cx/ring/RingGnome/currentcallview.ui"); |
| 596 | |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 597 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_info); |
| 598 | 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] | 599 | 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] | 600 | 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] | 601 | 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] | 602 | 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] | 603 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status); |
| 604 | 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] | 605 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_description); |
| 606 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_value); |
| 607 | 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] | 608 | 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] | 609 | 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] | 610 | 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] | 611 | 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] | 612 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_hold); |
| 613 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_muteaudio); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 614 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_record); |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 615 | 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] | 616 | 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] | 617 | 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] | 618 | |
| 619 | current_call_view_signals[VIDEO_DOUBLE_CLICKED] = g_signal_new ( |
| 620 | "video-double-clicked", |
| 621 | G_TYPE_FROM_CLASS(klass), |
| 622 | (GSignalFlags) (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), |
| 623 | 0, |
| 624 | nullptr, |
| 625 | nullptr, |
| 626 | g_cclosure_marshal_VOID__VOID, |
| 627 | G_TYPE_NONE, 0); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 628 | } |
| 629 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 630 | static void |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 631 | update_state(CurrentCallView *view) |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 632 | { |
| 633 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 634 | if (!priv || !priv->conversation_) return; |
| 635 | auto callId = priv->conversation_->callId; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 636 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 637 | try { |
| 638 | auto call = priv->accountContainer_->info.callModel->getCall(callId); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 639 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 640 | auto pauseBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_hold); |
| 641 | auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/pause"); |
| 642 | if (call.status == lrc::api::call::Status::PAUSED) |
| 643 | image = gtk_image_new_from_resource ("/cx/ring/RingGnome/play"); |
| 644 | gtk_button_set_image(GTK_BUTTON(pauseBtn), image); |
Stepan Salenikovich | 7ec8fe8 | 2015-06-02 18:26:39 -0400 | [diff] [blame] | 645 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 646 | auto audioButton = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio); |
| 647 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio), call.audioMuted); |
| 648 | auto imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio"); |
| 649 | if (call.audioMuted) |
| 650 | imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio"); |
| 651 | gtk_button_set_image(GTK_BUTTON(audioButton), imageMuteAudio); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 652 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 653 | auto videoButton = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo); |
| 654 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo), call.videoMuted); |
| 655 | auto imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video"); |
| 656 | if (call.videoMuted) |
| 657 | imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video"); |
| 658 | gtk_button_set_image(GTK_BUTTON(videoButton), imageMuteVideo); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 659 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 660 | gchar *status = g_strdup_printf("%s", lrc::api::call::to_string(call.status).c_str()); |
| 661 | gtk_label_set_text(GTK_LABEL(priv->label_status), status); |
| 662 | g_free(status); |
| 663 | } catch (std::out_of_range& e) { |
| 664 | g_warning("Can't update state for callId=%s", callId.c_str()); |
| 665 | } |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 666 | } |
| 667 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 668 | static void |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 669 | update_name_and_photo(CurrentCallView *view) |
| 670 | { |
| 671 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 672 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 673 | QVariant var_i = GlobalInstances::pixmapManipulator().conversationPhoto( |
| 674 | *priv->conversation_, |
| 675 | priv->accountContainer_->info, |
| 676 | QSize(60, 60), |
| 677 | false |
| 678 | ); |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 679 | std::shared_ptr<GdkPixbuf> image = var_i.value<std::shared_ptr<GdkPixbuf>>(); |
| 680 | gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_peer), image.get()); |
| 681 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 682 | auto contactInfo = priv->accountContainer_->info.contactModel->getContact(priv->conversation_->participants.front()); |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 683 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 684 | auto name = contactInfo.profileInfo.alias; |
| 685 | gtk_label_set_text(GTK_LABEL(priv->label_name), name.c_str()); |
| 686 | |
| 687 | auto bestId = contactInfo.registeredName; |
| 688 | if (name != bestId) { |
| 689 | gtk_label_set_text(GTK_LABEL(priv->label_bestId), bestId.c_str()); |
Stepan Salenikovich | 46bb157 | 2017-05-19 16:09:43 -0400 | [diff] [blame] | 690 | gtk_widget_show(priv->label_bestId); |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | static void |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 695 | update_smartInfo(CurrentCallView *view) |
| 696 | { |
| 697 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 698 | |
| 699 | if (!SmartInfoHub::instance().isConference()) { |
| 700 | gchar* general_information = g_strdup_printf("Call ID: %s", SmartInfoHub::instance().callID().toStdString().c_str()); |
| 701 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_general_information), general_information); |
| 702 | g_free(general_information); |
| 703 | |
| 704 | gchar* description = g_strdup_printf("You\n" |
| 705 | "Framerate:\n" |
| 706 | "Video codec:\n" |
| 707 | "Audio codec:\n" |
| 708 | "Resolution:\n\n" |
| 709 | "Peer\n" |
| 710 | "Framerate:\n" |
| 711 | "Video codec:\n" |
| 712 | "Audio codec:\n" |
| 713 | "Resolution:"); |
| 714 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_description),description); |
| 715 | g_free(description); |
| 716 | |
| 717 | 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", |
| 718 | (double)SmartInfoHub::instance().localFps(), |
| 719 | SmartInfoHub::instance().localVideoCodec().toStdString().c_str(), |
| 720 | SmartInfoHub::instance().localAudioCodec().toStdString().c_str(), |
| 721 | SmartInfoHub::instance().localWidth(), |
| 722 | SmartInfoHub::instance().localHeight(), |
| 723 | (double)SmartInfoHub::instance().remoteFps(), |
| 724 | SmartInfoHub::instance().remoteVideoCodec().toStdString().c_str(), |
| 725 | SmartInfoHub::instance().remoteAudioCodec().toStdString().c_str(), |
| 726 | SmartInfoHub::instance().remoteWidth(), |
| 727 | SmartInfoHub::instance().remoteHeight()); |
| 728 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_value),value); |
| 729 | g_free(value); |
| 730 | } else { |
| 731 | gchar* general_information = g_strdup_printf("Conference ID: %s", SmartInfoHub::instance().callID().toStdString().c_str()); |
| 732 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_general_information), general_information); |
| 733 | g_free(general_information); |
| 734 | |
| 735 | gchar* description = g_strdup_printf("You\n" |
| 736 | "Framerate:\n" |
| 737 | "Video codec:\n" |
| 738 | "Audio codec:\n" |
| 739 | "Resolution:"); |
| 740 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_description),description); |
| 741 | g_free(description); |
| 742 | |
| 743 | gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d", |
| 744 | (double)SmartInfoHub::instance().localFps(), |
| 745 | SmartInfoHub::instance().localVideoCodec().toStdString().c_str(), |
| 746 | SmartInfoHub::instance().localAudioCodec().toStdString().c_str(), |
| 747 | SmartInfoHub::instance().localWidth(), |
| 748 | SmartInfoHub::instance().localHeight()); |
| 749 | gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_value),value); |
| 750 | g_free(value); |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 755 | static gboolean |
| 756 | on_button_press_in_video_event(GtkWidget *self, GdkEventButton *event, CurrentCallView *view) |
| 757 | { |
| 758 | g_return_val_if_fail(IS_VIDEO_WIDGET(self), FALSE); |
| 759 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 760 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 761 | // on double click |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 762 | if (event->type == GDK_2BUTTON_PRESS) { |
| 763 | g_debug("double click in video"); |
| 764 | g_signal_emit(G_OBJECT(view), current_call_view_signals[VIDEO_DOUBLE_CLICKED], 0); |
| 765 | } |
| 766 | |
| 767 | return GDK_EVENT_PROPAGATE; |
| 768 | } |
| 769 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 770 | static void |
| 771 | toggle_smartinfo(GSimpleAction* action, G_GNUC_UNUSED GVariant* state, GtkWidget* vbox_call_smartInfo) |
| 772 | { |
| 773 | if (g_variant_get_boolean(g_action_get_state(G_ACTION(action)))) { |
| 774 | gtk_widget_show(vbox_call_smartInfo); |
| 775 | } else { |
| 776 | gtk_widget_hide(vbox_call_smartInfo); |
| 777 | } |
| 778 | } |
| 779 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 780 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 781 | static void |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 782 | set_call_info(CurrentCallView *view) { |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 783 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 784 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 785 | // change some things depending on call state |
| 786 | update_state(view); |
| 787 | update_details(view); |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 788 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 789 | // NOTE/TODO we need to rewrite the video_widget file to use the new LRC. |
| 790 | g_signal_connect(priv->video_widget, "button-press-event", G_CALLBACK(video_widget_on_button_press_in_screen_event), nullptr); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 791 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 792 | // check if we already have a renderer |
| 793 | auto callToRender = priv->conversation_->callId; |
| 794 | if (!priv->conversation_->confId.empty()) |
| 795 | callToRender = priv->conversation_->confId; |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 796 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 797 | priv->accountContainer_->info.callModel->getRenderer(callToRender), |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 798 | VIDEO_RENDERER_REMOTE); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 799 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 800 | // local renderer |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 801 | if (Video::PreviewManager::instance().isPreviewing()) |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 802 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 803 | Video::PreviewManager::instance().previewRenderer(), |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 804 | VIDEO_RENDERER_LOCAL); |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 805 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 806 | // callback for local renderer |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 807 | priv->local_renderer_connection = QObject::connect( |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 808 | &Video::PreviewManager::instance(), |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 809 | &Video::PreviewManager::previewStarted, |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 810 | [priv](Video::Renderer *renderer) { |
Stepan Salenikovich | 0f69323 | 2015-04-22 10:45:08 -0400 | [diff] [blame] | 811 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
| 812 | renderer, |
| 813 | VIDEO_RENDERER_LOCAL); |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 814 | } |
| 815 | ); |
Stepan Salenikovich | bfe9ac6 | 2015-03-11 12:49:20 -0400 | [diff] [blame] | 816 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 817 | priv->smartinfo_refresh_connection = QObject::connect( |
| 818 | &SmartInfoHub::instance(), |
| 819 | &SmartInfoHub::changed, |
| 820 | [view, priv]() { update_smartInfo(view); } |
| 821 | ); |
Julien Grossholtz | a0d4f10 | 2015-10-22 14:24:17 -0400 | [diff] [blame] | 822 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 823 | priv->remote_renderer_connection = QObject::connect( |
| 824 | &*priv->accountContainer_->info.callModel, |
| 825 | &lrc::api::NewCallModel::remotePreviewStarted, |
| 826 | [priv](const std::string& callId, Video::Renderer *renderer) { |
| 827 | if (priv->conversation_->callId == callId) { |
| 828 | video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget), |
| 829 | renderer, |
| 830 | VIDEO_RENDERER_REMOTE); |
| 831 | } |
| 832 | } |
| 833 | ); |
Julien Grossholtz | a0d4f10 | 2015-10-22 14:24:17 -0400 | [diff] [blame] | 834 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 835 | priv->state_change_connection = QObject::connect( |
| 836 | &*priv->accountContainer_->info.callModel, |
| 837 | &lrc::api::NewCallModel::callStatusChanged, |
| 838 | [view, priv] (const std::string& callId) { |
| 839 | if (callId == priv->conversation_->callId) { |
| 840 | update_state(view); |
| 841 | update_name_and_photo(view); |
| 842 | } |
| 843 | }); |
| 844 | |
| 845 | priv->new_message_connection = QObject::connect( |
| 846 | &*priv->accountContainer_->info.conversationModel, &lrc::api::ConversationModel::newUnreadMessage, |
| 847 | [priv](const std::string& uid, uint64_t msgId, lrc::api::interaction::Info msg) { |
| 848 | Q_UNUSED(uid) |
| 849 | Q_UNUSED(msgId) |
| 850 | Q_UNUSED(msg) |
| 851 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE); |
| 852 | }); |
| 853 | |
| 854 | |
| 855 | // catch double click to make full screen |
Stepan Salenikovich | bfe9ac6 | 2015-03-11 12:49:20 -0400 | [diff] [blame] | 856 | g_signal_connect(priv->video_widget, "button-press-event", |
| 857 | G_CALLBACK(on_button_press_in_video_event), |
| 858 | view); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 859 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 860 | // handle smartinfo in right click menu |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 861 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo"); |
| 862 | priv->smartinfo_action = g_signal_connect(display_smartinfo, |
| 863 | "notify::state", |
| 864 | G_CALLBACK(toggle_smartinfo), |
| 865 | priv->vbox_call_smartInfo); |
| 866 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 867 | // init chat view |
Sébastien Blin | 366243f | 2017-11-03 14:14:54 -0400 | [diff] [blame] | 868 | priv->chat_view = chat_view_new(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container), priv->accountContainer_, priv->conversation_); |
| 869 | gtk_container_add(GTK_CONTAINER(priv->frame_chat), priv->chat_view); |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 870 | |
Sébastien Blin | 366243f | 2017-11-03 14:14:54 -0400 | [diff] [blame] | 871 | g_signal_connect_swapped(priv->chat_view, "new-interactions-displayed", G_CALLBACK(show_chat_view), view); |
| 872 | chat_view_set_header_visible(CHAT_VIEW(priv->chat_view), FALSE); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 873 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 874 | } |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 875 | |
| 876 | GtkWidget * |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 877 | current_call_view_new(WebKitChatContainer* view, AccountContainer* accountContainer, lrc::api::conversation::Info* conversation) |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 878 | { |
| 879 | auto self = g_object_new(CURRENT_CALL_VIEW_TYPE, NULL); |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 880 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 881 | priv->webkit_chat_container = GTK_WIDGET(view); |
| 882 | priv->conversation_ = conversation; |
| 883 | priv->accountContainer_ = accountContainer; |
| 884 | set_call_info(CURRENT_CALL_VIEW(self)); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 885 | |
| 886 | return GTK_WIDGET(self); |
| 887 | } |
| 888 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 889 | lrc::api::conversation::Info |
| 890 | current_call_view_get_conversation(CurrentCallView *self) |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 891 | { |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 892 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), lrc::api::conversation::Info()); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 893 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 894 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 895 | return *priv->conversation_; |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 896 | } |
Sébastien Blin | 366243f | 2017-11-03 14:14:54 -0400 | [diff] [blame] | 897 | |
| 898 | GtkWidget * |
| 899 | current_call_view_get_chat_view(CurrentCallView *self) |
| 900 | { |
| 901 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), nullptr); |
| 902 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 903 | return priv->chat_view; |
| 904 | } |