diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-12-24 02:44:56 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-12-24 02:44:56 -0500 |
commit | d2cbe00af25bacd40fc4c55191bf9c9073aca1bf (patch) | |
tree | c9e1132258c77b5c1c084cc5c323370b0afbb103 /src | |
parent | 1ba3daa04ac374504a5cdf62cb5fde44f12027bc (diff) | |
download | abaddon-portaudio-d2cbe00af25bacd40fc4c55191bf9c9073aca1bf.tar.gz abaddon-portaudio-d2cbe00af25bacd40fc4c55191bf9c9073aca1bf.zip |
colors, fallback if guild_folders is empty
Diffstat (limited to 'src')
-rw-r--r-- | src/components/channels.cpp | 36 | ||||
-rw-r--r-- | src/components/channels.hpp | 1 | ||||
-rw-r--r-- | src/components/channelscellrenderer.cpp | 13 | ||||
-rw-r--r-- | src/components/channelscellrenderer.hpp | 2 |
4 files changed, 36 insertions, 16 deletions
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++; - } - - /* - 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++; + 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; + + 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<Glib::RefPtr<Gdk::PixbufAnimation>> m_icon_anim; Gtk::TreeModelColumn<int64_t> m_sort; Gtk::TreeModelColumn<bool> m_nsfw; + Gtk::TreeModelColumn<std::optional<Gdk::RGBA>> 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<bool> CellRendererChannels::property_nsfw() { return m_property_nsfw.get_proxy(); } +Glib::PropertyProxy<std::optional<Gdk::RGBA>> 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<Cairo::Contex Gdk::Rectangle text_cell_area(text_x, text_y, text_w, text_h); static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelColor); - m_renderer_text.property_foreground_rgba() = color; + if (m_property_color.get_value().has_value()) { + m_renderer_text.property_foreground_rgba() = *m_property_color.get_value(); + } else { + m_renderer_text.property_foreground_rgba() = color; + } m_renderer_text.render(cr, widget, background_area, text_cell_area, flags); m_renderer_text.property_foreground_set() = false; } diff --git a/src/components/channelscellrenderer.hpp b/src/components/channelscellrenderer.hpp index 00c3603..f5ba796 100644 --- a/src/components/channelscellrenderer.hpp +++ b/src/components/channelscellrenderer.hpp @@ -28,6 +28,7 @@ public: Glib::PropertyProxy<Glib::RefPtr<Gdk::PixbufAnimation>> property_icon_animation(); Glib::PropertyProxy<bool> property_expanded(); Glib::PropertyProxy<bool> property_nsfw(); + Glib::PropertyProxy<std::optional<Gdk::RGBA>> 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<Glib::RefPtr<Gdk::PixbufAnimation>> m_property_pixbuf_animation; // guild Glib::Property<bool> m_property_expanded; // category Glib::Property<bool> m_property_nsfw; // channel + Glib::Property<std::optional<Gdk::RGBA>> 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 |