From c4226f3745b26a2439017e307c2febde48e59ece Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Mon, 30 Oct 2023 18:01:47 +0100 Subject: [PATCH] Readded signal_timeout instead of map to fix indicator being stuck --- include/modules/privacy/privacy_item.hpp | 4 +-- src/modules/privacy/privacy_item.cpp | 44 ++++++++++-------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/include/modules/privacy/privacy_item.hpp b/include/modules/privacy/privacy_item.hpp index 802ca08e..ac94d168 100644 --- a/include/modules/privacy/privacy_item.hpp +++ b/include/modules/privacy/privacy_item.hpp @@ -32,6 +32,8 @@ class PrivacyItem : public Gtk::Revealer { enum PrivacyNodeType privacy_type; std::list *nodes; + sigc::connection signal_conn; + Gtk::Box tooltip_window; bool init = false; @@ -47,8 +49,6 @@ class PrivacyItem : public Gtk::Revealer { Gtk::Box box_; Gtk::Image icon_; - void on_child_revealed_changed(); - void on_map_changed(); void update_tooltip(); }; diff --git a/src/modules/privacy/privacy_item.cpp b/src/modules/privacy/privacy_item.cpp index f4c04ede..9f1c0819 100644 --- a/src/modules/privacy/privacy_item.cpp +++ b/src/modules/privacy/privacy_item.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -28,6 +27,7 @@ PrivacyItem::PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privac : Gtk::Revealer(), privacy_type(privacy_type_), nodes(nodes_), + signal_conn(), tooltip_window(Gtk::ORIENTATION_VERTICAL, 0), box_(Gtk::ORIENTATION_HORIZONTAL, 0), icon_() { @@ -94,10 +94,6 @@ PrivacyItem::PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privac *this)); } - property_child_revealed().signal_changed().connect( - sigc::mem_fun(*this, &PrivacyItem::on_child_revealed_changed)); - signal_map().connect(sigc::mem_fun(*this, &PrivacyItem::on_map_changed)); - // Don't show by default set_reveal_child(true); set_visible(false); @@ -130,18 +126,6 @@ void PrivacyItem::update_tooltip() { bool PrivacyItem::is_enabled() { return enabled; } -void PrivacyItem::on_child_revealed_changed() { - if (!this->get_child_revealed()) { - set_visible(false); - } -} - -void PrivacyItem::on_map_changed() { - if (this->get_visible()) { - set_reveal_child(true); - } -} - void PrivacyItem::set_in_use(bool in_use) { if (in_use) { update_tooltip(); @@ -150,20 +134,30 @@ void PrivacyItem::set_in_use(bool in_use) { if (this->in_use == in_use && init) return; if (init) { + // Disconnect any previous connection so that it doesn't get activated in + // the future, hiding the module when it should be visible + signal_conn.disconnect(); + this->in_use = in_use; + guint duration = 0; if (this->in_use) { set_visible(true); - // The `on_map_changed` callback will call `set_reveal_child(true)` - // when the widget is realized so we don't need to call that here. - // This fixes a bug where the revealer wouldn't start the animation - // due to us changing the visibility at the same time. } else { set_reveal_child(false); - // The `on_child_revealed_changed` callback will call `set_visible(false)` - // when the animation has finished so we don't need to call that here. - // We do this so that the widget gets hidden after the revealer hide animation - // has finished. + duration = get_transition_duration(); } + + signal_conn = Glib::signal_timeout().connect(sigc::track_obj( + [this] { + if (this->in_use) { + set_reveal_child(true); + } else { + set_visible(false); + } + return false; + }, + *this), + duration); } else { set_visible(false); set_reveal_child(false);