forked from OpenGamers/abaddon
color nsfw channels
This commit is contained in:
@@ -66,6 +66,7 @@ ChannelList::ChannelList()
|
|||||||
column->add_attribute(renderer->property_icon(), m_columns.m_icon);
|
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_name(), m_columns.m_name);
|
||||||
column->add_attribute(renderer->property_expanded(), m_columns.m_expanded);
|
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_view.append_column(*column);
|
||||||
|
|
||||||
m_menu_guild_copy_id.signal_activate().connect([this] {
|
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_type] = RenderType::TextChannel;
|
||||||
channel_row[m_columns.m_id] = channel->ID;
|
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_name] = Glib::Markup::escape_text(*channel->Name);
|
||||||
|
channel_row[m_columns.m_nsfw] = channel->NSFW();
|
||||||
if (is_orphan)
|
if (is_orphan)
|
||||||
channel_row[m_columns.m_sort] = *channel->Position + OrphanChannelSortOffset;
|
channel_row[m_columns.m_sort] = *channel->Position + OrphanChannelSortOffset;
|
||||||
else
|
else
|
||||||
channel_row[m_columns.m_sort] = *channel->Position;
|
channel_row[m_columns.m_sort] = *channel->Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelList::UpdateCreateDMChannel(Snowflake id) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelList::UpdateCreateChannel(Snowflake id) {
|
void ChannelList::UpdateCreateChannel(Snowflake id) {
|
||||||
const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id);
|
const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id);
|
||||||
if (!channel.has_value()) return;
|
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_type] = RenderType::TextChannel;
|
||||||
channel_row[m_columns.m_id] = channel->ID;
|
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_name] = "#" + Glib::Markup::escape_text(*channel->Name);
|
||||||
|
channel_row[m_columns.m_nsfw] = channel->NSFW();
|
||||||
if (orphan)
|
if (orphan)
|
||||||
channel_row[m_columns.m_sort] = *channel->Position + OrphanChannelSortOffset;
|
channel_row[m_columns.m_sort] = *channel->Position + OrphanChannelSortOffset;
|
||||||
else
|
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_id] = channel.ID;
|
||||||
channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name);
|
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_sort] = *channel.Position + OrphanChannelSortOffset;
|
||||||
|
channel_row[m_columns.m_nsfw] = channel.NSFW();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &[category_id, channels] : categories) {
|
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_id] = channel.ID;
|
||||||
channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name);
|
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_sort] = *channel.Position;
|
||||||
|
channel_row[m_columns.m_nsfw] = channel.NSFW();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,6 +529,7 @@ ChannelList::ModelColumns::ModelColumns() {
|
|||||||
add(m_name);
|
add(m_name);
|
||||||
add(m_icon);
|
add(m_icon);
|
||||||
add(m_sort);
|
add(m_sort);
|
||||||
|
add(m_nsfw);
|
||||||
add(m_expanded);
|
add(m_expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,7 +539,8 @@ CellRendererChannels::CellRendererChannels()
|
|||||||
, m_property_type(*this, "render-type")
|
, m_property_type(*this, "render-type")
|
||||||
, m_property_name(*this, "name")
|
, m_property_name(*this, "name")
|
||||||
, m_property_pixbuf(*this, "pixbuf")
|
, 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_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
|
||||||
property_xpad() = 2;
|
property_xpad() = 2;
|
||||||
property_ypad() = 2;
|
property_ypad() = 2;
|
||||||
@@ -564,6 +568,10 @@ Glib::PropertyProxy<bool> CellRendererChannels::property_expanded() {
|
|||||||
return m_property_expanded.get_proxy();
|
return m_property_expanded.get_proxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Glib::PropertyProxy<bool> 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 {
|
void CellRendererChannels::get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const {
|
||||||
switch (m_property_type.get_value()) {
|
switch (m_property_type.get_value()) {
|
||||||
case RenderType::Guild:
|
case RenderType::Guild:
|
||||||
@@ -794,7 +802,13 @@ void CellRendererChannels::render_vfunc_channel(const Cairo::RefPtr<Cairo::Conte
|
|||||||
|
|
||||||
Gdk::Rectangle text_cell_area(text_x, text_y, text_w, text_h);
|
Gdk::Rectangle text_cell_area(text_x, text_y, text_w, text_h);
|
||||||
|
|
||||||
|
const static auto nsfw_color = Gdk::RGBA(Abaddon::Get().GetSettings().GetNSFWChannelColor());
|
||||||
|
if (m_property_nsfw.get_value())
|
||||||
|
m_renderer_text.property_foreground_rgba() = nsfw_color;
|
||||||
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
|
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
|
||||||
|
// setting property_foreground_rgba() sets this to true which makes non-nsfw cells use the property too which is bad
|
||||||
|
// so unset it
|
||||||
|
m_renderer_text.property_foreground_set() = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dm header
|
// dm header
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ constexpr static int GuildIconSize = 24;
|
|||||||
constexpr static int DMIconSize = 20;
|
constexpr static int DMIconSize = 20;
|
||||||
constexpr static int OrphanChannelSortOffset = -100; // forces orphan channels to the top of the list
|
constexpr static int OrphanChannelSortOffset = -100; // forces orphan channels to the top of the list
|
||||||
|
|
||||||
enum class RenderType {
|
enum class RenderType : uint8_t {
|
||||||
Guild,
|
Guild,
|
||||||
Category,
|
Category,
|
||||||
TextChannel,
|
TextChannel,
|
||||||
@@ -30,6 +30,7 @@ public:
|
|||||||
Glib::PropertyProxy<Glib::ustring> property_name();
|
Glib::PropertyProxy<Glib::ustring> property_name();
|
||||||
Glib::PropertyProxy<Glib::RefPtr<Gdk::Pixbuf>> property_icon();
|
Glib::PropertyProxy<Glib::RefPtr<Gdk::Pixbuf>> property_icon();
|
||||||
Glib::PropertyProxy<bool> property_expanded();
|
Glib::PropertyProxy<bool> property_expanded();
|
||||||
|
Glib::PropertyProxy<bool> property_nsfw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override;
|
void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override;
|
||||||
@@ -100,11 +101,11 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Gtk::CellRendererText m_renderer_text;
|
Gtk::CellRendererText m_renderer_text;
|
||||||
|
|
||||||
Glib::Property<RenderType> m_property_type;
|
Glib::Property<RenderType> m_property_type; // all
|
||||||
|
Glib::Property<Glib::ustring> m_property_name; // all
|
||||||
Glib::Property<Glib::ustring> m_property_name; // guild
|
Glib::Property<Glib::RefPtr<Gdk::Pixbuf>> m_property_pixbuf; // guild, dm
|
||||||
Glib::Property<Glib::RefPtr<Gdk::Pixbuf>> m_property_pixbuf; // guild
|
|
||||||
Glib::Property<bool> m_property_expanded; // category
|
Glib::Property<bool> m_property_expanded; // category
|
||||||
|
Glib::Property<bool> m_property_nsfw; // channel
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChannelList : public Gtk::ScrolledWindow {
|
class ChannelList : public Gtk::ScrolledWindow {
|
||||||
@@ -115,7 +116,6 @@ public:
|
|||||||
void UpdateRemoveGuild(Snowflake id);
|
void UpdateRemoveGuild(Snowflake id);
|
||||||
void UpdateRemoveChannel(Snowflake id);
|
void UpdateRemoveChannel(Snowflake id);
|
||||||
void UpdateChannel(Snowflake id);
|
void UpdateChannel(Snowflake id);
|
||||||
void UpdateCreateDMChannel(Snowflake id);
|
|
||||||
void UpdateCreateChannel(Snowflake id);
|
void UpdateCreateChannel(Snowflake id);
|
||||||
void UpdateGuild(Snowflake id);
|
void UpdateGuild(Snowflake id);
|
||||||
|
|
||||||
@@ -133,6 +133,7 @@ protected:
|
|||||||
Gtk::TreeModelColumn<Glib::ustring> m_name;
|
Gtk::TreeModelColumn<Glib::ustring> m_name;
|
||||||
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>> m_icon;
|
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>> m_icon;
|
||||||
Gtk::TreeModelColumn<int64_t> m_sort;
|
Gtk::TreeModelColumn<int64_t> m_sort;
|
||||||
|
Gtk::TreeModelColumn<bool> m_nsfw;
|
||||||
// Gtk::CellRenderer's property_is_expanded only works how i want it to if it has children
|
// 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)
|
// 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
|
// so this solution will have to do which i hate but the alternative is adding invisible children
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ void ChannelData::update_from_json(const nlohmann::json &j) {
|
|||||||
JS_RD("last_pin_timestamp", LastPinTimestamp);
|
JS_RD("last_pin_timestamp", LastPinTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChannelData::NSFW() const {
|
||||||
|
return IsNSFW.has_value() && *IsNSFW;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<PermissionOverwrite> ChannelData::GetOverwrite(Snowflake id) const {
|
std::optional<PermissionOverwrite> ChannelData::GetOverwrite(Snowflake id) const {
|
||||||
return Abaddon::Get().GetDiscordClient().GetPermissionOverwrite(ID, id);
|
return Abaddon::Get().GetDiscordClient().GetPermissionOverwrite(ID, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ struct ChannelData {
|
|||||||
friend void from_json(const nlohmann::json &j, ChannelData &m);
|
friend void from_json(const nlohmann::json &j, ChannelData &m);
|
||||||
void update_from_json(const nlohmann::json &j);
|
void update_from_json(const nlohmann::json &j);
|
||||||
|
|
||||||
|
bool NSFW() const;
|
||||||
std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const;
|
std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const;
|
||||||
std::vector<UserData> GetDMRecipients() const;
|
std::vector<UserData> GetDMRecipients() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,11 +63,15 @@ bool SettingsManager::GetShowCustomEmojis() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string SettingsManager::GetLinkColor() const {
|
std::string SettingsManager::GetLinkColor() const {
|
||||||
return GetSettingString("misc", "linkcolor", "rgba(40, 200, 180, 255)");
|
return GetSettingString("style", "linkcolor", "rgba(40, 200, 180, 255)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SettingsManager::GetChannelsExpanderColor() const {
|
std::string SettingsManager::GetChannelsExpanderColor() const {
|
||||||
return GetSettingString("misc", "expandercolor", "rgba(255, 83, 112, 255)");
|
return GetSettingString("style", "expandercolor", "rgba(255, 83, 112, 255)");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SettingsManager::GetNSFWChannelColor() const {
|
||||||
|
return GetSettingString("style", "nsfwchannelcolor", "#ed6666");
|
||||||
}
|
}
|
||||||
|
|
||||||
int SettingsManager::GetCacheHTTPConcurrency() const {
|
int SettingsManager::GetCacheHTTPConcurrency() const {
|
||||||
|
|||||||
@@ -29,9 +29,11 @@ public:
|
|||||||
// #3 it's a massive pain in the ass to try and bump the version to a functioning version
|
// #3 it's a massive pain in the ass to try and bump the version to a functioning version
|
||||||
// because they switch build systems to nmake/meson (took months to get merged in vcpkg)
|
// because they switch build systems to nmake/meson (took months to get merged in vcpkg)
|
||||||
// #4 c++ build systems sucks
|
// #4 c++ build systems sucks
|
||||||
// perhaps i'll bump to gtk4 when it's more stable
|
// three options are: use gtk4 with updated vcpkg, try and port it myself, or use msys2 instead of vcpkg
|
||||||
|
// im leaning towards msys
|
||||||
std::string GetLinkColor() const;
|
std::string GetLinkColor() const;
|
||||||
std::string GetChannelsExpanderColor() const;
|
std::string GetChannelsExpanderColor() const;
|
||||||
|
std::string GetNSFWChannelColor() const;
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user