content: Show room name and topic in header

This commit is contained in:
Raatty 2021-05-05 21:31:38 +12:00 committed by Julian Sparber
parent f0f0c4cbb9
commit 499555ec6b
2 changed files with 31 additions and 0 deletions

View file

@ -16,6 +16,20 @@
<property name="action-name">content.go-back</property>
</object>
</child>
<child type="title">
<object class="AdwWindowTitle">
<binding name="title">
<lookup name="display-name">
<lookup name="room">Content</lookup>
</lookup>
</binding>
<binding name="subtitle">
<lookup name="topic">
<lookup name="room">Content</lookup>
</lookup>
</binding>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="room_menu">
<property name="icon-name">view-more-symbolic</property>

View file

@ -118,6 +118,13 @@ mod imp {
CategoryType::default() as i32,
glib::ParamFlags::READABLE,
),
glib::ParamSpec::new_string(
"topic",
"Topic",
"The topic of this room",
None,
glib::ParamFlags::READABLE,
),
]
});
@ -153,6 +160,7 @@ mod imp {
"timeline" => self.timeline.get().unwrap().to_value(),
"category" => obj.category().to_value(),
"highlight" => obj.highlight().to_value(),
"topic" => obj.topic().to_value(),
"notification-count" => {
let highlight = matrix_room.unread_notification_counts().highlight_count;
let notification = matrix_room.unread_notification_counts().notification_count;
@ -310,6 +318,12 @@ impl Room {
);
}
pub fn topic(&self) -> Option<String> {
self.matrix_room()
.topic()
.filter(|topic| !topic.is_empty() && topic.find(|c: char| !c.is_whitespace()).is_some())
}
/// Returns the room member `User` object
///
/// The returned `User` is specific to this room
@ -339,6 +353,9 @@ impl Room {
// FIXME: this doesn't take in account changes in the calculated name
self.load_display_name()
}
AnyRoomEvent::State(AnyStateEvent::RoomTopic(_)) => {
self.notify("topic");
}
_ => {}
}
}