[fractal] room-history: Show selection when context menu is open



commit 7ffbf9849f1df51cf317f157dedf3347ba0d1cdb
Author: Julian Sparber <julian sparber net>
Date:   Fri Sep 9 12:08:13 2022 +0200

    room-history: Show selection when context menu is open
    
    Fixes: https://gitlab.gnome.org/GNOME/fractal/-/issues/938

 data/resources/style.css                     |  5 +++++
 src/session/content/room_history/item_row.rs | 20 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/data/resources/style.css b/data/resources/style.css
index 85926f26e..87a20f909 100644
--- a/data/resources/style.css
+++ b/data/resources/style.css
@@ -392,6 +392,11 @@ login {
   padding-bottom: 6px;
 }
 
+.room-history row.has-open-popup  {
+  background-color: alpha(currentColor, 0.07);
+  border-radius: 6px;
+}
+
 .room-history row.has-header {
   margin-top: 6px;
 }
diff --git a/src/session/content/room_history/item_row.rs b/src/session/content/room_history/item_row.rs
index 2711d10c5..ca7d95133 100644
--- a/src/session/content/room_history/item_row.rs
+++ b/src/session/content/room_history/item_row.rs
@@ -16,7 +16,7 @@ use crate::{
 };
 
 mod imp {
-    use std::cell::RefCell;
+    use std::{cell::RefCell, rc::Rc};
 
     use glib::{signal::SignalHandlerId, WeakRef};
     use once_cell::unsync::OnceCell;
@@ -114,6 +114,24 @@ mod imp {
                 let room_history = obj.room_history();
                 let popover = room_history.item_context_menu().to_owned();
 
+                if let Some(list_item) = obj.parent() {
+                    list_item.add_css_class("has-open-popup");
+
+                    let cell: Rc<RefCell<Option<glib::signal::SignalHandlerId>>> =
+                        Rc::new(RefCell::new(None));
+                    let signal_id = popover.connect_closed(
+                        clone!(@weak list_item, @strong cell => move |popover| {
+                            list_item.remove_css_class("has-open-popup");
+
+                            if let Some(signal_id) = cell.take() {
+                                popover.disconnect(signal_id);
+                            }
+                        }),
+                    );
+
+                    cell.replace(Some(signal_id));
+                }
+
                 if let Some(event) = event
                     .downcast_ref::<SupportedEvent>()
                     .filter(|event| event.content().is_some())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]