From d7bee05ee92bf14c1344d336cfa5398815e8ccc9 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 20 Jan 2024 20:37:16 -0500 Subject: add settings for channel list scrollbar policies --- src/components/channellist/channellist.cpp | 4 +++- src/settings.cpp | 2 ++ src/settings.hpp | 2 ++ src/util.cpp | 8 ++++++++ src/util.hpp | 3 +++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index 1cdf619..2bb2f11 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -1,13 +1,15 @@ #include "channellist.hpp" #include "abaddon.hpp" +#include "util.hpp" ChannelList::ChannelList() { ConnectSignals(); m_guilds.set_halign(Gtk::ALIGN_START); - m_guilds_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); + m_guilds_scroll.set_policy(Gtk::POLICY_NEVER, util::TranslateScrollPolicy(Abaddon::Get().GetSettings().ClassicGuildScrollPolicy)); + m_tree.set_policy(Gtk::POLICY_AUTOMATIC, util::TranslateScrollPolicy(Abaddon::Get().GetSettings().ClassicChannelScrollPolicy)); m_guilds.signal_guild_selected().connect([this](Snowflake guild_id) { m_tree.SetSelectedGuild(guild_id); diff --git a/src/settings.cpp b/src/settings.cpp index 654a726..0b1ef49 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -113,6 +113,8 @@ void SettingsManager::DefineSettings() { AddSetting("style", "mentionbadgecolor", "rgba(184, 37, 37, 0)"s, &Settings::MentionBadgeColor); AddSetting("style", "mentionbadgetextcolor", "rgba(251, 251, 251, 0)"s, &Settings::MentionBadgeTextColor); AddSetting("style", "unreadcolor", "rgba(255, 255, 255, 0)"s, &Settings::UnreadIndicatorColor); + AddSetting("style", "classic_guild_scroll_policy", "automatic"s, &Settings::ClassicGuildScrollPolicy); + AddSetting("style", "classic_channel_scroll_policy", "automatic"s, &Settings::ClassicChannelScrollPolicy); #ifdef _WIN32 AddSetting("notifications", "enabled", false, &Settings::NotificationsEnabled); diff --git a/src/settings.hpp b/src/settings.hpp index df723fc..d29c623 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -44,6 +44,8 @@ public: std::string MentionBadgeColor; std::string MentionBadgeTextColor; std::string UnreadIndicatorColor; + std::string ClassicGuildScrollPolicy; + std::string ClassicChannelScrollPolicy; // [notifications] bool NotificationsEnabled; diff --git a/src/util.cpp b/src/util.cpp index 09bb368..d0d6e24 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -228,3 +228,11 @@ uint64_t util::TimeToEpoch(int year, int month, int day, int hour, int minute, i secs += seconds; return secs; } + +Gtk::PolicyType util::TranslateScrollPolicy(const std::string &str) { + if (str == "never") return Gtk::POLICY_NEVER; + if (str == "automatic") return Gtk::POLICY_AUTOMATIC; + if (str == "always") return Gtk::POLICY_ALWAYS; + if (str == "external") return Gtk::POLICY_EXTERNAL; + return Gtk::POLICY_AUTOMATIC; +} diff --git a/src/util.hpp b/src/util.hpp index fc9568b..f839eca 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -14,6 +14,7 @@ #include #include +#include #include namespace Glib { @@ -38,6 +39,8 @@ bool IsFolder(std::string_view path); bool IsFile(std::string_view path); uint64_t TimeToEpoch(int year, int month, int day, int hour, int minute, int seconds); + +Gtk::PolicyType TranslateScrollPolicy(const std::string &str); } // namespace util void LaunchBrowser(const Glib::ustring &url); -- cgit v1.2.3