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