[fractal/fractal-next] content: Show room name and topic in header
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] content: Show room name and topic in header
- Date: Wed, 19 May 2021 06:42:51 +0000 (UTC)
commit 499555ec6bb91fd4a53fd2f25b958aee80399911
Author: Raatty <me raatty club>
Date: Wed May 5 21:31:38 2021 +1200
content: Show room name and topic in header
data/resources/ui/content.ui | 14 ++++++++++++++
src/session/room/room.rs | 17 +++++++++++++++++
2 files changed, 31 insertions(+)
---
diff --git a/data/resources/ui/content.ui b/data/resources/ui/content.ui
index bbe493d3..25395e48 100644
--- a/data/resources/ui/content.ui
+++ b/data/resources/ui/content.ui
@@ -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>
diff --git a/src/session/room/room.rs b/src/session/room/room.rs
index 0b7e3d70..f1782205 100644
--- a/src/session/room/room.rs
+++ b/src/session/room/room.rs
@@ -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");
+ }
_ => {}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]