forked from OpenGamers/abaddon
colors, fallback if guild_folders is empty
This commit is contained in:
parent
1ba3daa04a
commit
d2cbe00af2
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user