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