From a4d0cd9612dfa8b60fed63f1088b59b1762d217a Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 20 Jul 2021 17:55:03 -0400 Subject: color nsfw channels --- components/channels.cpp | 22 ++++++++++++++++++---- components/channels.hpp | 13 +++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'components') diff --git a/components/channels.cpp b/components/channels.cpp index 37e7625..547232c 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -66,6 +66,7 @@ ChannelList::ChannelList() column->add_attribute(renderer->property_icon(), m_columns.m_icon); column->add_attribute(renderer->property_name(), m_columns.m_name); column->add_attribute(renderer->property_expanded(), m_columns.m_expanded); + column->add_attribute(renderer->property_nsfw(), m_columns.m_nsfw); m_view.append_column(*column); m_menu_guild_copy_id.signal_activate().connect([this] { @@ -191,15 +192,13 @@ void ChannelList::UpdateChannel(Snowflake id) { channel_row[m_columns.m_type] = RenderType::TextChannel; channel_row[m_columns.m_id] = channel->ID; channel_row[m_columns.m_name] = Glib::Markup::escape_text(*channel->Name); + channel_row[m_columns.m_nsfw] = channel->NSFW(); if (is_orphan) channel_row[m_columns.m_sort] = *channel->Position + OrphanChannelSortOffset; else channel_row[m_columns.m_sort] = *channel->Position; } -void ChannelList::UpdateCreateDMChannel(Snowflake id) { -} - void ChannelList::UpdateCreateChannel(Snowflake id) { const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id); if (!channel.has_value()) return; @@ -221,6 +220,7 @@ void ChannelList::UpdateCreateChannel(Snowflake id) { channel_row[m_columns.m_type] = RenderType::TextChannel; channel_row[m_columns.m_id] = channel->ID; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel->Name); + channel_row[m_columns.m_nsfw] = channel->NSFW(); if (orphan) channel_row[m_columns.m_sort] = *channel->Position + OrphanChannelSortOffset; else @@ -293,6 +293,7 @@ Gtk::TreeModel::iterator ChannelList::AddGuild(const GuildData &guild) { channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); channel_row[m_columns.m_sort] = *channel.Position + OrphanChannelSortOffset; + channel_row[m_columns.m_nsfw] = channel.NSFW(); } for (const auto &[category_id, channels] : categories) { @@ -312,6 +313,7 @@ Gtk::TreeModel::iterator ChannelList::AddGuild(const GuildData &guild) { channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); channel_row[m_columns.m_sort] = *channel.Position; + channel_row[m_columns.m_nsfw] = channel.NSFW(); } } @@ -527,6 +529,7 @@ ChannelList::ModelColumns::ModelColumns() { add(m_name); add(m_icon); add(m_sort); + add(m_nsfw); add(m_expanded); } @@ -536,7 +539,8 @@ CellRendererChannels::CellRendererChannels() , m_property_type(*this, "render-type") , m_property_name(*this, "name") , m_property_pixbuf(*this, "pixbuf") - , m_property_expanded(*this, "expanded") { + , m_property_expanded(*this, "expanded") + , m_property_nsfw(*this, "nsfw") { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; property_xpad() = 2; property_ypad() = 2; @@ -564,6 +568,10 @@ Glib::PropertyProxy CellRendererChannels::property_expanded() { return m_property_expanded.get_proxy(); } +Glib::PropertyProxy CellRendererChannels::property_nsfw() { + return m_property_nsfw.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::Guild: @@ -794,7 +802,13 @@ void CellRendererChannels::render_vfunc_channel(const Cairo::RefPtr property_name(); Glib::PropertyProxy> property_icon(); Glib::PropertyProxy property_expanded(); + Glib::PropertyProxy property_nsfw(); protected: void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override; @@ -100,11 +101,11 @@ protected: private: Gtk::CellRendererText m_renderer_text; - Glib::Property m_property_type; - - Glib::Property m_property_name; // guild - Glib::Property> m_property_pixbuf; // guild + Glib::Property m_property_type; // all + Glib::Property m_property_name; // all + Glib::Property> m_property_pixbuf; // guild, dm Glib::Property m_property_expanded; // category + Glib::Property m_property_nsfw; // channel }; class ChannelList : public Gtk::ScrolledWindow { @@ -115,7 +116,6 @@ public: void UpdateRemoveGuild(Snowflake id); void UpdateRemoveChannel(Snowflake id); void UpdateChannel(Snowflake id); - void UpdateCreateDMChannel(Snowflake id); void UpdateCreateChannel(Snowflake id); void UpdateGuild(Snowflake id); @@ -133,6 +133,7 @@ protected: Gtk::TreeModelColumn m_name; Gtk::TreeModelColumn> m_icon; Gtk::TreeModelColumn m_sort; + Gtk::TreeModelColumn m_nsfw; // 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 -- cgit v1.2.3