diff --git a/src/components/channels.cpp b/src/components/channels.cpp index b14a3c1..5e4570b 100644 --- a/src/components/channels.cpp +++ b/src/components/channels.cpp @@ -89,6 +89,7 @@ ChannelList::ChannelList() column->add_attribute(renderer->property_id(), m_columns.m_id); column->add_attribute(renderer->property_expanded(), m_columns.m_expanded); column->add_attribute(renderer->property_nsfw(), m_columns.m_nsfw); + column->add_attribute(renderer->property_color(), m_columns.m_color); m_view.append_column(*column); m_menu_guild_copy_id.signal_activate().connect([this] { @@ -292,27 +293,29 @@ void ChannelList::UpdateListing() { int sort_value = 0; const auto folders = discord.GetUserSettings().GuildFolders; - for (const auto &group : folders) { - auto iter = AddFolder(group); - (*iter)[m_columns.m_sort] = sort_value++; - } + if (folders.empty()) { + // fallback if no organization has occurred (guild_folders will be empty) + const auto guild_ids = discord.GetUserSortedGuilds(); + for (const auto &guild_id : guild_ids) { + const auto guild = discord.GetGuild(guild_id); + if (!guild.has_value()) continue; - /* - int sortnum = 0; - for (const auto &guild_id : guild_ids) { - const auto guild = discord.GetGuild(guild_id); - if (!guild.has_value()) continue; - - auto iter = AddGuild(*guild); - (*iter)[m_columns.m_sort] = sortnum++; + auto iter = AddGuild(*guild, m_model->children()); + (*iter)[m_columns.m_sort] = sort_value++; + } + } else { + for (const auto &group : folders) { + auto iter = AddFolder(group); + (*iter)[m_columns.m_sort] = sort_value++; + } } - */ m_updating_listing = false; AddPrivateChannels(); } +// TODO update for folders void ChannelList::UpdateNewGuild(const GuildData &guild) { AddGuild(guild, m_model->children()); // update sort order @@ -602,6 +605,9 @@ Gtk::TreeModel::iterator ChannelList::AddFolder(const UserSettingsGuildFoldersEn } else { folder_row[m_columns.m_name] = "Folder"; } + if (folder.Color.has_value()) { + folder_row[m_columns.m_color] = IntToRGBA(*folder.Color); + } int sort_value = 0; for (const auto &guild_id : folder.GuildIDs) { @@ -973,6 +979,7 @@ void ChannelList::MoveRow(const Gtk::TreeModel::iterator &iter, const Gtk::TreeM M(m_sort); M(m_nsfw); M(m_expanded); + M(m_color); #undef M // recursively move children @@ -1085,4 +1092,5 @@ ChannelList::ModelColumns::ModelColumns() { add(m_sort); add(m_nsfw); add(m_expanded); + add(m_color); } diff --git a/src/components/channels.hpp b/src/components/channels.hpp index 37a3610..6ceaada 100644 --- a/src/components/channels.hpp +++ b/src/components/channels.hpp @@ -61,6 +61,7 @@ protected: Gtk::TreeModelColumn> m_icon_anim; Gtk::TreeModelColumn m_sort; Gtk::TreeModelColumn m_nsfw; + Gtk::TreeModelColumn> m_color; // for folders right now // Gtk::CellRenderer's property_is_expanded only works how i want it to if it has children // because otherwise it doesnt count as an "expander" (property_is_expander) // so this solution will have to do which i hate but the alternative is adding invisible children diff --git a/src/components/channelscellrenderer.cpp b/src/components/channelscellrenderer.cpp index 9e2d391..69f0450 100644 --- a/src/components/channelscellrenderer.cpp +++ b/src/components/channelscellrenderer.cpp @@ -18,7 +18,8 @@ CellRendererChannels::CellRendererChannels() , m_property_pixbuf(*this, "pixbuf") , m_property_pixbuf_animation(*this, "pixbuf-animation") , m_property_expanded(*this, "expanded") - , m_property_nsfw(*this, "nsfw") { + , m_property_nsfw(*this, "nsfw") + , m_property_color(*this, "color") { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; property_xpad() = 2; property_ypad() = 2; @@ -55,6 +56,10 @@ Glib::PropertyProxy CellRendererChannels::property_nsfw() { return m_property_nsfw.get_proxy(); } +Glib::PropertyProxy> CellRendererChannels::property_color() { + return m_property_color.get_proxy(); +} + void CellRendererChannels::get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const { switch (m_property_type.get_value()) { case RenderType::Folder: @@ -204,7 +209,11 @@ void CellRendererChannels::render_vfunc_folder(const Cairo::RefPtr> property_icon_animation(); Glib::PropertyProxy property_expanded(); Glib::PropertyProxy property_nsfw(); + Glib::PropertyProxy> property_color(); protected: void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override; @@ -130,6 +131,7 @@ private: Glib::Property> m_property_pixbuf_animation; // guild Glib::Property m_property_expanded; // category Glib::Property m_property_nsfw; // channel + Glib::Property> m_property_color; // folder // same pitfalls as in https://github.com/uowuo/abaddon/blob/60404783bd4ce9be26233fe66fc3a74475d9eaa3/components/cellrendererpixbufanimation.hpp#L32-L39 // this will manifest though since guild icons can change