[fractal/fractal-next] components: use reference to set menu for ContextMenuBin
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] components: use reference to set menu for ContextMenuBin
- Date: Wed, 1 Dec 2021 17:26:04 +0000 (UTC)
commit c3a8eb595a87160a51adef5a58cd0b80d7ffddce
Author: Julian Sparber <julian sparber net>
Date: Wed Dec 1 16:04:34 2021 +0100
components: use reference to set menu for ContextMenuBin
src/components/context_menu_bin.rs | 11 ++++-------
src/session/content/room_history/item_row.rs | 2 +-
src/session/media_viewer.rs | 2 +-
3 files changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/src/components/context_menu_bin.rs b/src/components/context_menu_bin.rs
index 02a5f6fd..0c44e3bb 100644
--- a/src/components/context_menu_bin.rs
+++ b/src/components/context_menu_bin.rs
@@ -89,10 +89,7 @@ mod imp {
) {
match pspec.name() {
"context-menu" => {
- let context_menu = value
- .get::<Option<gio::MenuModel>>()
- .expect("type conformity checked by `Object::set_property`");
- obj.set_context_menu(context_menu);
+ obj.set_context_menu(value.get::<Option<gio::MenuModel>>().unwrap().as_ref())
}
_ => unimplemented!(),
}
@@ -170,16 +167,16 @@ impl ContextMenuBin {
pub trait ContextMenuBinExt: 'static {
/// Set the `MenuModel` used in the context menu.
- fn set_context_menu(&self, menu: Option<gio::MenuModel>);
+ fn set_context_menu(&self, menu: Option<&gio::MenuModel>);
/// Get the `MenuModel` used in the context menu.
fn context_menu(&self) -> Option<gio::MenuModel>;
}
impl<O: IsA<ContextMenuBin>> ContextMenuBinExt for O {
- fn set_context_menu(&self, menu: Option<gio::MenuModel>) {
+ fn set_context_menu(&self, menu: Option<&gio::MenuModel>) {
let priv_ = imp::ContextMenuBin::from_instance(self.upcast_ref());
- priv_.popover.set_menu_model(menu.as_ref());
+ priv_.popover.set_menu_model(menu);
self.notify("context-menu");
}
diff --git a/src/session/content/room_history/item_row.rs b/src/session/content/room_history/item_row.rs
index 5f48008f..9d12cbde 100644
--- a/src/session/content/room_history/item_row.rs
+++ b/src/session/content/room_history/item_row.rs
@@ -117,7 +117,7 @@ impl ItemRow {
match item.type_() {
ItemType::Event(event) => {
if self.context_menu().is_none() {
- self.set_context_menu(Some(Self::event_menu_model()));
+ self.set_context_menu(Some(&Self::event_menu_model()));
}
self.set_event_actions(Some(event));
diff --git a/src/session/media_viewer.rs b/src/session/media_viewer.rs
index 839585df..b5f8a212 100644
--- a/src/session/media_viewer.rs
+++ b/src/session/media_viewer.rs
@@ -111,7 +111,7 @@ mod imp {
let menu_model = Some(Self::Type::event_menu_model());
self.menu_full.set_menu_model(menu_model.as_ref());
- obj.set_context_menu(menu_model);
+ obj.set_context_menu(menu_model.as_ref());
// Bind `fullscreened` to the window property of the same name.
obj.connect_notify_local(Some("root"), |obj, _| {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]