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