[fractal/fractal-next] Add Member object



commit b2ac1c6cf7b0c74fbfbfd33494b1a9a117659dd0
Author: Kai A. Hiller <V02460 gmail com>
Date:   Mon Aug 9 00:12:53 2021 +0200

    Add Member object

 src/meson.build            |  1 +
 src/session/room/member.rs | 38 ++++++++++++++++++++++++++++++++++++++
 src/session/room/mod.rs    |  2 ++
 3 files changed, 41 insertions(+)
---
diff --git a/src/meson.build b/src/meson.build
index b3e129b7..032fed6d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -56,6 +56,7 @@ sources = files(
   'session/room/event.rs',
   'session/room/highlight_flags.rs',
   'session/room/item.rs',
+  'session/room/member.rs',
   'session/room/mod.rs',
   'session/room/room.rs',
   'session/room/room_type.rs',
diff --git a/src/session/room/member.rs b/src/session/room/member.rs
new file mode 100644
index 00000000..99d6bb66
--- /dev/null
+++ b/src/session/room/member.rs
@@ -0,0 +1,38 @@
+use gtk::glib;
+use gtk::subclass::prelude::*;
+use matrix_sdk::ruma::events::room::member::MemberEventContent;
+use matrix_sdk::ruma::events::{StrippedStateEvent, SyncStateEvent};
+use matrix_sdk::ruma::identifiers::UserId;
+use matrix_sdk::RoomMember;
+
+use crate::prelude::*;
+use crate::session::{Room, User};
+
+mod imp {
+    use super::*;
+
+    #[derive(Debug, Default)]
+    pub struct Member {}
+
+    #[glib::object_subclass]
+    impl ObjectSubclass for Member {
+        const NAME: &'static str = "Member";
+        type Type = super::Member;
+        type ParentType = User;
+    }
+
+    impl ObjectImpl for Member {}
+}
+
+glib::wrapper! {
+    /// A User in the context of a given room.
+    pub struct Member(ObjectSubclass<imp::Member>) @extends User;
+}
+
+impl Member {
+    pub fn new(room: &Room, user_id: &UserId) -> Self {
+        let session = room.session();
+        glib::Object::new(&[("session", &session), ("user-id", &user_id.as_str())])
+            .expect("Failed to create Member")
+    }
+}
diff --git a/src/session/room/mod.rs b/src/session/room/mod.rs
index 146b1214..fa8d4f82 100644
--- a/src/session/room/mod.rs
+++ b/src/session/room/mod.rs
@@ -1,6 +1,7 @@
 mod event;
 mod highlight_flags;
 mod item;
+mod member;
 mod room;
 mod room_type;
 mod timeline;
@@ -9,6 +10,7 @@ pub use self::event::Event;
 pub use self::highlight_flags::HighlightFlags;
 pub use self::item::Item;
 pub use self::item::ItemType;
+pub use self::member::Member;
 pub use self::room::Room;
 pub use self::room_type::RoomType;
 pub use self::timeline::Timeline;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]