summaryrefslogtreecommitdiff
path: root/src/components/channellist/classic/guildlistfolderitem.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2024-01-08 20:53:40 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2024-01-08 20:53:40 -0500
commit9131158cbbf5800dd103d5b5fbfff96384352c77 (patch)
tree631e9120b5e0108b7169300760b8d21cb3bcee9c /src/components/channellist/classic/guildlistfolderitem.cpp
parentb700aa85d82b0af391e9fef84202488a779bc304 (diff)
downloadabaddon-portaudio-9131158cbbf5800dd103d5b5fbfff96384352c77.tar.gz
abaddon-portaudio-9131158cbbf5800dd103d5b5fbfff96384352c77.zip
add stack with icon and grid for classic listing folder icon
Diffstat (limited to 'src/components/channellist/classic/guildlistfolderitem.cpp')
-rw-r--r--src/components/channellist/classic/guildlistfolderitem.cpp71
1 files changed, 41 insertions, 30 deletions
diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp
index b6e49f1..e60bd5f 100644
--- a/src/components/channellist/classic/guildlistfolderitem.cpp
+++ b/src/components/channellist/classic/guildlistfolderitem.cpp
@@ -6,37 +6,31 @@
const int FolderGridButtonSize = 48;
const int FolderGridImageSize = 24;
-class GuildListFolderButton : public Gtk::Grid {
-public:
- GuildListFolderButton() {
- set_size_request(FolderGridButtonSize, FolderGridButtonSize);
- }
+GuildListFolderButton::GuildListFolderButton() {
+ set_size_request(FolderGridButtonSize, FolderGridButtonSize);
+}
+
+void GuildListFolderButton::SetGuilds(const std::vector<Snowflake> &guild_ids) {
+ for (int y = 0; y < 2; y++) {
+ for (int x = 0; x < 2; x++) {
+ const size_t i = y * 2 + x;
+ auto &widget = m_images[x][y];
+ widget.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(FolderGridImageSize);
+ attach(widget, x, y, 1, 1);
- void SetGuilds(const std::vector<Snowflake> &guild_ids) {
- for (int y = 0; y < 2; y++) {
- for (int x = 0; x < 2; x++) {
- const size_t i = y * 2 + x;
- auto &widget = m_images[x][y];
- widget.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(FolderGridImageSize);
- attach(widget, x, y, 1, 1);
-
- if (i < guild_ids.size()) {
- widget.show();
-
- if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(guild_ids[i]); guild.has_value()) {
- const auto cb = [&widget](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
- widget.property_pixbuf() = pb->scale_simple(FolderGridImageSize, FolderGridImageSize, Gdk::INTERP_BILINEAR);
- };
- Abaddon::Get().GetImageManager().LoadFromURL(guild->GetIconURL("png", "32"), sigc::track_obj(cb, *this));
- }
+ if (i < guild_ids.size()) {
+ widget.show();
+
+ if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(guild_ids[i]); guild.has_value()) {
+ const auto cb = [&widget](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
+ widget.property_pixbuf() = pb->scale_simple(FolderGridImageSize, FolderGridImageSize, Gdk::INTERP_BILINEAR);
+ };
+ Abaddon::Get().GetImageManager().LoadFromURL(guild->GetIconURL("png", "32"), sigc::track_obj(cb, *this));
}
}
}
}
-
-private:
- Gtk::Image m_images[2][2];
-};
+}
GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder) {
get_style_context()->add_class("classic-guild-folder");
@@ -49,17 +43,34 @@ GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &fo
m_ev.signal_button_press_event().connect([this](GdkEventButton *event) -> bool {
if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) {
m_revealer.set_reveal_child(!m_revealer.get_reveal_child());
+ if (!Abaddon::Get().GetSettings().FolderIconOnly) {
+ if (m_revealer.get_reveal_child()) {
+ m_stack.set_visible_child("icon", Gtk::STACK_TRANSITION_TYPE_SLIDE_DOWN);
+ } else {
+ m_stack.set_visible_child("grid", Gtk::STACK_TRANSITION_TYPE_SLIDE_UP);
+ }
+ }
}
+
return false;
});
- auto *btn = Gtk::make_managed<GuildListFolderButton>();
- btn->SetGuilds(folder.GuildIDs);
- m_ev.add(*btn);
+ m_grid.SetGuilds(folder.GuildIDs);
+ m_grid.show();
+
+ m_icon.property_icon_name() = "folder-symbolic";
+ m_icon.property_icon_size() = Gtk::ICON_SIZE_DND;
+ m_icon.show();
+
+ m_stack.add(m_grid, "grid");
+ m_stack.add(m_icon, "icon");
+ m_stack.set_visible_child(Abaddon::Get().GetSettings().FolderIconOnly ? "icon" : "grid");
+ m_stack.show();
+
+ m_ev.add(m_stack);
add(m_ev);
add(m_revealer);
- btn->show();
m_ev.show();
m_revealer.show();
m_box.show();