room-history: Show selection when context menu is open
Fixes: https://gitlab.gnome.org/GNOME/fractal/-/issues/938
This commit is contained in:
parent
5f0a4b48a7
commit
7ffbf9849f
2 changed files with 24 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue