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