Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 1 | /* |
Guillaume Roguez | 77c579d | 2018-01-30 15:54:02 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2018 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 |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 28 | #include <api/conversationmodel.h> |
| 29 | #include <api/contact.h> |
| 30 | #include <api/contactmodel.h> |
| 31 | #include <api/newcallmodel.h> |
Sébastien Blin | ceb9863 | 2018-07-23 13:59:18 -0400 | [diff] [blame] | 32 | #include <api/newcodecmodel.h> |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 33 | #include <globalinstances.h> |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 34 | #include <smartinfohub.h> |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 35 | #include <video/previewmanager.h> |
| 36 | |
| 37 | // Client |
| 38 | #include "chatview.h" |
| 39 | #include "native/pixbufmanipulator.h" |
| 40 | #include "ringnotify.h" |
| 41 | #include "utils/drawing.h" |
| 42 | #include "utils/files.h" |
| 43 | #include "video/video_widget.h" |
| 44 | |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 45 | #include <iostream> |
| 46 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 47 | namespace { namespace details |
| 48 | { |
| 49 | class CppImpl; |
| 50 | }} |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 51 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 52 | struct _CurrentCallView |
| 53 | { |
| 54 | GtkBox parent; |
| 55 | }; |
| 56 | |
| 57 | struct _CurrentCallViewClass |
| 58 | { |
| 59 | GtkBoxClass parent_class; |
| 60 | }; |
| 61 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 62 | struct CurrentCallViewPrivate |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 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; |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 82 | GtkWidget *togglebutton_transfer; |
| 83 | GtkWidget* siptransfer_popover; |
| 84 | GtkWidget* siptransfer_filter_entry; |
| 85 | GtkWidget* list_conversations; |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 86 | GtkWidget *togglebutton_hold; |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 87 | GtkWidget *togglebutton_record; |
Stepan Salenikovich | 77baa52 | 2015-07-07 15:29:14 -0400 | [diff] [blame] | 88 | GtkWidget *button_hangup; |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 89 | GtkWidget *scalebutton_quality; |
| 90 | GtkWidget *checkbutton_autoquality; |
Sébastien Blin | 366243f | 2017-11-03 14:14:54 -0400 | [diff] [blame] | 91 | GtkWidget *chat_view; |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 92 | GtkWidget *webkit_chat_container; // The webkit_chat_container is created once, then reused for all chat views |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 93 | |
| 94 | GSettings *settings; |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 95 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 96 | details::CppImpl* cpp; ///< Non-UI and C++ only code |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX); |
| 100 | |
| 101 | #define CURRENT_CALL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CURRENT_CALL_VIEW_TYPE, CurrentCallViewPrivate)) |
| 102 | |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 103 | enum { |
| 104 | VIDEO_DOUBLE_CLICKED, |
| 105 | LAST_SIGNAL |
| 106 | }; |
| 107 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 108 | //============================================================================== |
| 109 | |
| 110 | namespace { namespace details |
| 111 | { |
| 112 | |
| 113 | static constexpr int CONTROLS_FADE_TIMEOUT = 3000000; /* microseconds */ |
| 114 | static constexpr int FADE_DURATION = 500; /* miliseconds */ |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 115 | static guint current_call_view_signals[LAST_SIGNAL] = { 0 }; |
| 116 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 117 | namespace // Helpers |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 118 | { |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 119 | |
Stepan Salenikovich | daf3cb3 | 2016-10-12 16:39:42 -0400 | [diff] [blame] | 120 | static gboolean |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 121 | map_boolean_to_orientation(GValue* value, GVariant* variant, G_GNUC_UNUSED gpointer user_data) |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 122 | { |
| 123 | if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) { |
| 124 | if (g_variant_get_boolean(variant)) { |
| 125 | // true, chat should be horizontal (to the right) |
| 126 | g_value_set_enum(value, GTK_ORIENTATION_HORIZONTAL); |
| 127 | } else { |
| 128 | // false, chat should be vertical (at the bottom) |
| 129 | g_value_set_enum(value, GTK_ORIENTATION_VERTICAL); |
| 130 | } |
| 131 | return TRUE; |
| 132 | } |
| 133 | return FALSE; |
| 134 | } |
| 135 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 136 | static ClutterTransition* |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 137 | create_fade_out_transition() |
| 138 | { |
| 139 | auto transition = clutter_property_transition_new("opacity"); |
| 140 | clutter_transition_set_from(transition, G_TYPE_UINT, 255); |
| 141 | clutter_transition_set_to(transition, G_TYPE_UINT, 0); |
| 142 | clutter_timeline_set_duration(CLUTTER_TIMELINE(transition), FADE_DURATION); |
| 143 | clutter_timeline_set_repeat_count(CLUTTER_TIMELINE(transition), 0); |
| 144 | clutter_timeline_set_progress_mode(CLUTTER_TIMELINE(transition), CLUTTER_EASE_IN_OUT_CUBIC); |
| 145 | return transition; |
| 146 | } |
| 147 | |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 148 | static GtkBox * |
| 149 | gtk_scale_button_get_box(GtkScaleButton *button) |
| 150 | { |
| 151 | GtkWidget *box = NULL; |
| 152 | if (auto dock = gtk_scale_button_get_popup(button)) { |
| 153 | // the dock is a popover which contains the box |
| 154 | box = gtk_bin_get_child(GTK_BIN(dock)); |
| 155 | if (box) { |
| 156 | if (GTK_IS_FRAME(box)) { |
| 157 | // support older versions of gtk; the box used to be in a frame |
| 158 | box = gtk_bin_get_child(GTK_BIN(box)); |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return GTK_BOX(box); |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * This gets the GtkScaleButtonScale widget (which is a GtkScale) from the |
| 168 | * given GtkScaleButton in order to be able to modify its properties and connect |
| 169 | * to its signals |
| 170 | */ |
| 171 | static GtkScale * |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 172 | gtk_scale_button_get_scale(GtkScaleButton* button) |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 173 | { |
| 174 | GtkScale *scale = NULL; |
| 175 | |
| 176 | if (auto box = gtk_scale_button_get_box(button)) { |
| 177 | GList *children = gtk_container_get_children(GTK_CONTAINER(box)); |
| 178 | for (GList *c = children; c && !scale; c = c->next) { |
| 179 | if (GTK_IS_SCALE(c->data)) |
| 180 | scale = GTK_SCALE(c->data); |
| 181 | } |
| 182 | g_list_free(children); |
| 183 | } |
| 184 | |
| 185 | return scale; |
| 186 | } |
| 187 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 188 | } // namespace |
| 189 | |
| 190 | class CppImpl |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 191 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 192 | public: |
| 193 | explicit CppImpl(CurrentCallView& widget); |
| 194 | ~CppImpl(); |
| 195 | |
| 196 | void init(); |
| 197 | void setup(WebKitChatContainer* chat_widget, |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 198 | AccountInfoPointer const & account_info, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 199 | lrc::api::conversation::Info* conversation); |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 200 | void add_transfer_contact(const std::string& uri); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 201 | |
| 202 | void insertControls(); |
| 203 | void checkControlsFading(); |
| 204 | |
| 205 | CurrentCallView* self = nullptr; // The GTK widget itself |
| 206 | CurrentCallViewPrivate* widgets = nullptr; |
| 207 | |
| 208 | lrc::api::conversation::Info* conversation = nullptr; |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 209 | AccountInfoPointer const *accountInfo = nullptr; |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 210 | |
| 211 | QMetaObject::Connection state_change_connection; |
| 212 | QMetaObject::Connection local_renderer_connection; |
| 213 | QMetaObject::Connection remote_renderer_connection; |
| 214 | QMetaObject::Connection new_message_connection; |
| 215 | QMetaObject::Connection smartinfo_refresh_connection; |
| 216 | |
| 217 | // for clutter animations and to know when to fade in/out the overlays |
| 218 | ClutterTransition* fade_info = nullptr; |
| 219 | ClutterTransition* fade_controls = nullptr; |
| 220 | gint64 time_last_mouse_motion = 0; |
| 221 | guint timer_fade = 0; |
| 222 | |
| 223 | /* flag used to keep track of the video quality scale pressed state; |
| 224 | * we do not want to update the codec bitrate until the user releases the |
| 225 | * scale button */ |
| 226 | gboolean quality_scale_pressed = FALSE; |
| 227 | gulong insert_controls_id = 0; |
| 228 | guint smartinfo_action = 0; |
| 229 | |
| 230 | private: |
| 231 | CppImpl() = delete; |
| 232 | CppImpl(const CppImpl&) = delete; |
| 233 | CppImpl& operator=(const CppImpl&) = delete; |
| 234 | |
| 235 | void setCallInfo(); |
| 236 | void updateDetails(); |
| 237 | void updateState(); |
| 238 | void updateNameAndPhoto(); |
| 239 | void updateSmartInfo(); |
| 240 | }; |
| 241 | |
| 242 | inline namespace gtk_callbacks |
| 243 | { |
| 244 | |
| 245 | static void |
Sébastien Blin | ceb9863 | 2018-07-23 13:59:18 -0400 | [diff] [blame] | 246 | set_call_quality(CurrentCallView* view, bool auto_quality_on, double desired_quality) |
| 247 | { |
| 248 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 249 | |
| 250 | auto videoCodecs = (*priv->cpp->accountInfo)->codecModel->getVideoCodecs(); |
| 251 | for (const auto& codec : videoCodecs) { |
| 252 | if (auto_quality_on) { |
| 253 | (*priv->cpp->accountInfo)->codecModel->autoQuality(codec.id, true); |
| 254 | } else { |
| 255 | (*priv->cpp->accountInfo)->codecModel->autoQuality(codec.id, false); |
| 256 | double min_bitrate = 0., max_bitrate = 0., min_quality = 0., max_quality = 0.; |
| 257 | try { |
| 258 | min_bitrate = std::stoi(codec.min_bitrate); |
| 259 | max_bitrate = std::stoi(codec.max_bitrate); |
| 260 | min_quality = std::stoi(codec.min_quality); |
| 261 | max_quality = std::stoi(codec.max_quality); |
| 262 | } catch (...) { |
| 263 | g_error("Cannot convert a codec value to an int, abort"); |
| 264 | break; |
| 265 | } |
| 266 | |
| 267 | double bitrate = min_bitrate + (max_bitrate - min_bitrate)*(desired_quality/100.0); |
| 268 | if (bitrate < 0) bitrate = 0; |
| 269 | (*priv->cpp->accountInfo)->codecModel->bitrate(codec.id, bitrate); |
| 270 | |
| 271 | // note: a lower value means higher quality |
| 272 | double quality = min_quality - (min_quality - max_quality)*(desired_quality/100.0); |
| 273 | if (quality < 0) quality = 0; |
| 274 | (*priv->cpp->accountInfo)->codecModel->quality(codec.id, quality); |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | static void |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 280 | on_new_chat_interactions(CurrentCallView* view) |
| 281 | { |
| 282 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 283 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 284 | |
| 285 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE); |
| 286 | } |
| 287 | |
| 288 | static void |
Sébastien Blin | 31cc01e | 2018-06-08 10:51:03 -0400 | [diff] [blame] | 289 | set_record_animation(CurrentCallViewPrivate* priv) |
| 290 | { |
| 291 | auto callToRender = priv->cpp->conversation->callId; |
| 292 | if (!priv->cpp->conversation->confId.empty()) |
| 293 | callToRender = priv->cpp->conversation->confId; |
Sébastien Blin | 07f844a | 2018-07-12 12:07:39 -0400 | [diff] [blame] | 294 | bool nextStatus = (*priv->cpp->accountInfo)->callModel->isRecording(callToRender); |
| 295 | bool currentStatus = (*priv->cpp->accountInfo)->callModel->isRecording(callToRender); |
| 296 | if (nextStatus != currentStatus) { |
| 297 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_record), |
| 298 | (*priv->cpp->accountInfo)->callModel->isRecording(callToRender)); |
| 299 | } |
Sébastien Blin | 31cc01e | 2018-06-08 10:51:03 -0400 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | static void |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 303 | on_togglebutton_chat_toggled(GtkToggleButton* widget, CurrentCallView* view) |
| 304 | { |
| 305 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 306 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 307 | |
| 308 | if (gtk_toggle_button_get_active(widget)) { |
| 309 | gtk_widget_show_all(priv->frame_chat); |
| 310 | gtk_widget_grab_focus(priv->frame_chat); |
| 311 | } else { |
| 312 | gtk_widget_hide(priv->frame_chat); |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | static gboolean |
| 317 | on_timer_fade_timeout(CurrentCallView* view) |
| 318 | { |
| 319 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), G_SOURCE_REMOVE); |
| 320 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 321 | priv->cpp->checkControlsFading(); |
| 322 | return G_SOURCE_CONTINUE; |
| 323 | } |
| 324 | |
| 325 | static void |
| 326 | on_size_allocate(CurrentCallView* view) |
| 327 | { |
| 328 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 329 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 330 | |
| 331 | priv->cpp->insertControls(); |
| 332 | } |
| 333 | |
| 334 | static void |
| 335 | on_button_hangup_clicked(CurrentCallView* view) |
| 336 | { |
| 337 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 338 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Sébastien Blin | d460d70 | 2018-07-03 10:15:42 -0400 | [diff] [blame] | 339 | (*priv->cpp->accountInfo)->callModel->hangUp(priv->cpp->conversation->callId); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | static void |
| 343 | on_togglebutton_hold_clicked(CurrentCallView* view) |
| 344 | { |
| 345 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 346 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 347 | |
| 348 | auto callToHold = priv->cpp->conversation->callId; |
| 349 | if (!priv->cpp->conversation->confId.empty()) |
| 350 | callToHold = priv->cpp->conversation->confId; |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 351 | (*priv->cpp->accountInfo)->callModel->togglePause(callToHold); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | static void |
| 355 | on_togglebutton_record_clicked(CurrentCallView* view) |
| 356 | { |
| 357 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 358 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 359 | |
| 360 | auto callToRecord = priv->cpp->conversation->callId; |
| 361 | if (!priv->cpp->conversation->confId.empty()) |
| 362 | callToRecord = priv->cpp->conversation->confId; |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 363 | (*priv->cpp->accountInfo)->callModel->toggleAudioRecord(callToRecord); |
Sébastien Blin | 31cc01e | 2018-06-08 10:51:03 -0400 | [diff] [blame] | 364 | |
| 365 | set_record_animation(priv); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | static void |
| 369 | on_togglebutton_muteaudio_clicked(CurrentCallView* view) |
| 370 | { |
| 371 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 372 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 373 | |
| 374 | auto callToMute = priv->cpp->conversation->callId; |
| 375 | if (!priv->cpp->conversation->confId.empty()) |
| 376 | callToMute = priv->cpp->conversation->confId; |
| 377 | //auto muteAudioBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio); |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 378 | (*priv->cpp->accountInfo)->callModel->toggleMedia(callToMute, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 379 | lrc::api::NewCallModel::Media::AUDIO); |
| 380 | |
| 381 | auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio); |
| 382 | auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio"); |
| 383 | if (gtk_toggle_button_get_active(togglebutton)) |
| 384 | image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio"); |
| 385 | gtk_button_set_image(GTK_BUTTON(togglebutton), image); |
| 386 | } |
| 387 | |
| 388 | static void |
| 389 | on_togglebutton_mutevideo_clicked(CurrentCallView* view) |
| 390 | { |
| 391 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 392 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 393 | |
| 394 | auto callToMute = priv->cpp->conversation->callId; |
| 395 | if (!priv->cpp->conversation->confId.empty()) |
| 396 | callToMute = priv->cpp->conversation->confId; |
| 397 | //auto muteVideoBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo); |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 398 | (*priv->cpp->accountInfo)->callModel->toggleMedia(callToMute, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 399 | lrc::api::NewCallModel::Media::VIDEO); |
| 400 | |
| 401 | auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo); |
| 402 | auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video"); |
| 403 | if (gtk_toggle_button_get_active(togglebutton)) |
| 404 | image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video"); |
| 405 | gtk_button_set_image(GTK_BUTTON(togglebutton), image); |
| 406 | } |
| 407 | |
| 408 | static gboolean |
| 409 | on_mouse_moved(CurrentCallView* view) |
| 410 | { |
| 411 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 412 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 413 | |
| 414 | priv->cpp->time_last_mouse_motion = g_get_monotonic_time(); |
| 415 | |
| 416 | // since the mouse moved, make sure the controls are shown |
| 417 | if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->cpp->fade_info)) == CLUTTER_TIMELINE_FORWARD) { |
| 418 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->cpp->fade_info), CLUTTER_TIMELINE_BACKWARD); |
| 419 | clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->cpp->fade_controls), CLUTTER_TIMELINE_BACKWARD); |
| 420 | if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->cpp->fade_info))) { |
| 421 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->cpp->fade_info)); |
| 422 | clutter_timeline_rewind(CLUTTER_TIMELINE(priv->cpp->fade_controls)); |
| 423 | clutter_timeline_start(CLUTTER_TIMELINE(priv->cpp->fade_info)); |
| 424 | clutter_timeline_start(CLUTTER_TIMELINE(priv->cpp->fade_controls)); |
| 425 | } |
| 426 | } |
| 427 | |
Hugo Lefeuvre | 3642531 | 2018-07-24 16:46:01 -0400 | [diff] [blame] | 428 | return FALSE; // propagate event |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static void |
| 432 | on_autoquality_toggled(GtkToggleButton* button, CurrentCallView* view) |
| 433 | { |
| 434 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 435 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 436 | |
| 437 | gboolean auto_quality_on = gtk_toggle_button_get_active(button); |
| 438 | |
| 439 | auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 440 | auto plus_button = gtk_scale_button_get_plus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 441 | auto minus_button = gtk_scale_button_get_minus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 442 | |
| 443 | gtk_widget_set_sensitive(GTK_WIDGET(scale), !auto_quality_on); |
| 444 | gtk_widget_set_sensitive(plus_button, !auto_quality_on); |
| 445 | gtk_widget_set_sensitive(minus_button, !auto_quality_on); |
Sébastien Blin | 3667fa6 | 2017-11-23 09:11:53 -0500 | [diff] [blame] | 446 | |
| 447 | double desired_quality = gtk_scale_button_get_value(GTK_SCALE_BUTTON(priv->scalebutton_quality)); |
| 448 | |
Sébastien Blin | ceb9863 | 2018-07-23 13:59:18 -0400 | [diff] [blame] | 449 | set_call_quality(view, auto_quality_on, desired_quality); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | static void |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 453 | on_quality_changed(G_GNUC_UNUSED GtkScaleButton *button, G_GNUC_UNUSED gdouble value, |
| 454 | CurrentCallView* view) |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 455 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 456 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 457 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 458 | |
Hugo Lefeuvre | 8df7e77 | 2018-09-12 15:29:30 -0400 | [diff] [blame^] | 459 | /* no need to update quality if auto quality is enabled */ |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 460 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality))) return; |
| 461 | |
Hugo Lefeuvre | 8df7e77 | 2018-09-12 15:29:30 -0400 | [diff] [blame^] | 462 | /* update only if the scale button is released (reduces the number of updates) */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 463 | if (priv->cpp->quality_scale_pressed) return; |
Sébastien Blin | 3667fa6 | 2017-11-23 09:11:53 -0500 | [diff] [blame] | 464 | |
Sébastien Blin | ceb9863 | 2018-07-23 13:59:18 -0400 | [diff] [blame] | 465 | set_call_quality(view, false, gtk_scale_button_get_value(button)); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | static gboolean |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 469 | on_quality_button_pressed(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, |
| 470 | CurrentCallView* view) |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 471 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 472 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 473 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 474 | |
| 475 | priv->cpp->quality_scale_pressed = TRUE; |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 476 | |
| 477 | return GDK_EVENT_PROPAGATE; |
| 478 | } |
| 479 | |
| 480 | static gboolean |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 481 | on_quality_button_released(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, |
| 482 | CurrentCallView* view) |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 483 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 484 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 485 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 486 | |
| 487 | priv->cpp->quality_scale_pressed = FALSE; |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 488 | |
Hugo Lefeuvre | 8df7e77 | 2018-09-12 15:29:30 -0400 | [diff] [blame^] | 489 | // make sure the quality gets updated |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 490 | on_quality_changed(GTK_SCALE_BUTTON(priv->scalebutton_quality), 0, view); |
| 491 | |
| 492 | return GDK_EVENT_PROPAGATE; |
| 493 | } |
| 494 | |
| 495 | static gboolean |
| 496 | on_video_widget_focus(GtkWidget* widget, GtkDirectionType direction, CurrentCallView* view) |
| 497 | { |
| 498 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 499 | auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 500 | |
| 501 | // if this widget already has focus, we want the focus to move to the next widget, otherwise we |
| 502 | // will get stuck in a focus loop on the buttons |
| 503 | if (gtk_widget_has_focus(widget)) |
| 504 | return FALSE; |
| 505 | |
| 506 | // otherwise we want the focus to go to and change between the call control buttons |
| 507 | if (gtk_widget_child_focus(GTK_WIDGET(priv->hbox_call_controls), direction)) { |
| 508 | // selected a child, make sure call controls are shown |
| 509 | on_mouse_moved(view); |
| 510 | return TRUE; |
| 511 | } |
| 512 | |
Hugo Lefeuvre | 3642531 | 2018-07-24 16:46:01 -0400 | [diff] [blame] | 513 | // did not select the next child, propagate the event |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 514 | return FALSE; |
| 515 | } |
| 516 | |
| 517 | static gboolean |
| 518 | on_button_press_in_video_event(GtkWidget* widget, GdkEventButton *event, CurrentCallView* view) |
| 519 | { |
| 520 | g_return_val_if_fail(IS_VIDEO_WIDGET(widget), FALSE); |
| 521 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 522 | |
| 523 | // on double click |
| 524 | if (event->type == GDK_2BUTTON_PRESS) { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 525 | g_signal_emit(G_OBJECT(view), current_call_view_signals[VIDEO_DOUBLE_CLICKED], 0); |
| 526 | } |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 527 | |
| 528 | return GDK_EVENT_PROPAGATE; |
| 529 | } |
| 530 | |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 531 | static void |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 532 | on_toggle_smartinfo(GSimpleAction* action, G_GNUC_UNUSED GVariant* state, GtkWidget* vbox_call_smartInfo) |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 533 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 534 | if (g_variant_get_boolean(g_action_get_state(G_ACTION(action)))) { |
| 535 | gtk_widget_show(vbox_call_smartInfo); |
| 536 | } else { |
| 537 | gtk_widget_hide(vbox_call_smartInfo); |
| 538 | } |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 539 | } |
| 540 | |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 541 | static void |
| 542 | transfer_to_peer(CurrentCallViewPrivate* priv, const std::string& peerUri) |
| 543 | { |
| 544 | if (peerUri == priv->cpp->conversation->participants.front()) { |
| 545 | g_warning("avoid to transfer to the same call, abort."); |
| 546 | #if GTK_CHECK_VERSION(3,22,0) |
| 547 | gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover)); |
| 548 | #else |
| 549 | gtk_widget_hide(GTK_WIDGET(priv->siptransfer_popover)); |
| 550 | #endif |
| 551 | return; |
| 552 | } |
| 553 | try { |
| 554 | // If a call is already present with a peer, try an attended transfer. |
| 555 | auto callInfo = (*priv->cpp->accountInfo)->callModel->getCallFromURI(peerUri, true); |
| 556 | (*priv->cpp->accountInfo)->callModel->transferToCall( |
| 557 | priv->cpp->conversation->callId, callInfo.id); |
| 558 | } catch (std::out_of_range&) { |
| 559 | // No current call found with this URI, perform a blind transfer |
| 560 | (*priv->cpp->accountInfo)->callModel->transfer( |
| 561 | priv->cpp->conversation->callId, peerUri); |
| 562 | } |
| 563 | #if GTK_CHECK_VERSION(3,22,0) |
| 564 | gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover)); |
| 565 | #else |
| 566 | gtk_widget_hide(GTK_WIDGET(priv->siptransfer_popover)); |
| 567 | #endif |
| 568 | } |
| 569 | |
| 570 | static void |
| 571 | on_siptransfer_filter_activated(CurrentCallView* self) |
| 572 | { |
| 573 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 574 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 575 | |
| 576 | transfer_to_peer(priv, gtk_entry_get_text(GTK_ENTRY(priv->siptransfer_filter_entry))); |
| 577 | } |
| 578 | |
| 579 | static GtkLabel* |
| 580 | get_sip_address_label(GtkListBoxRow* row) |
| 581 | { |
| 582 | auto* row_children = gtk_container_get_children(GTK_CONTAINER(row)); |
| 583 | auto* box_infos = g_list_first(row_children)->data; |
| 584 | auto* children = gtk_container_get_children(GTK_CONTAINER(box_infos)); |
| 585 | return GTK_LABEL(g_list_last(children)->data); |
| 586 | } |
| 587 | |
| 588 | static void |
| 589 | transfer_to_conversation(GtkListBox*, GtkListBoxRow* row, CurrentCallView* self) |
| 590 | { |
| 591 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 592 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 593 | auto* sip_address = get_sip_address_label(row); |
| 594 | transfer_to_peer(priv, gtk_label_get_text(GTK_LABEL(sip_address))); |
| 595 | } |
| 596 | |
| 597 | static void |
| 598 | filter_transfer_list(CurrentCallView *self) |
| 599 | { |
| 600 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 601 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 602 | |
| 603 | std::string currentFilter = gtk_entry_get_text(GTK_ENTRY(priv->siptransfer_filter_entry)); |
| 604 | |
| 605 | auto row = 0; |
| 606 | while (GtkWidget* children = GTK_WIDGET(gtk_list_box_get_row_at_index(GTK_LIST_BOX(priv->list_conversations), row))) { |
| 607 | auto* sip_address = get_sip_address_label(GTK_LIST_BOX_ROW(children));; |
| 608 | if (row == 0) { |
| 609 | // Update searching item |
| 610 | if (currentFilter.empty() || currentFilter == priv->cpp->conversation->participants.front()) { |
| 611 | // Hide temporary item if filter is empty or same number |
| 612 | gtk_widget_hide(children); |
| 613 | } else { |
| 614 | // Else, show the temporary item (and select it) |
| 615 | gtk_label_set_text(GTK_LABEL(sip_address), currentFilter.c_str()); |
| 616 | gtk_widget_show_all(children); |
| 617 | gtk_list_box_select_row(GTK_LIST_BOX(priv->list_conversations), GTK_LIST_BOX_ROW(children)); |
| 618 | } |
| 619 | } else { |
| 620 | // It's a contact |
| 621 | std::string item_address = gtk_label_get_text(GTK_LABEL(sip_address)); |
| 622 | |
| 623 | if (item_address == priv->cpp->conversation->participants.front()) |
| 624 | // if item is the current conversation, hide it |
| 625 | gtk_widget_hide(children); |
| 626 | else if (currentFilter.empty()) |
| 627 | // filter is empty, show all items |
| 628 | gtk_widget_show_all(children); |
| 629 | else if (item_address.find(currentFilter) == std::string::npos || item_address == currentFilter) |
| 630 | // avoid duplicates and unwanted numbers |
| 631 | gtk_widget_hide(children); |
| 632 | else |
| 633 | // Item is filtered |
| 634 | gtk_widget_show_all(children); |
| 635 | } |
| 636 | ++row; |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | static void |
| 641 | on_button_transfer_clicked(CurrentCallView *self) |
| 642 | { |
| 643 | // Show and init list |
| 644 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
| 645 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 646 | gtk_popover_set_relative_to(GTK_POPOVER(priv->siptransfer_popover), GTK_WIDGET(priv->togglebutton_transfer)); |
| 647 | #if GTK_CHECK_VERSION(3,22,0) |
| 648 | gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover)); |
| 649 | #else |
| 650 | gtk_widget_show_all(GTK_WIDGET(priv->siptransfer_popover)); |
| 651 | #endif |
| 652 | gtk_widget_show_all(priv->siptransfer_popover); |
| 653 | filter_transfer_list(self); |
| 654 | } |
| 655 | |
| 656 | static void |
| 657 | on_siptransfer_text_changed(GtkSearchEntry*, CurrentCallView* self) |
| 658 | { |
| 659 | filter_transfer_list(self); |
| 660 | } |
| 661 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 662 | } // namespace gtk_callbacks |
| 663 | |
| 664 | CppImpl::CppImpl(CurrentCallView& widget) |
| 665 | : self {&widget} |
| 666 | , widgets {CURRENT_CALL_VIEW_GET_PRIVATE(&widget)} |
| 667 | {} |
| 668 | |
| 669 | CppImpl::~CppImpl() |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 670 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 671 | QObject::disconnect(state_change_connection); |
| 672 | QObject::disconnect(local_renderer_connection); |
| 673 | QObject::disconnect(remote_renderer_connection); |
| 674 | QObject::disconnect(smartinfo_refresh_connection); |
| 675 | QObject::disconnect(new_message_connection); |
| 676 | g_clear_object(&widgets->settings); |
| 677 | |
| 678 | g_source_remove(timer_fade); |
| 679 | |
| 680 | auto* display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), |
| 681 | "display-smartinfo"); |
| 682 | g_signal_handler_disconnect(display_smartinfo, smartinfo_action); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 683 | } |
| 684 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 685 | void |
| 686 | CppImpl::init() |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 687 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 688 | // CSS styles |
| 689 | auto provider = gtk_css_provider_new(); |
| 690 | gtk_css_provider_load_from_data(provider, |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 691 | ".search-entry-style { border: 0; border-radius: 0; } \ |
| 692 | .smartinfo-block-style { color: #8ae234; background-color: rgba(1, 1, 1, 0.33); } \ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 693 | @keyframes blink { 0% {opacity: 1;} 49% {opacity: 1;} 50% {opacity: 0;} 100% {opacity: 0;} } \ |
| 694 | .record-button { background: rgba(0, 0, 0, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 695 | .record-button:checked { animation: blink 1s; animation-iteration-count: infinite; } \ |
| 696 | .call-button { background: rgba(0, 0, 0, 0.35); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 697 | .call-button:hover { background: rgba(0, 0, 0, 0.2); } \ |
| 698 | .call-button:disabled { opacity: 0.2; } \ |
| 699 | .can-be-disabled:checked { background: rgba(219, 58, 55, 1); } \ |
| 700 | .hangup-button-style { background: rgba(219, 58, 55, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \ |
| 701 | .hangup-button-style:hover { background: rgba(219, 39, 25, 1); }", |
| 702 | -1, nullptr |
| 703 | ); |
| 704 | gtk_style_context_add_provider_for_screen(gdk_display_get_default_screen(gdk_display_get_default()), |
| 705 | GTK_STYLE_PROVIDER(provider), |
| 706 | GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
| 707 | |
| 708 | widgets->video_widget = video_widget_new(); |
| 709 | gtk_container_add(GTK_CONTAINER(widgets->frame_video), widgets->video_widget); |
| 710 | gtk_widget_show_all(widgets->frame_video); |
| 711 | |
| 712 | // add the overlay controls only once the view has been allocated a size to prevent size |
| 713 | // allocation warnings in the log |
| 714 | insert_controls_id = g_signal_connect(self, "size-allocate", G_CALLBACK(on_size_allocate), nullptr); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 715 | } |
| 716 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 717 | void |
| 718 | CppImpl::setup(WebKitChatContainer* chat_widget, |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 719 | AccountInfoPointer const & account_info, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 720 | lrc::api::conversation::Info* conv_info) |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 721 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 722 | widgets->webkit_chat_container = GTK_WIDGET(chat_widget); |
| 723 | conversation = conv_info; |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 724 | accountInfo = &account_info; |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 725 | setCallInfo(); |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 726 | |
| 727 | if ((*accountInfo)->profileInfo.type == lrc::api::profile::Type::RING) |
| 728 | gtk_widget_hide(widgets->togglebutton_transfer); |
| 729 | else { |
| 730 | // Remove previous list |
| 731 | while (GtkWidget* children = GTK_WIDGET(gtk_list_box_get_row_at_index(GTK_LIST_BOX(widgets->list_conversations), 10))) |
| 732 | gtk_container_remove(GTK_CONTAINER(widgets->list_conversations), children); |
| 733 | // Fill with SIP contacts |
| 734 | add_transfer_contact(""); // Temporary item |
| 735 | for (const auto& c : (*accountInfo)->conversationModel->getFilteredConversations(lrc::api::profile::Type::SIP)) |
| 736 | add_transfer_contact(c.participants.front()); |
| 737 | gtk_widget_show_all(widgets->list_conversations); |
| 738 | gtk_widget_show(widgets->togglebutton_transfer); |
| 739 | } |
Sébastien Blin | 31cc01e | 2018-06-08 10:51:03 -0400 | [diff] [blame] | 740 | |
| 741 | set_record_animation(widgets); |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | void |
| 745 | CppImpl::add_transfer_contact(const std::string& uri) |
| 746 | { |
| 747 | auto* box_item = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); |
| 748 | auto pixbufmanipulator = Interfaces::PixbufManipulator(); |
| 749 | auto image_buf = pixbufmanipulator.generateAvatar("", uri.empty() ? uri : "sip" + uri); |
| 750 | auto scaled = pixbufmanipulator.scaleAndFrame(image_buf.get(), QSize(48, 48)); |
| 751 | auto* avatar = gtk_image_new_from_pixbuf(scaled.get()); |
| 752 | auto* address = gtk_label_new(uri.c_str()); |
| 753 | gtk_container_add(GTK_CONTAINER(box_item), GTK_WIDGET(avatar)); |
| 754 | gtk_container_add(GTK_CONTAINER(box_item), GTK_WIDGET(address)); |
| 755 | gtk_list_box_insert(GTK_LIST_BOX(widgets->list_conversations), GTK_WIDGET(box_item), -1); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 756 | } |
| 757 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 758 | void |
| 759 | CppImpl::setCallInfo() |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 760 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 761 | // change some things depending on call state |
| 762 | updateState(); |
| 763 | updateDetails(); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 764 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 765 | // NOTE/TODO we need to rewrite the video_widget file to use the new LRC. |
| 766 | g_signal_connect(widgets->video_widget, "button-press-event", |
| 767 | G_CALLBACK(video_widget_on_button_press_in_screen_event), nullptr); |
| 768 | |
| 769 | // check if we already have a renderer |
| 770 | auto callToRender = conversation->callId; |
| 771 | if (!conversation->confId.empty()) |
| 772 | callToRender = conversation->confId; |
| 773 | video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget), |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 774 | (*accountInfo)->callModel->getRenderer(callToRender), |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 775 | VIDEO_RENDERER_REMOTE); |
| 776 | |
| 777 | // local renderer |
| 778 | if (Video::PreviewManager::instance().isPreviewing()) |
| 779 | video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget), |
| 780 | Video::PreviewManager::instance().previewRenderer(), |
| 781 | VIDEO_RENDERER_LOCAL); |
| 782 | |
| 783 | // callback for local renderer |
| 784 | local_renderer_connection = QObject::connect( |
| 785 | &Video::PreviewManager::instance(), |
| 786 | &Video::PreviewManager::previewStarted, |
| 787 | [this] (Video::Renderer* renderer) { |
| 788 | video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget), |
| 789 | renderer, |
| 790 | VIDEO_RENDERER_LOCAL); |
| 791 | } |
| 792 | ); |
| 793 | |
| 794 | smartinfo_refresh_connection = QObject::connect( |
| 795 | &SmartInfoHub::instance(), |
| 796 | &SmartInfoHub::changed, |
| 797 | [this] { updateSmartInfo(); } |
| 798 | ); |
| 799 | |
| 800 | remote_renderer_connection = QObject::connect( |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 801 | &*(*accountInfo)->callModel, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 802 | &lrc::api::NewCallModel::remotePreviewStarted, |
| 803 | [this] (const std::string& callId, Video::Renderer* renderer) { |
| 804 | if (conversation->callId == callId) { |
| 805 | video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget), |
| 806 | renderer, |
| 807 | VIDEO_RENDERER_REMOTE); |
| 808 | } |
| 809 | }); |
| 810 | |
| 811 | state_change_connection = QObject::connect( |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 812 | &*(*accountInfo)->callModel, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 813 | &lrc::api::NewCallModel::callStatusChanged, |
| 814 | [this] (const std::string& callId) { |
| 815 | if (callId == conversation->callId) { |
| 816 | updateState(); |
| 817 | updateNameAndPhoto(); |
| 818 | } |
| 819 | }); |
| 820 | |
| 821 | new_message_connection = QObject::connect( |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 822 | &*(*accountInfo)->conversationModel, |
Nicolas Jager | 6635b0d | 2018-01-24 12:25:28 -0500 | [diff] [blame] | 823 | &lrc::api::ConversationModel::newInteraction, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 824 | [this] (const std::string& uid, uint64_t msgId, lrc::api::interaction::Info msg) { |
| 825 | Q_UNUSED(uid) |
| 826 | Q_UNUSED(msgId) |
| 827 | Q_UNUSED(msg) |
| 828 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_chat), TRUE); |
| 829 | }); |
| 830 | |
| 831 | // catch double click to make full screen |
| 832 | g_signal_connect(widgets->video_widget, "button-press-event", |
| 833 | G_CALLBACK(on_button_press_in_video_event), self); |
| 834 | |
| 835 | // handle smartinfo in right click menu |
| 836 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), |
| 837 | "display-smartinfo"); |
| 838 | smartinfo_action = g_signal_connect(display_smartinfo, |
| 839 | "notify::state", |
| 840 | G_CALLBACK(on_toggle_smartinfo), |
| 841 | widgets->vbox_call_smartInfo); |
| 842 | |
| 843 | // init chat view |
| 844 | widgets->chat_view = chat_view_new(WEBKIT_CHAT_CONTAINER(widgets->webkit_chat_container), |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 845 | *accountInfo, conversation); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 846 | gtk_container_add(GTK_CONTAINER(widgets->frame_chat), widgets->chat_view); |
| 847 | |
| 848 | g_signal_connect_swapped(widgets->chat_view, "new-interactions-displayed", |
| 849 | G_CALLBACK(on_new_chat_interactions), self); |
| 850 | chat_view_set_header_visible(CHAT_VIEW(widgets->chat_view), FALSE); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 851 | } |
| 852 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 853 | void |
| 854 | CppImpl::insertControls() |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 855 | { |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 856 | /* only add the controls once */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 857 | g_signal_handler_disconnect(self, insert_controls_id); |
| 858 | insert_controls_id = 0; |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 859 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 860 | auto stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(widgets->video_widget)); |
| 861 | auto actor_info = gtk_clutter_actor_new_with_contents(widgets->hbox_call_info); |
| 862 | auto actor_controls = gtk_clutter_actor_new_with_contents(widgets->hbox_call_controls); |
| 863 | auto actor_smartInfo = gtk_clutter_actor_new_with_contents(widgets->vbox_call_smartInfo); |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 864 | |
| 865 | clutter_actor_add_child(stage, actor_info); |
| 866 | clutter_actor_set_x_align(actor_info, CLUTTER_ACTOR_ALIGN_FILL); |
| 867 | clutter_actor_set_y_align(actor_info, CLUTTER_ACTOR_ALIGN_START); |
| 868 | |
| 869 | clutter_actor_add_child(stage, actor_controls); |
| 870 | clutter_actor_set_x_align(actor_controls, CLUTTER_ACTOR_ALIGN_CENTER); |
| 871 | clutter_actor_set_y_align(actor_controls, CLUTTER_ACTOR_ALIGN_END); |
| 872 | |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 873 | clutter_actor_add_child(stage, actor_smartInfo); |
| 874 | clutter_actor_set_x_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_END); |
| 875 | clutter_actor_set_y_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_START); |
| 876 | ClutterMargin clutter_margin_smartInfo; |
| 877 | clutter_margin_smartInfo.top = 50; |
| 878 | clutter_margin_smartInfo.right = 10; |
philippegorley | a733794 | 2017-07-04 15:29:42 -0400 | [diff] [blame] | 879 | clutter_margin_smartInfo.left = 10; |
| 880 | clutter_margin_smartInfo.bottom = 10; |
Olivier Gregoire | 66e4df7 | 2016-06-17 18:39:05 -0400 | [diff] [blame] | 881 | clutter_actor_set_margin (actor_smartInfo, &clutter_margin_smartInfo); |
| 882 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 883 | /* add fade in and out states to the info and controls */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 884 | time_last_mouse_motion = g_get_monotonic_time(); |
| 885 | fade_info = create_fade_out_transition(); |
| 886 | fade_controls = create_fade_out_transition(); |
| 887 | clutter_actor_add_transition(actor_info, "fade_info", fade_info); |
| 888 | clutter_actor_add_transition(actor_controls, "fade_controls", fade_controls); |
| 889 | clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_info), CLUTTER_TIMELINE_BACKWARD); |
| 890 | clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_controls), CLUTTER_TIMELINE_BACKWARD); |
| 891 | clutter_timeline_stop(CLUTTER_TIMELINE(fade_info)); |
| 892 | clutter_timeline_stop(CLUTTER_TIMELINE(fade_controls)); |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 893 | |
| 894 | /* have a timer check every 1 second if the controls should fade out */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 895 | timer_fade = g_timeout_add(1000, (GSourceFunc)on_timer_fade_timeout, self); |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 896 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 897 | /* connect the controllers (new model) */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 898 | g_signal_connect_swapped(widgets->button_hangup, "clicked", G_CALLBACK(on_button_hangup_clicked), self); |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 899 | g_signal_connect_swapped(widgets->togglebutton_transfer, "clicked", G_CALLBACK(on_button_transfer_clicked), self); |
| 900 | g_signal_connect_swapped(widgets->siptransfer_filter_entry, "activate", G_CALLBACK(on_siptransfer_filter_activated), self); |
| 901 | g_signal_connect(widgets->siptransfer_filter_entry, "search-changed", G_CALLBACK(on_siptransfer_text_changed), self); |
| 902 | g_signal_connect(widgets->list_conversations, "row-activated", G_CALLBACK(transfer_to_conversation), self); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 903 | g_signal_connect_swapped(widgets->togglebutton_hold, "clicked", G_CALLBACK(on_togglebutton_hold_clicked), self); |
| 904 | g_signal_connect_swapped(widgets->togglebutton_muteaudio, "clicked", G_CALLBACK(on_togglebutton_muteaudio_clicked), self); |
| 905 | g_signal_connect_swapped(widgets->togglebutton_record, "clicked", G_CALLBACK(on_togglebutton_record_clicked), self); |
| 906 | g_signal_connect_swapped(widgets->togglebutton_mutevideo, "clicked", G_CALLBACK(on_togglebutton_mutevideo_clicked), self); |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 907 | |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 908 | /* connect to the mouse motion event to reset the last moved time */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 909 | g_signal_connect_swapped(widgets->video_widget, "motion-notify-event", G_CALLBACK(on_mouse_moved), self); |
| 910 | g_signal_connect_swapped(widgets->video_widget, "button-press-event", G_CALLBACK(on_mouse_moved), self); |
| 911 | g_signal_connect_swapped(widgets->video_widget, "button-release-event", G_CALLBACK(on_mouse_moved), self); |
Stepan Salenikovich | 0c7aa2a | 2015-11-06 17:00:08 -0500 | [diff] [blame] | 912 | |
Stepan Salenikovich | 5ed1b49 | 2015-11-13 14:03:31 -0500 | [diff] [blame] | 913 | /* manually handle the focus of the video widget to be able to focus on the call controls */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 914 | g_signal_connect(widgets->video_widget, "focus", G_CALLBACK(on_video_widget_focus), self); |
Stepan Salenikovich | 5ed1b49 | 2015-11-13 14:03:31 -0500 | [diff] [blame] | 915 | |
Sébastien Blin | 55bff9d | 2017-10-03 15:15:23 -0400 | [diff] [blame] | 916 | |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 917 | /* toggle whether or not the chat is displayed */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 918 | g_signal_connect(widgets->togglebutton_chat, "toggled", G_CALLBACK(on_togglebutton_chat_toggled), self); |
Stepan Salenikovich | a448f60 | 2015-05-29 13:33:06 -0400 | [diff] [blame] | 919 | |
Stepan Salenikovich | d2cad06 | 2016-01-08 13:43:49 -0500 | [diff] [blame] | 920 | /* bind the chat orientation to the gsetting */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 921 | widgets->settings = g_settings_new_full(get_ring_schema(), nullptr, nullptr); |
| 922 | g_settings_bind_with_mapping(widgets->settings, "chat-pane-horizontal", |
| 923 | widgets->paned_call, "orientation", |
Stepan Salenikovich | a5e8e36 | 2015-11-05 16:50:48 -0500 | [diff] [blame] | 924 | G_SETTINGS_BIND_GET, |
| 925 | map_boolean_to_orientation, |
| 926 | nullptr, nullptr, nullptr); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 927 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 928 | g_signal_connect(widgets->scalebutton_quality, "value-changed", G_CALLBACK(on_quality_changed), self); |
| 929 | |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 930 | /* customize the quality button scale */ |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 931 | if (auto scale_box = gtk_scale_button_get_box(GTK_SCALE_BUTTON(widgets->scalebutton_quality))) { |
| 932 | widgets->checkbutton_autoquality = gtk_check_button_new_with_label(C_("Enable automatic video quality", |
| 933 | "Auto")); |
| 934 | gtk_widget_show(widgets->checkbutton_autoquality); |
| 935 | gtk_box_pack_start(GTK_BOX(scale_box), widgets->checkbutton_autoquality, FALSE, TRUE, 0); |
| 936 | g_signal_connect(widgets->checkbutton_autoquality, "toggled", G_CALLBACK(on_autoquality_toggled), self); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 937 | } |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 938 | if (auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(widgets->scalebutton_quality))) { |
| 939 | g_signal_connect(scale, "button-press-event", G_CALLBACK(on_quality_button_pressed), self); |
| 940 | g_signal_connect(scale, "button-release-event", G_CALLBACK(on_quality_button_released), self); |
Stepan Salenikovich | 7e28355 | 2015-12-21 16:17:52 -0500 | [diff] [blame] | 941 | } |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 942 | |
Sébastien Blin | 7855135 | 2018-08-16 13:55:30 -0400 | [diff] [blame] | 943 | g_signal_connect(widgets->video_widget, "drag-data-received", |
| 944 | G_CALLBACK(video_widget_on_drag_data_received), nullptr); |
| 945 | |
Sébastien Blin | ceb9863 | 2018-07-23 13:59:18 -0400 | [diff] [blame] | 946 | auto videoCodecs = (*accountInfo)->codecModel->getVideoCodecs(); |
| 947 | if (!videoCodecs.empty()) { |
| 948 | bool autoQualityEnabled = videoCodecs.front().auto_quality_enabled; |
| 949 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->checkbutton_autoquality), |
| 950 | autoQualityEnabled); |
| 951 | } else { |
| 952 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->checkbutton_autoquality), |
| 953 | false); |
| 954 | } |
Sébastien Blin | 3667fa6 | 2017-11-23 09:11:53 -0500 | [diff] [blame] | 955 | |
Sébastien Blin | 4514eeb | 2017-07-25 14:17:01 -0400 | [diff] [blame] | 956 | // Get if the user wants to show the smartInfo box |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 957 | auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), |
| 958 | "display-smartinfo"); |
Sébastien Blin | 4514eeb | 2017-07-25 14:17:01 -0400 | [diff] [blame] | 959 | if (g_variant_get_boolean(g_action_get_state(G_ACTION(display_smartinfo)))) { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 960 | gtk_widget_show(widgets->vbox_call_smartInfo); |
Sébastien Blin | 4514eeb | 2017-07-25 14:17:01 -0400 | [diff] [blame] | 961 | } else { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 962 | gtk_widget_hide(widgets->vbox_call_smartInfo); |
Sébastien Blin | 4514eeb | 2017-07-25 14:17:01 -0400 | [diff] [blame] | 963 | } |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 964 | } |
| 965 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 966 | void |
| 967 | CppImpl::updateDetails() |
| 968 | { |
Hugo Lefeuvre | 8df7e77 | 2018-09-12 15:29:30 -0400 | [diff] [blame^] | 969 | if (!conversation) { |
| 970 | g_warning("Could not update currentcallview details (null conversation)"); |
| 971 | return; |
| 972 | } |
| 973 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 974 | auto callRendered = conversation->callId; |
| 975 | |
| 976 | if (!conversation->confId.empty()) |
| 977 | callRendered = conversation->confId; |
| 978 | |
| 979 | gtk_label_set_text(GTK_LABEL(widgets->label_duration), |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 980 | (*accountInfo)->callModel->getFormattedCallDuration(callRendered).c_str()); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 981 | |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 982 | auto call = (*accountInfo)->callModel->getCall(callRendered); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 983 | gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_muteaudio), |
| 984 | (call.type != lrc::api::call::Type::CONFERENCE)); |
| 985 | gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_mutevideo), |
| 986 | (call.type != lrc::api::call::Type::CONFERENCE)); |
| 987 | } |
| 988 | |
| 989 | void |
| 990 | CppImpl::updateState() |
| 991 | { |
Hugo Lefeuvre | 8df7e77 | 2018-09-12 15:29:30 -0400 | [diff] [blame^] | 992 | if (!conversation) { |
| 993 | g_warning("Could not update currentcallview state (null conversation)"); |
| 994 | return; |
| 995 | } |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 996 | |
| 997 | auto callId = conversation->callId; |
| 998 | |
| 999 | try { |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 1000 | auto call = (*accountInfo)->callModel->getCall(callId); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1001 | |
| 1002 | auto pauseBtn = GTK_TOGGLE_BUTTON(widgets->togglebutton_hold); |
| 1003 | auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/pause"); |
| 1004 | if (call.status == lrc::api::call::Status::PAUSED) |
| 1005 | image = gtk_image_new_from_resource ("/cx/ring/RingGnome/play"); |
| 1006 | gtk_button_set_image(GTK_BUTTON(pauseBtn), image); |
| 1007 | |
| 1008 | auto audioButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio); |
| 1009 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio), call.audioMuted); |
| 1010 | auto imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio"); |
| 1011 | if (call.audioMuted) |
| 1012 | imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio"); |
| 1013 | gtk_button_set_image(GTK_BUTTON(audioButton), imageMuteAudio); |
| 1014 | |
| 1015 | auto videoButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo); |
| 1016 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo), call.videoMuted); |
| 1017 | auto imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video"); |
| 1018 | if (call.videoMuted) |
| 1019 | imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video"); |
| 1020 | gtk_button_set_image(GTK_BUTTON(videoButton), imageMuteVideo); |
| 1021 | |
| 1022 | gchar *status = g_strdup_printf("%s", lrc::api::call::to_string(call.status).c_str()); |
| 1023 | gtk_label_set_text(GTK_LABEL(widgets->label_status), status); |
| 1024 | g_free(status); |
| 1025 | } catch (std::out_of_range& e) { |
| 1026 | g_warning("Can't update state for callId=%s", callId.c_str()); |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | void |
| 1031 | CppImpl::updateNameAndPhoto() |
| 1032 | { |
| 1033 | QVariant var_i = GlobalInstances::pixmapManipulator().conversationPhoto( |
| 1034 | *conversation, |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 1035 | **(accountInfo), |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1036 | QSize(60, 60), |
| 1037 | false |
| 1038 | ); |
| 1039 | std::shared_ptr<GdkPixbuf> image = var_i.value<std::shared_ptr<GdkPixbuf>>(); |
| 1040 | gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->image_peer), image.get()); |
| 1041 | |
| 1042 | try { |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 1043 | auto contactInfo = (*accountInfo)->contactModel->getContact(conversation->participants.front()); |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1044 | auto name = contactInfo.profileInfo.alias; |
| 1045 | gtk_label_set_text(GTK_LABEL(widgets->label_name), name.c_str()); |
| 1046 | |
| 1047 | auto bestId = contactInfo.registeredName; |
| 1048 | if (name != bestId) { |
| 1049 | gtk_label_set_text(GTK_LABEL(widgets->label_bestId), bestId.c_str()); |
| 1050 | gtk_widget_show(widgets->label_bestId); |
| 1051 | } |
| 1052 | } catch (const std::out_of_range&) { |
| 1053 | // ContactModel::getContact() exception |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | void |
| 1058 | CppImpl::updateSmartInfo() |
| 1059 | { |
| 1060 | if (!SmartInfoHub::instance().isConference()) { |
| 1061 | gchar* general_information = g_strdup_printf( |
| 1062 | "Call ID: %s", SmartInfoHub::instance().callID().toStdString().c_str()); |
| 1063 | gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_general_information), general_information); |
| 1064 | g_free(general_information); |
| 1065 | |
| 1066 | gchar* description = g_strdup_printf("You\n" |
| 1067 | "Framerate:\n" |
| 1068 | "Video codec:\n" |
| 1069 | "Audio codec:\n" |
| 1070 | "Resolution:\n\n" |
| 1071 | "Peer\n" |
| 1072 | "Framerate:\n" |
| 1073 | "Video codec:\n" |
| 1074 | "Audio codec:\n" |
| 1075 | "Resolution:"); |
| 1076 | gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_description),description); |
| 1077 | g_free(description); |
| 1078 | |
| 1079 | 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", |
| 1080 | (double)SmartInfoHub::instance().localFps(), |
| 1081 | SmartInfoHub::instance().localVideoCodec().toStdString().c_str(), |
| 1082 | SmartInfoHub::instance().localAudioCodec().toStdString().c_str(), |
| 1083 | SmartInfoHub::instance().localWidth(), |
| 1084 | SmartInfoHub::instance().localHeight(), |
| 1085 | (double)SmartInfoHub::instance().remoteFps(), |
| 1086 | SmartInfoHub::instance().remoteVideoCodec().toStdString().c_str(), |
| 1087 | SmartInfoHub::instance().remoteAudioCodec().toStdString().c_str(), |
| 1088 | SmartInfoHub::instance().remoteWidth(), |
| 1089 | SmartInfoHub::instance().remoteHeight()); |
| 1090 | gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_value),value); |
| 1091 | g_free(value); |
| 1092 | } else { |
| 1093 | gchar* general_information = g_strdup_printf( |
| 1094 | "Conference ID: %s", SmartInfoHub::instance().callID().toStdString().c_str()); |
| 1095 | gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_general_information), general_information); |
| 1096 | g_free(general_information); |
| 1097 | |
| 1098 | gchar* description = g_strdup_printf("You\n" |
| 1099 | "Framerate:\n" |
| 1100 | "Video codec:\n" |
| 1101 | "Audio codec:\n" |
| 1102 | "Resolution:"); |
| 1103 | gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_description),description); |
| 1104 | g_free(description); |
| 1105 | |
| 1106 | gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d", |
| 1107 | (double)SmartInfoHub::instance().localFps(), |
| 1108 | SmartInfoHub::instance().localVideoCodec().toStdString().c_str(), |
| 1109 | SmartInfoHub::instance().localAudioCodec().toStdString().c_str(), |
| 1110 | SmartInfoHub::instance().localWidth(), |
| 1111 | SmartInfoHub::instance().localHeight()); |
| 1112 | gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_value),value); |
| 1113 | g_free(value); |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | void |
| 1118 | CppImpl::checkControlsFading() |
| 1119 | { |
| 1120 | auto current_time = g_get_monotonic_time(); |
| 1121 | if (current_time - time_last_mouse_motion >= CONTROLS_FADE_TIMEOUT) { |
| 1122 | // timeout has passed, hide the controls |
| 1123 | if (clutter_timeline_get_direction(CLUTTER_TIMELINE(fade_info)) == CLUTTER_TIMELINE_BACKWARD) { |
| 1124 | clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_info), CLUTTER_TIMELINE_FORWARD); |
| 1125 | clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_controls), CLUTTER_TIMELINE_FORWARD); |
| 1126 | if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(fade_info))) { |
| 1127 | clutter_timeline_rewind(CLUTTER_TIMELINE(fade_info)); |
| 1128 | clutter_timeline_rewind(CLUTTER_TIMELINE(fade_controls)); |
| 1129 | clutter_timeline_start(CLUTTER_TIMELINE(fade_info)); |
| 1130 | clutter_timeline_start(CLUTTER_TIMELINE(fade_controls)); |
| 1131 | } |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | updateDetails(); |
| 1136 | } |
| 1137 | |
| 1138 | }} // namespace <anonymous>::details |
| 1139 | |
| 1140 | //============================================================================== |
| 1141 | |
| 1142 | lrc::api::conversation::Info |
| 1143 | current_call_view_get_conversation(CurrentCallView *self) |
| 1144 | { |
| 1145 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), lrc::api::conversation::Info()); |
| 1146 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 1147 | return *priv->cpp->conversation; |
| 1148 | } |
| 1149 | |
| 1150 | GtkWidget * |
| 1151 | current_call_view_get_chat_view(CurrentCallView *self) |
| 1152 | { |
| 1153 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), nullptr); |
| 1154 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 1155 | return priv->chat_view; |
| 1156 | } |
| 1157 | |
| 1158 | //============================================================================== |
| 1159 | |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 1160 | static void |
| 1161 | current_call_view_init(CurrentCallView *view) |
| 1162 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1163 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 1164 | gtk_widget_init_template(GTK_WIDGET(view)); |
| 1165 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1166 | // CppImpl ctor |
| 1167 | priv->cpp = new details::CppImpl {*view}; |
| 1168 | priv->cpp->init(); |
| 1169 | } |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 1170 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1171 | static void |
| 1172 | current_call_view_dispose(GObject *object) |
| 1173 | { |
| 1174 | auto* view = CURRENT_CALL_VIEW(object); |
| 1175 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 1176 | |
Hugo Lefeuvre | edad883 | 2018-05-14 16:36:06 -0400 | [diff] [blame] | 1177 | // navbar was hidden during setCallInfo, we need to make it visible again before view destruction |
| 1178 | auto children = gtk_container_get_children(GTK_CONTAINER(priv->frame_chat)); |
| 1179 | auto chat_view = children->data; |
| 1180 | chat_view_set_header_visible(CHAT_VIEW(chat_view), TRUE); |
| 1181 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1182 | delete priv->cpp; |
| 1183 | priv->cpp = nullptr; |
Stepan Salenikovich | 8809293 | 2017-05-15 18:19:00 -0400 | [diff] [blame] | 1184 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1185 | G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | static void |
| 1189 | current_call_view_class_init(CurrentCallViewClass *klass) |
| 1190 | { |
| 1191 | G_OBJECT_CLASS(klass)->dispose = current_call_view_dispose; |
| 1192 | |
| 1193 | gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass), |
| 1194 | "/cx/ring/RingGnome/currentcallview.ui"); |
| 1195 | |
Stepan Salenikovich | e178e63 | 2015-11-06 13:31:19 -0500 | [diff] [blame] | 1196 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_info); |
| 1197 | 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] | 1198 | 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] | 1199 | 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] | 1200 | 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] | 1201 | 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] | 1202 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status); |
| 1203 | 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] | 1204 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_description); |
| 1205 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_value); |
| 1206 | 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] | 1207 | 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] | 1208 | 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] | 1209 | 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] | 1210 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_chat); |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 1211 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_transfer); |
AmarOk | e7c0297 | 2017-07-17 15:21:20 -0400 | [diff] [blame] | 1212 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_hold); |
| 1213 | 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] | 1214 | 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] | 1215 | 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] | 1216 | 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] | 1217 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, scalebutton_quality); |
Sébastien Blin | 784f2a3 | 2018-05-30 17:31:13 -0400 | [diff] [blame] | 1218 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, siptransfer_popover); |
| 1219 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, siptransfer_filter_entry); |
| 1220 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, list_conversations); |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 1221 | |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1222 | details::current_call_view_signals[VIDEO_DOUBLE_CLICKED] = g_signal_new ( |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 1223 | "video-double-clicked", |
| 1224 | G_TYPE_FROM_CLASS(klass), |
| 1225 | (GSignalFlags) (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), |
| 1226 | 0, |
| 1227 | nullptr, |
| 1228 | nullptr, |
| 1229 | g_cclosure_marshal_VOID__VOID, |
| 1230 | G_TYPE_NONE, 0); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 1231 | } |
| 1232 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1233 | GtkWidget * |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1234 | current_call_view_new(WebKitChatContainer* chat_widget, |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 1235 | AccountInfoPointer const & accountInfo, |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1236 | lrc::api::conversation::Info* conversation) |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1237 | { |
Guillaume Roguez | aaf8b0f | 2018-01-24 14:38:43 -0500 | [diff] [blame] | 1238 | auto* self = g_object_new(CURRENT_CALL_VIEW_TYPE, NULL); |
| 1239 | auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 1240 | |
Hugo Lefeuvre | 6f2ceb1 | 2018-04-18 15:08:01 -0400 | [diff] [blame] | 1241 | priv->cpp->setup(chat_widget, accountInfo, conversation); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1242 | return GTK_WIDGET(self); |
| 1243 | } |