Commit 6ee8df62 authored by Guillaume Roguez's avatar Guillaume Roguez

ringmainwindow: refactor hide_view_clicked

* go to CppImpl
* make clear separation between callbacks and actions.

Change-Id: I9f9d1efb88f1f22fb550e556f11e091065707762
Reviewed-by: Sébastien Blin's avatarSébastien Blin <sebastien.blin@savoirfairelinux.com>
parent 1d963276
......@@ -133,6 +133,7 @@ public:
void enterFullScreen();
void leaveFullScreen();
void toggleFullScreen();
void resetToWelcome();
RingMainWindow* self = nullptr; // The GTK widget itself
RingMainWindowPrivate* priv = nullptr;
......@@ -169,20 +170,27 @@ private:
CppImpl& operator=(const CppImpl&) = delete;
};
static void
hide_view_clicked(RingMainWindow *self);
inline namespace gtk_callbacks
{
static void
ring_init_lrc(RingMainWindow *win, const std::string& accountId);
video_double_clicked(RingMainWindow* self)
{
g_return_if_fail(IS_RING_MAIN_WINDOW(self));
auto* priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self));
priv->cpp->toggleFullScreen();
}
static void
video_double_clicked(RingMainWindow *self)
hide_view_clicked(RingMainWindow* self)
{
g_return_if_fail(IS_RING_MAIN_WINDOW(self));
auto* priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self));
priv->cpp->toggleFullScreen();
priv->cpp->resetToWelcome();
}
} // namespace gtk_callbacks
static void
set_pending_contact_request_tab_icon(RingMainWindow* self)
{
......@@ -204,20 +212,7 @@ set_pending_contact_request_tab_icon(RingMainWindow* self)
}
static void
hide_view_clicked(RingMainWindow *self)
{
auto priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self));
// clear selection and go to welcome page.
auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations));
gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_conversations));
auto selection_contact_request = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contact_requests));
gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_contact_request));
auto* old_view = gtk_bin_get_child(GTK_BIN(priv->frame_call));
lrc::api::conversation::Info current_item;
if (IS_CHAT_VIEW(old_view))
current_item = chat_view_get_conversation(CHAT_VIEW(old_view));
priv->cpp->changeView(RING_WELCOME_VIEW_TYPE, current_item);
}
ring_init_lrc(RingMainWindow *win, const std::string& accountId);
static void
show_combobox_account_selector(RingMainWindow *self, gboolean show)
......@@ -366,7 +361,7 @@ ring_init_lrc(RingMainWindow *win, const std::string& accountId)
// We are on the conversation cleared.
// Go to welcome view because user doesn't want this conversation
// TODO go to first conversation?
hide_view_clicked(win);
priv->cpp->resetToWelcome();
}
};
......@@ -959,6 +954,21 @@ CppImpl::toggleFullScreen()
enterFullScreen();
}
/// Clear selection and go to welcome page.
void
CppImpl::resetToWelcome()
{
auto selection_conversations = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_conversations));
gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_conversations));
auto selection_contact_request = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_contact_requests));
gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection_contact_request));
auto* old_view = gtk_bin_get_child(GTK_BIN(priv->frame_call));
lrc::api::conversation::Info current_item;
if (IS_CHAT_VIEW(old_view))
current_item = chat_view_get_conversation(CHAT_VIEW(old_view));
changeView(RING_WELCOME_VIEW_TYPE, current_item);
}
} // namespace details
//==============================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment