diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/channellist/channellist.cpp | 50 | ||||
-rw-r--r-- | src/components/channellist/channellist.hpp | 10 | ||||
-rw-r--r-- | src/components/channellist/channellisttree.cpp | 14 | ||||
-rw-r--r-- | src/components/channellist/channellisttree.hpp | 6 | ||||
-rw-r--r-- | src/components/channellist/classic/guildlist.cpp | 24 | ||||
-rw-r--r-- | src/components/channellist/classic/guildlist.hpp | 12 | ||||
-rw-r--r-- | src/components/channellist/classic/guildlistguilditem.cpp | 7 | ||||
-rw-r--r-- | src/windows/mainwindow.cpp | 2 |
8 files changed, 112 insertions, 13 deletions
diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index 38a9ecc..6cb5321 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -1,12 +1,26 @@ #include "channellist.hpp" ChannelList::ChannelList() { + ConnectSignals(); + + m_guilds.set_halign(Gtk::ALIGN_START); + + m_guilds_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); + + m_guilds.signal_guild_selected().connect([this](Snowflake guild_id) { + m_tree.SetSelectedGuild(guild_id); + }); + + m_guilds.show(); m_tree.show(); - add(m_tree); + m_guilds_scroll.add(m_guilds); + pack_start(m_guilds_scroll, false, false); // only take the space it needs + pack_start(m_tree, true, true); // use all the remaining space } void ChannelList::UpdateListing() { m_tree.UpdateListing(); + m_guilds.UpdateListing(); } void ChannelList::SetActiveChannel(Snowflake id, bool expand_to) { @@ -18,13 +32,45 @@ void ChannelList::UseExpansionState(const ExpansionStateRoot &state) { } ExpansionStateRoot ChannelList::GetExpansionState() const { - m_tree.GetExpansionState(); + return m_tree.GetExpansionState(); } void ChannelList::UsePanedHack(Gtk::Paned &paned) { m_tree.UsePanedHack(paned); } +void ChannelList::SetClassic(bool value) { + m_tree.SetClassic(value); + m_guilds_scroll.set_visible(value); +} + +void ChannelList::ConnectSignals() { + // TODO: if these all just travel upwards to the singleton then get rid of them but mayeb they dont + m_tree.signal_action_open_new_tab().connect([this](Snowflake id) { + m_signal_action_open_new_tab.emit(id); + }); + + m_tree.signal_action_join_voice_channel().connect([this](Snowflake id) { + m_signal_action_join_voice_channel.emit(id); + }); + + m_tree.signal_action_disconnect_voice().connect([this]() { + m_signal_action_disconnect_voice.emit(); + }); + + m_tree.signal_action_channel_item_select().connect([this](Snowflake id) { + m_signal_action_channel_item_select.emit(id); + }); + + m_tree.signal_action_guild_leave().connect([this](Snowflake id) { + m_signal_action_guild_leave.emit(id); + }); + + m_tree.signal_action_guild_settings().connect([this](Snowflake id) { + m_signal_action_guild_settings.emit(id); + }); +} + ChannelList::type_signal_action_open_new_tab ChannelList::signal_action_open_new_tab() { return m_signal_action_open_new_tab; } diff --git a/src/components/channellist/channellist.hpp b/src/components/channellist/channellist.hpp index 5863485..692afa7 100644 --- a/src/components/channellist/channellist.hpp +++ b/src/components/channellist/channellist.hpp @@ -2,11 +2,12 @@ #include <gtkmm/box.h> #include <gtkmm/paned.h> #include "channellisttree.hpp" +#include "classic/guildlist.hpp" #include "discord/snowflake.hpp" #include "state.hpp" // Contains the actual ChannelListTree and the classic listing if enabled -class ChannelList : public Gtk::Box { +class ChannelList : public Gtk::HBox { // have to proxy public and signals to underlying tree... ew!!! public: ChannelList(); @@ -20,9 +21,16 @@ public: void UsePanedHack(Gtk::Paned &paned); + void SetClassic(bool value); + private: + void ConnectSignals(); + ChannelListTree m_tree; + Gtk::ScrolledWindow m_guilds_scroll; + GuildList m_guilds; + public: using type_signal_action_channel_item_select = sigc::signal<void, Snowflake>; using type_signal_action_guild_leave = sigc::signal<void, Snowflake>; diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index 22f8581..b9b5c08 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -85,8 +85,10 @@ ChannelListTree::ChannelListTree() }); m_filter_model->set_visible_func([this](const Gtk::TreeModel::const_iterator &iter) -> bool { + if (!m_classic) return true; + if ((*iter)[m_columns.m_type] == RenderType::Guild) { - return (*iter)[m_columns.m_id] == 754921263616753776ULL; + return (*iter)[m_columns.m_id] == m_classic_selected_guild; } return true; }); @@ -301,6 +303,16 @@ void ChannelListTree::UsePanedHack(Gtk::Paned &paned) { paned.property_position().signal_changed().connect(sigc::mem_fun(*this, &ChannelListTree::OnPanedPositionChanged)); } +void ChannelListTree::SetClassic(bool value) { + m_classic = value; + m_filter_model->refilter(); +} + +void ChannelListTree::SetSelectedGuild(Snowflake guild_id) { + m_classic_selected_guild = guild_id; + m_filter_model->refilter(); +} + void ChannelListTree::OnPanedPositionChanged() { m_view.queue_draw(); } diff --git a/src/components/channellist/channellisttree.hpp b/src/components/channellist/channellisttree.hpp index 0cd76e0..bb7396e 100644 --- a/src/components/channellist/channellisttree.hpp +++ b/src/components/channellist/channellisttree.hpp @@ -33,6 +33,9 @@ public: void UsePanedHack(Gtk::Paned &paned); + void SetClassic(bool value); + void SetSelectedGuild(Snowflake guild_id); + protected: void OnPanedPositionChanged(); @@ -186,6 +189,9 @@ protected: bool m_updating_listing = false; + bool m_classic = false; + Snowflake m_classic_selected_guild; + Snowflake m_active_channel; public: diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 0d5737b..6c1fbc3 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -6,18 +6,40 @@ GuildList::GuildList() { show_all_children(); } +void GuildList::UpdateListing() { + auto &discord = Abaddon::Get().GetDiscordClient(); + + Clear(); + + // does this function still even work ??lol + const auto ids = discord.GetUserSortedGuilds(); + for (const auto id : ids) { + AddGuild(id); + } +} + void GuildList::AddGuild(Snowflake id) { const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(id); if (!guild.has_value()) return; auto *item = Gtk::make_managed<GuildListGuildItem>(*guild); + item->signal_button_press_event().connect([this, id](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { + m_signal_guild_selected.emit(id); + } + return true; + }); item->show(); add(*item); } void GuildList::Clear() { const auto children = get_children(); - for (auto child : children) { + for (auto *child : children) { delete child; } } + +GuildList::type_signal_guild_selected GuildList::signal_guild_selected() { + return m_signal_guild_selected; +} diff --git a/src/components/channellist/classic/guildlist.hpp b/src/components/channellist/classic/guildlist.hpp index 244313f..856cf4d 100644 --- a/src/components/channellist/classic/guildlist.hpp +++ b/src/components/channellist/classic/guildlist.hpp @@ -6,7 +6,17 @@ class GuildList : public Gtk::ListBox { public: GuildList(); - void AddGuild(Snowflake id); + void UpdateListing(); +private: + void AddGuild(Snowflake id); void Clear(); + +public: + using type_signal_guild_selected = sigc::signal<void, Snowflake>; + + type_signal_guild_selected signal_guild_selected(); + +private: + type_signal_guild_selected m_signal_guild_selected; }; diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp index 88ed2a9..5cec281 100644 --- a/src/components/channellist/classic/guildlistguilditem.cpp +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -6,13 +6,6 @@ GuildListGuildItem::GuildListGuildItem(const GuildData &guild) add(m_image); show_all_children(); - signal_button_press_event().connect([this](GdkEventButton *event) -> bool { - if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { - printf("Click %llu\n", (uint64_t)ID); - } - return true; - }); - set_tooltip_text(guild.Name); UpdateIcon(); diff --git a/src/windows/mainwindow.cpp b/src/windows/mainwindow.cpp index 8e030ed..ea67d2b 100644 --- a/src/windows/mainwindow.cpp +++ b/src/windows/mainwindow.cpp @@ -33,6 +33,8 @@ MainWindow::MainWindow() }); #endif + // TEMP TEMP TEMP TEMP!!!!!!!!!!!! AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + m_channel_list.SetClassic(true); m_channel_list.set_vexpand(true); m_channel_list.set_size_request(-1, -1); m_channel_list.show(); |