Fork
Some checks failed
clang-format / lint (push) Has been cancelled
freebsd / build (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
Nix-Tests / nix-flake-check (push) Has been cancelled

This commit is contained in:
2025-10-09 22:05:52 -07:00
parent 559079e9a6
commit c5a7fae1d9
14 changed files with 138 additions and 20 deletions

View File

@ -51,8 +51,12 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
if (config_["drawer"].isObject()) {
is_drawer = true;
const auto& drawer_config = config_["drawer"];
if (drawer_config["toggle-signal"].isInt()) {
toggle_signal = std::make_optional(drawer_config["toggle-signal"].asInt());
}
const int transition_duration =
(drawer_config["transition-duration"].isInt() ? drawer_config["transition-duration"].asInt()
: 500);
@ -84,6 +88,14 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
event_box_.add(box);
}
void Group::toggle() {
if ((box.get_state_flags() & Gtk::StateFlags::STATE_FLAG_PRELIGHT) != 0U) {
hide_group();
} else {
show_group();
}
}
void Group::show_group() {
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
revealer.set_reveal_child(true);
@ -112,11 +124,7 @@ bool Group::handleToggle(GdkEventButton* const& e) {
if (!click_to_reveal || e->button != 1) {
return false;
}
if ((box.get_state_flags() & Gtk::StateFlags::STATE_FLAG_PRELIGHT) != 0U) {
hide_group();
} else {
show_group();
}
toggle();
return true;
}
@ -124,6 +132,12 @@ auto Group::update() -> void {
// noop
}
void Group::refresh(int sig) {
if (toggle_signal.has_value() && sig == SIGRTMIN + toggle_signal.value()) {
toggle();
}
}
Gtk::Box& Group::getBox() { return is_drawer ? (is_first_widget ? box : revealer_box) : box; }
void Group::addWidget(Gtk::Widget& widget) {