From 5b806a25894bf183515c64ac8099911da8f4a0c7 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 8 Apr 2022 23:47:12 -0400 Subject: basic tabs system --- src/components/chatwindow.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/components/chatwindow.cpp') diff --git a/src/components/chatwindow.cpp b/src/components/chatwindow.cpp index 582343d..99ec8a0 100644 --- a/src/components/chatwindow.cpp +++ b/src/components/chatwindow.cpp @@ -4,6 +4,9 @@ #include "ratelimitindicator.hpp" #include "chatinput.hpp" #include "chatlist.hpp" +#ifdef WITH_LIBHANDY + #include "channeltabswitcherhandy.hpp" +#endif ChatWindow::ChatWindow() { Abaddon::Get().GetDiscordClient().signal_message_send_fail().connect(sigc::mem_fun(*this, &ChatWindow::OnMessageSendFail)); @@ -15,6 +18,13 @@ ChatWindow::ChatWindow() { m_rate_limit_indicator = Gtk::manage(new RateLimitIndicator); m_meta = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); +#ifdef WITH_LIBHANDY + m_tab_switcher = Gtk::make_managed(); + m_tab_switcher->signal_channel_switched_to().connect([this](Snowflake id) { + m_signal_action_channel_click.emit(id); + }); +#endif + m_rate_limit_indicator->set_margin_end(5); m_rate_limit_indicator->set_hexpand(true); m_rate_limit_indicator->set_halign(Gtk::ALIGN_END); @@ -88,6 +98,10 @@ ChatWindow::ChatWindow() { m_meta->add(*m_input_indicator); m_meta->add(*m_rate_limit_indicator); // m_scroll->add(*m_list); +#ifdef WITH_LIBHANDY + m_main->add(*m_tab_switcher); + m_tab_switcher->show(); +#endif m_main->add(m_topic); m_main->add(*m_chat); m_main->add(m_completer); @@ -115,6 +129,10 @@ void ChatWindow::SetActiveChannel(Snowflake id) { m_rate_limit_indicator->SetActiveChannel(id); if (m_is_replying) StopReplying(); + +#ifdef WITH_LIBHANDY + m_tab_switcher->ReplaceActiveTab(id); +#endif } void ChatWindow::AddNewMessage(const Message &data) { @@ -150,6 +168,12 @@ void ChatWindow::SetTopic(const std::string &text) { m_topic.set_visible(text.length() > 0); } +#ifdef WITH_LIBHANDY +void ChatWindow::OpenNewTab(Snowflake id) { + m_tab_switcher->AddChannelTab(id); +} +#endif + Snowflake ChatWindow::GetActiveChannel() const { return m_active_channel; } -- cgit v1.2.3