Browse Source

room-history: Show selection when context menu is open

Fixes: https://gitlab.gnome.org/GNOME/fractal/-/issues/938
merge-requests/1327/merge
Julian Sparber 4 years ago
parent
commit
7ffbf9849f
  1. 5
      data/resources/style.css
  2. 20
      src/session/content/room_history/item_row.rs

5
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;
}

20
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())

Loading…
Cancel
Save