Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1 | /* |
Stepan Salenikovich | be87d2c | 2016-01-25 14:14:34 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 Savoir-faire Linux Inc. |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -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 | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include "ringmainwindow.h" |
| 21 | |
Stepan Salenikovich | 5fd97bc | 2016-08-30 09:40:38 -0400 | [diff] [blame] | 22 | // system |
| 23 | #include <string.h> |
| 24 | #include <memory> |
| 25 | |
| 26 | // GTK+ related |
Stepan Salenikovich | a1b8cb3 | 2015-09-11 14:58:35 -0400 | [diff] [blame] | 27 | #include <glib/gi18n.h> |
Stepan Salenikovich | 5fd97bc | 2016-08-30 09:40:38 -0400 | [diff] [blame] | 28 | |
| 29 | // Qt |
| 30 | #include <QtCore/QItemSelectionModel> |
| 31 | #include <QtCore/QSortFilterProxyModel> |
Stepan Salenikovich | e993324 | 2016-06-21 18:08:48 -0400 | [diff] [blame] | 32 | #include <QtCore/QDateTime> |
Stepan Salenikovich | 5fd97bc | 2016-08-30 09:40:38 -0400 | [diff] [blame] | 33 | |
| 34 | // LRC |
Stepan Salenikovich | a355745 | 2015-02-20 14:14:12 -0500 | [diff] [blame] | 35 | #include <callmodel.h> |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 36 | #include <call.h> |
Stepan Salenikovich | 1514218 | 2015-03-11 17:15:26 -0400 | [diff] [blame] | 37 | #include <contactmethod.h> |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 38 | #include <accountmodel.h> |
Edric Milaret | 58e7107 | 2016-03-21 12:16:37 -0400 | [diff] [blame] | 39 | #include <codecmodel.h> |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 40 | #include <video/previewmanager.h> |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 41 | #include <personmodel.h> |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 42 | #include <globalinstances.h> |
Stepan Salenikovich | 5fd97bc | 2016-08-30 09:40:38 -0400 | [diff] [blame] | 43 | #include <categorizedcontactmodel.h> |
| 44 | #include <recentmodel.h> |
| 45 | #include <profilemodel.h> |
| 46 | #include <profile.h> |
Stepan Salenikovich | f53128f | 2016-10-07 10:32:16 -0400 | [diff] [blame] | 47 | #include <phonedirectorymodel.h> |
Stepan Salenikovich | 7b7be48 | 2016-11-03 16:57:48 -0400 | [diff] [blame] | 48 | #include <availableaccountmodel.h> |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 49 | #include <contactrequest.h> |
Stepan Salenikovich | 5fd97bc | 2016-08-30 09:40:38 -0400 | [diff] [blame] | 50 | |
| 51 | // Ring client |
| 52 | #include "models/gtkqtreemodel.h" |
| 53 | #include "incomingcallview.h" |
| 54 | #include "currentcallview.h" |
Stepan Salenikovich | f607822 | 2016-10-03 17:31:16 -0400 | [diff] [blame] | 55 | #include "models/gtkqtreemodel.h" |
Stepan Salenikovich | 5fd97bc | 2016-08-30 09:40:38 -0400 | [diff] [blame] | 56 | #include "accountview.h" |
| 57 | #include "dialogs.h" |
| 58 | #include "mediasettingsview.h" |
| 59 | #include "utils/drawing.h" |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 60 | #include "native/pixbufmanipulator.h" |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 61 | #include "models/activeitemproxymodel.h" |
Stepan Salenikovich | 9816a94 | 2015-04-22 17:49:16 -0400 | [diff] [blame] | 62 | #include "utils/calling.h" |
| 63 | #include "contactsview.h" |
| 64 | #include "historyview.h" |
| 65 | #include "utils/models.h" |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 66 | #include "generalsettingsview.h" |
Stepan Salenikovich | 75a3917 | 2015-07-10 13:21:08 -0400 | [diff] [blame] | 67 | #include "utils/accounts.h" |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 68 | #include "ringwelcomeview.h" |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 69 | #include "accountmigrationview.h" |
| 70 | #include "accountcreationwizard.h" |
Stepan Salenikovich | 2f8b449 | 2015-09-21 17:10:36 -0400 | [diff] [blame] | 71 | #include "recentcontactsview.h" |
Stepan Salenikovich | c6a3b98 | 2016-01-11 18:11:39 -0500 | [diff] [blame] | 72 | #include "chatview.h" |
Nicolas Jager | b413b30 | 2016-05-06 11:41:32 -0400 | [diff] [blame] | 73 | #include "avatarmanipulation.h" |
Stepan Salenikovich | ba87ae2 | 2016-09-13 14:27:20 -0400 | [diff] [blame] | 74 | #include "utils/files.h" |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 75 | #include "pendingcontactrequests.h" |
Nicolas Jager | b413b30 | 2016-05-06 11:41:32 -0400 | [diff] [blame] | 76 | |
Stepan Salenikovich | 9ffad5e | 2015-09-25 13:16:50 -0400 | [diff] [blame] | 77 | static constexpr const char* CALL_VIEW_NAME = "calls"; |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 78 | static constexpr const char* ACCOUNT_CREATION_WIZARD_VIEW_NAME = "account-creation-wizard"; |
| 79 | static constexpr const char* ACCOUNT_MIGRATION_VIEW_NAME = "account-migration-view"; |
Stepan Salenikovich | 9ffad5e | 2015-09-25 13:16:50 -0400 | [diff] [blame] | 80 | static constexpr const char* GENERAL_SETTINGS_VIEW_NAME = "general"; |
| 81 | static constexpr const char* AUDIO_SETTINGS_VIEW_NAME = "audio"; |
| 82 | static constexpr const char* MEDIA_SETTINGS_VIEW_NAME = "media"; |
| 83 | static constexpr const char* ACCOUNT_SETTINGS_VIEW_NAME = "accounts"; |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 84 | static constexpr const char* DEFAULT_VIEW_NAME = "welcome"; |
Stepan Salenikovich | 9ffad5e | 2015-09-25 13:16:50 -0400 | [diff] [blame] | 85 | static constexpr const char* VIEW_CONTACTS = "contacts"; |
| 86 | static constexpr const char* VIEW_HISTORY = "history"; |
| 87 | static constexpr const char* VIEW_PRESENCE = "presence"; |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 88 | |
| 89 | struct _RingMainWindow |
| 90 | { |
| 91 | GtkApplicationWindow parent; |
| 92 | }; |
| 93 | |
| 94 | struct _RingMainWindowClass |
| 95 | { |
| 96 | GtkApplicationWindowClass parent_class; |
| 97 | }; |
| 98 | |
| 99 | typedef struct _RingMainWindowPrivate RingMainWindowPrivate; |
| 100 | |
| 101 | struct _RingMainWindowPrivate |
| 102 | { |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 103 | GtkWidget *ring_menu; |
| 104 | GtkWidget *image_ring; |
| 105 | GtkWidget *ring_settings; |
| 106 | GtkWidget *image_settings; |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 107 | GtkWidget *hbox_settings; |
Stepan Salenikovich | 2f8b449 | 2015-09-21 17:10:36 -0400 | [diff] [blame] | 108 | GtkWidget *scrolled_window_smartview; |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 109 | GtkWidget *treeview_conversations; |
Stepan Salenikovich | a7a19bc | 2015-09-24 16:16:28 -0400 | [diff] [blame] | 110 | GtkWidget *scrolled_window_contacts; |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 111 | GtkWidget *treeview_contacts; |
Stepan Salenikovich | a7a19bc | 2015-09-24 16:16:28 -0400 | [diff] [blame] | 112 | GtkWidget *scrolled_window_history; |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 113 | GtkWidget *treeview_history; |
Stepan Salenikovich | bbb10d8 | 2015-05-13 12:26:44 -0400 | [diff] [blame] | 114 | GtkWidget *vbox_left_pane; |
Stepan Salenikovich | 45d25aa | 2015-02-20 17:39:09 -0500 | [diff] [blame] | 115 | GtkWidget *search_entry; |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 116 | GtkWidget *stack_main_view; |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 117 | GtkWidget *vbox_call_view; |
Stepan Salenikovich | 3034d92 | 2015-10-09 10:11:42 -0400 | [diff] [blame] | 118 | GtkWidget *frame_call; |
| 119 | GtkWidget *welcome_view; |
Stepan Salenikovich | e993324 | 2016-06-21 18:08:48 -0400 | [diff] [blame] | 120 | GtkWidget *button_new_conversation ; |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 121 | GtkWidget *account_settings_view; |
Stepan Salenikovich | 0bd5349 | 2015-05-11 14:28:52 -0400 | [diff] [blame] | 122 | GtkWidget *media_settings_view; |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 123 | GtkWidget *general_settings_view; |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 124 | GtkWidget *last_settings_view; |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 125 | GtkWidget *radiobutton_general_settings; |
Stepan Salenikovich | 5d3506e | 2015-03-30 11:01:29 -0400 | [diff] [blame] | 126 | GtkWidget *radiobutton_media_settings; |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 127 | GtkWidget *radiobutton_account_settings; |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 128 | GtkWidget *account_creation_wizard; |
| 129 | GtkWidget *account_migration_view; |
Nicolas Jager | 5590314 | 2017-02-01 14:43:45 -0500 | [diff] [blame] | 130 | GtkWidget *spinner_lookup; |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 131 | GtkWidget *combobox_account_selector; |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 132 | GtkWidget *treeview_contact_requests; |
| 133 | GtkWidget *scrolled_window_contact_requests; |
| 134 | GtkWidget *contact_request_view; |
Stepan Salenikovich | 5eab303 | 2015-03-28 10:50:51 -0400 | [diff] [blame] | 135 | |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 136 | /* Pending ring usernames lookup for the search entry */ |
| 137 | QMetaObject::Connection username_lookup; |
Guillaume Roguez | e7221ed | 2017-03-17 20:09:56 -0400 | [diff] [blame] | 138 | std::string* pending_username_lookup; |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 139 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 140 | /* The webkit_chat_container is created once, then reused for all chat views */ |
| 141 | GtkWidget *webkit_chat_container; |
| 142 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 143 | QMetaObject::Connection selected_item_changed; |
| 144 | QMetaObject::Connection selected_call_over; |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 145 | |
| 146 | gboolean show_settings; |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 147 | |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 148 | /* fullscreen */ |
| 149 | gboolean is_fullscreen; |
Stepan Salenikovich | ba87ae2 | 2016-09-13 14:27:20 -0400 | [diff] [blame] | 150 | |
| 151 | GSettings *settings; |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | G_DEFINE_TYPE_WITH_PRIVATE(RingMainWindow, ring_main_window, GTK_TYPE_APPLICATION_WINDOW); |
| 155 | |
| 156 | #define RING_MAIN_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), RING_MAIN_WINDOW_TYPE, RingMainWindowPrivate)) |
| 157 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 158 | static gboolean selection_changed(RingMainWindow *win); |
| 159 | |
| 160 | static WebKitChatContainer* |
| 161 | get_webkit_chat_container(RingMainWindow *win) |
| 162 | { |
| 163 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 164 | if (!priv->webkit_chat_container) |
| 165 | { |
| 166 | priv->webkit_chat_container = webkit_chat_container_new(); |
| 167 | |
| 168 | //We don't want it to be deleted, ever. |
| 169 | g_object_ref(priv->webkit_chat_container); |
| 170 | } |
| 171 | return WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container); |
| 172 | } |
| 173 | |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 174 | static void |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 175 | enter_full_screen(RingMainWindow *self) |
| 176 | { |
| 177 | g_return_if_fail(IS_RING_MAIN_WINDOW(self)); |
| 178 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self)); |
| 179 | |
| 180 | if (!priv->is_fullscreen) { |
| 181 | gtk_widget_hide(priv->vbox_left_pane); |
| 182 | gtk_window_fullscreen(GTK_WINDOW(self)); |
| 183 | priv->is_fullscreen = TRUE; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | static void |
| 188 | leave_full_screen(RingMainWindow *self) |
| 189 | { |
| 190 | g_return_if_fail(IS_RING_MAIN_WINDOW(self)); |
| 191 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self)); |
| 192 | |
| 193 | if (priv->is_fullscreen) { |
| 194 | gtk_widget_show(priv->vbox_left_pane); |
| 195 | gtk_window_unfullscreen(GTK_WINDOW(self)); |
| 196 | priv->is_fullscreen = FALSE; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | static void |
Stepan Salenikovich | 5e431cf | 2015-12-24 14:09:01 -0500 | [diff] [blame] | 201 | video_double_clicked(G_GNUC_UNUSED CurrentCallView *view, RingMainWindow *self) |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 202 | { |
| 203 | g_return_if_fail(IS_RING_MAIN_WINDOW(self)); |
| 204 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self)); |
| 205 | |
| 206 | if (priv->is_fullscreen) { |
| 207 | leave_full_screen(self); |
| 208 | } else { |
| 209 | enter_full_screen(self); |
| 210 | } |
| 211 | } |
| 212 | |
Stepan Salenikovich | 8043a56 | 2016-03-18 13:56:40 -0400 | [diff] [blame] | 213 | static void |
| 214 | hide_view_clicked(G_GNUC_UNUSED GtkWidget *view, RingMainWindow *self) |
| 215 | { |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 216 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self)); |
Stepan Salenikovich | 8043a56 | 2016-03-18 13:56:40 -0400 | [diff] [blame] | 217 | |
| 218 | /* clear selection */ |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 219 | auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations)); |
| 220 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_conversations)); |
| 221 | auto selection_contacts = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contacts)); |
| 222 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_contacts)); |
| 223 | auto selection_history = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_history)); |
| 224 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_history)); |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 225 | auto selection_contact_request = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contact_requests)); |
| 226 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_contact_request)); |
| 227 | |
Stepan Salenikovich | 8043a56 | 2016-03-18 13:56:40 -0400 | [diff] [blame] | 228 | } |
| 229 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 230 | static void |
| 231 | change_view(RingMainWindow *self, GtkWidget* old, QObject *object, GType type) |
| 232 | { |
| 233 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 234 | leave_full_screen(self); |
| 235 | gtk_container_remove(GTK_CONTAINER(priv->frame_call), old); |
| 236 | |
| 237 | GtkWidget *new_view = nullptr; |
| 238 | |
| 239 | QObject::disconnect(priv->selected_item_changed); |
| 240 | QObject::disconnect(priv->selected_call_over); |
| 241 | |
| 242 | if (g_type_is_a(INCOMING_CALL_VIEW_TYPE, type)) { |
| 243 | if (auto call = qobject_cast<Call *>(object)) { |
| 244 | new_view = incoming_call_view_new(call, get_webkit_chat_container(self)); |
| 245 | priv->selected_item_changed = QObject::connect( |
| 246 | call, |
| 247 | &Call::lifeCycleStateChanged, |
| 248 | [self] (Call::LifeCycleState, Call::LifeCycleState) |
| 249 | {g_idle_add((GSourceFunc)selection_changed, self);} |
| 250 | ); |
| 251 | priv->selected_call_over = QObject::connect( |
| 252 | call, |
| 253 | &Call::isOver, |
| 254 | [self] () |
| 255 | {g_idle_add((GSourceFunc)selection_changed, self);} |
| 256 | ); |
| 257 | } else |
| 258 | g_warning("Trying to display a view of type IncomingCallView, but the object is not of type Call"); |
| 259 | } else if (g_type_is_a(CURRENT_CALL_VIEW_TYPE, type)) { |
| 260 | if (auto call = qobject_cast<Call *>(object)) { |
| 261 | new_view = current_call_view_new(call, get_webkit_chat_container(self)); |
| 262 | g_signal_connect(new_view, "video-double-clicked", G_CALLBACK(video_double_clicked), self); |
| 263 | priv->selected_item_changed = QObject::connect( |
| 264 | call, |
| 265 | &Call::lifeCycleStateChanged, |
| 266 | [self] (Call::LifeCycleState, Call::LifeCycleState) |
| 267 | {g_idle_add((GSourceFunc)selection_changed, self);} |
| 268 | ); |
| 269 | priv->selected_call_over = QObject::connect( |
| 270 | call, |
| 271 | &Call::isOver, |
| 272 | [self] () |
| 273 | {g_idle_add((GSourceFunc)selection_changed, self);} |
| 274 | ); |
| 275 | } else |
| 276 | g_warning("Trying to display a view of type CurrentCallView, but the object is not of type Call"); |
| 277 | } else if (g_type_is_a(CHAT_VIEW_TYPE, type)) { |
| 278 | if (auto person = qobject_cast<Person *>(object)) { |
| 279 | new_view = chat_view_new_person(get_webkit_chat_container(self), person); |
| 280 | g_signal_connect(new_view, "hide-view-clicked", G_CALLBACK(hide_view_clicked), self); |
| 281 | |
| 282 | /* connect to the Person's callAdded signal, because we want to switch to the call view |
| 283 | * in this case */ |
| 284 | priv->selected_item_changed = QObject::connect( |
| 285 | person, |
| 286 | &Person::callAdded, |
| 287 | [self] (Call*) |
| 288 | {g_idle_add((GSourceFunc)selection_changed, self);} |
| 289 | ); |
| 290 | } else if (auto cm = qobject_cast<ContactMethod *>(object)) { |
| 291 | new_view = chat_view_new_cm(get_webkit_chat_container(self), cm); |
| 292 | g_signal_connect(new_view, "hide-view-clicked", G_CALLBACK(hide_view_clicked), self); |
| 293 | |
| 294 | /* connect to the ContactMethod's callAdded signal, because we want to switch to the |
| 295 | * call view in this case */ |
| 296 | priv->selected_item_changed = QObject::connect( |
| 297 | cm, |
| 298 | &ContactMethod::callAdded, |
| 299 | [self] (Call*) |
| 300 | {g_idle_add((GSourceFunc)selection_changed, self);} |
| 301 | ); |
| 302 | } else { |
| 303 | g_warning("Trying to display a veiw of type ChatView, but the object is neither a Person nor a ContactMethod"); |
| 304 | } |
| 305 | } else { |
| 306 | // display the welcome view |
| 307 | new_view = priv->welcome_view; |
| 308 | } |
| 309 | |
| 310 | gtk_container_add(GTK_CONTAINER(priv->frame_call), new_view); |
| 311 | gtk_widget_show(new_view); |
| 312 | } |
| 313 | |
Stepan Salenikovich | c132342 | 2016-01-06 10:54:44 -0500 | [diff] [blame] | 314 | /** |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 315 | * This function determines which view to display in the right panel of the main window based on |
| 316 | * which item is selected in one of the 3 contact list views (Conversations, Contacts, History). The |
| 317 | * possible views ares: |
Stepan Salenikovich | c132342 | 2016-01-06 10:54:44 -0500 | [diff] [blame] | 318 | * - incoming call view |
| 319 | * - current call view |
Stepan Salenikovich | c6a3b98 | 2016-01-11 18:11:39 -0500 | [diff] [blame] | 320 | * - chat view |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 321 | * - welcome view (if no valid item is selected) |
| 322 | * |
| 323 | * There should never be a conflict of which item should be displayed (ie: which item is selected), |
| 324 | * as there should only ever be one selection at a time in the 3 views except in the case that the |
| 325 | * same item is selected in more than one view (see the compare_treeview_selection() function). |
| 326 | * |
| 327 | * This function could be called from a g_idle source, so it returns a boolean to remove itself from |
| 328 | * being called again. The boolean doesn't reflect success nor failure. |
Stepan Salenikovich | c132342 | 2016-01-06 10:54:44 -0500 | [diff] [blame] | 329 | */ |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 330 | static gboolean |
| 331 | selection_changed(RingMainWindow *win) |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 332 | { |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 333 | |
| 334 | g_return_val_if_fail(IS_RING_MAIN_WINDOW(win), G_SOURCE_REMOVE); |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 335 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(win)); |
| 336 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 337 | auto old_view = gtk_bin_get_child(GTK_BIN(priv->frame_call)); |
Stepan Salenikovich | bd4b377 | 2015-12-13 23:28:06 -0500 | [diff] [blame] | 338 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 339 | /* if we're showing the settings, then we need to make sure to remove any possible ongoing call |
| 340 | * view so that we don't have more than one VideoWidget at a time */ |
| 341 | if (priv->show_settings) { |
| 342 | if (old_view != priv->welcome_view) { |
| 343 | leave_full_screen(win); |
| 344 | gtk_container_remove(GTK_CONTAINER(priv->frame_call), old_view); |
| 345 | gtk_container_add(GTK_CONTAINER(priv->frame_call), priv->welcome_view); |
| 346 | gtk_widget_show(priv->welcome_view); |
| 347 | } |
| 348 | return G_SOURCE_REMOVE; |
| 349 | } |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 350 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 351 | /* there should only be one item selected at a time, get which one is selected */ |
| 352 | auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations)); |
| 353 | auto selection_contacts = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contacts)); |
| 354 | auto selection_history = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_history)); |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 355 | auto selection_contact_request = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contact_requests)); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 356 | |
| 357 | GtkTreeModel *model = nullptr; |
| 358 | GtkTreeIter iter; |
| 359 | QModelIndex idx; |
| 360 | |
| 361 | if (gtk_tree_selection_get_selected(selection_conversations, &model, &iter)) { |
Stepan Salenikovich | f607822 | 2016-10-03 17:31:16 -0400 | [diff] [blame] | 362 | idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 363 | } else if (gtk_tree_selection_get_selected(selection_contacts, &model, &iter)) { |
Stepan Salenikovich | f607822 | 2016-10-03 17:31:16 -0400 | [diff] [blame] | 364 | idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 365 | } else if (gtk_tree_selection_get_selected(selection_history, &model, &iter)) { |
Stepan Salenikovich | f607822 | 2016-10-03 17:31:16 -0400 | [diff] [blame] | 366 | idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter); |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 367 | } else if (gtk_tree_selection_get_selected(selection_contact_request, &model, &iter)) { |
| 368 | idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), &iter); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 369 | } |
Stepan Salenikovich | e1b5489 | 2015-12-13 22:18:44 -0500 | [diff] [blame] | 370 | |
Stepan Salenikovich | c6a3b98 | 2016-01-11 18:11:39 -0500 | [diff] [blame] | 371 | /* check which object type is selected */ |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 372 | auto type = idx.data(static_cast<int>(Ring::Role::ObjectType)); |
| 373 | auto object = idx.data(static_cast<int>(Ring::Role::Object)); |
Stepan Salenikovich | c6a3b98 | 2016-01-11 18:11:39 -0500 | [diff] [blame] | 374 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 375 | if (idx.isValid() && type.isValid() && object.isValid()) { |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 376 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 377 | /* we prioritize the views in the following order: |
| 378 | * - call view (if there is an ongoing call associated with the item) |
| 379 | * - chat view built from Person |
| 380 | * - chat view built from ContactMethod |
| 381 | */ |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 382 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 383 | Person *person = nullptr; |
| 384 | ContactMethod *cm = nullptr; |
| 385 | Call *call = nullptr; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 386 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 387 | /* use the RecentModel to see if there are any ongoing calls associated with the selected item */ |
| 388 | switch(type.value<Ring::ObjectType>()) { |
| 389 | case Ring::ObjectType::Person: |
| 390 | { |
| 391 | person = object.value<Person *>(); |
| 392 | auto recent_idx = RecentModel::instance().getIndex(person); |
| 393 | if (recent_idx.isValid()) { |
| 394 | call = RecentModel::instance().getActiveCall(recent_idx); |
| 395 | } |
| 396 | } |
| 397 | break; |
| 398 | case Ring::ObjectType::ContactMethod: |
| 399 | { |
| 400 | cm = object.value<ContactMethod *>(); |
| 401 | auto recent_idx = RecentModel::instance().getIndex(cm); |
| 402 | if (recent_idx.isValid()) { |
| 403 | call = RecentModel::instance().getActiveCall(recent_idx); |
| 404 | } |
| 405 | } |
| 406 | break; |
| 407 | case Ring::ObjectType::Call: |
| 408 | { |
| 409 | /* if the call is over (eg: if it comes from the history model) then we first check |
| 410 | * if there is an ongoing call with the same ContactMethod, otherwise we need to get |
| 411 | * the associated Person or ContactMethod */ |
| 412 | call = object.value<Call *>(); |
| 413 | if (call->isHistory()) { |
| 414 | cm = call->peerContactMethod(); |
| 415 | call = nullptr; |
| 416 | if (cm) { |
| 417 | auto recent_idx = RecentModel::instance().getIndex(cm); |
| 418 | if (recent_idx.isValid()) { |
| 419 | call = RecentModel::instance().getActiveCall(recent_idx); |
| 420 | } |
| 421 | person = cm->contact(); |
Stepan Salenikovich | c6a3b98 | 2016-01-11 18:11:39 -0500 | [diff] [blame] | 422 | } |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 423 | } |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 424 | } |
| 425 | break; |
| 426 | case Ring::ObjectType::Media: |
| 427 | case Ring::ObjectType::Certificate: |
Nicolas Jager | c74f761 | 2017-03-28 09:48:18 -0400 | [diff] [blame] | 428 | case Ring::ObjectType::ContactRequest: |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 429 | case Ring::ObjectType::COUNT__: |
| 430 | // nothing to do |
| 431 | break; |
| 432 | } |
| 433 | |
| 434 | /* we prioritize showing the call view */ |
| 435 | if (call) { |
| 436 | auto state = call->lifeCycleState(); |
| 437 | |
| 438 | Call *current_call = nullptr; |
| 439 | |
| 440 | switch(state) { |
| 441 | case Call::LifeCycleState::CREATION: |
| 442 | case Call::LifeCycleState::INITIALIZATION: |
| 443 | case Call::LifeCycleState::FINISHED: |
| 444 | // check if we're already displaying this call |
| 445 | if (IS_INCOMING_CALL_VIEW(old_view)) |
| 446 | current_call = incoming_call_view_get_call(INCOMING_CALL_VIEW(old_view)); |
| 447 | if (current_call != call) |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 448 | change_view(win, old_view, call, INCOMING_CALL_VIEW_TYPE); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 449 | break; |
| 450 | case Call::LifeCycleState::PROGRESS: |
| 451 | // check if we're already displaying this call |
| 452 | if (IS_CURRENT_CALL_VIEW(old_view)) |
| 453 | current_call = current_call_view_get_call(CURRENT_CALL_VIEW(old_view)); |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 454 | if (current_call != call) |
| 455 | change_view(win, old_view, call, CURRENT_CALL_VIEW_TYPE); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 456 | break; |
| 457 | case Call::LifeCycleState::COUNT__: |
| 458 | g_warning("LifeCycleState should never be COUNT"); |
| 459 | break; |
| 460 | } |
Stepan Salenikovich | c6a3b98 | 2016-01-11 18:11:39 -0500 | [diff] [blame] | 461 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 462 | } else if (person) { |
| 463 | /* show chat view constructed from Person object */ |
| 464 | |
| 465 | // check if we're already displaying the chat view for this person |
| 466 | Person *current_person = nullptr; |
| 467 | if (IS_CHAT_VIEW(old_view)) |
| 468 | current_person = chat_view_get_person(CHAT_VIEW(old_view)); |
| 469 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 470 | if (current_person != person) |
| 471 | change_view(win, old_view, person, CHAT_VIEW_TYPE); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 472 | } else if (cm) { |
| 473 | /* show chat view constructed from CM */ |
| 474 | |
| 475 | // check if we're already displaying the chat view for this cm |
| 476 | ContactMethod *current_cm = nullptr; |
| 477 | if (IS_CHAT_VIEW(old_view)) |
| 478 | current_cm = chat_view_get_cm(CHAT_VIEW(old_view)); |
| 479 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 480 | if (current_cm != cm) |
| 481 | change_view(win, old_view, cm, CHAT_VIEW_TYPE); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 482 | } else { |
| 483 | /* not a supported object type, display the welcome view */ |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 484 | if (old_view != priv->welcome_view) |
| 485 | change_view(win, old_view, nullptr, RING_WELCOME_VIEW_TYPE); |
Stepan Salenikovich | c6a3b98 | 2016-01-11 18:11:39 -0500 | [diff] [blame] | 486 | } |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 487 | } else { |
| 488 | /* selection isn't valid, display the welcome view */ |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 489 | if (old_view != priv->welcome_view) |
| 490 | change_view(win, old_view, nullptr, RING_WELCOME_VIEW_TYPE); |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 491 | } |
Stepan Salenikovich | 504f772 | 2016-01-20 17:10:45 -0500 | [diff] [blame] | 492 | |
| 493 | return G_SOURCE_REMOVE; |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 494 | } |
| 495 | |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 496 | static void |
Nicolas Jager | 65d6e1f | 2017-03-27 16:57:55 -0400 | [diff] [blame] | 497 | process_search_entry_contact_method(RingMainWindow *self, const URI& uri, Account* accountOrNullptr) |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 498 | { |
| 499 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 500 | |
Nicolas Jager | 65d6e1f | 2017-03-27 16:57:55 -0400 | [diff] [blame] | 501 | auto cm = PhoneDirectoryModel::instance().getNumber(uri, accountOrNullptr); |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 502 | |
| 503 | if (g_settings_get_boolean(priv->settings, "search-entry-places-call")) { |
| 504 | place_new_call(cm); |
| 505 | |
| 506 | /* move focus away from entry so that DTMF tones can be entered via the keyboard */ |
| 507 | gtk_widget_child_focus(GTK_WIDGET(self), GTK_DIR_TAB_FORWARD); |
| 508 | } else { |
| 509 | // if its a new CM, bring it to the top |
| 510 | if (cm->lastUsed() == 0) |
| 511 | cm->setLastUsed(QDateTime::currentDateTime().toTime_t()); |
| 512 | |
| 513 | // select cm |
| 514 | RecentModel::instance().selectionModel()->setCurrentIndex(RecentModel::instance().getIndex(cm), QItemSelectionModel::ClearAndSelect); |
| 515 | } |
| 516 | gtk_entry_set_text(GTK_ENTRY(priv->search_entry), ""); |
| 517 | } |
| 518 | |
| 519 | static void |
Stepan Salenikovich | b0ffc34 | 2016-10-13 13:10:55 -0400 | [diff] [blame] | 520 | search_entry_activated(RingMainWindow *self) |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 521 | { |
Stepan Salenikovich | b0ffc34 | 2016-10-13 13:10:55 -0400 | [diff] [blame] | 522 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 523 | |
Nicolas Jager | 5590314 | 2017-02-01 14:43:45 -0500 | [diff] [blame] | 524 | const auto *querry = gtk_entry_get_text(GTK_ENTRY(priv->search_entry)); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 525 | |
Nicolas Jager | 5590314 | 2017-02-01 14:43:45 -0500 | [diff] [blame] | 526 | URI uri = URI(querry); |
Stepan Salenikovich | 7b7be48 | 2016-11-03 16:57:48 -0400 | [diff] [blame] | 527 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 528 | /* we don't want to lookup a ring id and we require to have a ring account chosen */ |
| 529 | if (uri.protocolHint() != URI::ProtocolHint::RING && get_active_ring_account()) { |
| 530 | *priv->pending_username_lookup = querry; |
Stepan Salenikovich | 7b7be48 | 2016-11-03 16:57:48 -0400 | [diff] [blame] | 531 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 532 | gtk_spinner_start(GTK_SPINNER(priv->spinner_lookup)); |
| 533 | gtk_entry_set_text(GTK_ENTRY(priv->search_entry), ""); |
Stepan Salenikovich | 7b7be48 | 2016-11-03 16:57:48 -0400 | [diff] [blame] | 534 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 535 | QString username_to_lookup = uri.format(URI::Section::USER_INFO|URI::Section::HOSTNAME|URI::Section::PORT); |
Stepan Salenikovich | 7b7be48 | 2016-11-03 16:57:48 -0400 | [diff] [blame] | 536 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 537 | /* disconect previous lookup */ |
| 538 | QObject::disconnect(priv->username_lookup); |
Stepan Salenikovich | efd8cae | 2016-11-10 13:41:30 -0500 | [diff] [blame] | 539 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 540 | /* connect new lookup */ |
| 541 | priv->username_lookup = QObject::connect( |
| 542 | &NameDirectory::instance(), |
| 543 | &NameDirectory::registeredNameFound, |
| 544 | [self, priv, username_to_lookup] (Account* account, NameDirectory::LookupStatus status, const QString& address, const QString& name) { |
Stepan Salenikovich | 7b7be48 | 2016-11-03 16:57:48 -0400 | [diff] [blame] | 545 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 546 | auto name_qbarray = name.toLatin1(); |
| 547 | if ( strcmp(priv->pending_username_lookup->data(), name_qbarray.data()) != 0 ) |
| 548 | return; |
Stepan Salenikovich | 895a70b | 2015-03-27 16:02:27 -0400 | [diff] [blame] | 549 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 550 | gtk_entry_set_text(GTK_ENTRY(priv->search_entry), ""); |
Stepan Salenikovich | 895a70b | 2015-03-27 16:02:27 -0400 | [diff] [blame] | 551 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 552 | switch(status) |
| 553 | { |
| 554 | case NameDirectory::LookupStatus::SUCCESS: |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 555 | { |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 556 | URI uri = URI("ring:" + address); |
| 557 | process_search_entry_contact_method(self, uri, account); |
| 558 | break; |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 559 | } |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 560 | case NameDirectory::LookupStatus::INVALID_NAME: |
| 561 | { |
| 562 | //Can't be a ring username, could be something else. |
| 563 | auto dialog = gtk_message_dialog_new( |
| 564 | GTK_WINDOW(self), |
| 565 | GTK_DIALOG_DESTROY_WITH_PARENT, |
| 566 | GTK_MESSAGE_ERROR, |
| 567 | GTK_BUTTONS_CLOSE, |
| 568 | _("Invalid Ring username: %s"), |
| 569 | name.toUtf8().constData() |
| 570 | ); |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 571 | |
Nicolas Jager | 40916b4 | 2017-03-18 14:59:20 -0400 | [diff] [blame] | 572 | gtk_dialog_run (GTK_DIALOG (dialog)); |
| 573 | gtk_widget_destroy (dialog); |
| 574 | break; |
| 575 | } |
| 576 | case NameDirectory::LookupStatus::ERROR: |
| 577 | { |
| 578 | auto dialog = gtk_message_dialog_new( |
| 579 | GTK_WINDOW(self), |
| 580 | GTK_DIALOG_DESTROY_WITH_PARENT, |
| 581 | GTK_MESSAGE_ERROR, |
| 582 | GTK_BUTTONS_CLOSE, |
| 583 | _("Error resolving username, nameserver is possibly unreachable") |
| 584 | ); |
| 585 | |
| 586 | gtk_dialog_run(GTK_DIALOG (dialog)); |
| 587 | gtk_widget_destroy(dialog); |
| 588 | break; |
| 589 | } |
| 590 | case NameDirectory::LookupStatus::NOT_FOUND: |
| 591 | { |
| 592 | auto dialog = gtk_message_dialog_new( |
| 593 | GTK_WINDOW(self), |
| 594 | GTK_DIALOG_DESTROY_WITH_PARENT, |
| 595 | GTK_MESSAGE_ERROR, |
| 596 | GTK_BUTTONS_CLOSE, |
| 597 | _("Could not resolve Ring username: %s"), |
| 598 | name.toUtf8().constData() |
| 599 | ); |
| 600 | |
| 601 | gtk_dialog_run(GTK_DIALOG (dialog)); |
| 602 | gtk_widget_destroy(dialog); |
| 603 | break; |
| 604 | } |
| 605 | } |
| 606 | *priv->pending_username_lookup = ""; |
| 607 | gtk_spinner_stop(GTK_SPINNER(priv->spinner_lookup)); |
| 608 | } |
| 609 | ); |
| 610 | |
| 611 | /* lookup */ |
| 612 | NameDirectory::instance().lookupName(get_active_ring_account(), QString(), username_to_lookup); |
| 613 | }else // no lookup |
| 614 | process_search_entry_contact_method(self, uri, nullptr); |
Stepan Salenikovich | 297b5d1 | 2015-02-26 17:51:13 -0500 | [diff] [blame] | 615 | } |
| 616 | |
Stepan Salenikovich | 7c71bfe | 2015-05-13 18:08:09 -0400 | [diff] [blame] | 617 | static gboolean |
Stepan Salenikovich | bd02958 | 2015-03-24 11:00:56 -0400 | [diff] [blame] | 618 | save_accounts(GtkWidget *working_dialog) |
| 619 | { |
| 620 | /* save changes to accounts */ |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 621 | AccountModel::instance().save(); |
Stepan Salenikovich | bd02958 | 2015-03-24 11:00:56 -0400 | [diff] [blame] | 622 | |
| 623 | if (working_dialog) |
| 624 | gtk_widget_destroy(working_dialog); |
| 625 | |
| 626 | return G_SOURCE_REMOVE; |
| 627 | } |
| 628 | |
Stepan Salenikovich | 1514218 | 2015-03-11 17:15:26 -0400 | [diff] [blame] | 629 | static void |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 630 | settings_clicked(G_GNUC_UNUSED GtkButton *button, RingMainWindow *win) |
| 631 | { |
| 632 | g_return_if_fail(IS_RING_MAIN_WINDOW(win)); |
| 633 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 634 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 635 | /* check which view to show */ |
Stepan Salenikovich | bd4b377 | 2015-12-13 23:28:06 -0500 | [diff] [blame] | 636 | if (!priv->show_settings) { |
| 637 | /* show the settings */ |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 638 | priv->show_settings = TRUE; |
Stepan Salenikovich | bd4b377 | 2015-12-13 23:28:06 -0500 | [diff] [blame] | 639 | |
Stepan Salenikovich | c132342 | 2016-01-06 10:54:44 -0500 | [diff] [blame] | 640 | /* make sure we are not showing a call view so we don't have more than one clutter stage at a time */ |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 641 | selection_changed(win); |
Stepan Salenikovich | bd4b377 | 2015-12-13 23:28:06 -0500 | [diff] [blame] | 642 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 643 | /* show settings */ |
Stepan Salenikovich | d61974b | 2016-03-18 16:36:27 -0400 | [diff] [blame] | 644 | gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-ok-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 645 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 646 | gtk_widget_show(priv->hbox_settings); |
| 647 | |
Stepan Salenikovich | 4111891 | 2015-05-01 11:25:46 -0400 | [diff] [blame] | 648 | /* make sure to start preview if we're showing the video settings */ |
Stepan Salenikovich | 0bd5349 | 2015-05-11 14:28:52 -0400 | [diff] [blame] | 649 | if (priv->last_settings_view == priv->media_settings_view) |
| 650 | media_settings_view_show_preview(MEDIA_SETTINGS_VIEW(priv->media_settings_view), TRUE); |
Stepan Salenikovich | 4111891 | 2015-05-01 11:25:46 -0400 | [diff] [blame] | 651 | |
Nicolas Jager | 6f5e04a | 2016-05-18 15:04:59 -0400 | [diff] [blame] | 652 | /* make sure to show the profile if we're showing the general settings */ |
| 653 | if (priv->last_settings_view == priv->general_settings_view) |
| 654 | general_settings_view_show_profile(GENERAL_SETTINGS_VIEW(priv->general_settings_view), TRUE); |
| 655 | |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 656 | gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), priv->last_settings_view); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 657 | } else { |
Stepan Salenikovich | bd4b377 | 2015-12-13 23:28:06 -0500 | [diff] [blame] | 658 | /* hide the settings */ |
| 659 | priv->show_settings = FALSE; |
| 660 | |
Stepan Salenikovich | bd02958 | 2015-03-24 11:00:56 -0400 | [diff] [blame] | 661 | /* show working dialog in case save operation takes time */ |
| 662 | GtkWidget *working = ring_dialog_working(GTK_WIDGET(win), NULL); |
| 663 | gtk_window_present(GTK_WINDOW(working)); |
| 664 | |
| 665 | /* now save after the time it takes to transition back to the call view (400ms) |
| 666 | * the save doesn't happen before the "working" dialog is presented |
| 667 | * the timeout function should destroy the "working" dialog when done saving |
| 668 | */ |
Stepan Salenikovich | 12fee94 | 2015-03-25 18:38:47 -0400 | [diff] [blame] | 669 | g_timeout_add_full(G_PRIORITY_DEFAULT, 400, (GSourceFunc)save_accounts, working, NULL); |
Stepan Salenikovich | bd02958 | 2015-03-24 11:00:56 -0400 | [diff] [blame] | 670 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 671 | /* show calls */ |
Stepan Salenikovich | d61974b | 2016-03-18 16:36:27 -0400 | [diff] [blame] | 672 | gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-system-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 673 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 674 | gtk_widget_hide(priv->hbox_settings); |
| 675 | |
Stepan Salenikovich | bd4b377 | 2015-12-13 23:28:06 -0500 | [diff] [blame] | 676 | /* make sure video preview is stopped, in case it was started */ |
| 677 | media_settings_view_show_preview(MEDIA_SETTINGS_VIEW(priv->media_settings_view), FALSE); |
Nicolas Jager | 6f5e04a | 2016-05-18 15:04:59 -0400 | [diff] [blame] | 678 | general_settings_view_show_profile(GENERAL_SETTINGS_VIEW(priv->general_settings_view), FALSE); |
Stepan Salenikovich | bd4b377 | 2015-12-13 23:28:06 -0500 | [diff] [blame] | 679 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 680 | gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), CALL_VIEW_NAME); |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 681 | |
Stepan Salenikovich | c132342 | 2016-01-06 10:54:44 -0500 | [diff] [blame] | 682 | /* show the view which was selected previously */ |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 683 | selection_changed(win); |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 684 | } |
| 685 | } |
| 686 | |
| 687 | static void |
Stepan Salenikovich | 5d3506e | 2015-03-30 11:01:29 -0400 | [diff] [blame] | 688 | show_media_settings(GtkToggleButton *navbutton, RingMainWindow *win) |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 689 | { |
| 690 | g_return_if_fail(IS_RING_MAIN_WINDOW(win)); |
| 691 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 692 | |
| 693 | if (gtk_toggle_button_get_active(navbutton)) { |
Stepan Salenikovich | 0bd5349 | 2015-05-11 14:28:52 -0400 | [diff] [blame] | 694 | media_settings_view_show_preview(MEDIA_SETTINGS_VIEW(priv->media_settings_view), TRUE); |
Stepan Salenikovich | 5d3506e | 2015-03-30 11:01:29 -0400 | [diff] [blame] | 695 | gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), MEDIA_SETTINGS_VIEW_NAME); |
Stepan Salenikovich | 0bd5349 | 2015-05-11 14:28:52 -0400 | [diff] [blame] | 696 | priv->last_settings_view = priv->media_settings_view; |
Stepan Salenikovich | 4111891 | 2015-05-01 11:25:46 -0400 | [diff] [blame] | 697 | } else { |
Stepan Salenikovich | 0bd5349 | 2015-05-11 14:28:52 -0400 | [diff] [blame] | 698 | media_settings_view_show_preview(MEDIA_SETTINGS_VIEW(priv->media_settings_view), FALSE); |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | |
| 702 | static void |
| 703 | show_account_settings(GtkToggleButton *navbutton, RingMainWindow *win) |
| 704 | { |
| 705 | g_return_if_fail(IS_RING_MAIN_WINDOW(win)); |
| 706 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 707 | |
| 708 | if (gtk_toggle_button_get_active(navbutton)) { |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 709 | gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), ACCOUNT_SETTINGS_VIEW_NAME); |
| 710 | priv->last_settings_view = priv->account_settings_view; |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 711 | } |
| 712 | } |
| 713 | |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 714 | static void |
| 715 | show_general_settings(GtkToggleButton *navbutton, RingMainWindow *win) |
| 716 | { |
| 717 | g_return_if_fail(IS_RING_MAIN_WINDOW(win)); |
| 718 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 719 | |
| 720 | if (gtk_toggle_button_get_active(navbutton)) { |
Nicolas Jager | 6f5e04a | 2016-05-18 15:04:59 -0400 | [diff] [blame] | 721 | general_settings_view_show_profile(GENERAL_SETTINGS_VIEW(priv->general_settings_view), TRUE); |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 722 | gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), GENERAL_SETTINGS_VIEW_NAME); |
| 723 | priv->last_settings_view = priv->general_settings_view; |
Nicolas Jager | 6f5e04a | 2016-05-18 15:04:59 -0400 | [diff] [blame] | 724 | } else { |
| 725 | general_settings_view_show_profile(GENERAL_SETTINGS_VIEW(priv->general_settings_view), FALSE); |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 726 | } |
| 727 | } |
| 728 | |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 729 | static void |
Stepan Salenikovich | 37194a6 | 2017-04-14 16:43:27 -0400 | [diff] [blame^] | 730 | show_combobox_account_selector(RingMainWindow *self, gboolean show) |
| 731 | { |
| 732 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 733 | /* we only want to show the account selector when there is more than 1 eneabled account; so |
| 734 | * every time we want to show it, we should preform this check */ |
| 735 | gtk_widget_set_visible(priv->combobox_account_selector, |
| 736 | show && AvailableAccountModel::instance().rowCount() > 1); |
| 737 | } |
| 738 | |
| 739 | static void |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 740 | on_account_creation_completed(RingMainWindow *win) |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 741 | { |
Stepan Salenikovich | babe26f | 2016-02-12 16:47:07 -0500 | [diff] [blame] | 742 | g_return_if_fail(IS_RING_MAIN_WINDOW(win)); |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 743 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 744 | |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 745 | gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), CALL_VIEW_NAME); |
| 746 | |
| 747 | /* destroy the wizard */ |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 748 | if (priv->account_creation_wizard) |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 749 | { |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 750 | gtk_container_remove(GTK_CONTAINER(priv->stack_main_view), priv->account_creation_wizard); |
| 751 | gtk_widget_destroy(priv->account_creation_wizard); |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 752 | } |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 753 | |
| 754 | /* show the settings button*/ |
| 755 | gtk_widget_show(priv->ring_settings); |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 756 | |
| 757 | /* show the account selector */ |
Stepan Salenikovich | 37194a6 | 2017-04-14 16:43:27 -0400 | [diff] [blame^] | 758 | show_combobox_account_selector(win, TRUE); |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 759 | |
| 760 | /* init the selection for the account selector */ |
| 761 | gtk_combo_box_set_active(GTK_COMBO_BOX(priv->combobox_account_selector), 0); |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 762 | } |
| 763 | |
| 764 | static void |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 765 | show_account_creation_wizard(RingMainWindow *win) |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 766 | { |
| 767 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 768 | |
aviau | 61d05b3 | 2016-10-18 16:47:53 -0400 | [diff] [blame] | 769 | if (!priv->account_creation_wizard) |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 770 | { |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 771 | priv->account_creation_wizard = account_creation_wizard_new(false); |
| 772 | g_object_add_weak_pointer(G_OBJECT(priv->account_creation_wizard), (gpointer *)&priv->account_creation_wizard); |
| 773 | g_signal_connect_swapped(priv->account_creation_wizard, "account-creation-completed", G_CALLBACK(on_account_creation_completed), win); |
Stepan Salenikovich | 419414c | 2016-06-07 10:35:07 -0400 | [diff] [blame] | 774 | |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 775 | gtk_stack_add_named(GTK_STACK(priv->stack_main_view), |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 776 | priv->account_creation_wizard, |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 777 | ACCOUNT_CREATION_WIZARD_VIEW_NAME); |
| 778 | } |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 779 | |
Stepan Salenikovich | 6450567 | 2015-09-24 10:46:07 -0400 | [diff] [blame] | 780 | /* hide settings button until account creation is complete */ |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 781 | gtk_widget_hide(priv->ring_settings); |
Stepan Salenikovich | 37194a6 | 2017-04-14 16:43:27 -0400 | [diff] [blame^] | 782 | show_combobox_account_selector(win, FALSE); |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 783 | |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 784 | gtk_widget_show(priv->account_creation_wizard); |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 785 | |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 786 | gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), priv->account_creation_wizard); |
Stepan Salenikovich | b8e4127 | 2015-03-27 14:31:54 -0400 | [diff] [blame] | 787 | } |
| 788 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 789 | static void |
Stepan Salenikovich | a06ce19 | 2016-11-01 14:26:43 -0400 | [diff] [blame] | 790 | search_entry_text_changed(GtkSearchEntry *search_entry, RingMainWindow *self) |
Stepan Salenikovich | eafc3dd | 2015-04-16 18:38:01 -0400 | [diff] [blame] | 791 | { |
Stepan Salenikovich | dcfb503 | 2016-10-26 18:57:56 -0400 | [diff] [blame] | 792 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 793 | |
Stepan Salenikovich | eafc3dd | 2015-04-16 18:38:01 -0400 | [diff] [blame] | 794 | /* get the text from the entry */ |
| 795 | const gchar *text = gtk_entry_get_text(GTK_ENTRY(search_entry)); |
| 796 | |
Stepan Salenikovich | f53128f | 2016-10-07 10:32:16 -0400 | [diff] [blame] | 797 | RecentModel::instance().peopleProxy()->setFilterRegExp(QRegExp(text, Qt::CaseInsensitive, QRegExp::FixedString)); |
Stepan Salenikovich | dcfb503 | 2016-10-26 18:57:56 -0400 | [diff] [blame] | 798 | contacts_view_set_filter_string(CONTACTS_VIEW(priv->treeview_contacts), text); |
| 799 | history_view_set_filter_string(HISTORY_VIEW(priv->treeview_history), text); |
Stepan Salenikovich | eafc3dd | 2015-04-16 18:38:01 -0400 | [diff] [blame] | 800 | } |
| 801 | |
Stepan Salenikovich | b01d736 | 2015-04-27 23:02:00 -0400 | [diff] [blame] | 802 | static gboolean |
aviau | 4c87b83 | 2016-12-13 14:18:53 -0500 | [diff] [blame] | 803 | search_entry_key_released(G_GNUC_UNUSED GtkEntry *search_entry, GdkEventKey *key, RingMainWindow *self) |
Stepan Salenikovich | cac3504 | 2016-10-28 12:07:38 -0400 | [diff] [blame] | 804 | { |
| 805 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 806 | |
| 807 | // if esc key pressed, clear the regex (keep the text, the user might not want to actually delete it) |
| 808 | if (key->keyval == GDK_KEY_Escape) { |
| 809 | RecentModel::instance().peopleProxy()->setFilterRegExp(QRegExp()); |
| 810 | contacts_view_set_filter_string(CONTACTS_VIEW(priv->treeview_contacts), ""); |
| 811 | history_view_set_filter_string(HISTORY_VIEW(priv->treeview_history), ""); |
| 812 | return GDK_EVENT_STOP; |
| 813 | } |
| 814 | |
| 815 | return GDK_EVENT_PROPAGATE; |
| 816 | } |
| 817 | |
| 818 | static gboolean |
Stepan Salenikovich | b01d736 | 2015-04-27 23:02:00 -0400 | [diff] [blame] | 819 | dtmf_pressed(RingMainWindow *win, |
| 820 | GdkEventKey *event, |
| 821 | G_GNUC_UNUSED gpointer user_data) |
| 822 | { |
| 823 | g_return_val_if_fail(event->type == GDK_KEY_PRESS, GDK_EVENT_PROPAGATE); |
| 824 | |
| 825 | /* we want to react to digit key presses, as long as a GtkEntry is not the |
| 826 | * input focus |
| 827 | */ |
| 828 | GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(win)); |
| 829 | if (GTK_IS_ENTRY(focus)) |
| 830 | return GDK_EVENT_PROPAGATE; |
| 831 | |
| 832 | /* make sure that a call is selected*/ |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 833 | QItemSelectionModel *selection = CallModel::instance().selectionModel(); |
Stepan Salenikovich | b01d736 | 2015-04-27 23:02:00 -0400 | [diff] [blame] | 834 | QModelIndex idx = selection->currentIndex(); |
| 835 | if (!idx.isValid()) |
| 836 | return GDK_EVENT_PROPAGATE; |
| 837 | |
| 838 | /* make sure that the selected call is in progress */ |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 839 | Call *call = CallModel::instance().getCall(idx); |
Stepan Salenikovich | b01d736 | 2015-04-27 23:02:00 -0400 | [diff] [blame] | 840 | Call::LifeCycleState state = call->lifeCycleState(); |
| 841 | if (state != Call::LifeCycleState::PROGRESS) |
| 842 | return GDK_EVENT_PROPAGATE; |
| 843 | |
Stepan Salenikovich | 447f4a7 | 2015-04-29 11:09:28 -0400 | [diff] [blame] | 844 | /* filter out cretain MOD masked key presses so that, for example, 'Ctrl+c' |
| 845 | * does not result in a 'c' being played. |
| 846 | * we filter Ctrl, Alt, and SUPER/HYPER/META keys */ |
| 847 | if ( event->state |
| 848 | & ( GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK )) |
| 849 | return GDK_EVENT_PROPAGATE; |
| 850 | |
Stepan Salenikovich | b01d736 | 2015-04-27 23:02:00 -0400 | [diff] [blame] | 851 | /* pass the character that was entered to be played by the daemon; |
| 852 | * the daemon will filter out invalid DTMF characters */ |
| 853 | guint32 unicode_val = gdk_keyval_to_unicode(event->keyval); |
| 854 | QString val = QString::fromUcs4(&unicode_val, 1); |
| 855 | call->playDTMF(val); |
| 856 | g_debug("attemptingto play DTMF tone during ongoing call: %s", val.toUtf8().constData()); |
Stepan Salenikovich | 447f4a7 | 2015-04-29 11:09:28 -0400 | [diff] [blame] | 857 | |
| 858 | /* always propogate the key, so we don't steal accelerators/shortcuts */ |
| 859 | return GDK_EVENT_PROPAGATE; |
Stepan Salenikovich | b01d736 | 2015-04-27 23:02:00 -0400 | [diff] [blame] | 860 | } |
| 861 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 862 | /** |
| 863 | * This function determines if two different contact list views (Conversations, Contacts, History) |
| 864 | * have the same item selected. Note that the same item does not necessarily mean the same object. |
| 865 | * For example, if the history view has a Call selected and the Conversations view has a Person |
| 866 | * selected which is associated with the ContactMethod to which that Call was made, then this will |
| 867 | * evaluate to TRUE. |
| 868 | */ |
| 869 | static gboolean |
| 870 | compare_treeview_selection(GtkTreeSelection *selection1, GtkTreeSelection *selection2) |
| 871 | { |
| 872 | g_return_val_if_fail(selection1 && selection2, FALSE); |
| 873 | |
| 874 | if (selection1 == selection2) return TRUE; |
| 875 | |
| 876 | auto idx1 = get_index_from_selection(selection1); |
| 877 | auto type1 = idx1.data(static_cast<int>(Ring::Role::ObjectType)); |
| 878 | auto object1 = idx1.data(static_cast<int>(Ring::Role::Object)); |
| 879 | |
| 880 | auto idx2 = get_index_from_selection(selection2); |
| 881 | auto type2 = idx2.data(static_cast<int>(Ring::Role::ObjectType)); |
| 882 | auto object2 = idx2.data(static_cast<int>(Ring::Role::Object)); |
| 883 | |
| 884 | if (idx1.isValid() && type1.isValid() && object1.isValid() && idx2.isValid() && type2.isValid() && object2.isValid()) { |
| 885 | Call *call1 = nullptr; |
| 886 | ContactMethod *cm1 = nullptr; |
| 887 | Person *person1 = nullptr; |
| 888 | |
| 889 | Call *call2 = nullptr; |
| 890 | ContactMethod *cm2 = nullptr; |
| 891 | Person *person2 = nullptr; |
| 892 | |
| 893 | switch(type1.value<Ring::ObjectType>()) { |
| 894 | case Ring::ObjectType::Person: |
| 895 | person1 = object1.value<Person *>(); |
| 896 | break; |
| 897 | case Ring::ObjectType::ContactMethod: |
| 898 | cm1 = object1.value<ContactMethod *>(); |
| 899 | person1 = cm1->contact(); |
| 900 | break; |
| 901 | case Ring::ObjectType::Call: |
| 902 | call1 = object1.value<Call *>(); |
| 903 | cm1 = call1->peerContactMethod(); |
| 904 | person1 = cm1->contact(); |
| 905 | break; |
| 906 | case Ring::ObjectType::Media: |
| 907 | case Ring::ObjectType::Certificate: |
Nicolas Jager | c74f761 | 2017-03-28 09:48:18 -0400 | [diff] [blame] | 908 | case Ring::ObjectType::ContactRequest: |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 909 | case Ring::ObjectType::COUNT__: |
| 910 | // nothing to do |
| 911 | break; |
| 912 | } |
| 913 | |
| 914 | switch(type2.value<Ring::ObjectType>()) { |
| 915 | case Ring::ObjectType::Person: |
| 916 | person2 = object2.value<Person *>(); |
| 917 | break; |
| 918 | case Ring::ObjectType::ContactMethod: |
| 919 | cm2 = object2.value<ContactMethod *>(); |
| 920 | person2 = cm2->contact(); |
| 921 | break; |
| 922 | case Ring::ObjectType::Call: |
| 923 | call2 = object2.value<Call *>(); |
| 924 | cm2 = call2->peerContactMethod(); |
| 925 | person2 = cm2->contact(); |
| 926 | break; |
| 927 | case Ring::ObjectType::Media: |
| 928 | case Ring::ObjectType::Certificate: |
Nicolas Jager | c74f761 | 2017-03-28 09:48:18 -0400 | [diff] [blame] | 929 | case Ring::ObjectType::ContactRequest: |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 930 | case Ring::ObjectType::COUNT__: |
| 931 | // nothing to do |
| 932 | break; |
| 933 | } |
| 934 | |
| 935 | if (person1 != nullptr && person1 == person2) |
| 936 | return TRUE; |
| 937 | if (cm1 != nullptr && cm1 == cm2) |
| 938 | return TRUE; |
| 939 | if (call1 != nullptr && call1 == call2) |
| 940 | return TRUE; |
| 941 | } |
| 942 | |
| 943 | return FALSE; |
| 944 | } |
| 945 | |
| 946 | static void |
| 947 | conversation_selection_changed(GtkTreeSelection *selection, RingMainWindow *self) |
| 948 | { |
| 949 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 950 | GtkTreeIter iter; |
| 951 | GtkTreeModel *model = nullptr; |
| 952 | if (gtk_tree_selection_get_selected(selection, &model, &iter)) { |
| 953 | /* something is selected in the conversations view, clear the selection in the other views; |
| 954 | * unless the current selection is of the same item; we don't try to match the selection in |
| 955 | * all views since not all items exist in all 3 contact list views |
| 956 | */ |
| 957 | |
| 958 | auto selection_contacts = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contacts)); |
| 959 | if (!compare_treeview_selection(selection, selection_contacts)) |
| 960 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_contacts)); |
| 961 | |
| 962 | auto selection_history = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_history)); |
| 963 | if (!compare_treeview_selection(selection, selection_history)) |
| 964 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_history)); |
| 965 | } |
| 966 | |
| 967 | selection_changed(self); |
| 968 | } |
| 969 | |
| 970 | static void |
| 971 | contact_selection_changed(GtkTreeSelection *selection, RingMainWindow *self) |
| 972 | { |
| 973 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 974 | GtkTreeIter iter; |
| 975 | if (gtk_tree_selection_get_selected(selection, nullptr, &iter)) { |
| 976 | /* something is selected in the contacts view, clear the selection in the other views; |
| 977 | * unless the current selection is of the same item; we don't try to match the selection in |
| 978 | * all views since not all items exist in all 3 contact list views |
| 979 | */ |
| 980 | auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations)); |
| 981 | if (!compare_treeview_selection(selection, selection_conversations)) |
| 982 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_conversations)); |
| 983 | |
| 984 | auto selection_history = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_history)); |
| 985 | if (!compare_treeview_selection(selection, selection_history)) |
| 986 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_history)); |
| 987 | } |
| 988 | |
| 989 | selection_changed(self); |
| 990 | } |
| 991 | |
| 992 | static void |
| 993 | history_selection_changed(GtkTreeSelection *selection, RingMainWindow *self) |
| 994 | { |
| 995 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 996 | GtkTreeIter iter; |
| 997 | if (gtk_tree_selection_get_selected(selection, nullptr, &iter)) { |
| 998 | /* something is selected in the history view, clear the selection in the other views; |
| 999 | * unless the current selection is of the same item; we don't try to match the selection in |
| 1000 | * all views since not all items exist in all 3 contact list views |
| 1001 | */ |
| 1002 | |
| 1003 | auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations)); |
| 1004 | if (!compare_treeview_selection(selection, selection_conversations)) |
| 1005 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_conversations)); |
| 1006 | |
| 1007 | auto selection_contacts = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contacts)); |
| 1008 | if (!compare_treeview_selection(selection, selection_contacts)) |
| 1009 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_contacts)); |
| 1010 | } |
| 1011 | |
| 1012 | selection_changed(self); |
| 1013 | } |
| 1014 | |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 1015 | |
| 1016 | /** |
| 1017 | * gtk callback function called when the selection in the contact request list changed |
| 1018 | */ |
| 1019 | static void |
| 1020 | contact_request_selection_changed(GtkTreeSelection *selection, RingMainWindow *self) |
| 1021 | { |
| 1022 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 1023 | GtkTreeIter iter; |
| 1024 | |
| 1025 | if (gtk_tree_selection_get_selected(selection, nullptr, &iter)) { |
| 1026 | /* unselect previous selection in conversations list */ |
| 1027 | auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations)); |
| 1028 | if (!compare_treeview_selection(selection, selection_conversations)) |
| 1029 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_conversations)); |
| 1030 | |
| 1031 | /* unselect previous selection in contacts list */ |
| 1032 | auto selection_contacts = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contacts)); |
| 1033 | if (!compare_treeview_selection(selection, selection_contacts)) |
| 1034 | gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_contacts)); |
| 1035 | } |
| 1036 | |
| 1037 | selection_changed(self); |
| 1038 | } |
| 1039 | |
Stepan Salenikovich | ba87ae2 | 2016-09-13 14:27:20 -0400 | [diff] [blame] | 1040 | static gboolean |
| 1041 | window_size_changed(GtkWidget *win, GdkEventConfigure *event, gpointer) |
| 1042 | { |
| 1043 | auto *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 1044 | |
| 1045 | g_settings_set_int(priv->settings, "window-width", event->width); |
| 1046 | g_settings_set_int(priv->settings, "window-height", event->height); |
| 1047 | |
| 1048 | return GDK_EVENT_PROPAGATE; |
| 1049 | } |
| 1050 | |
Stepan Salenikovich | eafc3dd | 2015-04-16 18:38:01 -0400 | [diff] [blame] | 1051 | static void |
Stepan Salenikovich | e993324 | 2016-06-21 18:08:48 -0400 | [diff] [blame] | 1052 | search_entry_places_call_changed(GSettings *settings, const gchar *key, RingMainWindow *self) |
| 1053 | { |
| 1054 | auto priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 1055 | |
| 1056 | if (g_settings_get_boolean(settings, key)) { |
| 1057 | gtk_widget_set_tooltip_text(priv->button_new_conversation, C_("button next to search entry will place a new call", "place call")); |
| 1058 | } else { |
| 1059 | gtk_widget_set_tooltip_text(priv->button_new_conversation, C_("button next to search entry will open chat", "open chat")); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | static void |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1064 | handle_account_migrations(RingMainWindow *win) |
| 1065 | { |
| 1066 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 1067 | |
| 1068 | /* If there is an existing migration view, remove it */ |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 1069 | if (priv->account_migration_view) |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1070 | { |
Stepan Salenikovich | 56530b1 | 2016-10-20 17:51:34 -0400 | [diff] [blame] | 1071 | gtk_widget_destroy(priv->account_migration_view); |
| 1072 | priv->account_migration_view = nullptr; |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | QList<Account*> accounts = AccountModel::instance().accountsToMigrate(); |
| 1076 | if (!accounts.isEmpty()) |
| 1077 | { |
| 1078 | Account* account = accounts.first(); |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1079 | |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 1080 | priv->account_migration_view = account_migration_view_new(account); |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 1081 | g_signal_connect_swapped(priv->account_migration_view, "account-migration-completed", G_CALLBACK(handle_account_migrations), win); |
| 1082 | g_signal_connect_swapped(priv->account_migration_view, "account-migration-failed", G_CALLBACK(handle_account_migrations), win); |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1083 | |
| 1084 | gtk_widget_hide(priv->ring_settings); |
Stepan Salenikovich | 37194a6 | 2017-04-14 16:43:27 -0400 | [diff] [blame^] | 1085 | show_combobox_account_selector(win, FALSE); |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 1086 | gtk_widget_show(priv->account_migration_view); |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1087 | gtk_stack_add_named( |
| 1088 | GTK_STACK(priv->stack_main_view), |
aviau | 6908184 | 2016-10-14 14:51:54 -0400 | [diff] [blame] | 1089 | priv->account_migration_view, |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1090 | ACCOUNT_MIGRATION_VIEW_NAME |
| 1091 | ); |
| 1092 | gtk_stack_set_visible_child_name( |
| 1093 | GTK_STACK(priv->stack_main_view), |
| 1094 | ACCOUNT_MIGRATION_VIEW_NAME |
| 1095 | ); |
| 1096 | } |
| 1097 | else |
| 1098 | { |
| 1099 | gtk_widget_show(priv->ring_settings); |
Stepan Salenikovich | 37194a6 | 2017-04-14 16:43:27 -0400 | [diff] [blame^] | 1100 | show_combobox_account_selector(win, TRUE); |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1101 | |
| 1102 | /* init the selection for the account selector */ |
| 1103 | gtk_combo_box_set_active(GTK_COMBO_BOX(priv->combobox_account_selector), 0); |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | static void |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1108 | selected_account_changed(GtkComboBox *gtk_combo_box, RingMainWindow *self) |
| 1109 | { |
| 1110 | int nbr = gtk_combo_box_get_active(gtk_combo_box); |
| 1111 | |
| 1112 | QModelIndex idx = AccountModel::instance().userSelectionModel()->model()->index(nbr, 0); |
| 1113 | auto account = AccountModel::instance().getAccountByModelIndex(idx); |
| 1114 | |
| 1115 | AccountModel::instance().setUserChosenAccount(account); |
| 1116 | |
| 1117 | // we closing any view opened to avoid confusion (especially between SIP and Ring protocols). |
| 1118 | hide_view_clicked(nullptr, self); |
| 1119 | } |
| 1120 | |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1121 | /** |
| 1122 | * set the column value by printing the alias and the state of an account in combobox_account_selector. |
| 1123 | */ |
| 1124 | static void |
| 1125 | print_account_and_state(GtkCellLayout* cell_layout, |
| 1126 | GtkCellRenderer* cell_renderer, |
| 1127 | GtkTreeModel* tree_model, |
| 1128 | GtkTreeIter* iter, |
| 1129 | gpointer* data) |
| 1130 | { |
| 1131 | (void) cell_layout; // UNUSED |
| 1132 | (void) data; // UNUSED |
| 1133 | |
| 1134 | QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1135 | gchar* display_alias = nullptr; |
| 1136 | |
| 1137 | if (idx.isValid()) { |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1138 | auto state = idx.data(static_cast<int>(Account::Role::RegistrationState)); |
| 1139 | auto name = idx.data(static_cast<int>(Account::Role::Alias)); |
| 1140 | auto account_alias = name.value<QString>().toStdString(); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1141 | |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1142 | switch (state.value<Account::RegistrationState>()) { |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1143 | case Account::RegistrationState::READY: |
| 1144 | { |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1145 | display_alias = g_strdup_printf("%s",account_alias.c_str()); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1146 | } |
| 1147 | break; |
| 1148 | case Account::RegistrationState::UNREGISTERED: |
| 1149 | { |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1150 | display_alias = g_strdup_printf("<span fgcolor=\"gray\">%s</span>", account_alias.c_str()); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1151 | } |
| 1152 | break; |
| 1153 | case Account::RegistrationState::TRYING: |
| 1154 | case Account::RegistrationState::INITIALIZING: |
| 1155 | { |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1156 | auto account_alias_i18n = g_markup_printf_escaped (C_("string format will be replaced by the account alias", "%s..."), account_alias.c_str()); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1157 | display_alias = g_strdup_printf("<span fgcolor=\"gray\" font_style=\"italic\">%s</span>", account_alias_i18n); |
| 1158 | } |
| 1159 | break; |
| 1160 | case Account::RegistrationState::ERROR: |
| 1161 | { |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1162 | auto error_string = g_markup_printf_escaped(C_("string format will be replaced by the account alias", "%s (error)"), account_alias.c_str()); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1163 | display_alias = g_strdup_printf("<span fgcolor=\"red\">%s</span>", error_string); |
| 1164 | } |
| 1165 | case Account::RegistrationState::COUNT__: |
| 1166 | break; |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | g_object_set(G_OBJECT(cell_renderer), "markup", display_alias, nullptr); |
| 1171 | g_free(display_alias); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1172 | |
| 1173 | } |
| 1174 | |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1175 | static void |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1176 | ring_main_window_init(RingMainWindow *win) |
| 1177 | { |
| 1178 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); |
| 1179 | gtk_widget_init_template(GTK_WIDGET(win)); |
| 1180 | |
Guillaume Roguez | e7221ed | 2017-03-17 20:09:56 -0400 | [diff] [blame] | 1181 | priv->pending_username_lookup = new std::string; // see object finilize for delete |
| 1182 | |
Stepan Salenikovich | ba87ae2 | 2016-09-13 14:27:20 -0400 | [diff] [blame] | 1183 | /* bind to window size settings */ |
| 1184 | priv->settings = g_settings_new_full(get_ring_schema(), nullptr, nullptr); |
| 1185 | auto width = g_settings_get_int(priv->settings, "window-width"); |
| 1186 | auto height = g_settings_get_int(priv->settings, "window-height"); |
| 1187 | gtk_window_set_default_size(GTK_WINDOW(win), width, height); |
| 1188 | g_signal_connect(win, "configure-event", G_CALLBACK(window_size_changed), nullptr); |
| 1189 | |
Stepan Salenikovich | e993324 | 2016-06-21 18:08:48 -0400 | [diff] [blame] | 1190 | /* search-entry-places-call setting */ |
| 1191 | search_entry_places_call_changed(priv->settings, "search-entry-places-call", win); |
| 1192 | g_signal_connect(priv->settings, "changed::search-entry-places-call", G_CALLBACK(search_entry_places_call_changed), win); |
| 1193 | |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1194 | /* set window icon */ |
| 1195 | GError *error = NULL; |
| 1196 | GdkPixbuf* icon = gdk_pixbuf_new_from_resource("/cx/ring/RingGnome/ring-symbol-blue", &error); |
| 1197 | if (icon == NULL) { |
| 1198 | g_debug("Could not load icon: %s", error->message); |
Stepan Salenikovich | 8a287fc | 2015-05-01 16:53:20 -0400 | [diff] [blame] | 1199 | g_clear_error(&error); |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1200 | } else |
| 1201 | gtk_window_set_icon(GTK_WINDOW(win), icon); |
| 1202 | |
| 1203 | /* set menu icon */ |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1204 | GdkPixbuf* image_ring = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-symbol-blue", |
Stepan Salenikovich | d61974b | 2016-03-18 16:36:27 -0400 | [diff] [blame] | 1205 | -1, 16, TRUE, &error); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1206 | if (image_ring == NULL) { |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1207 | g_debug("Could not load icon: %s", error->message); |
Stepan Salenikovich | 8a287fc | 2015-05-01 16:53:20 -0400 | [diff] [blame] | 1208 | g_clear_error(&error); |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1209 | } else |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1210 | gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_ring), image_ring); |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1211 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1212 | /* ring menu */ |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1213 | GtkBuilder *builder = gtk_builder_new_from_resource("/cx/ring/RingGnome/ringgearsmenu.ui"); |
| 1214 | GMenuModel *menu = G_MENU_MODEL(gtk_builder_get_object(builder, "menu")); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1215 | gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(priv->ring_menu), menu); |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1216 | g_object_unref(builder); |
Stepan Salenikovich | a355745 | 2015-02-20 14:14:12 -0500 | [diff] [blame] | 1217 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1218 | /* settings icon */ |
Stepan Salenikovich | d61974b | 2016-03-18 16:36:27 -0400 | [diff] [blame] | 1219 | gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-system-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1220 | |
| 1221 | /* connect settings button signal */ |
| 1222 | g_signal_connect(priv->ring_settings, "clicked", G_CALLBACK(settings_clicked), win); |
| 1223 | |
| 1224 | /* add the call view to the main stack */ |
| 1225 | gtk_stack_add_named(GTK_STACK(priv->stack_main_view), |
| 1226 | priv->vbox_call_view, |
| 1227 | CALL_VIEW_NAME); |
| 1228 | |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1229 | /* init the settings views */ |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1230 | priv->account_settings_view = account_view_new(); |
| 1231 | gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->account_settings_view, ACCOUNT_SETTINGS_VIEW_NAME); |
| 1232 | |
Stepan Salenikovich | 0bd5349 | 2015-05-11 14:28:52 -0400 | [diff] [blame] | 1233 | priv->media_settings_view = media_settings_view_new(); |
| 1234 | gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->media_settings_view, MEDIA_SETTINGS_VIEW_NAME); |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 1235 | |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 1236 | priv->general_settings_view = general_settings_view_new(); |
| 1237 | gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->general_settings_view, GENERAL_SETTINGS_VIEW_NAME); |
| 1238 | |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 1239 | /* make the setting we will show first the active one */ |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 1240 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_general_settings), TRUE); |
| 1241 | priv->last_settings_view = priv->general_settings_view; |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 1242 | |
| 1243 | /* connect the settings button signals to switch settings views */ |
Stepan Salenikovich | 5d3506e | 2015-03-30 11:01:29 -0400 | [diff] [blame] | 1244 | g_signal_connect(priv->radiobutton_media_settings, "toggled", G_CALLBACK(show_media_settings), win); |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 1245 | g_signal_connect(priv->radiobutton_account_settings, "toggled", G_CALLBACK(show_account_settings), win); |
Stepan Salenikovich | de89611 | 2015-05-11 16:46:33 -0400 | [diff] [blame] | 1246 | g_signal_connect(priv->radiobutton_general_settings, "toggled", G_CALLBACK(show_general_settings), win); |
Stepan Salenikovich | f903d1b | 2015-03-25 14:51:45 -0400 | [diff] [blame] | 1247 | |
Stepan Salenikovich | a7a19bc | 2015-09-24 16:16:28 -0400 | [diff] [blame] | 1248 | /* populate the notebook */ |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1249 | priv->treeview_conversations = recent_contacts_view_new(); |
| 1250 | gtk_container_add(GTK_CONTAINER(priv->scrolled_window_smartview), priv->treeview_conversations); |
Stepan Salenikovich | 7c71bfe | 2015-05-13 18:08:09 -0400 | [diff] [blame] | 1251 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1252 | priv->treeview_contacts = contacts_view_new(); |
| 1253 | gtk_container_add(GTK_CONTAINER(priv->scrolled_window_contacts), priv->treeview_contacts); |
Stepan Salenikovich | 1514218 | 2015-03-11 17:15:26 -0400 | [diff] [blame] | 1254 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1255 | priv->treeview_history = history_view_new(); |
| 1256 | gtk_container_add(GTK_CONTAINER(priv->scrolled_window_history), priv->treeview_history); |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 1257 | |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1258 | /* use this event to refresh the treeview_conversations when account selection changed */ |
| 1259 | QObject::connect(AccountModel::instance().userSelectionModel(), &QItemSelectionModel::currentChanged, [priv](const QModelIndex& idx){ |
| 1260 | // next line will refresh the recentmodel so the treeview will do |
| 1261 | RecentModel::instance().peopleProxy()->setFilterRegExp(""); |
| 1262 | |
| 1263 | // set the good index to the combox. Required when the selected account changed by different way than selecting |
| 1264 | // from the combo box. |
| 1265 | gtk_combo_box_set_active(GTK_COMBO_BOX(priv->combobox_account_selector), idx.row()); |
| 1266 | |
| 1267 | }); |
| 1268 | |
Stepan Salenikovich | 37194a6 | 2017-04-14 16:43:27 -0400 | [diff] [blame^] | 1269 | auto available_accounts_changed = [win, priv] { |
| 1270 | /* if we're hiding the settings it means we're in the migration or wizard view and we don't |
| 1271 | * want to show the combo box */ |
| 1272 | if (gtk_widget_get_visible(priv->ring_settings)) |
| 1273 | show_combobox_account_selector(win, TRUE); |
| 1274 | }; |
| 1275 | QObject::connect(&AvailableAccountModel::instance(), &QAbstractItemModel::rowsRemoved, available_accounts_changed); |
| 1276 | QObject::connect(&AvailableAccountModel::instance(), &QAbstractItemModel::rowsInserted, available_accounts_changed); |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1277 | |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 1278 | priv->treeview_contact_requests = pending_contact_requests_view_new(); |
| 1279 | gtk_container_add(GTK_CONTAINER(priv->scrolled_window_contact_requests), priv->treeview_contact_requests); |
| 1280 | |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 1281 | /* welcome/default view */ |
Stepan Salenikovich | 3034d92 | 2015-10-09 10:11:42 -0400 | [diff] [blame] | 1282 | priv->welcome_view = ring_welcome_view_new(); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1283 | g_object_ref(priv->welcome_view); // increase ref because don't want it to be destroyed when not displayed |
Stepan Salenikovich | 3034d92 | 2015-10-09 10:11:42 -0400 | [diff] [blame] | 1284 | gtk_container_add(GTK_CONTAINER(priv->frame_call), priv->welcome_view); |
| 1285 | gtk_widget_show(priv->welcome_view); |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 1286 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1287 | auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations)); |
| 1288 | g_signal_connect(selection_conversations, "changed", G_CALLBACK(conversation_selection_changed), win); |
Stepan Salenikovich | 2f8b449 | 2015-09-21 17:10:36 -0400 | [diff] [blame] | 1289 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1290 | auto selection_contacts = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contacts)); |
| 1291 | g_signal_connect(selection_contacts, "changed", G_CALLBACK(contact_selection_changed), win); |
| 1292 | |
| 1293 | auto selection_history = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_history)); |
| 1294 | g_signal_connect(selection_history, "changed", G_CALLBACK(history_selection_changed), win); |
Stepan Salenikovich | 2f8b449 | 2015-09-21 17:10:36 -0400 | [diff] [blame] | 1295 | |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 1296 | auto selection_contact_request = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contact_requests)); |
| 1297 | g_signal_connect(selection_contact_request, "changed", G_CALLBACK(contact_request_selection_changed), win); |
| 1298 | |
Stepan Salenikovich | b0ffc34 | 2016-10-13 13:10:55 -0400 | [diff] [blame] | 1299 | g_signal_connect_swapped(priv->button_new_conversation, "clicked", G_CALLBACK(search_entry_activated), win); |
| 1300 | g_signal_connect_swapped(priv->search_entry, "activate", G_CALLBACK(search_entry_activated), win); |
Stepan Salenikovich | a06ce19 | 2016-11-01 14:26:43 -0400 | [diff] [blame] | 1301 | g_signal_connect(priv->search_entry, "search-changed", G_CALLBACK(search_entry_text_changed), win); |
Stepan Salenikovich | cac3504 | 2016-10-28 12:07:38 -0400 | [diff] [blame] | 1302 | g_signal_connect(priv->search_entry, "key-release-event", G_CALLBACK(search_entry_key_released), win); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1303 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1304 | /* make sure the incoming call is the selected call in the CallModel */ |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1305 | QObject::connect( |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 1306 | &CallModel::instance(), |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1307 | &CallModel::incomingCall, |
Stepan Salenikovich | dcfb503 | 2016-10-26 18:57:56 -0400 | [diff] [blame] | 1308 | [priv](Call* call) { |
Nicolas Jager | 85e992a | 2017-03-22 04:11:47 -0400 | [diff] [blame] | 1309 | // select the revelant account |
| 1310 | AccountModel::instance().setUserChosenAccount(call->account()); |
| 1311 | |
Stepan Salenikovich | f53128f | 2016-10-07 10:32:16 -0400 | [diff] [blame] | 1312 | // clear the regex to make sure the call is shown |
| 1313 | RecentModel::instance().peopleProxy()->setFilterRegExp(QRegExp()); |
Stepan Salenikovich | dcfb503 | 2016-10-26 18:57:56 -0400 | [diff] [blame] | 1314 | contacts_view_set_filter_string(CONTACTS_VIEW(priv->treeview_contacts),""); |
| 1315 | history_view_set_filter_string(HISTORY_VIEW(priv->treeview_history), ""); |
Stepan Salenikovich | f53128f | 2016-10-07 10:32:16 -0400 | [diff] [blame] | 1316 | |
| 1317 | // now make sure its selected |
| 1318 | RecentModel::instance().selectionModel()->clearCurrentIndex(); |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1319 | CallModel::instance().selectCall(call); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1320 | } |
| 1321 | ); |
Stepan Salenikovich | 5eab303 | 2015-03-28 10:50:51 -0400 | [diff] [blame] | 1322 | |
Stepan Salenikovich | b01d736 | 2015-04-27 23:02:00 -0400 | [diff] [blame] | 1323 | /* react to digit key press events */ |
| 1324 | g_signal_connect(win, "key-press-event", G_CALLBACK(dtmf_pressed), NULL); |
Stepan Salenikovich | 48b45c1 | 2015-09-25 15:49:51 -0400 | [diff] [blame] | 1325 | |
| 1326 | /* set the search entry placeholder text */ |
| 1327 | gtk_entry_set_placeholder_text(GTK_ENTRY(priv->search_entry), |
| 1328 | C_("Please try to make the translation 50 chars or less so that it fits into the layout", "Search contacts or enter number")); |
aviau | 6aeb485 | 2016-08-18 16:01:09 -0400 | [diff] [blame] | 1329 | |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 1330 | /* init chat webkit container so that it starts loading before the first time we need it*/ |
| 1331 | get_webkit_chat_container(win); |
| 1332 | |
Stepan Salenikovich | cbc8dcc | 2017-04-05 11:27:10 -0400 | [diff] [blame] | 1333 | if (has_ring_account()) { |
| 1334 | /* user has ring account, so show the call view right away */ |
| 1335 | gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), priv->vbox_call_view); |
| 1336 | |
| 1337 | handle_account_migrations(win); |
| 1338 | } else { |
| 1339 | /* user has to create the ring account */ |
| 1340 | show_account_creation_wizard(win); |
| 1341 | } |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1342 | |
| 1343 | /* model for the combobox for Account chooser */ |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1344 | auto account_model = gtk_q_tree_model_new(&AvailableAccountModel::instance(), 1, |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1345 | 0, Account::Role::Alias, G_TYPE_STRING); |
| 1346 | |
| 1347 | gtk_combo_box_set_model(GTK_COMBO_BOX(priv->combobox_account_selector), GTK_TREE_MODEL(account_model)); |
| 1348 | |
| 1349 | auto *renderer = gtk_cell_renderer_text_new(); |
| 1350 | |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1351 | /* set visibility */ |
Stepan Salenikovich | 37194a6 | 2017-04-14 16:43:27 -0400 | [diff] [blame^] | 1352 | show_combobox_account_selector(win, TRUE); |
Nicolas Jager | a169c71 | 2017-04-14 12:02:50 -0400 | [diff] [blame] | 1353 | |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1354 | /* layout */ |
| 1355 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->combobox_account_selector), renderer, FALSE); |
| 1356 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(priv->combobox_account_selector), renderer, "text", 0, NULL); |
Nicolas Jager | 5e2be73 | 2017-03-18 21:35:50 -0400 | [diff] [blame] | 1357 | gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(priv->combobox_account_selector), |
| 1358 | renderer, |
| 1359 | (GtkCellLayoutDataFunc)print_account_and_state, |
| 1360 | nullptr, nullptr); |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1361 | |
| 1362 | g_signal_connect(priv->combobox_account_selector, "changed", G_CALLBACK(selected_account_changed), win); |
| 1363 | |
| 1364 | /* init the selection for the account selector */ |
| 1365 | selected_account_changed(GTK_COMBO_BOX(priv->combobox_account_selector), win); |
| 1366 | |
| 1367 | g_object_unref(account_model); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1368 | } |
| 1369 | |
| 1370 | static void |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 1371 | ring_main_window_dispose(GObject *object) |
| 1372 | { |
Stepan Salenikovich | bbb10d8 | 2015-05-13 12:26:44 -0400 | [diff] [blame] | 1373 | RingMainWindow *self = RING_MAIN_WINDOW(object); |
| 1374 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 1375 | |
Stepan Salenikovich | 09e0b78 | 2016-09-07 16:28:50 -0400 | [diff] [blame] | 1376 | QObject::disconnect(priv->selected_item_changed); |
| 1377 | QObject::disconnect(priv->selected_call_over); |
aviau | 8c0b242 | 2016-10-31 16:06:44 -0400 | [diff] [blame] | 1378 | QObject::disconnect(priv->username_lookup); |
aviau | 039001d | 2016-09-29 16:39:05 -0400 | [diff] [blame] | 1379 | |
| 1380 | g_clear_object(&priv->welcome_view); |
| 1381 | g_clear_object(&priv->webkit_chat_container); |
Stepan Salenikovich | bbb10d8 | 2015-05-13 12:26:44 -0400 | [diff] [blame] | 1382 | |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 1383 | G_OBJECT_CLASS(ring_main_window_parent_class)->dispose(object); |
| 1384 | } |
| 1385 | |
| 1386 | static void |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1387 | ring_main_window_finalize(GObject *object) |
| 1388 | { |
Stepan Salenikovich | ba87ae2 | 2016-09-13 14:27:20 -0400 | [diff] [blame] | 1389 | RingMainWindow *self = RING_MAIN_WINDOW(object); |
| 1390 | RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(self); |
| 1391 | |
| 1392 | g_clear_object(&priv->settings); |
| 1393 | |
Guillaume Roguez | e7221ed | 2017-03-17 20:09:56 -0400 | [diff] [blame] | 1394 | delete priv->pending_username_lookup; |
| 1395 | priv->pending_username_lookup = nullptr; |
| 1396 | |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1397 | G_OBJECT_CLASS(ring_main_window_parent_class)->finalize(object); |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | static void |
| 1401 | ring_main_window_class_init(RingMainWindowClass *klass) |
| 1402 | { |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1403 | G_OBJECT_CLASS(klass)->finalize = ring_main_window_finalize; |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 1404 | G_OBJECT_CLASS(klass)->dispose = ring_main_window_dispose; |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 1405 | |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1406 | gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass), |
| 1407 | "/cx/ring/RingGnome/ringmainwindow.ui"); |
| 1408 | |
Stepan Salenikovich | bbb10d8 | 2015-05-13 12:26:44 -0400 | [diff] [blame] | 1409 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, vbox_left_pane); |
Stepan Salenikovich | 2f8b449 | 2015-09-21 17:10:36 -0400 | [diff] [blame] | 1410 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, scrolled_window_smartview); |
Stepan Salenikovich | a7a19bc | 2015-09-24 16:16:28 -0400 | [diff] [blame] | 1411 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, scrolled_window_contacts); |
| 1412 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, scrolled_window_history); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1413 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, ring_menu); |
| 1414 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, image_ring); |
| 1415 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, ring_settings); |
| 1416 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, image_settings); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1417 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, hbox_settings); |
Stepan Salenikovich | 45d25aa | 2015-02-20 17:39:09 -0500 | [diff] [blame] | 1418 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, search_entry); |
Stepan Salenikovich | 6977184 | 2015-02-24 18:11:45 -0500 | [diff] [blame] | 1419 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, stack_main_view); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1420 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, vbox_call_view); |
Stepan Salenikovich | 3034d92 | 2015-10-09 10:11:42 -0400 | [diff] [blame] | 1421 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, frame_call); |
Stepan Salenikovich | e993324 | 2016-06-21 18:08:48 -0400 | [diff] [blame] | 1422 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, button_new_conversation ); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1423 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_general_settings); |
Stepan Salenikovich | 5d3506e | 2015-03-30 11:01:29 -0400 | [diff] [blame] | 1424 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_media_settings); |
Stepan Salenikovich | 2d63d5e | 2015-03-22 23:23:54 -0400 | [diff] [blame] | 1425 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_account_settings); |
Nicolas Jager | 5590314 | 2017-02-01 14:43:45 -0500 | [diff] [blame] | 1426 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, spinner_lookup); |
Nicolas Jager | 15a8b90 | 2017-03-21 07:53:06 -0400 | [diff] [blame] | 1427 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, combobox_account_selector); |
Nicolas Jager | 0efc843 | 2017-03-22 16:22:00 -0400 | [diff] [blame] | 1428 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, scrolled_window_contact_requests); |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | GtkWidget * |
| 1432 | ring_main_window_new (GtkApplication *app) |
| 1433 | { |
Stepan Salenikovich | 61cbab0 | 2015-03-16 18:35:10 -0400 | [diff] [blame] | 1434 | gpointer win = g_object_new(RING_MAIN_WINDOW_TYPE, "application", app, NULL); |
| 1435 | |
Stepan Salenikovich | 61cbab0 | 2015-03-16 18:35:10 -0400 | [diff] [blame] | 1436 | return (GtkWidget *)win; |
Stepan Salenikovich | 434b88f | 2015-02-19 17:49:08 -0500 | [diff] [blame] | 1437 | } |