room-history: Set room menu as primary menu when the sidebar is hidden
i.e. when the window is narrow.
This commit is contained in:
parent
227e9e9076
commit
4dbe94fcb5
|
@ -16,7 +16,7 @@ use crate::session::model::{
|
|||
};
|
||||
|
||||
mod imp {
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
||||
use glib::{object::WeakRef, signal::SignalHandlerId, subclass::InitializingObject};
|
||||
use once_cell::sync::Lazy;
|
||||
|
@ -27,6 +27,8 @@ mod imp {
|
|||
#[template(resource = "/org/gnome/Fractal/ui/session/view/content/mod.ui")]
|
||||
pub struct Content {
|
||||
pub session: WeakRef<Session>,
|
||||
/// Whether this is the only visible view, i.e. there is no sidebar.
|
||||
pub only_view: Cell<bool>,
|
||||
pub item_binding: RefCell<Option<glib::Binding>>,
|
||||
pub item: RefCell<Option<glib::Object>>,
|
||||
pub signal_handler: RefCell<Option<SignalHandlerId>>,
|
||||
|
@ -67,6 +69,7 @@ mod imp {
|
|||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
||||
vec![
|
||||
glib::ParamSpecObject::builder::<Session>("session").build(),
|
||||
glib::ParamSpecBoolean::builder("only-view").build(),
|
||||
glib::ParamSpecObject::builder::<glib::Object>("item")
|
||||
.explicit_notify()
|
||||
.build(),
|
||||
|
@ -81,6 +84,7 @@ mod imp {
|
|||
|
||||
match pspec.name() {
|
||||
"session" => obj.set_session(value.get().unwrap()),
|
||||
"only-view" => self.only_view.set(value.get().unwrap()),
|
||||
"item" => obj.set_item(value.get().unwrap()),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
|
@ -91,6 +95,7 @@ mod imp {
|
|||
|
||||
match pspec.name() {
|
||||
"session" => obj.session().to_value(),
|
||||
"only-view" => self.only_view.get().to_value(),
|
||||
"item" => obj.item().to_value(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="ContentRoomHistory" id="room_history"/>
|
||||
<object class="ContentRoomHistory" id="room_history">
|
||||
<property name="only-view" bind-source="Content" bind-property="only-view" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="ContentInvite" id="invite"/>
|
||||
|
|
|
@ -58,6 +58,8 @@ mod imp {
|
|||
#[template(resource = "/org/gnome/Fractal/ui/session/view/content/room_history/mod.ui")]
|
||||
pub struct RoomHistory {
|
||||
pub room: RefCell<Option<Room>>,
|
||||
/// Whether this is the only view visible, i.e. there is no sidebar.
|
||||
pub only_view: Cell<bool>,
|
||||
pub room_members: RefCell<Option<MemberList>>,
|
||||
pub room_handlers: RefCell<Vec<SignalHandlerId>>,
|
||||
pub timeline_handlers: RefCell<Vec<SignalHandlerId>>,
|
||||
|
@ -197,6 +199,7 @@ mod imp {
|
|||
glib::ParamSpecObject::builder::<Room>("room")
|
||||
.explicit_notify()
|
||||
.build(),
|
||||
glib::ParamSpecBoolean::builder("only-view").build(),
|
||||
glib::ParamSpecBoolean::builder("empty")
|
||||
.explicit_notify()
|
||||
.build(),
|
||||
|
@ -214,6 +217,7 @@ mod imp {
|
|||
|
||||
match pspec.name() {
|
||||
"room" => obj.set_room(value.get().unwrap()),
|
||||
"only-view" => self.only_view.set(value.get().unwrap()),
|
||||
"sticky" => obj.set_sticky(value.get().unwrap()),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
|
@ -224,6 +228,7 @@ mod imp {
|
|||
|
||||
match pspec.name() {
|
||||
"room" => obj.room().to_value(),
|
||||
"only-view" => self.only_view.get().to_value(),
|
||||
"empty" => obj.is_empty().to_value(),
|
||||
"sticky" => obj.sticky().to_value(),
|
||||
_ => unimplemented!(),
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
<object class="GtkMenuButton" id="room_menu">
|
||||
<property name="icon-name">view-more-symbolic</property>
|
||||
<property name="menu-model">room-menu-model</property>
|
||||
<property name="primary" bind-source="ContentRoomHistory" bind-property="only-view" bind-flags="sync-create"/>
|
||||
<property name="tooltip-text" translatable="yes">Room Menu</property>
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Room Menu</property>
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
<property name="content">
|
||||
<object class="Content" id="content">
|
||||
<property name="session" bind-source="SessionView" bind-property="session" bind-flags="sync-create"/>
|
||||
<binding name="only-view">
|
||||
<lookup type="Window" name="compact">
|
||||
<lookup name="root">SessionView</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
|
Loading…
Reference in New Issue