From 72d0a0d2a098d9f75291bdad73d02d3601c82945 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 17 Sep 2020 02:26:33 -0400 Subject: refactor channel listing --- components/channels.hpp | 96 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 21 deletions(-) (limited to 'components/channels.hpp') diff --git a/components/channels.hpp b/components/channels.hpp index 53f3789..a771933 100644 --- a/components/channels.hpp +++ b/components/channels.hpp @@ -7,34 +7,88 @@ #include #include "../discord/discord.hpp" +class ChannelListRow : public Gtk::ListBoxRow { +public: + bool IsUserCollapsed; + bool IsHidden; + Snowflake ID; + std::unordered_set Children; + + typedef sigc::signal type_signal_list_collapse; + typedef sigc::signal type_signal_list_uncollapse; + + type_signal_list_collapse signal_list_collapse(); + type_signal_list_uncollapse signal_list_uncollapse(); + +protected: + type_signal_list_collapse m_signal_list_collapse; + type_signal_list_uncollapse m_signal_list_uncollapse; +}; + +class ChannelListRowDMHeader : public ChannelListRow { +public: + ChannelListRowDMHeader(); + +protected: + Gtk::EventBox *m_ev; + Gtk::Box *m_box; + Gtk::Label *m_lbl; +}; + +class ChannelListRowDMChannel : public ChannelListRow { +public: + ChannelListRowDMChannel(const Channel *data); + +protected: + Gtk::EventBox *m_ev; + Gtk::Box *m_box; + Gtk::Label *m_lbl; +}; + +class ChannelListRowGuild : public ChannelListRow { +public: + ChannelListRowGuild(const Guild *data); + + int GuildIndex; + +protected: + Gtk::EventBox *m_ev; + Gtk::Box *m_box; + Gtk::Label *m_lbl; +}; + +class ChannelListRowCategory : public ChannelListRow { +public: + ChannelListRowCategory(const Channel *data); + +protected: + Gtk::EventBox *m_ev; + Gtk::Box *m_box; + Gtk::Label *m_lbl; + Gtk::Arrow *m_arrow; +}; + +class ChannelListRowChannel : public ChannelListRow { +public: + ChannelListRowChannel(const Channel *data); + +protected: + Gtk::EventBox *m_ev; + Gtk::Box *m_box; + Gtk::Label *m_lbl; +}; + class ChannelList { public: ChannelList(); Gtk::Widget *GetRoot() const; - void SetListingFromGuilds(const DiscordClient::guilds_type &guilds); + void UpdateListing(); void Clear(); protected: Gtk::ListBox *m_list; Gtk::ScrolledWindow *m_main; - struct ListItemInfo { - enum ListItemType { - Guild, - Category, - Channel, - }; - int GuildIndex; - Snowflake ID; - std::unordered_set Children; - bool IsUserCollapsed; - bool IsHidden; - ListItemType Type; - // for categories - Gtk::Arrow *CatArrow = nullptr; - }; - std::unordered_map m_infos; - void on_row_activated(Gtk::ListBoxRow *row); int m_guild_count; @@ -47,10 +101,10 @@ protected: void on_menu_copyid(); Glib::Dispatcher m_update_dispatcher; - mutable std::mutex m_update_mutex; - std::queue m_update_queue; + //mutable std::mutex m_update_mutex; + //std::queue> m_update_queue; void AddPrivateChannels(); // retard moment - void SetListingFromGuildsInternal(); + void UpdateListingInternal(); void AttachMenuHandler(Gtk::ListBoxRow *row); public: -- cgit v1.2.3