[fractal/fractal-next] app: Replace imp::from_instance with obj.imp()



commit c68e24d2e1081e3257e0110a96d6cc9c4a77b65e
Author: Kévin Commaille <zecakeh tedomum fr>
Date:   Mon Jan 24 16:49:41 2022 +0100

    app: Replace imp::from_instance with obj.imp()

 src/application.rs                                 |  9 +--
 src/components/auth_dialog.rs                      |  9 +--
 src/components/avatar.rs                           | 14 ++--
 src/components/badge.rs                            |  6 +-
 src/components/context_menu_bin.rs                 | 16 ++--
 src/components/in_app_notification.rs              | 16 ++--
 src/components/label_with_widgets.rs               | 25 +++---
 src/components/loading_listbox_row.rs              | 10 +--
 src/components/pill.rs                             | 10 +--
 src/components/reaction_chooser.rs                 |  7 +-
 src/components/room_title.rs                       | 10 +--
 src/components/spinner_button.rs                   |  9 +--
 src/components/video_player.rs                     |  9 +--
 src/contrib/qr_code.rs                             | 19 ++---
 src/contrib/qr_code_scanner/camera_paintable.rs    | 19 ++---
 src/contrib/qr_code_scanner/mod.rs                 | 19 ++---
 src/contrib/qr_code_scanner/qr_code_detector.rs    |  5 +-
 src/error.rs                                       |  6 +-
 src/login.rs                                       | 20 +++--
 .../account_settings/devices_page/device.rs        | 20 ++---
 .../account_settings/devices_page/device_item.rs   |  3 +-
 .../account_settings/devices_page/device_list.rs   | 35 ++++----
 .../account_settings/devices_page/device_row.rs    | 12 +--
 src/session/account_settings/devices_page/mod.rs   | 10 +--
 src/session/account_settings/mod.rs                |  7 +-
 src/session/avatar.rs                              | 26 +++---
 src/session/content/explore/mod.rs                 | 29 +++----
 src/session/content/explore/public_room.rs         | 27 +++----
 src/session/content/explore/public_room_list.rs    | 30 +++----
 src/session/content/explore/public_room_row.rs     | 16 ++--
 src/session/content/invite.rs                      | 19 ++---
 src/session/content/mod.rs                         | 16 ++--
 .../content/room_details/invite_subpage/invitee.rs | 17 ++--
 .../room_details/invite_subpage/invitee_list.rs    | 34 +++-----
 .../room_details/invite_subpage/invitee_row.rs     |  5 +-
 .../content/room_details/invite_subpage/mod.rs     | 27 +++----
 .../room_details/member_page/member_menu.rs        | 14 ++--
 .../content/room_details/member_page/member_row.rs |  5 +-
 .../content/room_details/member_page/mod.rs        | 38 ++++-----
 src/session/content/room_details/mod.rs            | 24 +++---
 src/session/content/room_history/divider_row.rs    |  6 +-
 src/session/content/room_history/item_row.rs       | 11 ++-
 .../content/room_history/message_row/file.rs       | 12 +--
 .../content/room_history/message_row/media.rs      | 27 +++----
 .../content/room_history/message_row/mod.rs        | 12 ++-
 .../content/room_history/message_row/reaction.rs   |  2 +-
 .../room_history/message_row/reaction_list.rs      |  4 +-
 .../content/room_history/message_row/reply.rs      |  9 +--
 .../content/room_history/message_row/text.rs       | 10 +--
 src/session/content/room_history/mod.rs            | 28 +++----
 .../content/room_history/state_row/creation.rs     |  2 +-
 .../content/room_history/state_row/tombstone.rs    |  3 +-
 .../content/room_history/verification_info_bar.rs  |  7 +-
 src/session/content/verification/emoji.rs          |  2 +-
 .../verification/identity_verification_widget.rs   | 45 +++++------
 .../content/verification/session_verification.rs   | 36 ++++-----
 src/session/event_source_dialog.rs                 |  4 +-
 src/session/media_viewer.rs                        | 30 +++----
 src/session/mod.rs                                 | 63 ++++++---------
 src/session/room/event.rs                          | 52 +++++-------
 src/session/room/item.rs                           | 31 +++-----
 src/session/room/member.rs                         |  6 +-
 src/session/room/member_list.rs                    | 11 +--
 src/session/room/mod.rs                            | 81 ++++++++-----------
 src/session/room/power_levels.rs                   |  9 +--
 src/session/room/reaction_group.rs                 | 13 +--
 src/session/room/reaction_list.rs                  | 15 ++--
 src/session/room/timeline.rs                       | 50 +++++-------
 src/session/room_creation/mod.rs                   | 15 ++--
 src/session/room_list.rs                           | 40 +++-------
 .../account_switcher/avatar_with_selection.rs      |  5 +-
 src/session/sidebar/account_switcher/item.rs       |  4 +-
 src/session/sidebar/account_switcher/mod.rs        |  2 +-
 src/session/sidebar/account_switcher/user_entry.rs |  7 +-
 src/session/sidebar/category.rs                    | 12 +--
 src/session/sidebar/category_row.rs                | 21 ++---
 src/session/sidebar/entry.rs                       |  3 +-
 src/session/sidebar/entry_row.rs                   |  7 +-
 src/session/sidebar/item_list.rs                   | 19 ++---
 src/session/sidebar/mod.rs                         | 32 +++-----
 src/session/sidebar/room_row.rs                    |  7 +-
 src/session/sidebar/row.rs                         |  5 +-
 src/session/sidebar/selection.rs                   | 17 ++--
 src/session/sidebar/verification_row.rs            |  7 +-
 src/session/user.rs                                | 27 +++----
 src/session/verification/identity_verification.rs  | 92 +++++++---------------
 src/session/verification/verification_list.rs      | 15 +---
 src/window.rs                                      | 13 ++-
 88 files changed, 591 insertions(+), 992 deletions(-)
---
diff --git a/src/application.rs b/src/application.rs
index b5ae4a65..782abd7a 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -85,16 +85,11 @@ impl Application {
     }
 
     fn get_main_window(&self) -> Window {
-        imp::Application::from_instance(self)
-            .window
-            .get()
-            .unwrap()
-            .upgrade()
-            .unwrap()
+        self.imp().window.get().unwrap().upgrade().unwrap()
     }
 
     pub fn settings(&self) -> Settings {
-        imp::Application::from_instance(self).settings.clone()
+        self.imp().settings.clone()
     }
 
     fn setup_gactions(&self) {
diff --git a/src/components/auth_dialog.rs b/src/components/auth_dialog.rs
index abb748b7..fd21c54e 100644
--- a/src/components/auth_dialog.rs
+++ b/src/components/auth_dialog.rs
@@ -209,8 +209,7 @@ impl AuthDialog {
     }
 
     pub fn session(&self) -> Session {
-        let priv_ = imp::AuthDialog::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     pub async fn authenticate<
@@ -221,7 +220,7 @@ impl AuthDialog {
         &self,
         callback: FN,
     ) -> Option<Result<Response, Error>> {
-        let priv_ = imp::AuthDialog::from_instance(self);
+        let priv_ = self.imp();
         let client = self.session().client();
         let mut auth_data = None;
 
@@ -315,7 +314,7 @@ impl AuthDialog {
     }
 
     fn show_auth_error(&self, auth_error: &Option<ErrorBody>) {
-        let priv_ = imp::AuthDialog::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(auth_error) = auth_error {
             priv_.error.set_label(&auth_error.message);
@@ -326,7 +325,7 @@ impl AuthDialog {
     }
 
     fn setup_fallback_page(&self, homeserver: &str, auth_type: &str, session: &str) {
-        let priv_ = imp::AuthDialog::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(handler) = priv_.open_browser_btn_handler.take() {
             priv_.open_browser_btn.disconnect(handler);
diff --git a/src/components/avatar.rs b/src/components/avatar.rs
index e2eaa8e6..90dce0d1 100644
--- a/src/components/avatar.rs
+++ b/src/components/avatar.rs
@@ -108,12 +108,11 @@ impl Avatar {
     }
 
     pub fn set_size(&self, size: i32) {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.avatar.set_size(size);
+        self.imp().avatar.set_size(size);
     }
 
     pub fn set_item(&self, item: Option<AvatarItem>) {
-        let priv_ = imp::Avatar::from_instance(self);
+        let priv_ = self.imp();
 
         if *priv_.item.borrow() == item {
             return;
@@ -129,18 +128,15 @@ impl Avatar {
     }
 
     pub fn size(&self) -> i32 {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.avatar.size()
+        self.imp().avatar.size()
     }
 
     pub fn item(&self) -> Option<AvatarItem> {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.item.borrow().clone()
+        self.imp().item.borrow().clone()
     }
 
     fn request_custom_avatar(&self) {
-        let priv_ = imp::Avatar::from_instance(self);
-        if let Some(item) = &*priv_.item.borrow() {
+        if let Some(item) = &*self.imp().item.borrow() {
             // FIXME: update on size changes
             item.set_needed_size(self.size());
         }
diff --git a/src/components/badge.rs b/src/components/badge.rs
index a6f50a0c..81aee0fc 100644
--- a/src/components/badge.rs
+++ b/src/components/badge.rs
@@ -86,14 +86,12 @@ impl Badge {
     }
 
     pub fn power_level(&self) -> PowerLevel {
-        let priv_ = imp::Badge::from_instance(self);
-        priv_.power_level.get()
+        self.imp().power_level.get()
     }
 
     pub fn set_power_level(&self, power_level: PowerLevel) {
-        let priv_ = imp::Badge::from_instance(self);
         self.update_badge(power_level);
-        priv_.power_level.set(power_level);
+        self.imp().power_level.set(power_level);
         self.notify("power-level");
     }
 
diff --git a/src/components/context_menu_bin.rs b/src/components/context_menu_bin.rs
index c6f0d43e..4ac6a921 100644
--- a/src/components/context_menu_bin.rs
+++ b/src/components/context_menu_bin.rs
@@ -58,8 +58,7 @@ mod imp {
             );
 
             klass.install_action("context-menu.close", None, move |widget, _, _| {
-                let priv_ = imp::ContextMenuBin::from_instance(widget);
-                priv_.popover.popdown();
+                widget.imp().popover.popdown();
             });
         }
 
@@ -150,8 +149,7 @@ impl ContextMenuBin {
     }
 
     fn open_menu_at(&self, x: i32, y: i32) {
-        let priv_ = imp::ContextMenuBin::from_instance(self);
-        let popover = &priv_.popover;
+        let popover = &self.imp().popover;
 
         debug!("Context menu was activated");
 
@@ -177,24 +175,20 @@ pub trait ContextMenuBinExt: 'static {
 
 impl<O: IsA<ContextMenuBin>> ContextMenuBinExt for O {
     fn set_context_menu(&self, menu: Option<&gio::MenuModel>) {
-        let priv_ = imp::ContextMenuBin::from_instance(self.upcast_ref());
-
         if self.context_menu().as_ref() == menu {
             return;
         }
 
-        priv_.popover.set_menu_model(menu);
+        self.upcast_ref().imp().popover.set_menu_model(menu);
         self.notify("context-menu");
     }
 
     fn context_menu(&self) -> Option<gio::MenuModel> {
-        let priv_ = imp::ContextMenuBin::from_instance(self.upcast_ref());
-        priv_.popover.menu_model()
+        self.upcast_ref().imp().popover.menu_model()
     }
 
     fn popover(&self) -> &gtk::PopoverMenu {
-        let priv_ = imp::ContextMenuBin::from_instance(self.upcast_ref());
-        &priv_.popover
+        &self.upcast_ref().imp().popover
     }
 }
 
diff --git a/src/components/in_app_notification.rs b/src/components/in_app_notification.rs
index 192b8009..31d78e12 100644
--- a/src/components/in_app_notification.rs
+++ b/src/components/in_app_notification.rs
@@ -82,8 +82,7 @@ mod imp {
             self.parent_constructed(obj);
             self.revealer
                 .connect_child_revealed_notify(clone!(@weak obj => move |revealer| {
-                    let priv_ = imp::InAppNotification::from_instance(&obj);
-                    revealer.set_visible(priv_.shows_error.get());
+                    revealer.set_visible(obj.imp().shows_error.get());
                 }));
         }
 
@@ -111,7 +110,7 @@ impl InAppNotification {
     }
 
     pub fn set_error_list(&self, error_list: Option<gio::ListStore>) {
-        let priv_ = imp::InAppNotification::from_instance(self);
+        let priv_ = self.imp();
         if self.error_list() == error_list {
             return;
         }
@@ -123,13 +122,12 @@ impl InAppNotification {
         if let Some(ref error_list) = error_list {
             let handler = error_list.connect_items_changed(
                 clone!(@weak self as obj => move |_, position, removed, added| {
-                        let priv_ = imp::InAppNotification::from_instance(&obj);
                         // If the first error is removed we need to display the next error
                         if position == 0 && removed > 0 {
                                 obj.next();
                         }
 
-                        if added > 0  && !priv_.shows_error.get() {
+                        if added > 0  && !obj.imp().shows_error.get() {
                                 obj.next();
                         }
 
@@ -144,13 +142,12 @@ impl InAppNotification {
     }
 
     pub fn error_list(&self) -> Option<gio::ListStore> {
-        let priv_ = imp::InAppNotification::from_instance(self);
-        priv_.error_list.borrow().to_owned()
+        self.imp().error_list.borrow().to_owned()
     }
 
     /// Show the next message in the `error-list`
     fn next(&self) {
-        let priv_ = imp::InAppNotification::from_instance(self);
+        let priv_ = self.imp();
 
         let shows_error = if let Some(widget) = priv_
             .error_list
@@ -178,8 +175,7 @@ impl InAppNotification {
     }
 
     fn dismiss(&self) {
-        let priv_ = imp::InAppNotification::from_instance(self);
-        if let Some(error_list) = &*priv_.error_list.borrow() {
+        if let Some(error_list) = &*self.imp().error_list.borrow() {
             error_list.remove(0);
         }
     }
diff --git a/src/components/label_with_widgets.rs b/src/components/label_with_widgets.rs
index afff1373..8c50f280 100644
--- a/src/components/label_with_widgets.rs
+++ b/src/components/label_with_widgets.rs
@@ -190,14 +190,13 @@ impl LabelWithWidgets {
     }
 
     pub fn append_child<P: IsA<gtk::Widget>>(&self, child: &P) {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
-        priv_.widgets.borrow_mut().push(child.clone().upcast());
+        self.imp().widgets.borrow_mut().push(child.clone().upcast());
         child.set_parent(self);
         self.invalidate_child_widgets();
     }
 
     pub fn set_widgets<P: IsA<gtk::Widget>>(&self, widgets: Vec<P>) {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.widgets.borrow_mut().clear();
         priv_
@@ -212,12 +211,11 @@ impl LabelWithWidgets {
     }
 
     pub fn widgets(&self) -> Vec<gtk::Widget> {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
-        priv_.widgets.borrow().to_owned()
+        self.imp().widgets.borrow().to_owned()
     }
 
     pub fn set_label(&self, label: Option<String>) {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.text.borrow().as_ref() == label.as_ref() {
             return;
@@ -236,12 +234,11 @@ impl LabelWithWidgets {
     }
 
     pub fn label(&self) -> Option<String> {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
-        priv_.text.borrow().to_owned()
+        self.imp().text.borrow().to_owned()
     }
 
     pub fn set_placeholder(&self, placeholder: Option<String>) {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.placeholder.borrow().as_ref() == placeholder.as_ref() {
             return;
@@ -259,18 +256,16 @@ impl LabelWithWidgets {
     }
 
     pub fn placeholder(&self) -> Option<String> {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
-        priv_.placeholder.borrow().to_owned()
+        self.imp().placeholder.borrow().to_owned()
     }
 
     fn invalidate_child_widgets(&self) {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
-        priv_.widgets_sizes.borrow_mut().clear();
+        self.imp().widgets_sizes.borrow_mut().clear();
         self.queue_resize();
     }
 
     fn allocate_shapes(&self) {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
+        let priv_ = self.imp();
         let mut widgets_sizes = priv_.widgets_sizes.borrow_mut();
 
         let mut child_size_changed = false;
@@ -321,7 +316,7 @@ impl LabelWithWidgets {
     }
 
     fn allocate_children(&self) {
-        let priv_ = imp::LabelWithWidgets::from_instance(self);
+        let priv_ = self.imp();
         let widgets = priv_.widgets.borrow();
         let widgets_sizes = priv_.widgets_sizes.borrow();
 
diff --git a/src/components/loading_listbox_row.rs b/src/components/loading_listbox_row.rs
index 053ca1a8..9c7d83c6 100644
--- a/src/components/loading_listbox_row.rs
+++ b/src/components/loading_listbox_row.rs
@@ -130,12 +130,11 @@ impl LoadingListBoxRow {
     }
 
     pub fn is_loading(&self) -> bool {
-        let priv_ = imp::LoadingListBoxRow::from_instance(self);
-        !priv_.is_error.get()
+        !self.imp().is_error.get()
     }
 
     pub fn set_loading(&self, loading: bool) {
-        let priv_ = imp::LoadingListBoxRow::from_instance(self);
+        let priv_ = self.imp();
 
         if self.is_loading() == loading {
             return;
@@ -148,8 +147,7 @@ impl LoadingListBoxRow {
     }
 
     pub fn error(&self) -> Option<glib::GString> {
-        let priv_ = imp::LoadingListBoxRow::from_instance(self);
-        let message = priv_.error_label.text();
+        let message = self.imp().error_label.text();
         if message.is_empty() {
             None
         } else {
@@ -158,7 +156,7 @@ impl LoadingListBoxRow {
     }
 
     pub fn set_error(&self, message: Option<&str>) {
-        let priv_ = imp::LoadingListBoxRow::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(message) = message {
             priv_.is_error.set(true);
diff --git a/src/components/pill.rs b/src/components/pill.rs
index 52f50d79..52cc999d 100644
--- a/src/components/pill.rs
+++ b/src/components/pill.rs
@@ -108,7 +108,7 @@ impl Pill {
     }
 
     pub fn set_user(&self, user: Option<User>) {
-        let priv_ = imp::Pill::from_instance(self);
+        let priv_ = self.imp();
 
         if *priv_.user.borrow() == user {
             return;
@@ -136,12 +136,11 @@ impl Pill {
     }
 
     pub fn user(&self) -> Option<User> {
-        let priv_ = imp::Pill::from_instance(self);
-        priv_.user.borrow().clone()
+        self.imp().user.borrow().clone()
     }
 
     pub fn set_room(&self, room: Option<Room>) {
-        let priv_ = imp::Pill::from_instance(self);
+        let priv_ = self.imp();
 
         if *priv_.room.borrow() == room {
             return;
@@ -169,8 +168,7 @@ impl Pill {
     }
 
     pub fn room(&self) -> Option<Room> {
-        let priv_ = imp::Pill::from_instance(self);
-        priv_.room.borrow().clone()
+        self.imp().room.borrow().clone()
     }
 }
 
diff --git a/src/components/reaction_chooser.rs b/src/components/reaction_chooser.rs
index 87e1aad1..8b4429fc 100644
--- a/src/components/reaction_chooser.rs
+++ b/src/components/reaction_chooser.rs
@@ -118,12 +118,11 @@ impl ReactionChooser {
     }
 
     pub fn reactions(&self) -> Option<ReactionList> {
-        let priv_ = imp::ReactionChooser::from_instance(self);
-        priv_.reactions.borrow().clone()
+        self.imp().reactions.borrow().clone()
     }
 
     pub fn set_reactions(&self, reactions: Option<ReactionList>) {
-        let priv_ = imp::ReactionChooser::from_instance(self);
+        let priv_ = self.imp();
         let prev_reactions = self.reactions();
 
         if prev_reactions == reactions {
@@ -151,7 +150,7 @@ impl ReactionChooser {
     }
 
     fn update_reactions(&self) {
-        let priv_ = imp::ReactionChooser::from_instance(self);
+        let priv_ = self.imp();
         let mut reaction_bindings = priv_.reaction_bindings.borrow_mut();
         let reactions = self.reactions();
 
diff --git a/src/components/room_title.rs b/src/components/room_title.rs
index 92209ed6..937cb2de 100644
--- a/src/components/room_title.rs
+++ b/src/components/room_title.rs
@@ -104,7 +104,7 @@ impl RoomTitle {
     }
 
     pub fn set_title(&self, title: Option<String>) {
-        let priv_ = imp::RoomTitle::from_instance(self);
+        let priv_ = self.imp();
         // Parse and escape markup in title
         let title = title.map(|s| markup(&s));
         // If there's an existing title, check that current title and new title aren't
@@ -120,12 +120,11 @@ impl RoomTitle {
     }
 
     pub fn title(&self) -> Option<String> {
-        let priv_ = imp::RoomTitle::from_instance(self);
-        priv_.title.borrow().clone()
+        self.imp().title.borrow().clone()
     }
 
     pub fn set_subtitle(&self, subtitle: Option<String>) {
-        let priv_ = imp::RoomTitle::from_instance(self);
+        let priv_ = self.imp();
         // Parse and escape markup in subtitle
         let subtitle = subtitle.map(|s| markup(&s));
         // If there's an existing subtitle, check that current subtitle and new subtitle
@@ -141,8 +140,7 @@ impl RoomTitle {
     }
 
     pub fn subtitle(&self) -> Option<String> {
-        let priv_ = imp::RoomTitle::from_instance(self);
-        priv_.subtitle.borrow().clone()
+        self.imp().subtitle.borrow().clone()
     }
 }
 
diff --git a/src/components/spinner_button.rs b/src/components/spinner_button.rs
index 9debb494..6dbc5242 100644
--- a/src/components/spinner_button.rs
+++ b/src/components/spinner_button.rs
@@ -91,7 +91,7 @@ impl SpinnerButton {
     }
 
     pub fn set_label(&self, label: &str) {
-        let priv_ = imp::SpinnerButton::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.label.label().as_str() == label {
             return;
@@ -103,12 +103,11 @@ impl SpinnerButton {
     }
 
     pub fn label(&self) -> glib::GString {
-        let priv_ = imp::SpinnerButton::from_instance(self);
-        priv_.label.label()
+        self.imp().label.label()
     }
 
     pub fn set_loading(&self, loading: bool) {
-        let priv_ = imp::SpinnerButton::from_instance(self);
+        let priv_ = self.imp();
 
         if self.loading() == loading {
             return;
@@ -126,7 +125,7 @@ impl SpinnerButton {
     }
 
     pub fn loading(&self) -> bool {
-        let priv_ = imp::SpinnerButton::from_instance(self);
+        let priv_ = self.imp();
         priv_.stack.visible_child().as_ref() == Some(priv_.spinner.upcast_ref())
     }
 }
diff --git a/src/components/video_player.rs b/src/components/video_player.rs
index 90663dd9..541cabe0 100644
--- a/src/components/video_player.rs
+++ b/src/components/video_player.rs
@@ -91,24 +91,21 @@ impl VideoPlayer {
     }
 
     pub fn compact(&self) -> bool {
-        let priv_ = imp::VideoPlayer::from_instance(self);
-        priv_.compact.get()
+        self.imp().compact.get()
     }
 
     pub fn set_compact(&self, compact: bool) {
-        let priv_ = imp::VideoPlayer::from_instance(self);
-
         if self.compact() == compact {
             return;
         }
 
-        priv_.compact.set(compact);
+        self.imp().compact.set(compact);
         self.notify("compact");
     }
 
     /// Set the media_file to display.
     pub fn set_media_file(&self, media_file: &gtk::MediaFile) {
-        let priv_ = imp::VideoPlayer::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(handler_id) = priv_.duration_handler.take() {
             if let Some(paintable) = priv_.video.paintable() {
diff --git a/src/contrib/qr_code.rs b/src/contrib/qr_code.rs
index cafec831..d51aaddc 100644
--- a/src/contrib/qr_code.rs
+++ b/src/contrib/qr_code.rs
@@ -188,37 +188,32 @@ pub trait QRCodeExt {
 
 impl<W: IsA<QRCode>> QRCodeExt for W {
     fn set_bytes(&self, bytes: &[u8]) {
-        let this = imp::QRCode::from_instance(self.as_ref());
-
         let data = QRCodeData::try_from(bytes).unwrap_or_else(|_| {
             glib::g_warning!(None, "Failed to load QRCode from bytes");
             Default::default()
         });
-        this.data.replace(data);
+        self.as_ref().imp().data.replace(data);
 
         self.as_ref().queue_draw();
         self.as_ref().queue_resize();
     }
 
     fn set_qrcode(&self, qrcode: qrcode::QrCode) {
-        let this = imp::QRCode::from_instance(self.as_ref());
-
-        this.data.replace(QRCodeData::from(qrcode));
+        self.as_ref().imp().data.replace(QRCodeData::from(qrcode));
 
         self.as_ref().queue_draw();
         self.as_ref().queue_resize();
     }
 
     fn block_size(&self) -> u32 {
-        let this = imp::QRCode::from_instance(self.as_ref());
-
-        this.block_size.get()
+        self.as_ref().imp().block_size.get()
     }
 
     fn set_block_size(&self, block_size: u32) {
-        let this = imp::QRCode::from_instance(self.as_ref());
-
-        this.block_size.set(std::cmp::max(block_size, 1));
+        self.as_ref()
+            .imp()
+            .block_size
+            .set(std::cmp::max(block_size, 1));
         self.notify("block-size");
         self.as_ref().queue_draw();
         self.as_ref().queue_resize();
diff --git a/src/contrib/qr_code_scanner/camera_paintable.rs b/src/contrib/qr_code_scanner/camera_paintable.rs
index 50aaa593..be2f9f39 100644
--- a/src/contrib/qr_code_scanner/camera_paintable.rs
+++ b/src/contrib/qr_code_scanner/camera_paintable.rs
@@ -193,15 +193,13 @@ mod camera_sink {
 
     impl CameraSink {
         pub fn new(sender: Sender<Action>) -> Self {
-            let sink = glib::Object::new(&[]).expect("Failed to create a CameraSink");
-            let priv_ = imp::CameraSink::from_instance(&sink);
-            priv_.sender.lock().unwrap().replace(sender);
+            let sink = glib::Object::new::<Self>(&[]).expect("Failed to create a CameraSink");
+            sink.imp().sender.lock().unwrap().replace(sender);
             sink
         }
 
         pub fn pending_frame(&self) -> Option<Frame> {
-            let self_ = imp::CameraSink::from_instance(self);
-            self_.pending_frame.lock().unwrap().take()
+            self.imp().pending_frame.lock().unwrap().take()
         }
     }
 }
@@ -347,7 +345,7 @@ impl CameraPaintable {
     }
 
     fn init_pipeline(&self, pipewire_src: gst::Element) {
-        let self_ = imp::CameraPaintable::from_instance(self);
+        let self_ = self.imp();
         let pipeline = gst::Pipeline::new(None);
         let detector = QrCodeDetector::new(self_.sender.clone()).upcast();
 
@@ -408,16 +406,13 @@ impl CameraPaintable {
     }
 
     pub fn close_pipeline(&self) {
-        let self_ = imp::CameraPaintable::from_instance(self);
-        if let Some(pipeline) = self_.pipeline.borrow_mut().take() {
+        if let Some(pipeline) = self.imp().pipeline.borrow_mut().take() {
             pipeline.set_state(gst::State::Null).unwrap();
         }
     }
 
     pub fn init_widgets(&self) {
-        let self_ = imp::CameraPaintable::from_instance(self);
-
-        let receiver = self_.receiver.borrow_mut().take().unwrap();
+        let receiver = self.imp().receiver.borrow_mut().take().unwrap();
         receiver.attach(
             None,
             glib::clone!(@weak self as paintable => @default-return glib::Continue(false), move |action| 
paintable.do_action(action)),
@@ -425,7 +420,7 @@ impl CameraPaintable {
     }
 
     fn do_action(&self, action: Action) -> glib::Continue {
-        let self_ = imp::CameraPaintable::from_instance(self);
+        let self_ = self.imp();
         match action {
             Action::FrameChanged => {
                 if let Some(frame) = self_
diff --git a/src/contrib/qr_code_scanner/mod.rs b/src/contrib/qr_code_scanner/mod.rs
index 63e7fdf6..72db9c41 100644
--- a/src/contrib/qr_code_scanner/mod.rs
+++ b/src/contrib/qr_code_scanner/mod.rs
@@ -117,25 +117,21 @@ impl QrCodeScanner {
     }
 
     async fn connection(&self) -> Result<&zbus::Connection, ashpd::Error> {
-        let priv_ = imp::QrCodeScanner::from_instance(self);
-
-        Ok(priv_
+        Ok(self
+            .imp()
             .connection
             .get_or_try_init(zbus::Connection::session)
             .await?)
     }
 
     pub fn stop(&self) {
-        let self_ = imp::QrCodeScanner::from_instance(self);
-
-        self_.paintable.close_pipeline();
+        self.imp().paintable.close_pipeline();
     }
 
     pub async fn start(&self) -> bool {
-        let priv_ = imp::QrCodeScanner::from_instance(self);
         if let Ok(stream_fd) = self.stream().await {
             if let Ok(node_id) = camera::pipewire_node_id(stream_fd).await {
-                priv_.paintable.set_pipewire_fd(stream_fd, node_id);
+                self.imp().paintable.set_pipewire_fd(stream_fd, node_id);
                 self.set_has_camera(true);
                 return true;
             }
@@ -165,18 +161,15 @@ impl QrCodeScanner {
     }
 
     pub fn has_camera(&self) -> bool {
-        let priv_ = imp::QrCodeScanner::from_instance(self);
-        priv_.has_camera.get()
+        self.imp().has_camera.get()
     }
 
     fn set_has_camera(&self, has_camera: bool) {
-        let priv_ = imp::QrCodeScanner::from_instance(self);
-
         if has_camera == self.has_camera() {
             return;
         }
 
-        priv_.has_camera.set(has_camera);
+        self.imp().has_camera.set(has_camera);
         self.notify("has-camera");
     }
 
diff --git a/src/contrib/qr_code_scanner/qr_code_detector.rs b/src/contrib/qr_code_scanner/qr_code_detector.rs
index 47ea6ab8..aec1857c 100644
--- a/src/contrib/qr_code_scanner/qr_code_detector.rs
+++ b/src/contrib/qr_code_scanner/qr_code_detector.rs
@@ -134,9 +134,8 @@ unsafe impl Sync for QrCodeDetector {}
 
 impl QrCodeDetector {
     pub fn new(sender: Sender<Action>) -> Self {
-        let sink = glib::Object::new(&[]).expect("Failed to create a QrCodeDetector");
-        let priv_ = imp::QrCodeDetector::from_instance(&sink);
-        priv_.sender.lock().unwrap().replace(sender);
+        let sink = glib::Object::new::<Self>(&[]).expect("Failed to create a QrCodeDetector");
+        sink.imp().sender.lock().unwrap().replace(sender);
         sink
     }
 }
diff --git a/src/error.rs b/src/error.rs
index f32ebc46..f7fd750c 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -37,14 +37,12 @@ impl Error {
     /// Set a function that builds the widget used to display this error in the
     /// UI
     pub fn set_widget_builder<F: Fn(&Self) -> Option<gtk::Widget> + 'static>(&self, f: F) {
-        let priv_ = imp::Error::from_instance(self);
-        priv_.widget_builder.replace(Some(Box::new(f)));
+        self.imp().widget_builder.replace(Some(Box::new(f)));
     }
 
     /// Produces a widget via the function set in `Self::set_widget_builder()`
     pub fn widget(&self) -> Option<gtk::Widget> {
-        let priv_ = imp::Error::from_instance(self);
-        let widget_builder = priv_.widget_builder.borrow();
+        let widget_builder = self.imp().widget_builder.borrow();
         let widget_builder = widget_builder.as_ref()?;
         widget_builder(self)
     }
diff --git a/src/login.rs b/src/login.rs
index be09aec2..60d65eb0 100644
--- a/src/login.rs
+++ b/src/login.rs
@@ -103,7 +103,7 @@ impl Login {
     }
 
     fn enable_next_action(&self) {
-        let priv_ = imp::Login::from_instance(self);
+        let priv_ = self.imp();
         let homeserver = priv_.homeserver_entry.text();
         let username_length = priv_.username_entry.text_length();
         let password_length = priv_.password_entry.text().len();
@@ -122,7 +122,7 @@ impl Login {
     }
 
     fn login(&self) {
-        let priv_ = imp::Login::from_instance(self);
+        let priv_ = self.imp();
         let homeserver = priv_.homeserver_entry.text().to_string();
         let username = priv_.username_entry.text().to_string();
         let password = priv_.password_entry.text().to_string();
@@ -141,7 +141,7 @@ impl Login {
     }
 
     pub fn clean(&self) {
-        let priv_ = imp::Login::from_instance(self);
+        let priv_ = self.imp();
         priv_.homeserver_entry.set_text("");
         priv_.username_entry.set_text("");
         priv_.password_entry.set_text("");
@@ -150,7 +150,7 @@ impl Login {
     }
 
     fn freeze(&self) {
-        let priv_ = imp::Login::from_instance(self);
+        let priv_ = self.imp();
 
         self.action_set_enabled("login.next", false);
         priv_
@@ -160,7 +160,7 @@ impl Login {
     }
 
     fn unfreeze(&self) {
-        let priv_ = imp::Login::from_instance(self);
+        let priv_ = self.imp();
 
         self.action_set_enabled("login.next", true);
         priv_.next_stack.set_visible_child(&priv_.next_label.get());
@@ -182,7 +182,7 @@ impl Login {
     }
 
     fn drop_session_reference(&self) {
-        let priv_ = imp::Login::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(session) = priv_.current_session.take() {
             if let Some(id) = priv_.prepared_source_id.take() {
@@ -198,17 +198,15 @@ impl Login {
     }
 
     pub fn default_widget(&self) -> gtk::Widget {
-        imp::Login::from_instance(self).next_button.get().upcast()
+        self.imp().next_button.get().upcast()
     }
 
     pub fn show_back_to_session_button(&self, show: bool) {
-        let priv_ = imp::Login::from_instance(self);
-
-        priv_.back_to_session_button.set_visible(show);
+        self.imp().back_to_session_button.set_visible(show);
     }
 
     fn set_handler_for_prepared_session(&self, session: &Session) {
-        let priv_ = imp::Login::from_instance(self);
+        let priv_ = self.imp();
         priv_
             .prepared_source_id
             .replace(Some(session.connect_prepared(
diff --git a/src/session/account_settings/devices_page/device.rs 
b/src/session/account_settings/devices_page/device.rs
index 34e21a8b..a5075ecc 100644
--- a/src/session/account_settings/devices_page/device.rs
+++ b/src/session/account_settings/devices_page/device.rs
@@ -131,12 +131,11 @@ impl Device {
     }
 
     pub fn session(&self) -> Session {
-        let priv_ = imp::Device::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     fn set_matrix_device(&self, device: MatrixDevice, crypto_device: Option<CryptoDevice>) {
-        let priv_ = imp::Device::from_instance(self);
+        let priv_ = self.imp();
         priv_.device.set(device).unwrap();
         if let Some(crypto_device) = crypto_device {
             priv_.crypto_device.set(crypto_device).unwrap();
@@ -144,13 +143,11 @@ impl Device {
     }
 
     pub fn device_id(&self) -> &DeviceId {
-        let priv_ = imp::Device::from_instance(self);
-        &priv_.device.get().unwrap().device_id
+        &self.imp().device.get().unwrap().device_id
     }
 
     pub fn display_name(&self) -> &str {
-        let priv_ = imp::Device::from_instance(self);
-        if let Some(ref display_name) = priv_.device.get().unwrap().display_name {
+        if let Some(ref display_name) = self.imp().device.get().unwrap().display_name {
             display_name
         } else {
             self.device_id().as_str()
@@ -158,15 +155,13 @@ impl Device {
     }
 
     pub fn last_seen_ip(&self) -> Option<&str> {
-        let priv_ = imp::Device::from_instance(self);
         // TODO: Would be nice to also show the location
         // See: https://gitlab.gnome.org/GNOME/fractal/-/issues/700
-        priv_.device.get().unwrap().last_seen_ip.as_deref()
+        self.imp().device.get().unwrap().last_seen_ip.as_deref()
     }
 
     pub fn last_seen_ts(&self) -> Option<glib::DateTime> {
-        let priv_ = imp::Device::from_instance(self);
-        priv_
+        self.imp()
             .device
             .get()
             .unwrap()
@@ -214,8 +209,7 @@ impl Device {
     }
 
     pub fn is_verified(&self) -> bool {
-        let priv_ = imp::Device::from_instance(self);
-        priv_
+        self.imp()
             .crypto_device
             .get()
             .map_or(false, |device| device.verified())
diff --git a/src/session/account_settings/devices_page/device_item.rs 
b/src/session/account_settings/devices_page/device_item.rs
index e63645c9..3c50d26a 100644
--- a/src/session/account_settings/devices_page/device_item.rs
+++ b/src/session/account_settings/devices_page/device_item.rs
@@ -92,7 +92,6 @@ impl Item {
     }
 
     pub fn type_(&self) -> &ItemType {
-        let priv_ = imp::Item::from_instance(self);
-        priv_.type_.get().unwrap()
+        self.imp().type_.get().unwrap()
     }
 }
diff --git a/src/session/account_settings/devices_page/device_list.rs 
b/src/session/account_settings/devices_page/device_list.rs
index 7c650bcb..644d60dc 100644
--- a/src/session/account_settings/devices_page/device_list.rs
+++ b/src/session/account_settings/devices_page/device_list.rs
@@ -116,12 +116,11 @@ impl DeviceList {
     }
 
     pub fn session(&self) -> Session {
-        let priv_ = imp::DeviceList::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     fn set_loading(&self, loading: bool) {
-        let priv_ = imp::DeviceList::from_instance(self);
+        let priv_ = self.imp();
 
         if loading == priv_.loading.get() {
             return;
@@ -134,35 +133,33 @@ impl DeviceList {
     }
 
     fn loading(&self) -> bool {
-        let priv_ = imp::DeviceList::from_instance(self);
-        priv_.loading.get()
+        self.imp().loading.get()
     }
 
     pub fn current_device(&self) -> DeviceItem {
-        let priv_ = imp::DeviceList::from_instance(self);
-
-        priv_.current_device.borrow().clone().unwrap_or_else(|| {
-            if self.loading() {
-                DeviceItem::for_loading_spinner()
-            } else {
-                DeviceItem::for_error(gettext("Failed to load connected device."))
-            }
-        })
+        self.imp()
+            .current_device
+            .borrow()
+            .clone()
+            .unwrap_or_else(|| {
+                if self.loading() {
+                    DeviceItem::for_loading_spinner()
+                } else {
+                    DeviceItem::for_error(gettext("Failed to load connected device."))
+                }
+            })
     }
 
     fn set_current_device(&self, device: Option<DeviceItem>) {
-        let priv_ = imp::DeviceList::from_instance(self);
-
-        priv_.current_device.replace(device);
+        self.imp().current_device.replace(device);
 
         self.notify("current-device");
     }
 
     fn update_list(&self, devices: Vec<DeviceItem>) {
-        let priv_ = imp::DeviceList::from_instance(self);
         let added = devices.len();
 
-        let prev_devices = priv_.list.replace(devices);
+        let prev_devices = self.imp().list.replace(devices);
 
         self.items_changed(0, prev_devices.len() as u32, added as u32);
     }
diff --git a/src/session/account_settings/devices_page/device_row.rs 
b/src/session/account_settings/devices_page/device_row.rs
index 05f2d558..3525b58e 100644
--- a/src/session/account_settings/devices_page/device_row.rs
+++ b/src/session/account_settings/devices_page/device_row.rs
@@ -111,12 +111,11 @@ impl DeviceRow {
     }
 
     pub fn device(&self) -> Option<Device> {
-        let priv_ = imp::DeviceRow::from_instance(self);
-        priv_.device.borrow().clone()
+        self.imp().device.borrow().clone()
     }
 
     pub fn set_device(&self, device: Option<Device>) {
-        let priv_ = imp::DeviceRow::from_instance(self);
+        let priv_ = self.imp();
 
         if self.device() == device {
             return;
@@ -151,16 +150,13 @@ impl DeviceRow {
     }
 
     fn delete(&self) {
-        let priv_ = imp::DeviceRow::from_instance(self);
-
-        priv_.delete_button.set_loading(true);
+        self.imp().delete_button.set_loading(true);
 
         if let Some(device) = self.device() {
             spawn!(clone!(@weak self as obj => async move {
                 let window: Option<gtk::Window> = obj.root().and_then(|root| root.downcast().ok());
                 let success = device.delete(window.as_ref()).await;
-                let priv_ = imp::DeviceRow::from_instance(&obj);
-                priv_.delete_button.set_loading(false);
+                obj.imp().delete_button.set_loading(false);
 
                 if success {
                     obj.hide();
diff --git a/src/session/account_settings/devices_page/mod.rs 
b/src/session/account_settings/devices_page/mod.rs
index 5fe1358e..b9b520d7 100644
--- a/src/session/account_settings/devices_page/mod.rs
+++ b/src/session/account_settings/devices_page/mod.rs
@@ -102,12 +102,11 @@ impl DevicesPage {
     }
 
     pub fn user(&self) -> Option<User> {
-        let priv_ = imp::DevicesPage::from_instance(self);
-        priv_.user.borrow().clone()
+        self.imp().user.borrow().clone()
     }
 
     fn set_user(&self, user: Option<User>) {
-        let priv_ = imp::DevicesPage::from_instance(self);
+        let priv_ = self.imp();
 
         if self.user() == user {
             return;
@@ -166,12 +165,11 @@ impl DevicesPage {
     }
 
     fn set_other_sessions_visibility(&self, visible: bool) {
-        let priv_ = imp::DevicesPage::from_instance(self);
-        priv_.other_sessions_group.set_visible(visible);
+        self.imp().other_sessions_group.set_visible(visible);
     }
 
     fn set_current_device(&self, device_list: &DeviceList) {
-        let priv_ = imp::DevicesPage::from_instance(self);
+        let priv_ = self.imp();
         if let Some(child) = priv_.current_session.first_child() {
             priv_.current_session.remove(&child);
         }
diff --git a/src/session/account_settings/mod.rs b/src/session/account_settings/mod.rs
index 1ca05c7c..08b90dd0 100644
--- a/src/session/account_settings/mod.rs
+++ b/src/session/account_settings/mod.rs
@@ -91,18 +91,15 @@ impl AccountSettings {
     }
 
     pub fn user(&self) -> Option<User> {
-        let priv_ = imp::AccountSettings::from_instance(self);
-        priv_.user.borrow().clone()
+        self.imp().user.borrow().clone()
     }
 
     fn set_user(&self, user: Option<User>) {
-        let priv_ = imp::AccountSettings::from_instance(self);
-
         if self.user() == user {
             return;
         }
 
-        priv_.user.replace(user);
+        self.imp().user.replace(user);
         self.notify("user");
     }
 }
diff --git a/src/session/avatar.rs b/src/session/avatar.rs
index 2c4bc426..862214fa 100644
--- a/src/session/avatar.rs
+++ b/src/session/avatar.rs
@@ -140,22 +140,18 @@ impl Avatar {
     }
 
     fn session(&self) -> Session {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     pub fn image(&self) -> Option<gdk::Paintable> {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.image.borrow().clone()
+        self.imp().image.borrow().clone()
     }
 
     fn set_image_data(&self, data: Option<Vec<u8>>) {
-        let priv_ = imp::Avatar::from_instance(self);
-
         let image = data
             .and_then(|data| gdk::Texture::from_bytes(&glib::Bytes::from(&data)).ok())
             .map(|texture| texture.upcast());
-        priv_.image.replace(image);
+        self.imp().image.replace(image);
         self.notify("image");
     }
 
@@ -193,25 +189,23 @@ impl Avatar {
     }
 
     pub fn set_display_name(&self, display_name: Option<String>) {
-        let priv_ = imp::Avatar::from_instance(self);
         if self.display_name() == display_name {
             return;
         }
 
-        priv_.display_name.replace(display_name);
+        self.imp().display_name.replace(display_name);
 
         self.notify("display-name");
     }
 
     pub fn display_name(&self) -> Option<String> {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.display_name.borrow().clone()
+        self.imp().display_name.borrow().clone()
     }
 
     /// Set the needed size.
     /// Only the biggest size will be stored
     pub fn set_needed_size(&self, size: i32) {
-        let priv_ = imp::Avatar::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.needed_size.get() < size {
             priv_.needed_size.set(size);
@@ -226,12 +220,11 @@ impl Avatar {
 
     /// Get the biggest needed size
     pub fn needed_size(&self) -> i32 {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.needed_size.get()
+        self.imp().needed_size.get()
     }
 
     pub fn set_url(&self, url: Option<Box<MxcUri>>) {
-        let priv_ = imp::Avatar::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.url.borrow().as_ref() == url.as_ref() {
             return;
@@ -250,8 +243,7 @@ impl Avatar {
     }
 
     pub fn url(&self) -> Option<Box<MxcUri>> {
-        let priv_ = imp::Avatar::from_instance(self);
-        priv_.url.borrow().to_owned()
+        self.imp().url.borrow().to_owned()
     }
 }
 
diff --git a/src/session/content/explore/mod.rs b/src/session/content/explore/mod.rs
index 3d198c68..eba2fdbc 100644
--- a/src/session/content/explore/mod.rs
+++ b/src/session/content/explore/mod.rs
@@ -113,8 +113,7 @@ mod imp {
 
             adj.connect_value_changed(clone!(@weak obj => move |adj| {
                 if adj.upper() - adj.value() < adj.page_size() * 2.0 {
-                    let priv_ = imp::Explore::from_instance(&obj);
-                    if let Some(public_room_list) = &*priv_.public_room_list.borrow() {
+                    if let Some(public_room_list) = &*obj.imp().public_room_list.borrow() {
                         public_room_list.load_public_rooms(false);
                     }
                 }
@@ -122,7 +121,7 @@ mod imp {
 
             self.search_entry
                 .connect_search_changed(clone!(@weak obj => move |_| {
-                    let priv_ = imp::Explore::from_instance(&obj);
+                    let priv_ = obj.imp();
                     if let Some(public_room_list) = &*priv_.public_room_list.borrow() {
                         let text = priv_.search_entry.text().as_str().to_string();
                         let network = priv_.network_menu.active_id().map(|id| id.as_str().to_owned());
@@ -147,8 +146,7 @@ impl Explore {
     }
 
     pub fn session(&self) -> Option<Session> {
-        let priv_ = imp::Explore::from_instance(self);
-        priv_
+        self.imp()
             .session
             .borrow()
             .as_ref()
@@ -156,15 +154,14 @@ impl Explore {
     }
 
     pub fn init(&self) {
-        let priv_ = imp::Explore::from_instance(self);
         self.load_protocols();
-        if let Some(public_room_list) = &*priv_.public_room_list.borrow() {
+        if let Some(public_room_list) = &*self.imp().public_room_list.borrow() {
             public_room_list.load_public_rooms(true);
         }
     }
 
     pub fn set_session(&self, session: Option<Session>) {
-        let priv_ = imp::Explore::from_instance(self);
+        let priv_ = self.imp();
 
         if session == self.session() {
             return;
@@ -200,7 +197,7 @@ impl Explore {
     }
 
     fn set_visible_child(&self) {
-        let priv_ = imp::Explore::from_instance(self);
+        let priv_ = self.imp();
         if let Some(public_room_list) = &*priv_.public_room_list.borrow() {
             if public_room_list.loading() {
                 priv_.stack.set_visible_child(&*priv_.spinner);
@@ -213,27 +210,25 @@ impl Explore {
     }
 
     fn set_protocols(&self, protocols: get_protocols::Response) {
-        let priv_ = imp::Explore::from_instance(self);
-
         for protocol in protocols
             .protocols
             .into_iter()
             .flat_map(|(_, protocol)| protocol.instances)
         {
-            priv_
+            self.imp()
                 .network_menu
                 .append(Some(&protocol.instance_id), &protocol.desc);
         }
     }
 
     fn load_protocols(&self) {
-        let priv_ = imp::Explore::from_instance(self);
+        let network_menu = &self.imp().network_menu;
         let client = self.session().unwrap().client();
 
-        priv_.network_menu.remove_all();
-        priv_.network_menu.append(Some("matrix"), "Matrix");
-        priv_.network_menu.append(Some("all"), "All rooms");
-        priv_.network_menu.set_active(Some(0));
+        network_menu.remove_all();
+        network_menu.append(Some("matrix"), "Matrix");
+        network_menu.append(Some("all"), "All rooms");
+        network_menu.set_active(Some(0));
 
         let handle =
             spawn_tokio!(async move { client.send(get_protocols::Request::new(), None).await });
diff --git a/src/session/content/explore/public_room.rs b/src/session/content/explore/public_room.rs
index 3d3c998d..4c9dfb1b 100644
--- a/src/session/content/explore/public_room.rs
+++ b/src/session/content/explore/public_room.rs
@@ -130,45 +130,38 @@ impl PublicRoom {
     }
 
     pub fn room_list(&self) -> &RoomList {
-        let priv_ = imp::PublicRoom::from_instance(self);
-        priv_.room_list.get().unwrap()
+        self.imp().room_list.get().unwrap()
     }
 
     pub fn avatar(&self) -> &Avatar {
-        let priv_ = imp::PublicRoom::from_instance(self);
-        priv_.avatar.get().unwrap()
+        self.imp().avatar.get().unwrap()
     }
 
     /// The room if the user is already a member of this room.
     pub fn room(&self) -> Option<&Room> {
-        let priv_ = imp::PublicRoom::from_instance(self);
-        priv_.room.get()
+        self.imp().room.get()
     }
 
     fn set_room(&self, room: Room) {
-        let priv_ = imp::PublicRoom::from_instance(self);
-        priv_.room.set(room).unwrap();
+        self.imp().room.set(room).unwrap();
         self.notify("room");
     }
 
     fn set_pending(&self, is_pending: bool) {
-        let priv_ = imp::PublicRoom::from_instance(self);
-
         if self.is_pending() == is_pending {
             return;
         }
 
-        priv_.is_pending.set(is_pending);
+        self.imp().is_pending.set(is_pending);
         self.notify("pending");
     }
 
     pub fn is_pending(&self) -> bool {
-        let priv_ = imp::PublicRoom::from_instance(self);
-        priv_.is_pending.get()
+        self.imp().is_pending.get()
     }
 
     pub fn set_matrix_public_room(&self, room: PublicRoomsChunk) {
-        let priv_ = imp::PublicRoom::from_instance(self);
+        let priv_ = self.imp();
 
         let display_name = room.name.clone().map(Into::into);
         self.avatar().set_display_name(display_name);
@@ -181,8 +174,7 @@ impl PublicRoom {
             let handler_id = self.room_list().connect_items_changed(
                 clone!(@weak self as obj => move |room_list, _, _, _| {
                     if let Some(room) = room_list.get(&room_id) {
-                        let priv_ = imp::PublicRoom::from_instance(&obj);
-                        if let Some(handler_id) = priv_.room_handler.take() {
+                        if let Some(handler_id) = obj.imp().room_handler.take() {
                             obj.set_room(room);
                             room_list.disconnect(handler_id);
                         }
@@ -199,8 +191,7 @@ impl PublicRoom {
     }
 
     pub fn matrix_public_room(&self) -> Option<&PublicRoomsChunk> {
-        let priv_ = imp::PublicRoom::from_instance(self);
-        priv_.matrix_public_room.get()
+        self.imp().matrix_public_room.get()
     }
 
     pub fn join_or_view(&self) {
diff --git a/src/session/content/explore/public_room_list.rs b/src/session/content/explore/public_room_list.rs
index 7e179ae7..5a487f8e 100644
--- a/src/session/content/explore/public_room_list.rs
+++ b/src/session/content/explore/public_room_list.rs
@@ -136,8 +136,7 @@ impl PublicRoomList {
     }
 
     pub fn session(&self) -> Option<Session> {
-        let priv_ = imp::PublicRoomList::from_instance(self);
-        priv_
+        self.imp()
             .session
             .borrow()
             .as_ref()
@@ -145,41 +144,34 @@ impl PublicRoomList {
     }
 
     pub fn set_session(&self, session: Option<Session>) {
-        let priv_ = imp::PublicRoomList::from_instance(self);
-
         if session == self.session() {
             return;
         }
 
-        priv_
+        self.imp()
             .session
             .replace(session.map(|session| session.downgrade()));
         self.notify("session");
     }
 
     pub fn loading(&self) -> bool {
-        let priv_ = imp::PublicRoomList::from_instance(self);
-        self.request_sent() && priv_.list.borrow().is_empty()
+        self.request_sent() && self.imp().list.borrow().is_empty()
     }
 
     pub fn empty(&self) -> bool {
-        let priv_ = imp::PublicRoomList::from_instance(self);
-        !self.request_sent() && priv_.list.borrow().is_empty()
+        !self.request_sent() && self.imp().list.borrow().is_empty()
     }
 
     pub fn complete(&self) -> bool {
-        let priv_ = imp::PublicRoomList::from_instance(self);
-        priv_.next_batch.borrow().is_none()
+        self.imp().next_batch.borrow().is_none()
     }
 
     fn request_sent(&self) -> bool {
-        let priv_ = imp::PublicRoomList::from_instance(self);
-        priv_.request_sent.get()
+        self.imp().request_sent.get()
     }
 
     fn set_request_sent(&self, request_sent: bool) {
-        let priv_ = imp::PublicRoomList::from_instance(self);
-        priv_.request_sent.set(request_sent);
+        self.imp().request_sent.set(request_sent);
 
         self.notify("loading");
         self.notify("empty");
@@ -192,7 +184,7 @@ impl PublicRoomList {
         server: Option<String>,
         network: Option<String>,
     ) {
-        let priv_ = imp::PublicRoomList::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.search_term.borrow().as_ref() == search_term.as_ref()
             && priv_.server.borrow().as_ref() == server.as_ref()
@@ -208,7 +200,7 @@ impl PublicRoomList {
     }
 
     fn handle_public_rooms_response(&self, response: PublicRoomsResponse) {
-        let priv_ = imp::PublicRoomList::from_instance(self);
+        let priv_ = self.imp();
         let session = self.session().unwrap();
         let room_list = session.room_list();
 
@@ -260,14 +252,14 @@ impl PublicRoomList {
         server: Option<String>,
         network: Option<String>,
     ) -> bool {
-        let priv_ = imp::PublicRoomList::from_instance(self);
+        let priv_ = self.imp();
         priv_.search_term.borrow().as_ref() == search_term.as_ref()
             && priv_.server.borrow().as_ref() == server.as_ref()
             && priv_.network.borrow().as_ref() == network.as_ref()
     }
 
     pub fn load_public_rooms(&self, clear: bool) {
-        let priv_ = imp::PublicRoomList::from_instance(self);
+        let priv_ = self.imp();
 
         if self.request_sent() && !clear {
             return;
diff --git a/src/session/content/explore/public_room_row.rs b/src/session/content/explore/public_room_row.rs
index 1af5eede..fdd222c5 100644
--- a/src/session/content/explore/public_room_row.rs
+++ b/src/session/content/explore/public_room_row.rs
@@ -89,8 +89,7 @@ mod imp {
         fn constructed(&self, obj: &Self::Type) {
             self.parent_constructed(obj);
             self.button.connect_clicked(clone!(@weak obj => move |_| {
-                let priv_ = imp::PublicRoomRow::from_instance(&obj);
-                if let Some(public_room) = &*priv_.public_room.borrow() {
+                if let Some(public_room) = &*obj.imp().public_room.borrow() {
                     public_room.join_or_view();
                 };
             }));
@@ -123,12 +122,11 @@ impl PublicRoomRow {
     }
 
     pub fn public_room(&self) -> Option<PublicRoom> {
-        let priv_ = imp::PublicRoomRow::from_instance(self);
-        priv_.public_room.borrow().clone()
+        self.imp().public_room.borrow().clone()
     }
 
     pub fn set_public_room(&self, public_room: Option<PublicRoom>) {
-        let priv_ = imp::PublicRoomRow::from_instance(self);
+        let priv_ = self.imp();
         let old_public_room = self.public_room();
 
         if old_public_room == public_room {
@@ -222,14 +220,14 @@ impl PublicRoomRow {
     }
 
     fn update_button(&self, public_room: &PublicRoom) {
-        let priv_ = imp::PublicRoomRow::from_instance(self);
+        let button = &self.imp().button;
         if public_room.room().is_some() {
-            priv_.button.set_label(&gettext("View"));
+            button.set_label(&gettext("View"));
         } else {
-            priv_.button.set_label(&gettext("Join"));
+            button.set_label(&gettext("Join"));
         }
 
-        priv_.button.set_loading(public_room.is_pending());
+        button.set_loading(public_room.is_pending());
     }
 }
 
diff --git a/src/session/content/invite.rs b/src/session/content/invite.rs
index f66e9f29..5cc3d6ce 100644
--- a/src/session/content/invite.rs
+++ b/src/session/content/invite.rs
@@ -144,7 +144,7 @@ impl Invite {
     }
 
     pub fn set_room(&self, room: Option<Room>) {
-        let priv_ = imp::Invite::from_instance(self);
+        let priv_ = self.imp();
 
         if self.room() == room {
             return;
@@ -176,7 +176,7 @@ impl Invite {
                 Some("category"),
                 clone!(@weak self as obj => move |room, _| {
                         if room.category() != RoomType::Invited {
-                                let priv_ = imp::Invite::from_instance(&obj);
+                                let priv_ = obj.imp();
                                 priv_.reject_requests.borrow_mut().remove(room);
                                 priv_.accept_requests.borrow_mut().remove(room);
                                 obj.reset();
@@ -195,12 +195,11 @@ impl Invite {
     }
 
     pub fn room(&self) -> Option<Room> {
-        let priv_ = imp::Invite::from_instance(self);
-        priv_.room.borrow().clone()
+        self.imp().room.borrow().clone()
     }
 
     fn reset(&self) {
-        let priv_ = imp::Invite::from_instance(self);
+        let priv_ = self.imp();
         priv_.accept_button.set_loading(false);
         priv_.reject_button.set_loading(false);
         self.action_set_enabled("invite.accept", true);
@@ -208,7 +207,7 @@ impl Invite {
     }
 
     fn accept(&self) -> Option<()> {
-        let priv_ = imp::Invite::from_instance(self);
+        let priv_ = self.imp();
         let room = self.room()?;
 
         self.action_set_enabled("invite.accept", false);
@@ -218,10 +217,9 @@ impl Invite {
 
         spawn!(
             clone!(@weak self as obj, @strong room => move || async move {
-                    let priv_ = imp::Invite::from_instance(&obj);
                     let result = room.accept_invite().await;
                     if result.is_err() {
-                        priv_.accept_requests.borrow_mut().remove(&room);
+                        obj.imp().accept_requests.borrow_mut().remove(&room);
                         obj.reset();
                     }
             })()
@@ -231,7 +229,7 @@ impl Invite {
     }
 
     fn reject(&self) -> Option<()> {
-        let priv_ = imp::Invite::from_instance(self);
+        let priv_ = self.imp();
         let room = self.room()?;
 
         self.action_set_enabled("invite.accept", false);
@@ -241,10 +239,9 @@ impl Invite {
 
         spawn!(
             clone!(@weak self as obj, @strong room => move || async move {
-                    let priv_ = imp::Invite::from_instance(&obj);
                     let result = room.reject_invite().await;
                     if result.is_err() {
-                        priv_.reject_requests.borrow_mut().remove(&room);
+                        obj.imp().reject_requests.borrow_mut().remove(&room);
                         obj.reset();
                     }
             })()
diff --git a/src/session/content/mod.rs b/src/session/content/mod.rs
index 8038042e..03864802 100644
--- a/src/session/content/mod.rs
+++ b/src/session/content/mod.rs
@@ -147,7 +147,7 @@ mod imp {
             self.parent_constructed(obj);
             self.stack
                 .connect_visible_child_notify(clone!(@weak obj => move |stack| {
-                    let priv_ = imp::Content::from_instance(&obj);
+                    let priv_ = obj.imp();
                     if stack.visible_child().as_ref() != 
Some(priv_.verification_page.upcast_ref::<gtk::Widget>()) {
                         priv_.identity_verification_widget.set_request(None);
                     }
@@ -170,8 +170,7 @@ impl Content {
     }
 
     pub fn session(&self) -> Option<Session> {
-        let priv_ = imp::Content::from_instance(self);
-        priv_
+        self.imp()
             .session
             .borrow()
             .as_ref()
@@ -179,20 +178,18 @@ impl Content {
     }
 
     pub fn set_session(&self, session: Option<Session>) {
-        let priv_ = imp::Content::from_instance(self);
-
         if session == self.session() {
             return;
         }
 
-        priv_
+        self.imp()
             .session
             .replace(session.map(|session| session.downgrade()));
         self.notify("session");
     }
 
     pub fn set_item(&self, item: Option<glib::Object>) {
-        let priv_ = imp::Content::from_instance(self);
+        let priv_ = self.imp();
 
         if self.item() == item {
             return;
@@ -236,12 +233,11 @@ impl Content {
     }
 
     pub fn item(&self) -> Option<glib::Object> {
-        let priv_ = imp::Content::from_instance(self);
-        priv_.item.borrow().clone()
+        self.imp().item.borrow().clone()
     }
 
     fn set_visible_child(&self) {
-        let priv_ = imp::Content::from_instance(self);
+        let priv_ = self.imp();
 
         match self.item() {
             None => {
diff --git a/src/session/content/room_details/invite_subpage/invitee.rs 
b/src/session/content/room_details/invite_subpage/invitee.rs
index 56acd849..cce5d7ac 100644
--- a/src/session/content/room_details/invite_subpage/invitee.rs
+++ b/src/session/content/room_details/invite_subpage/invitee.rs
@@ -95,41 +95,34 @@ impl Invitee {
     }
 
     pub fn is_invited(&self) -> bool {
-        let priv_ = imp::Invitee::from_instance(self);
-        priv_.invited.get()
+        self.imp().invited.get()
     }
 
     pub fn set_invited(&self, invited: bool) {
-        let priv_ = imp::Invitee::from_instance(self);
-
         if self.is_invited() == invited {
             return;
         }
 
-        priv_.invited.set(invited);
+        self.imp().invited.set(invited);
         self.notify("invited");
     }
 
     pub fn anchor(&self) -> Option<gtk::TextChildAnchor> {
-        let priv_ = imp::Invitee::from_instance(self);
-        priv_.anchor.borrow().clone()
+        self.imp().anchor.borrow().clone()
     }
 
     pub fn take_anchor(&self) -> Option<gtk::TextChildAnchor> {
-        let priv_ = imp::Invitee::from_instance(self);
-        let anchor = priv_.anchor.take();
+        let anchor = self.imp().anchor.take();
         self.notify("anchor");
         anchor
     }
 
     pub fn set_anchor(&self, anchor: Option<gtk::TextChildAnchor>) {
-        let priv_ = imp::Invitee::from_instance(self);
-
         if self.anchor() == anchor {
             return;
         }
 
-        priv_.anchor.replace(anchor);
+        self.imp().anchor.replace(anchor);
         self.notify("anchor");
     }
 }
diff --git a/src/session/content/room_details/invite_subpage/invitee_list.rs 
b/src/session/content/room_details/invite_subpage/invitee_list.rs
index 4b7950e5..4d0af43e 100644
--- a/src/session/content/room_details/invite_subpage/invitee_list.rs
+++ b/src/session/content/room_details/invite_subpage/invitee_list.rs
@@ -173,12 +173,11 @@ impl InviteeList {
     }
 
     pub fn room(&self) -> &Room {
-        let priv_ = imp::InviteeList::from_instance(self);
-        priv_.room.get().unwrap()
+        self.imp().room.get().unwrap()
     }
 
     pub fn set_search_term(&self, search_term: Option<String>) {
-        let priv_ = imp::InviteeList::from_instance(self);
+        let priv_ = self.imp();
 
         if search_term.as_ref() == priv_.search_term.borrow().as_ref() {
             return;
@@ -195,12 +194,11 @@ impl InviteeList {
     }
 
     fn search_term(&self) -> Option<String> {
-        let priv_ = imp::InviteeList::from_instance(self);
-        priv_.search_term.borrow().clone()
+        self.imp().search_term.borrow().clone()
     }
 
     fn set_state(&self, state: InviteeListState) {
-        let priv_ = imp::InviteeList::from_instance(self);
+        let priv_ = self.imp();
 
         if state == self.state() {
             return;
@@ -211,15 +209,13 @@ impl InviteeList {
     }
 
     pub fn state(&self) -> InviteeListState {
-        let priv_ = imp::InviteeList::from_instance(self);
-        priv_.state.get()
+        self.imp().state.get()
     }
 
     fn set_list(&self, users: Vec<Invitee>) {
-        let priv_ = imp::InviteeList::from_instance(self);
         let added = users.len();
 
-        let prev_users = priv_.list.replace(users);
+        let prev_users = self.imp().list.replace(users);
 
         self.items_changed(0, prev_users.len() as u32, added as u32);
     }
@@ -295,7 +291,6 @@ impl InviteeList {
     }
 
     fn search_users(&self) {
-        let priv_ = imp::InviteeList::from_instance(self);
         let client = self.room().session().client();
         let search_term = if let Some(search_term) = self.search_term() {
             search_term
@@ -318,7 +313,7 @@ impl InviteeList {
 
         let (future, handle) = futures::future::abortable(handle);
 
-        if let Some(abort_handle) = priv_.abort_handle.replace(Some(handle)) {
+        if let Some(abort_handle) = self.imp().abort_handle.replace(Some(handle)) {
             abort_handle.abort();
         }
 
@@ -330,14 +325,12 @@ impl InviteeList {
     }
 
     fn get_invitee(&self, user_id: &UserId) -> Option<Invitee> {
-        let priv_ = imp::InviteeList::from_instance(self);
-        priv_.invitee_list.borrow().get(user_id).cloned()
+        self.imp().invitee_list.borrow().get(user_id).cloned()
     }
 
     pub fn add_invitee(&self, user: Invitee) {
-        let priv_ = imp::InviteeList::from_instance(self);
         user.set_invited(true);
-        priv_
+        self.imp()
             .invitee_list
             .borrow_mut()
             .insert(user.user_id(), user.clone());
@@ -346,8 +339,7 @@ impl InviteeList {
     }
 
     pub fn invitees(&self) -> Vec<Invitee> {
-        let priv_ = imp::InviteeList::from_instance(self);
-        priv_
+        self.imp()
             .invitee_list
             .borrow()
             .values()
@@ -356,8 +348,7 @@ impl InviteeList {
     }
 
     fn remove_invitee(&self, user_id: Arc<UserId>) {
-        let priv_ = imp::InviteeList::from_instance(self);
-        let removed = priv_.invitee_list.borrow_mut().remove(&user_id);
+        let removed = self.imp().invitee_list.borrow_mut().remove(&user_id);
         if let Some(user) = removed {
             user.set_invited(false);
             self.emit_by_name::<()>("invitee-removed", &[&user]);
@@ -366,8 +357,7 @@ impl InviteeList {
     }
 
     pub fn has_selected(&self) -> bool {
-        let priv_ = imp::InviteeList::from_instance(self);
-        !priv_.invitee_list.borrow().is_empty()
+        !self.imp().invitee_list.borrow().is_empty()
     }
 
     pub fn connect_invitee_added<F: Fn(&Self, &Invitee) + 'static>(
diff --git a/src/session/content/room_details/invite_subpage/invitee_row.rs 
b/src/session/content/room_details/invite_subpage/invitee_row.rs
index 04341e95..521cbab1 100644
--- a/src/session/content/room_details/invite_subpage/invitee_row.rs
+++ b/src/session/content/room_details/invite_subpage/invitee_row.rs
@@ -87,12 +87,11 @@ impl InviteeRow {
     }
 
     pub fn user(&self) -> Option<Invitee> {
-        let priv_ = imp::InviteeRow::from_instance(self);
-        priv_.user.borrow().clone()
+        self.imp().user.borrow().clone()
     }
 
     pub fn set_user(&self, user: Option<Invitee>) {
-        let priv_ = imp::InviteeRow::from_instance(self);
+        let priv_ = self.imp();
 
         if self.user() == user {
             return;
diff --git a/src/session/content/room_details/invite_subpage/mod.rs 
b/src/session/content/room_details/invite_subpage/mod.rs
index 8b2c0ff3..a1f4fd8b 100644
--- a/src/session/content/room_details/invite_subpage/mod.rs
+++ b/src/session/content/room_details/invite_subpage/mod.rs
@@ -196,12 +196,11 @@ impl InviteSubpage {
     }
 
     pub fn room(&self) -> Option<Room> {
-        let priv_ = imp::InviteSubpage::from_instance(self);
-        priv_.room.borrow().clone()
+        self.imp().room.borrow().clone()
     }
 
     fn set_room(&self, room: Option<Room>) {
-        let priv_ = imp::InviteSubpage::from_instance(self);
+        let priv_ = self.imp();
 
         if self.room() == room {
             return;
@@ -252,7 +251,7 @@ impl InviteSubpage {
     }
 
     fn add_user_pill(&self, user: &Invitee) {
-        let priv_ = imp::InviteSubpage::from_instance(self);
+        let priv_ = self.imp();
 
         let pill = Pill::new();
         pill.set_margin_start(3);
@@ -279,22 +278,19 @@ impl InviteSubpage {
     }
 
     fn remove_user_pill(&self, user: &Invitee) {
-        let priv_ = imp::InviteSubpage::from_instance(self);
-
         if let Some(anchor) = user.take_anchor() {
             if !anchor.is_deleted() {
-                let mut start_iter = priv_.text_buffer.iter_at_child_anchor(&anchor);
+                let text_buffer = &self.imp().text_buffer;
+                let mut start_iter = text_buffer.iter_at_child_anchor(&anchor);
                 let mut end_iter = start_iter;
                 end_iter.forward_char();
-                priv_.text_buffer.delete(&mut start_iter, &mut end_iter);
+                text_buffer.delete(&mut start_iter, &mut end_iter);
             }
         }
     }
 
     fn invitee_list(&self) -> Option<InviteeList> {
-        let priv_ = imp::InviteSubpage::from_instance(self);
-
-        priv_
+        self.imp()
             .list_view
             .model()?
             .downcast::<gtk::NoSelection>()
@@ -306,9 +302,7 @@ impl InviteSubpage {
     }
 
     fn invite(&self) {
-        let priv_ = imp::InviteSubpage::from_instance(self);
-
-        priv_.invite_button.set_loading(true);
+        self.imp().invite_button.set_loading(true);
         if let Some(room) = self.room() {
             if let Some(user_list) = self.invitee_list() {
                 let invitees: Vec<User> = user_list
@@ -317,17 +311,16 @@ impl InviteSubpage {
                     .map(glib::object::Cast::upcast)
                     .collect();
                 spawn!(clone!(@weak self as obj => async move {
-                    let priv_ = imp::InviteSubpage::from_instance(&obj);
                     room.invite(invitees.as_slice()).await;
                     obj.close();
-                    priv_.invite_button.set_loading(false);
+                    obj.imp().invite_button.set_loading(false);
                 }));
             }
         }
     }
 
     fn update_view(&self) {
-        let priv_ = imp::InviteSubpage::from_instance(self);
+        let priv_ = self.imp();
         match self
             .invitee_list()
             .expect("Can't update view without an InviteeList")
diff --git a/src/session/content/room_details/member_page/member_menu.rs 
b/src/session/content/room_details/member_page/member_menu.rs
index 82ead061..aa72a56f 100644
--- a/src/session/content/room_details/member_page/member_menu.rs
+++ b/src/session/content/room_details/member_page/member_menu.rs
@@ -90,12 +90,11 @@ impl MemberMenu {
     }
 
     pub fn member(&self) -> Option<Member> {
-        let priv_ = imp::MemberMenu::from_instance(self);
-        priv_.member.borrow().clone()
+        self.imp().member.borrow().clone()
     }
 
     pub fn set_member(&self, member: Option<Member>) {
-        let priv_ = imp::MemberMenu::from_instance(self);
+        let priv_ = self.imp();
         let prev_member = self.member();
 
         if prev_member == member {
@@ -130,8 +129,7 @@ impl MemberMenu {
     }
 
     fn popover_menu(&self) -> &gtk::PopoverMenu {
-        let priv_ = imp::MemberMenu::from_instance(self);
-        priv_.popover.get_or_init(|| {
+        self.imp().popover.get_or_init(|| {
             gtk::PopoverMenu::from_model(Some(
                 &gtk::Builder::from_resource("/org/gnome/FractalNext/member-menu.ui")
                     .object::<gio::MenuModel>("menu_model")
@@ -145,7 +143,6 @@ impl MemberMenu {
     /// For convenience it allows to set the member for which the popover is
     /// shown
     pub fn present_popover(&self, button: &gtk::ToggleButton, member: Option<Member>) {
-        let priv_ = imp::MemberMenu::from_instance(self);
         let popover = self.popover_menu();
         let _guard = popover.freeze_notify();
 
@@ -158,18 +155,17 @@ impl MemberMenu {
             obj.unparent_popover();
         }));
 
-        priv_.destroy_handler.replace(Some(handler));
+        self.imp().destroy_handler.replace(Some(handler));
 
         popover.set_parent(button);
         popover.show();
     }
 
     fn unparent_popover(&self) {
-        let priv_ = imp::MemberMenu::from_instance(self);
         let popover = self.popover_menu();
 
         if let Some(parent) = popover.parent() {
-            if let Some(handler) = priv_.destroy_handler.take() {
+            if let Some(handler) = self.imp().destroy_handler.take() {
                 parent.disconnect(handler);
             }
 
diff --git a/src/session/content/room_details/member_page/member_row.rs 
b/src/session/content/room_details/member_page/member_row.rs
index 8e61fc56..063f3ef5 100644
--- a/src/session/content/room_details/member_page/member_row.rs
+++ b/src/session/content/room_details/member_page/member_row.rs
@@ -101,12 +101,11 @@ impl MemberRow {
     }
 
     pub fn member(&self) -> Option<Member> {
-        let priv_ = imp::MemberRow::from_instance(self);
-        priv_.member.borrow().clone()
+        self.imp().member.borrow().clone()
     }
 
     pub fn set_member(&self, member: Option<Member>) {
-        let priv_ = imp::MemberRow::from_instance(self);
+        let priv_ = self.imp();
 
         if self.member() == member {
             return;
diff --git a/src/session/content/room_details/member_page/mod.rs 
b/src/session/content/room_details/member_page/mod.rs
index 93397a77..de6b601c 100644
--- a/src/session/content/room_details/member_page/mod.rs
+++ b/src/session/content/room_details/member_page/mod.rs
@@ -137,17 +137,15 @@ impl MemberPage {
     }
 
     pub fn room(&self) -> &Room {
-        let priv_ = imp::MemberPage::from_instance(self);
-        priv_.room.get().unwrap()
+        self.imp().room.get().unwrap()
     }
 
     fn set_room(&self, room: Room) {
-        let priv_ = imp::MemberPage::from_instance(self);
-        priv_.room.set(room).expect("Room already initialized");
+        self.imp().room.set(room).expect("Room already initialized");
     }
 
     fn init_member_search(&self) {
-        let priv_ = imp::MemberPage::from_instance(self);
+        let priv_ = self.imp();
         let members = self.room().members();
 
         // Sort the members list by power level, then display name.
@@ -202,10 +200,9 @@ impl MemberPage {
     }
 
     fn init_member_count(&self) {
-        let priv_ = imp::MemberPage::from_instance(self);
         let members = self.room().members();
 
-        let member_count = priv_.member_count.get();
+        let member_count = self.imp().member_count.get();
         fn set_member_count(member_count: &gtk::Label, n: u32) {
             member_count.set_text(&ngettext!("{} Member", "{} Members", n, n));
         }
@@ -216,27 +213,24 @@ impl MemberPage {
     }
 
     fn init_invite_button(&self) {
-        let priv_ = imp::MemberPage::from_instance(self);
+        let invite_button = &*self.imp().invite_button;
 
         let invite_possible = self.room().new_allowed_expr(RoomAction::Invite);
         const NONE_OBJECT: Option<&glib::Object> = None;
-        invite_possible.bind(&*priv_.invite_button, "sensitive", NONE_OBJECT);
-
-        priv_
-            .invite_button
-            .connect_clicked(clone!(@weak self as obj => move |_| {
-                let window = obj
-                .root()
-                .unwrap()
-                .downcast::<RoomDetails>()
-                .unwrap();
-                window.present_invite_subpage();
-            }));
+        invite_possible.bind(invite_button, "sensitive", NONE_OBJECT);
+
+        invite_button.connect_clicked(clone!(@weak self as obj => move |_| {
+            let window = obj
+            .root()
+            .unwrap()
+            .downcast::<RoomDetails>()
+            .unwrap();
+            window.present_invite_subpage();
+        }));
     }
 
     pub fn member_menu(&self) -> &MemberMenu {
-        let priv_ = imp::MemberPage::from_instance(self);
-        priv_.member_menu.get_or_init(|| {
+        self.imp().member_menu.get_or_init(|| {
             let menu = MemberMenu::new();
 
             menu.connect_notify_local(
diff --git a/src/session/content/room_details/mod.rs b/src/session/content/room_details/mod.rs
index 29d62045..d025044b 100644
--- a/src/session/content/room_details/mod.rs
+++ b/src/session/content/room_details/mod.rs
@@ -132,18 +132,16 @@ impl RoomDetails {
     }
 
     pub fn room(&self) -> &Room {
-        let priv_ = imp::RoomDetails::from_instance(self);
         // Use unwrap because room property is CONSTRUCT_ONLY.
-        priv_.room.get().unwrap()
+        self.imp().room.get().unwrap()
     }
 
     fn set_room(&self, room: Room) {
-        let priv_ = imp::RoomDetails::from_instance(self);
-        priv_.room.set(room).expect("Room already initialized");
+        self.imp().room.set(room).expect("Room already initialized");
     }
 
     fn init_avatar(&self) {
-        let priv_ = imp::RoomDetails::from_instance(self);
+        let priv_ = self.imp();
         let avatar_remove_button = &priv_.avatar_remove_button;
         let avatar_edit_button = &priv_.avatar_edit_button;
 
@@ -166,7 +164,7 @@ impl RoomDetails {
     }
 
     fn init_edit_toggle(&self) {
-        let priv_ = imp::RoomDetails::from_instance(self);
+        let priv_ = self.imp();
         let edit_toggle = &priv_.edit_toggle;
         let label_enabled = gettext("Save Details");
         let label_disabled = gettext("Edit Details");
@@ -182,7 +180,7 @@ impl RoomDetails {
             }
             button.set_label(&label_disabled);
 
-            let priv_ = imp::RoomDetails::from_instance(&this);
+            let priv_ = this.imp();
             let room = this.room();
 
             let room_name = priv_.room_name_entry.buffer().text();
@@ -196,8 +194,7 @@ impl RoomDetails {
         priv_
             .room_name_entry
             .connect_activate(clone!(@weak self as this => move |_entry| {
-                let priv_ = imp::RoomDetails::from_instance(&this);
-                priv_.edit_toggle.set_active(false);
+                this.imp().edit_toggle.set_active(false);
             }));
 
         // Hide edit controls when the user is not eligible to perform the actions.
@@ -212,7 +209,6 @@ impl RoomDetails {
     }
 
     fn init_avatar_chooser(&self) {
-        let priv_ = imp::RoomDetails::from_instance(self);
         let avatar_chooser = gtk::FileChooserNative::new(
             Some(&gettext("Choose avatar")),
             Some(self),
@@ -230,15 +226,14 @@ impl RoomDetails {
 
         // We must keep a reference to FileChooserNative around as it is not
         // managed by GTK.
-        priv_
+        self.imp()
             .avatar_chooser
             .set(avatar_chooser)
             .expect("File chooser already initialized");
     }
 
     fn avatar_chooser(&self) -> &gtk::FileChooserNative {
-        let priv_ = imp::RoomDetails::from_instance(self);
-        priv_.avatar_chooser.get().unwrap()
+        self.imp().avatar_chooser.get().unwrap()
     }
 
     fn open_avatar_chooser(&self) {
@@ -257,7 +252,6 @@ impl RoomDetails {
     }
 
     pub fn member_page(&self) -> &MemberPage {
-        let priv_ = imp::RoomDetails::from_instance(self);
-        priv_.member_page.get().unwrap()
+        self.imp().member_page.get().unwrap()
     }
 }
diff --git a/src/session/content/room_history/divider_row.rs b/src/session/content/room_history/divider_row.rs
index ca7f47ff..810660b0 100644
--- a/src/session/content/room_history/divider_row.rs
+++ b/src/session/content/room_history/divider_row.rs
@@ -82,12 +82,10 @@ impl DividerRow {
     }
 
     pub fn set_label(&self, label: &str) {
-        let priv_ = imp::DividerRow::from_instance(self);
-        priv_.label.set_text(label);
+        self.imp().label.set_text(label);
     }
 
     pub fn label(&self) -> String {
-        let priv_ = imp::DividerRow::from_instance(self);
-        priv_.label.text().as_str().to_owned()
+        self.imp().label.text().as_str().to_owned()
     }
 }
diff --git a/src/session/content/room_history/item_row.rs b/src/session/content/room_history/item_row.rs
index 1d4408b2..7e3eb30b 100644
--- a/src/session/content/room_history/item_row.rs
+++ b/src/session/content/room_history/item_row.rs
@@ -105,8 +105,7 @@ impl ItemRow {
 
     /// Get the row's `Item`.
     pub fn item(&self) -> Option<Item> {
-        let priv_ = imp::ItemRow::from_instance(self);
-        priv_.item.borrow().clone()
+        self.imp().item.borrow().clone()
     }
 
     /// This method sets this row to a new `Item`.
@@ -115,7 +114,7 @@ impl ItemRow {
     /// possible, but it will create a new widget and drop the old one if it
     /// has to.
     fn set_item(&self, item: Option<Item>) {
-        let priv_ = imp::ItemRow::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(ItemType::Event(event)) = priv_.item.borrow().as_ref().map(|item| item.type_())
         {
@@ -246,7 +245,7 @@ impl ItemRow {
     ///
     /// If it doesn't exist, it is created
     fn set_reaction_chooser(&self, reactions: &ReactionList) {
-        let priv_ = imp::ItemRow::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.reaction_chooser.borrow().is_none() {
             let reaction_chooser = ReactionChooser::new();
@@ -265,7 +264,7 @@ impl ItemRow {
 
     /// Remove the reaction chooser and the emoji chooser, if they exist.
     fn remove_reaction_chooser(&self) {
-        let priv_ = imp::ItemRow::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(reaction_chooser) = priv_.reaction_chooser.take() {
             reaction_chooser.unparent();
@@ -277,7 +276,7 @@ impl ItemRow {
     }
 
     fn show_emoji_chooser(&self) {
-        let priv_ = imp::ItemRow::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.emoji_chooser.borrow().is_none() {
             let emoji_chooser = gtk::EmojiChooser::builder().has_arrow(false).build();
diff --git a/src/session/content/room_history/message_row/file.rs 
b/src/session/content/room_history/message_row/file.rs
index 5017ed22..49deeecb 100644
--- a/src/session/content/room_history/message_row/file.rs
+++ b/src/session/content/room_history/message_row/file.rs
@@ -97,7 +97,7 @@ impl MessageFile {
     }
 
     pub fn set_filename(&self, filename: Option<String>) {
-        let priv_ = imp::MessageFile::from_instance(self);
+        let priv_ = self.imp();
 
         let name = filename.filter(|name| !name.is_empty());
 
@@ -110,24 +110,20 @@ impl MessageFile {
     }
 
     pub fn filename(&self) -> Option<String> {
-        let priv_ = imp::MessageFile::from_instance(self);
-        priv_.filename.borrow().to_owned()
+        self.imp().filename.borrow().to_owned()
     }
 
     pub fn set_compact(&self, compact: bool) {
-        let priv_ = imp::MessageFile::from_instance(self);
-
         if self.compact() == compact {
             return;
         }
 
-        priv_.compact.set(compact);
+        self.imp().compact.set(compact);
         self.notify("compact");
     }
 
     pub fn compact(&self) -> bool {
-        let priv_ = imp::MessageFile::from_instance(self);
-        priv_.compact.get()
+        self.imp().compact.get()
     }
 }
 
diff --git a/src/session/content/room_history/message_row/media.rs 
b/src/session/content/room_history/message_row/media.rs
index 1b9f6415..f515d285 100644
--- a/src/session/content/room_history/message_row/media.rs
+++ b/src/session/content/room_history/message_row/media.rs
@@ -272,44 +272,37 @@ impl MessageMedia {
     }
 
     pub fn width(&self) -> i32 {
-        let priv_ = imp::MessageMedia::from_instance(self);
-        priv_.width.get()
+        self.imp().width.get()
     }
 
     fn set_width(&self, width: i32) {
-        let priv_ = imp::MessageMedia::from_instance(self);
-
         if self.width() == width {
             return;
         }
 
-        priv_.width.set(width);
+        self.imp().width.set(width);
         self.notify("width");
     }
 
     pub fn height(&self) -> i32 {
-        let priv_ = imp::MessageMedia::from_instance(self);
-        priv_.height.get()
+        self.imp().height.get()
     }
 
     fn set_height(&self, height: i32) {
-        let priv_ = imp::MessageMedia::from_instance(self);
-
         if self.height() == height {
             return;
         }
 
-        priv_.height.set(height);
+        self.imp().height.set(height);
         self.notify("height");
     }
 
     pub fn state(&self) -> MediaState {
-        let priv_ = imp::MessageMedia::from_instance(self);
-        priv_.state.get()
+        self.imp().state.get()
     }
 
     fn set_state(&self, state: MediaState) {
-        let priv_ = imp::MessageMedia::from_instance(self);
+        let priv_ = self.imp();
 
         if self.state() == state {
             return;
@@ -335,13 +328,11 @@ impl MessageMedia {
     }
 
     fn compact(&self) -> bool {
-        let priv_ = imp::MessageMedia::from_instance(self);
-        priv_.compact.get()
+        self.imp().compact.get()
     }
 
     fn set_compact(&self, compact: bool) {
-        let priv_ = imp::MessageMedia::from_instance(self);
-        priv_.compact.set(compact);
+        self.imp().compact.set(compact);
         self.notify("compact");
     }
 
@@ -421,7 +412,7 @@ impl MessageMedia {
         spawn!(
             glib::PRIORITY_LOW,
             clone!(@weak self as obj => async move {
-                let priv_ = imp::MessageMedia::from_instance(&obj);
+                let priv_ = obj.imp();
 
                 match handle.await.unwrap() {
                     Ok((Some(data), id)) => {
diff --git a/src/session/content/room_history/message_row/mod.rs 
b/src/session/content/room_history/message_row/mod.rs
index 36b2b138..ca3848e7 100644
--- a/src/session/content/room_history/message_row/mod.rs
+++ b/src/session/content/room_history/message_row/mod.rs
@@ -128,12 +128,12 @@ impl MessageRow {
     }
 
     pub fn show_header(&self) -> bool {
-        let priv_ = imp::MessageRow::from_instance(self);
+        let priv_ = self.imp();
         priv_.avatar.is_visible() && priv_.header.is_visible()
     }
 
     pub fn set_show_header(&self, visible: bool) {
-        let priv_ = imp::MessageRow::from_instance(self);
+        let priv_ = self.imp();
         priv_.avatar.set_visible(visible);
         priv_.header.set_visible(visible);
 
@@ -149,7 +149,7 @@ impl MessageRow {
     }
 
     pub fn set_event(&self, event: Event) {
-        let priv_ = imp::MessageRow::from_instance(self);
+        let priv_ = self.imp();
         // Remove signals and bindings from the previous event
         if let Some(event) = priv_.event.take() {
             if let Some(source_changed_handler) = priv_.source_changed_handler.take() {
@@ -200,13 +200,11 @@ impl MessageRow {
     }
 
     fn update_content(&self, event: &Event) {
-        let priv_ = imp::MessageRow::from_instance(self);
-
         if event.is_reply() {
             spawn!(
                 glib::PRIORITY_HIGH,
                 clone!(@weak self as obj, @weak event => async move {
-                    let priv_ = imp::MessageRow::from_instance(&obj);
+                    let priv_ = obj.imp();
 
                     if let Ok(Some(related_event)) = event.reply_to_event().await {
                         let reply = MessageReply::new();
@@ -220,7 +218,7 @@ impl MessageRow {
                 })
             );
         } else {
-            build_content(&*priv_.content, event, false);
+            build_content(&*self.imp().content, event, false);
         }
     }
 }
diff --git a/src/session/content/room_history/message_row/reaction.rs 
b/src/session/content/room_history/message_row/reaction.rs
index dab6b5a3..7d435f8a 100644
--- a/src/session/content/room_history/message_row/reaction.rs
+++ b/src/session/content/room_history/message_row/reaction.rs
@@ -92,7 +92,7 @@ impl MessageReaction {
     }
 
     fn set_group(&self, group: ReactionGroup) {
-        let priv_ = imp::MessageReaction::from_instance(self);
+        let priv_ = self.imp();
         let key = group.key();
         priv_.reaction_key.set_label(key);
         priv_
diff --git a/src/session/content/room_history/message_row/reaction_list.rs 
b/src/session/content/room_history/message_row/reaction_list.rs
index 2215888d..0a4fda0b 100644
--- a/src/session/content/room_history/message_row/reaction_list.rs
+++ b/src/session/content/room_history/message_row/reaction_list.rs
@@ -51,9 +51,7 @@ impl MessageReactionList {
     }
 
     pub fn set_reaction_list(&self, reaction_list: &ReactionList) {
-        let priv_ = imp::MessageReactionList::from_instance(self);
-
-        priv_.flow_box.bind_model(Some(reaction_list), |obj| {
+        self.imp().flow_box.bind_model(Some(reaction_list), |obj| {
             MessageReaction::new(obj.clone().downcast().unwrap()).upcast()
         });
     }
diff --git a/src/session/content/room_history/message_row/reply.rs 
b/src/session/content/room_history/message_row/reply.rs
index 9d939733..ad5fbb70 100644
--- a/src/session/content/room_history/message_row/reply.rs
+++ b/src/session/content/room_history/message_row/reply.rs
@@ -52,18 +52,15 @@ impl MessageReply {
     }
 
     pub fn set_related_content_sender(&self, user: User) {
-        let priv_ = imp::MessageReply::from_instance(self);
-        priv_.pill.set_user(Some(user));
+        self.imp().pill.set_user(Some(user));
     }
 
     pub fn related_content(&self) -> &adw::Bin {
-        let priv_ = imp::MessageReply::from_instance(self);
-        priv_.related_content.as_ref()
+        self.imp().related_content.as_ref()
     }
 
     pub fn content(&self) -> &adw::Bin {
-        let priv_ = imp::MessageReply::from_instance(self);
-        priv_.content.as_ref()
+        self.imp().content.as_ref()
     }
 }
 
diff --git a/src/session/content/room_history/message_row/text.rs 
b/src/session/content/room_history/message_row/text.rs
index 26281aa3..a11dd5bb 100644
--- a/src/session/content/room_history/message_row/text.rs
+++ b/src/session/content/room_history/message_row/text.rs
@@ -145,7 +145,7 @@ impl MessageText {
     }
 
     pub fn set_body(&self, body: Option<String>) {
-        let priv_ = imp::MessageText::from_instance(self);
+        let priv_ = self.imp();
 
         if body.as_ref() == priv_.body.borrow().as_ref() {
             return;
@@ -155,12 +155,11 @@ impl MessageText {
     }
 
     pub fn body(&self) -> Option<String> {
-        let priv_ = imp::MessageText::from_instance(self);
-        priv_.body.borrow().to_owned()
+        self.imp().body.borrow().to_owned()
     }
 
     pub fn set_sender(&self, sender: Option<Member>) {
-        let priv_ = imp::MessageText::from_instance(self);
+        let priv_ = self.imp();
 
         if sender.as_ref() == priv_.sender.borrow().as_ref() {
             return;
@@ -171,8 +170,7 @@ impl MessageText {
     }
 
     pub fn sender(&self) -> Option<Member> {
-        let priv_ = imp::MessageText::from_instance(self);
-        priv_.sender.borrow().to_owned()
+        self.imp().sender.borrow().to_owned()
     }
 
     /// Display the given emote for `sender`.
diff --git a/src/session/content/room_history/mod.rs b/src/session/content/room_history/mod.rs
index 83466eee..7fdb6074 100644
--- a/src/session/content/room_history/mod.rs
+++ b/src/session/content/room_history/mod.rs
@@ -229,7 +229,7 @@ mod imp {
             let adj = self.listview.vadjustment().unwrap();
 
             adj.connect_value_changed(clone!(@weak obj => move |adj| {
-                let priv_ = imp::RoomHistory::from_instance(&obj);
+                let priv_ = obj.imp();
 
                 if priv_.is_auto_scrolling.get() {
                     if adj.value() + adj.page_size() == adj.upper() {
@@ -306,7 +306,7 @@ impl RoomHistory {
     }
 
     pub fn set_room(&self, room: Option<Room>) {
-        let priv_ = imp::RoomHistory::from_instance(self);
+        let priv_ = self.imp();
 
         if self.room() == room {
             return;
@@ -353,9 +353,8 @@ impl RoomHistory {
                 Some("loading"),
                 clone!(@weak self as obj => move |timeline, _| {
                     // We need to make sure that we loaded enough events to fill the `ScrolledWindow`
-                    let priv_ = imp::RoomHistory::from_instance(&obj);
                     if !timeline.loading() {
-                        let adj = priv_.listview.vadjustment().unwrap();
+                        let adj = obj.imp().listview.vadjustment().unwrap();
                         obj.load_more_messages(&adj);
                     }
                 }),
@@ -382,12 +381,11 @@ impl RoomHistory {
     }
 
     pub fn room(&self) -> Option<Room> {
-        let priv_ = imp::RoomHistory::from_instance(self);
-        priv_.room.borrow().clone()
+        self.imp().room.borrow().clone()
     }
 
     pub fn send_text_message(&self) {
-        let priv_ = imp::RoomHistory::from_instance(self);
+        let priv_ = self.imp();
         let buffer = priv_.message_entry.buffer();
         let (start_iter, end_iter) = buffer.bounds();
         let body_len = buffer.text(&start_iter, &end_iter, true).len();
@@ -484,9 +482,7 @@ impl RoomHistory {
     }
 
     pub fn leave(&self) {
-        let priv_ = imp::RoomHistory::from_instance(self);
-
-        if let Some(room) = &*priv_.room.borrow() {
+        if let Some(room) = &*self.imp().room.borrow() {
             room.set_category(RoomType::Left);
         }
     }
@@ -510,7 +506,7 @@ impl RoomHistory {
     }
 
     fn update_room_state(&self) {
-        let priv_ = imp::RoomHistory::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(room) = &*priv_.room.borrow() {
             if room.category() == RoomType::Left {
@@ -524,7 +520,7 @@ impl RoomHistory {
     }
 
     fn set_empty_timeline(&self) {
-        let priv_ = imp::RoomHistory::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(room) = &*priv_.room.borrow() {
             if room.timeline().is_empty() {
@@ -555,13 +551,11 @@ impl RoomHistory {
     }
 
     pub fn sticky(&self) -> bool {
-        let priv_ = imp::RoomHistory::from_instance(self);
-
-        priv_.sticky.get()
+        self.imp().sticky.get()
     }
 
     pub fn set_sticky(&self, sticky: bool) {
-        let priv_ = imp::RoomHistory::from_instance(self);
+        let priv_ = self.imp();
 
         if self.sticky() == sticky {
             return;
@@ -575,7 +569,7 @@ impl RoomHistory {
 
     /// Scroll to the newest message in the timeline
     pub fn scroll_down(&self) {
-        let priv_ = imp::RoomHistory::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.is_auto_scrolling.set(true);
 
diff --git a/src/session/content/room_history/state_row/creation.rs 
b/src/session/content/room_history/state_row/creation.rs
index 7110e3d5..9629dd50 100644
--- a/src/session/content/room_history/state_row/creation.rs
+++ b/src/session/content/room_history/state_row/creation.rs
@@ -50,7 +50,7 @@ impl StateCreation {
     }
 
     fn set_event(&self, event: &RoomCreateEventContent) {
-        let priv_ = imp::StateCreation::from_instance(self);
+        let priv_ = self.imp();
         if let Some(predecessor) = &event.predecessor {
             priv_.previous_room_btn.set_detailed_action_name(&format!(
                 "session.show-room::{}",
diff --git a/src/session/content/room_history/state_row/tombstone.rs 
b/src/session/content/room_history/state_row/tombstone.rs
index ddb9e8ff..9ff1f790 100644
--- a/src/session/content/room_history/state_row/tombstone.rs
+++ b/src/session/content/room_history/state_row/tombstone.rs
@@ -47,8 +47,7 @@ impl StateTombstone {
     }
 
     fn set_event(&self, event: &RoomTombstoneEventContent) {
-        let priv_ = imp::StateTombstone::from_instance(self);
-        priv_.new_room_btn.set_detailed_action_name(&format!(
+        self.imp().new_room_btn.set_detailed_action_name(&format!(
             "session.show-room::{}",
             event.replacement_room.as_str()
         ));
diff --git a/src/session/content/room_history/verification_info_bar.rs 
b/src/session/content/room_history/verification_info_bar.rs
index c0721527..97900bd9 100644
--- a/src/session/content/room_history/verification_info_bar.rs
+++ b/src/session/content/room_history/verification_info_bar.rs
@@ -108,12 +108,11 @@ impl VerificationInfoBar {
     }
 
     pub fn request(&self) -> Option<IdentityVerification> {
-        let priv_ = imp::VerificationInfoBar::from_instance(self);
-        priv_.request.borrow().clone()
+        self.imp().request.borrow().clone()
     }
 
     pub fn set_request(&self, request: Option<IdentityVerification>) {
-        let priv_ = imp::VerificationInfoBar::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(old_request) = &*priv_.request.borrow() {
             if Some(old_request) == request.as_ref() {
@@ -156,7 +155,7 @@ impl VerificationInfoBar {
     }
 
     pub fn update_view(&self) {
-        let priv_ = imp::VerificationInfoBar::from_instance(self);
+        let priv_ = self.imp();
         let visible = if let Some(request) = self.request() {
             if request.is_finished() {
                 false
diff --git a/src/session/content/verification/emoji.rs b/src/session/content/verification/emoji.rs
index 9550918b..fe872425 100644
--- a/src/session/content/verification/emoji.rs
+++ b/src/session/content/verification/emoji.rs
@@ -50,7 +50,7 @@ impl Emoji {
     }
 
     pub fn set_emoji(&self, emoji: &MatrixEmoji) {
-        let priv_ = imp::Emoji::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.emoji.set_text(emoji.symbol);
         priv_.emoji_name.set_text(emoji.description);
diff --git a/src/session/content/verification/identity_verification_widget.rs 
b/src/session/content/verification/identity_verification_widget.rs
index b9d5bd80..3e4d2810 100644
--- a/src/session/content/verification/identity_verification_widget.rs
+++ b/src/session/content/verification/identity_verification_widget.rs
@@ -156,17 +156,15 @@ mod imp {
             self.parent_constructed(obj);
             self.accept_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.decline_btn.set_sensitive(false);
+                    obj.imp().decline_btn.set_sensitive(false);
                     obj.accept();
                 }));
 
             self.emoji_match_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.emoji_not_match_btn.set_sensitive(false);
+                    obj.imp().emoji_not_match_btn.set_sensitive(false);
                     if let Some(request) = obj.request() {
                         request.emoji_match();
                     }
@@ -174,9 +172,8 @@ mod imp {
 
             self.emoji_not_match_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.emoji_match_btn.set_sensitive(false);
+                    obj.imp().emoji_match_btn.set_sensitive(false);
                     if let Some(request) = obj.request() {
                         request.emoji_not_match();
                     }
@@ -184,27 +181,24 @@ mod imp {
 
             self.start_emoji_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.scan_qr_code_btn.set_sensitive(false);
+                    obj.imp().scan_qr_code_btn.set_sensitive(false);
                     if let Some(request) = obj.request() {
                         request.start_sas();
                     }
                 }));
             self.start_emoji_btn2
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.take_screenshot_btn2.set_sensitive(false);
+                    obj.imp().take_screenshot_btn2.set_sensitive(false);
                     if let Some(request) = obj.request() {
                         request.start_sas();
                     }
                 }));
             self.start_emoji_btn3
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.take_screenshot_btn3.set_sensitive(false);
+                    obj.imp().take_screenshot_btn3.set_sensitive(false);
                     if let Some(request) = obj.request() {
                         request.start_sas();
                     }
@@ -212,7 +206,7 @@ mod imp {
 
             self.scan_qr_code_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
+                    let priv_ = obj.imp();
                     button.set_loading(true);
                     priv_.start_emoji_btn.set_sensitive(false);
                     if priv_.qr_code_scanner.has_camera() {
@@ -224,17 +218,15 @@ mod imp {
 
             self.take_screenshot_btn2
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.start_emoji_btn2.set_sensitive(false);
+                    obj.imp().start_emoji_btn2.set_sensitive(false);
                     obj.take_screenshot();
                 }));
 
             self.take_screenshot_btn3
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
-                    priv_.start_emoji_btn3.set_sensitive(false);
+                    obj.imp().start_emoji_btn3.set_sensitive(false);
                     obj.take_screenshot();
                 }));
 
@@ -294,12 +286,11 @@ impl IdentityVerificationWidget {
     }
 
     pub fn request(&self) -> Option<IdentityVerification> {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
-        priv_.request.borrow().clone()
+        self.imp().request.borrow().clone()
     }
 
     pub fn set_request(&self, request: Option<IdentityVerification>) {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+        let priv_ = self.imp();
         let previous_request = self.request();
 
         if previous_request == request {
@@ -345,7 +336,7 @@ impl IdentityVerificationWidget {
     }
 
     fn reset(&self) {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+        let priv_ = self.imp();
         priv_.accept_btn.set_loading(false);
         priv_.accept_btn.set_sensitive(true);
         priv_.decline_btn.set_sensitive(true);
@@ -370,7 +361,7 @@ impl IdentityVerificationWidget {
     }
 
     fn clean_emoji(&self) {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+        let priv_ = self.imp();
 
         while let Some(child) = priv_.emoji_row_1.first_child() {
             priv_.emoji_row_1.remove(&child);
@@ -394,7 +385,7 @@ impl IdentityVerificationWidget {
     }
 
     fn update_view(&self) {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+        let priv_ = self.imp();
         if let Some(request) = self.request() {
             match request.state() {
                 VerificationState::Requested => {
@@ -455,7 +446,7 @@ impl IdentityVerificationWidget {
 
     fn start_scanning(&self) {
         spawn!(clone!(@weak self as obj => async move {
-            let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
+            let priv_ = obj.imp();
             if priv_.qr_code_scanner.start().await {
                 priv_.main_stack.set_visible_child_name("scan-qr-code");
             } else {
@@ -476,7 +467,7 @@ impl IdentityVerificationWidget {
     }
 
     fn finish_scanning(&self, data: QrVerificationData) {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+        let priv_ = self.imp();
         priv_.qr_code_scanner.stop();
         if let Some(request) = self.request() {
             request.scanned_qr_code(data);
@@ -485,7 +476,7 @@ impl IdentityVerificationWidget {
     }
 
     fn update_camera_state(&self) {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+        let priv_ = self.imp();
         if priv_.qr_code_scanner.has_camera() {
             priv_
                 .scan_qr_code_btn
@@ -498,7 +489,7 @@ impl IdentityVerificationWidget {
     }
 
     fn init_mode(&self) {
-        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+        let priv_ = self.imp();
         let request = if let Some(request) = self.request() {
             request
         } else {
diff --git a/src/session/content/verification/session_verification.rs 
b/src/session/content/verification/session_verification.rs
index 36c7371d..522c6b4d 100644
--- a/src/session/content/verification/session_verification.rs
+++ b/src/session/content/verification/session_verification.rs
@@ -143,22 +143,19 @@ impl SessionVerification {
 
     /// The current `Session`.
     pub fn session(&self) -> Session {
-        let priv_ = imp::SessionVerification::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     fn set_session(&self, session: Session) {
-        let priv_ = imp::SessionVerification::from_instance(self);
-        priv_.session.set(session.downgrade()).unwrap()
+        self.imp().session.set(session.downgrade()).unwrap()
     }
 
     fn request(&self) -> Option<IdentityVerification> {
-        let priv_ = imp::SessionVerification::from_instance(self);
-        priv_.request.borrow().clone()
+        self.imp().request.borrow().clone()
     }
 
     fn set_request(&self, request: Option<IdentityVerification>) {
-        let priv_ = imp::SessionVerification::from_instance(self);
+        let priv_ = self.imp();
         let previous_request = self.request();
 
         if previous_request == request {
@@ -197,14 +194,14 @@ impl SessionVerification {
     }
 
     fn reset(&self) {
-        let priv_ = imp::SessionVerification::from_instance(self);
+        let bootstrap_button = &self.imp().bootstrap_button;
 
-        priv_.bootstrap_button.set_sensitive(true);
-        priv_.bootstrap_button.set_loading(false);
+        bootstrap_button.set_sensitive(true);
+        bootstrap_button.set_loading(false);
     }
 
     fn update_view(&self, request: &IdentityVerification) {
-        let priv_ = imp::SessionVerification::from_instance(self);
+        let priv_ = self.imp();
 
         if request.is_finished() && request.state() != VerificationState::Completed {
             self.start_request();
@@ -228,15 +225,13 @@ impl SessionVerification {
     }
 
     fn show_recovery(&self) {
-        let priv_ = imp::SessionVerification::from_instance(self);
-
         // TODO: stop the request
 
-        priv_.main_stack.set_visible_child_name("recovery");
+        self.imp().main_stack.set_visible_child_name("recovery");
     }
 
     fn show_bootstrap(&self) {
-        let priv_ = imp::SessionVerification::from_instance(self);
+        let priv_ = self.imp();
 
         self.set_request(None);
         priv_.bootstrap_label.set_label(&gettext("If you lost access to all other session you can create a 
new crypto identity. Be care full because this will reset all verified users and make previously encrypted 
conversations unreadable."));
@@ -247,8 +242,9 @@ impl SessionVerification {
     }
 
     fn start_request(&self) {
-        let priv_ = imp::SessionVerification::from_instance(self);
-        priv_.main_stack.set_visible_child_name("wait-for-device");
+        self.imp()
+            .main_stack
+            .set_visible_child_name("wait-for-device");
 
         spawn!(clone!(@weak self as obj => async move {
             let request = IdentityVerification::create(&obj.session(), None).await;
@@ -258,16 +254,16 @@ impl SessionVerification {
     }
 
     fn previous(&self) {
-        let priv_ = imp::SessionVerification::from_instance(self);
+        let main_stack = &self.imp().main_stack;
 
-        if let Some(child_name) = priv_.main_stack.visible_child_name() {
+        if let Some(child_name) = main_stack.visible_child_name() {
             match child_name.as_str() {
                 "recovery" => {
                     self.start_request();
                     return;
                 }
                 "recovery-passphrase" | "recovery-key" => {
-                    priv_.main_stack.set_visible_child_name("recovery");
+                    main_stack.set_visible_child_name("recovery");
                     return;
                 }
                 "bootstrap" => {
diff --git a/src/session/event_source_dialog.rs b/src/session/event_source_dialog.rs
index 79da3498..1949287c 100644
--- a/src/session/event_source_dialog.rs
+++ b/src/session/event_source_dialog.rs
@@ -107,10 +107,8 @@ impl EventSourceDialog {
     }
 
     pub fn copy_to_clipboard(&self) {
-        let priv_ = imp::EventSourceDialog::from_instance(self);
-
         let clipboard = self.clipboard();
-        let buffer = priv_.source_view.buffer();
+        let buffer = self.imp().source_view.buffer();
         let (start_iter, end_iter) = buffer.bounds();
         clipboard.set_text(buffer.text(&start_iter, &end_iter, true).as_ref());
     }
diff --git a/src/session/media_viewer.rs b/src/session/media_viewer.rs
index 1b7bbdba..1d696e74 100644
--- a/src/session/media_viewer.rs
+++ b/src/session/media_viewer.rs
@@ -40,13 +40,12 @@ mod imp {
             Self::Type::bind_template_callbacks(klass);
 
             klass.install_action("media-viewer.close", None, move |obj, _, _| {
-                let priv_ = imp::MediaViewer::from_instance(obj);
-
                 if obj.fullscreened() {
                     obj.activate_action("win.toggle-fullscreen", None).unwrap();
                 }
 
-                if let Some(stream) = priv_
+                if let Some(stream) = obj
+                    .imp()
                     .media
                     .child()
                     .and_then(|w| w.downcast::<gtk::Video>().ok())
@@ -161,8 +160,7 @@ impl MediaViewer {
     }
 
     pub fn event(&self) -> Option<Event> {
-        let priv_ = imp::MediaViewer::from_instance(self);
-        priv_
+        self.imp()
             .event
             .borrow()
             .as_ref()
@@ -170,40 +168,36 @@ impl MediaViewer {
     }
 
     pub fn set_event(&self, event: Option<Event>) {
-        let priv_ = imp::MediaViewer::from_instance(self);
-
         if event == self.event() {
             return;
         }
 
-        priv_.event.replace(event.map(|event| event.downgrade()));
+        self.imp()
+            .event
+            .replace(event.map(|event| event.downgrade()));
         self.build();
         self.notify("event");
     }
 
     pub fn body(&self) -> Option<String> {
-        let priv_ = imp::MediaViewer::from_instance(self);
-        priv_.body.borrow().clone()
+        self.imp().body.borrow().clone()
     }
 
     pub fn set_body(&self, body: Option<String>) {
-        let priv_ = imp::MediaViewer::from_instance(self);
-
         if body == self.body() {
             return;
         }
 
-        priv_.body.replace(body);
+        self.imp().body.replace(body);
         self.notify("body");
     }
 
     pub fn fullscreened(&self) -> bool {
-        let priv_ = imp::MediaViewer::from_instance(self);
-        priv_.fullscreened.get()
+        self.imp().fullscreened.get()
     }
 
     pub fn set_fullscreened(&self, fullscreened: bool) {
-        let priv_ = imp::MediaViewer::from_instance(self);
+        let priv_ = self.imp();
 
         if fullscreened == self.fullscreened() {
             return;
@@ -234,7 +228,7 @@ impl MediaViewer {
                         spawn!(
                             glib::PRIORITY_LOW,
                             clone!(@weak self as obj => async move {
-                                let priv_ = imp::MediaViewer::from_instance(&obj);
+                                let priv_ = obj.imp();
 
                                 match event.get_media_content().await {
                                     Ok((_, _, data)) => {
@@ -266,7 +260,7 @@ impl MediaViewer {
                         spawn!(
                             glib::PRIORITY_LOW,
                             clone!(@weak self as obj => async move {
-                                let priv_ = imp::MediaViewer::from_instance(&obj);
+                                let priv_ = obj.imp();
 
                                 match event.get_media_content().await {
                                     Ok((uid, filename, data)) => {
diff --git a/src/session/mod.rs b/src/session/mod.rs
index 2420a1f0..5af81403 100644
--- a/src/session/mod.rs
+++ b/src/session/mod.rs
@@ -126,8 +126,7 @@ mod imp {
 
             klass.install_action("session.logout", None, move |session, _, _| {
                 spawn!(clone!(@weak session => async move {
-                    let priv_ = imp::Session::from_instance(&session);
-                    priv_.logout_on_dispose.set(false);
+                    session.imp().logout_on_dispose.set(false);
                     session.logout().await
                 }));
             });
@@ -228,7 +227,7 @@ mod imp {
             self.sidebar.connect_notify_local(
                 Some("selected-item"),
                 clone!(@weak obj => move |_, _| {
-                    let priv_ = imp::Session::from_instance(&obj);
+                    let priv_ = obj.imp();
 
                     if priv_.sidebar.selected_item().is_none() {
                         priv_.content.navigate(adw::NavigationDirection::Back);
@@ -268,15 +267,13 @@ impl Session {
     }
 
     pub fn select_room(&self, room: Option<Room>) {
-        let priv_ = imp::Session::from_instance(self);
-        priv_
+        self.imp()
             .sidebar
             .set_selected_item(room.map(|item| item.upcast()));
     }
 
     pub fn select_item(&self, item: Option<glib::Object>) {
-        let priv_ = imp::Session::from_instance(self);
-        priv_.sidebar.set_selected_item(item);
+        self.imp().sidebar.set_selected_item(item);
     }
 
     pub fn select_room_by_id(&self, room_id: &RoomId) {
@@ -288,8 +285,7 @@ impl Session {
     }
 
     pub fn login_with_password(&self, homeserver: Url, username: String, password: String) {
-        let priv_ = imp::Session::from_instance(self);
-        priv_.logout_on_dispose.set(true);
+        self.imp().logout_on_dispose.set(true);
         let mut path = glib::user_data_dir();
         path.push(
             &Uuid::new_v4()
@@ -346,8 +342,7 @@ impl Session {
     }
 
     fn toggle_room_search(&self) {
-        let priv_ = imp::Session::from_instance(self);
-        let room_search = priv_.sidebar.room_search_bar();
+        let room_search = self.imp().sidebar.room_search_bar();
         room_search.set_search_mode(!room_search.is_search_mode());
     }
 
@@ -382,7 +377,7 @@ impl Session {
         result: Result<(Client, StoredSession), matrix_sdk::Error>,
         store_session: bool,
     ) {
-        let priv_ = imp::Session::from_instance(self);
+        let priv_ = self.imp();
         let error = match result {
             Ok((client, session)) => {
                 priv_.client.replace(Some(client.clone()));
@@ -459,7 +454,6 @@ impl Session {
     }
 
     fn sync(&self) {
-        let priv_ = imp::Session::from_instance(self);
         let sender = self.create_new_sync_response_sender();
         let client = self.client();
         let handle = spawn_tokio!(async move {
@@ -490,23 +484,22 @@ impl Session {
             }
         });
 
-        priv_.sync_tokio_handle.replace(Some(handle));
+        self.imp().sync_tokio_handle.replace(Some(handle));
     }
 
     async fn create_session_verification(&self) {
-        let priv_ = imp::Session::from_instance(self);
+        let stack = &self.imp().stack;
 
         let widget = SessionVerification::new(self);
-        priv_.stack.add_named(&widget, Some("session-verification"));
-        priv_.stack.set_visible_child(&widget);
+        stack.add_named(&widget, Some("session-verification"));
+        stack.set_visible_child(&widget);
     }
 
     fn mark_ready(&self) {
-        let priv_ = imp::Session::from_instance(self);
         let client = self.client();
         let user_id = self.user().unwrap().user_id();
 
-        priv_.is_ready.set(true);
+        self.imp().is_ready.set(true);
 
         let has_cross_signing_keys = spawn_tokio!(async move {
             if let Some(cross_signing_status) = client.cross_signing_status().await {
@@ -529,7 +522,7 @@ impl Session {
         });
 
         spawn!(clone!(@weak self as obj => async move {
-            let priv_ = imp::Session::from_instance(&obj);
+            let priv_ = obj.imp();
             if !has_cross_signing_keys.await.unwrap() {
                 if need_new_identity.await.unwrap() {
                     let client = obj.client();
@@ -552,8 +545,7 @@ impl Session {
     }
 
     fn is_ready(&self) -> bool {
-        let priv_ = &imp::Session::from_instance(self);
-        priv_.is_ready.get()
+        self.imp().is_ready.get()
     }
 
     pub fn room_list(&self) -> &RoomList {
@@ -565,20 +557,17 @@ impl Session {
     }
 
     pub fn item_list(&self) -> &ItemList {
-        let priv_ = &imp::Session::from_instance(self);
-        priv_
+        self.imp()
             .item_list
             .get_or_init(|| ItemList::new(&RoomList::new(self), &VerificationList::new(self)))
     }
 
     pub fn user(&self) -> Option<&User> {
-        let priv_ = &imp::Session::from_instance(self);
-        priv_.user.get()
+        self.imp().user.get()
     }
 
     pub fn client(&self) -> Client {
-        let priv_ = &imp::Session::from_instance(self);
-        priv_
+        self.imp()
             .client
             .borrow()
             .clone()
@@ -589,7 +578,6 @@ impl Session {
     fn create_new_sync_response_sender(
         &self,
     ) -> SyncSender<Result<SyncResponse, matrix_sdk::Error>> {
-        let priv_ = imp::Session::from_instance(self);
         let (sender, receiver) = glib::MainContext::sync_channel::<
             Result<SyncResponse, matrix_sdk::Error>,
         >(Default::default(), 100);
@@ -602,7 +590,7 @@ impl Session {
             }),
         );
 
-        priv_.source_id.replace(Some(source_id));
+        self.imp().source_id.replace(Some(source_id));
 
         sender
     }
@@ -669,8 +657,7 @@ impl Session {
     }
 
     pub fn set_logged_in_users(&self, sessions_stack_pages: &SelectionModel) {
-        let priv_ = &imp::Session::from_instance(self);
-        priv_
+        self.imp()
             .sidebar
             .set_logged_in_users(sessions_stack_pages, self);
     }
@@ -693,14 +680,14 @@ impl Session {
     }
 
     pub async fn logout(&self) {
-        let priv_ = imp::Session::from_instance(self);
+        let stack = &self.imp().stack;
         self.emit_by_name::<()>("logged-out", &[]);
 
         debug!("The session is about to be logout");
 
         // First stop the verification in progress
-        if let Some(session_verificiation) = priv_.stack.child_by_name("session-verification") {
-            priv_.stack.remove(&session_verificiation);
+        if let Some(session_verificiation) = stack.child_by_name("session-verification") {
+            stack.remove(&session_verificiation);
         }
 
         let client = self.client();
@@ -726,7 +713,7 @@ impl Session {
     }
 
     fn cleanup_session(&self) {
-        let priv_ = imp::Session::from_instance(self);
+        let priv_ = self.imp();
         let info = priv_.info.get().unwrap();
 
         priv_.is_ready.set(false);
@@ -755,7 +742,7 @@ impl Session {
 
     /// Show the content of the session
     pub fn show_content(&self) {
-        let priv_ = imp::Session::from_instance(self);
+        let priv_ = self.imp();
 
         // FIXME: we should actually check if we have now the keys
         priv_.stack.set_visible_child(&*priv_.content);
@@ -770,7 +757,7 @@ impl Session {
 
     /// Show a media event
     pub fn show_media(&self, event: &Event) {
-        let priv_ = imp::Session::from_instance(self);
+        let priv_ = self.imp();
         priv_.media_viewer.set_event(Some(event.clone()));
 
         priv_.stack.set_visible_child(&*priv_.media_viewer);
diff --git a/src/session/room/event.rs b/src/session/room/event.rs
index e2a10d52..466c7d3d 100644
--- a/src/session/room/event.rs
+++ b/src/session/room/event.rs
@@ -193,25 +193,22 @@ impl Event {
     }
 
     pub fn room(&self) -> Room {
-        let priv_ = imp::Event::from_instance(self);
-        priv_.room.get().unwrap().upgrade().unwrap()
+        self.imp().room.get().unwrap().upgrade().unwrap()
     }
 
     /// Get the matrix event
     ///
     /// If the `SyncRoomEvent` couldn't be deserialized this is `None`
     pub fn matrix_event(&self) -> Option<AnySyncRoomEvent> {
-        let priv_ = imp::Event::from_instance(self);
-        priv_.event.borrow().clone()
+        self.imp().event.borrow().clone()
     }
 
     pub fn matrix_pure_event(&self) -> SyncRoomEvent {
-        let priv_ = imp::Event::from_instance(self);
-        priv_.pure_event.borrow().clone().unwrap()
+        self.imp().pure_event.borrow().clone().unwrap()
     }
 
     pub fn set_matrix_pure_event(&self, event: SyncRoomEvent) {
-        let priv_ = imp::Event::from_instance(self);
+        let priv_ = self.imp();
 
         if let Ok(deserialized) = event.event.deserialize() {
             priv_.event.replace(Some(deserialized));
@@ -226,7 +223,7 @@ impl Event {
     }
 
     pub fn matrix_sender(&self) -> Arc<UserId> {
-        let priv_ = imp::Event::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(event) = priv_.event.borrow().as_ref() {
             event.sender().into()
@@ -244,7 +241,7 @@ impl Event {
     }
 
     pub fn matrix_event_id(&self) -> Box<EventId> {
-        let priv_ = imp::Event::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(event) = priv_.event.borrow().as_ref() {
             event.event_id().to_owned()
@@ -262,9 +259,7 @@ impl Event {
     }
 
     pub fn matrix_transaction_id(&self) -> Option<String> {
-        let priv_ = imp::Event::from_instance(self);
-
-        priv_
+        self.imp()
             .pure_event
             .borrow()
             .as_ref()
@@ -278,12 +273,10 @@ impl Event {
 
     /// The pretty-formatted JSON of this matrix event.
     pub fn original_source(&self) -> String {
-        let priv_ = imp::Event::from_instance(self);
-
         // We have to convert it to a Value, because a RawValue cannot be
         // pretty-printed.
         let json: serde_json::Value = serde_json::from_str(
-            priv_
+            self.imp()
                 .pure_event
                 .borrow()
                 .as_ref()
@@ -308,8 +301,7 @@ impl Event {
     }
 
     pub fn timestamp(&self) -> DateTime {
-        let priv_ = imp::Event::from_instance(self);
-
+        let priv_ = self.imp();
         let ts = if let Some(event) = priv_.event.borrow().as_ref() {
             event.origin_server_ts().as_secs()
         } else {
@@ -347,9 +339,7 @@ impl Event {
 
     /// Find the related event if any
     pub fn related_matrix_event(&self) -> Option<Box<EventId>> {
-        let priv_ = imp::Event::from_instance(self);
-
-        match priv_.event.borrow().as_ref()? {
+        match self.imp().event.borrow().as_ref()? {
             AnySyncRoomEvent::Message(ref message) => match message {
                 AnySyncMessageEvent::RoomRedaction(event) => Some(event.redacts.clone()),
                 _ => match message.content() {
@@ -375,7 +365,7 @@ impl Event {
     /// Whether this event is hidden from the user or displayed in the room
     /// history.
     pub fn is_hidden_event(&self) -> bool {
-        let priv_ = imp::Event::from_instance(self);
+        let priv_ = self.imp();
 
         if self.related_matrix_event().is_some() {
             if let Some(AnySyncRoomEvent::Message(message)) = priv_.event.borrow().as_ref() {
@@ -466,7 +456,7 @@ impl Event {
     }
 
     pub fn set_show_header(&self, visible: bool) {
-        let priv_ = imp::Event::from_instance(self);
+        let priv_ = self.imp();
         if priv_.show_header.get() == visible {
             return;
         }
@@ -475,9 +465,7 @@ impl Event {
     }
 
     pub fn show_header(&self) -> bool {
-        let priv_ = imp::Event::from_instance(self);
-
-        priv_.show_header.get()
+        self.imp().show_header.get()
     }
 
     /// The content of this message.
@@ -526,12 +514,11 @@ impl Event {
     }
 
     pub fn prepend_replacing_events(&self, events: Vec<Event>) {
-        let priv_ = imp::Event::from_instance(self);
-        priv_.replacing_events.borrow_mut().splice(..0, events);
+        self.imp().replacing_events.borrow_mut().splice(..0, events);
     }
 
     pub fn append_replacing_events(&self, events: Vec<Event>) {
-        let priv_ = imp::Event::from_instance(self);
+        let priv_ = self.imp();
         let old_replacement = self.replacement();
 
         priv_.replacing_events.borrow_mut().extend(events);
@@ -563,8 +550,7 @@ impl Event {
     }
 
     pub fn replacing_events(&self) -> Vec<Event> {
-        let priv_ = imp::Event::from_instance(self);
-        priv_.replacing_events.borrow().clone()
+        self.imp().replacing_events.borrow().clone()
     }
 
     /// The `Event` that replaces this one, if any.
@@ -603,14 +589,12 @@ impl Event {
 
     /// The reactions for this event.
     pub fn reactions(&self) -> &ReactionList {
-        let priv_ = imp::Event::from_instance(self);
-        &priv_.reactions
+        &self.imp().reactions
     }
 
     /// Add reactions to this event.
     pub fn add_reactions(&self, reactions: Vec<Event>) {
-        let priv_ = imp::Event::from_instance(self);
-        priv_.reactions.add_reactions(reactions);
+        self.imp().reactions.add_reactions(reactions);
     }
 
     /// The content of this matrix event.
diff --git a/src/session/room/item.rs b/src/session/room/item.rs
index 36a50d92..37285a60 100644
--- a/src/session/room/item.rs
+++ b/src/session/room/item.rs
@@ -168,8 +168,7 @@ impl Item {
     }
 
     pub fn matrix_event(&self) -> Option<AnySyncRoomEvent> {
-        let priv_ = imp::Item::from_instance(self);
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             event.matrix_event()
         } else {
             None
@@ -177,8 +176,7 @@ impl Item {
     }
 
     pub fn event(&self) -> Option<&Event> {
-        let priv_ = imp::Item::from_instance(self);
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             Some(event)
         } else {
             None
@@ -186,8 +184,7 @@ impl Item {
     }
 
     pub fn matrix_sender(&self) -> Option<Arc<UserId>> {
-        let priv_ = imp::Item::from_instance(self);
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             Some(event.matrix_sender())
         } else {
             None
@@ -195,9 +192,7 @@ impl Item {
     }
 
     pub fn matrix_event_id(&self) -> Option<Box<EventId>> {
-        let priv_ = imp::Item::from_instance(self);
-
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             Some(event.matrix_event_id())
         } else {
             None
@@ -205,9 +200,7 @@ impl Item {
     }
 
     pub fn event_timestamp(&self) -> Option<DateTime> {
-        let priv_ = imp::Item::from_instance(self);
-
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             Some(event.timestamp())
         } else {
             None
@@ -215,12 +208,11 @@ impl Item {
     }
 
     pub fn set_show_header(&self, visible: bool) {
-        let priv_ = imp::Item::from_instance(self);
         if self.show_header() == visible {
             return;
         }
 
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             event.set_show_header(visible);
         }
 
@@ -228,9 +220,7 @@ impl Item {
     }
 
     pub fn show_header(&self) -> bool {
-        let priv_ = imp::Item::from_instance(self);
-
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             event.show_header()
         } else {
             false
@@ -238,9 +228,7 @@ impl Item {
     }
 
     pub fn can_hide_header(&self) -> bool {
-        let priv_ = imp::Item::from_instance(self);
-
-        if let ItemType::Event(event) = priv_.type_.get().unwrap() {
+        if let ItemType::Event(event) = self.imp().type_.get().unwrap() {
             event.can_hide_header()
         } else {
             false
@@ -248,8 +236,7 @@ impl Item {
     }
 
     pub fn type_(&self) -> &ItemType {
-        let priv_ = imp::Item::from_instance(self);
-        priv_.type_.get().unwrap()
+        self.imp().type_.get().unwrap()
     }
 
     pub fn connect_show_header_notify<F: Fn(&Self, &glib::ParamSpec) + 'static>(
diff --git a/src/session/room/member.rs b/src/session/room/member.rs
index c65eaedd..90ea62b2 100644
--- a/src/session/room/member.rs
+++ b/src/session/room/member.rs
@@ -76,16 +76,14 @@ impl Member {
     }
 
     pub fn power_level(&self) -> PowerLevel {
-        let priv_ = imp::Member::from_instance(self);
-        priv_.power_level.get()
+        self.imp().power_level.get()
     }
 
     fn set_power_level(&self, power_level: PowerLevel) {
         if self.power_level() == power_level {
             return;
         }
-        let priv_ = imp::Member::from_instance(self);
-        priv_.power_level.replace(power_level);
+        self.imp().power_level.replace(power_level);
         self.notify("power-level");
     }
 
diff --git a/src/session/room/member_list.rs b/src/session/room/member_list.rs
index 1fc95380..88afd8fd 100644
--- a/src/session/room/member_list.rs
+++ b/src/session/room/member_list.rs
@@ -98,8 +98,7 @@ impl MemberList {
     }
 
     pub fn room(&self) -> Room {
-        let priv_ = imp::MemberList::from_instance(self);
-        priv_.room.get().unwrap().upgrade().unwrap()
+        self.imp().room.get().unwrap().upgrade().unwrap()
     }
 
     /// Updates members with the given RoomMember values.
@@ -107,7 +106,7 @@ impl MemberList {
     /// If some of the values do not correspond to existing members, new members
     /// are created.
     pub fn update_from_room_members(&self, new_members: &[matrix_sdk::RoomMember]) {
-        let mut members = imp::MemberList::from_instance(self).members.borrow_mut();
+        let mut members = self.imp().members.borrow_mut();
         let prev_len = members.len();
         for member in new_members {
             members
@@ -130,7 +129,7 @@ impl MemberList {
     ///
     /// Creates a new member first if there is no member with the given ID.
     pub fn member_by_id(&self, user_id: Arc<UserId>) -> Member {
-        let mut members = imp::MemberList::from_instance(self).members.borrow_mut();
+        let mut members = self.imp().members.borrow_mut();
         let mut was_member_added = false;
         let prev_len = members.len();
         let member = members
@@ -163,8 +162,6 @@ impl MemberList {
 
     /// Returns whether the given user id is present in `MemberList`
     pub fn contains(&self, user_id: &UserId) -> bool {
-        let priv_ = imp::MemberList::from_instance(self);
-
-        priv_.members.borrow().contains_key(user_id)
+        self.imp().members.borrow().contains_key(user_id)
     }
 }
diff --git a/src/session/room/mod.rs b/src/session/room/mod.rs
index 400bdde1..c3733b85 100644
--- a/src/session/room/mod.rs
+++ b/src/session/room/mod.rs
@@ -336,23 +336,20 @@ impl Room {
     }
 
     pub fn session(&self) -> Session {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     pub fn room_id(&self) -> &RoomId {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.room_id.get().unwrap()
+        self.imp().room_id.get().unwrap()
     }
 
     fn matrix_room(&self) -> MatrixRoom {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.matrix_room.borrow().as_ref().unwrap().clone()
+        self.imp().matrix_room.borrow().as_ref().unwrap().clone()
     }
 
     /// Set the new sdk room struct represented by this `Room`
     fn set_matrix_room(&self, matrix_room: MatrixRoom) {
-        let priv_ = imp::Room::from_instance(self);
+        let priv_ = self.imp();
 
         // Check if the previous type was different
         if let Some(ref old_matrix_room) = *priv_.matrix_room.borrow() {
@@ -427,18 +424,15 @@ impl Room {
     }
 
     pub fn category(&self) -> RoomType {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.category.get()
+        self.imp().category.get()
     }
 
     fn set_category_internal(&self, category: RoomType) {
-        let priv_ = imp::Room::from_instance(self);
-
         if self.category() == category {
             return;
         }
 
-        priv_.category.set(category);
+        self.imp().category.set(category);
         self.notify("category");
         self.emit_by_name::<()>("order-changed", &[]);
     }
@@ -618,13 +612,11 @@ impl Room {
     }
 
     pub fn timeline(&self) -> &Timeline {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.timeline.get().unwrap()
+        self.imp().timeline.get().unwrap()
     }
 
     pub fn members(&self) -> &MemberList {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.members.get().unwrap()
+        self.imp().members.get().unwrap()
     }
 
     fn notify_notification_count(&self) {
@@ -633,8 +625,8 @@ impl Room {
     }
 
     pub fn highlight(&self) -> HighlightFlags {
-        let priv_ = imp::Room::from_instance(self);
-        let count = priv_
+        let count = self
+            .imp()
             .matrix_room
             .borrow()
             .as_ref()
@@ -651,19 +643,16 @@ impl Room {
     }
 
     pub fn display_name(&self) -> String {
-        let priv_ = imp::Room::from_instance(self);
-        let display_name = priv_.name.borrow().clone();
+        let display_name = self.imp().name.borrow().clone();
         display_name.unwrap_or_else(|| gettext("Unknown"))
     }
 
     fn set_display_name(&self, display_name: Option<String>) {
-        let priv_ = imp::Room::from_instance(self);
-
         if Some(self.display_name()) == display_name {
             return;
         }
 
-        priv_.name.replace(display_name);
+        self.imp().name.replace(display_name);
         self.notify("display-name");
     }
 
@@ -722,8 +711,7 @@ impl Room {
     }
 
     pub fn avatar(&self) -> &Avatar {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.avatar.get().unwrap()
+        self.imp().avatar.get().unwrap()
     }
 
     pub fn topic(&self) -> Option<String> {
@@ -763,20 +751,17 @@ impl Room {
     }
 
     pub fn power_levels(&self) -> PowerLevels {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.power_levels.borrow().clone()
+        self.imp().power_levels.borrow().clone()
     }
 
     pub fn inviter(&self) -> Option<Member> {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.inviter.borrow().clone()
+        self.imp().inviter.borrow().clone()
     }
 
     /// Handle stripped state events.
     ///
     /// Events passed to this function aren't added to the timeline.
     pub fn handle_invite_events(&self, events: Vec<AnyStrippedStateEvent>) {
-        let priv_ = imp::Room::from_instance(self);
         let invite_event = events
             .iter()
             .find(|event| {
@@ -804,13 +789,13 @@ impl Room {
             inviter.update_from_member_event(event);
         }
 
-        priv_.inviter.replace(Some(inviter));
+        self.imp().inviter.replace(Some(inviter));
         self.notify("inviter");
     }
 
     /// Add new events to the timeline
     pub fn append_events(&self, batch: Vec<Event>) {
-        let priv_ = imp::Room::from_instance(self);
+        let priv_ = self.imp();
 
         // FIXME: notify only when the count has changed
         self.notify_notification_count();
@@ -855,12 +840,11 @@ impl Room {
 
     /// Returns the point in time this room received its latest event.
     pub fn latest_change(&self) -> Option<glib::DateTime> {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.latest_change.borrow().clone()
+        self.imp().latest_change.borrow().clone()
     }
 
     pub fn load_members(&self) {
-        let priv_ = imp::Room::from_instance(self);
+        let priv_ = self.imp();
         if priv_.members_loaded.get() {
             return;
         }
@@ -872,7 +856,7 @@ impl Room {
             glib::PRIORITY_LOW,
             clone!(@weak self as obj => async move {
                 // FIXME: We should retry to load the room members if the request failed
-                let priv_ = imp::Room::from_instance(&obj);
+                let priv_ = obj.imp();
                 match handle.await.unwrap() {
                     Ok(members) => {
                         // Add all members needed to display room events.
@@ -924,15 +908,17 @@ impl Room {
 
     /// Send the given `event` in this room, with the temporary ID `txn_id`.
     fn send_room_message_event(&self, event: AnySyncMessageEvent, txn_id: Uuid) {
-        let priv_ = imp::Room::from_instance(self);
-
         if let MatrixRoom::Joined(matrix_room) = self.matrix_room() {
             let content = event.content();
             let json = serde_json::to_string(&AnySyncRoomEvent::Message(event)).unwrap();
             let raw_event: Raw<AnySyncRoomEvent> =
                 Raw::from_json(RawValue::from_string(json).unwrap());
             let event = Event::new(raw_event.into(), self);
-            priv_.timeline.get().unwrap().append_pending(txn_id, event);
+            self.imp()
+                .timeline
+                .get()
+                .unwrap()
+                .append_pending(txn_id, event);
 
             let handle = spawn_tokio!(async move { matrix_room.send(content, Some(txn_id)).await });
 
@@ -994,13 +980,16 @@ impl Room {
             unsigned: Unsigned::default(),
         });
 
-        let priv_ = imp::Room::from_instance(self);
         if let MatrixRoom::Joined(matrix_room) = self.matrix_room() {
             let json = serde_json::to_string(&AnySyncRoomEvent::Message(event)).unwrap();
             let raw_event: Raw<AnySyncRoomEvent> =
                 Raw::from_json(RawValue::from_string(json).unwrap());
             let event = Event::new(raw_event.into(), self);
-            priv_.timeline.get().unwrap().append_pending(txn_id, event);
+            self.imp()
+                .timeline
+                .get()
+                .unwrap()
+                .append_pending(txn_id, event);
 
             let handle = spawn_tokio!(async move {
                 matrix_room
@@ -1185,12 +1174,11 @@ impl Room {
     }
 
     pub fn predecessor(&self) -> Option<&RoomId> {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.predecessor.get().map(std::ops::Deref::deref)
+        self.imp().predecessor.get().map(std::ops::Deref::deref)
     }
 
     fn load_predecessor(&self) -> Option<()> {
-        let priv_ = imp::Room::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.predecessor.get().is_some() {
             return None;
@@ -1205,12 +1193,11 @@ impl Room {
     }
 
     pub fn successor(&self) -> Option<&RoomId> {
-        let priv_ = imp::Room::from_instance(self);
-        priv_.successor.get().map(std::ops::Deref::deref)
+        self.imp().successor.get().map(std::ops::Deref::deref)
     }
 
     pub fn load_successor(&self) -> Option<()> {
-        let priv_ = imp::Room::from_instance(self);
+        let priv_ = self.imp();
 
         if priv_.successor.get().is_some() {
             return None;
diff --git a/src/session/room/power_levels.rs b/src/session/room/power_levels.rs
index d8318266..684e1e85 100644
--- a/src/session/room/power_levels.rs
+++ b/src/session/room/power_levels.rs
@@ -70,14 +70,12 @@ impl PowerLevels {
     }
 
     pub fn power_levels(&self) -> BoxedPowerLevelsEventContent {
-        let priv_ = imp::PowerLevels::from_instance(self);
-        priv_.content.borrow().clone()
+        self.imp().content.borrow().clone()
     }
 
     /// Returns the power level minimally required to perform the given action.
     pub fn min_level_for_room_action(&self, room_action: &RoomAction) -> PowerLevel {
-        let priv_ = imp::PowerLevels::from_instance(self);
-        let content = priv_.content.borrow();
+        let content = self.imp().content.borrow();
         min_level_for_room_action(&content.0, room_action)
     }
 
@@ -103,9 +101,8 @@ impl PowerLevels {
 
     /// Updates the power levels from the given event.
     pub fn update_from_event(&self, event: SyncStateEvent<RoomPowerLevelsEventContent>) {
-        let priv_ = imp::PowerLevels::from_instance(self);
         let content = BoxedPowerLevelsEventContent(event.content);
-        priv_.content.replace(content);
+        self.imp().content.replace(content);
         self.notify("power-levels");
     }
 }
diff --git a/src/session/room/reaction_group.rs b/src/session/room/reaction_group.rs
index 8b207440..00cdae9b 100644
--- a/src/session/room/reaction_group.rs
+++ b/src/session/room/reaction_group.rs
@@ -96,13 +96,11 @@ impl ReactionGroup {
     }
 
     pub fn key(&self) -> &str {
-        let priv_ = imp::ReactionGroup::from_instance(self);
-        priv_.key.get().unwrap()
+        self.imp().key.get().unwrap()
     }
 
     pub fn count(&self) -> u32 {
-        let priv_ = imp::ReactionGroup::from_instance(self);
-        priv_
+        self.imp()
             .reactions
             .borrow()
             .iter()
@@ -112,8 +110,7 @@ impl ReactionGroup {
 
     /// The reaction in this group sent by this user, if any.
     pub fn user_reaction(&self) -> Option<Event> {
-        let priv_ = imp::ReactionGroup::from_instance(self);
-        let reactions = priv_.reactions.borrow();
+        let reactions = self.imp().reactions.borrow();
         if let Some(user) = reactions
             .first()
             .and_then(|event| event.room().session().user().cloned())
@@ -138,9 +135,7 @@ impl ReactionGroup {
         let mut added_reactions = Vec::with_capacity(new_reactions.len());
 
         {
-            let mut reactions = imp::ReactionGroup::from_instance(self)
-                .reactions
-                .borrow_mut();
+            let mut reactions = self.imp().reactions.borrow_mut();
 
             reactions.reserve(new_reactions.len());
 
diff --git a/src/session/room/reaction_list.rs b/src/session/room/reaction_list.rs
index 02654025..bff36dd9 100644
--- a/src/session/room/reaction_list.rs
+++ b/src/session/room/reaction_list.rs
@@ -62,9 +62,7 @@ impl ReactionList {
     ///
     /// Ignores `Event`s that are not reactions.
     pub fn add_reactions(&self, new_reactions: Vec<Event>) {
-        let mut reactions = imp::ReactionList::from_instance(self)
-            .reactions
-            .borrow_mut();
+        let mut reactions = self.imp().reactions.borrow_mut();
         let prev_len = reactions.len();
 
         // Group reactions by key
@@ -114,14 +112,17 @@ impl ReactionList {
     ///
     /// Returns `None` if no action group was found with this key.
     pub fn reaction_group_by_key(&self, key: &str) -> Option<ReactionGroup> {
-        let priv_ = imp::ReactionList::from_instance(self);
-        priv_.reactions.borrow().get(key).cloned()
+        self.imp().reactions.borrow().get(key).cloned()
     }
 
     /// Remove a reaction group by its key.
     pub fn remove_reaction_group(&self, key: &str) {
-        let priv_ = imp::ReactionList::from_instance(self);
-        let (pos, ..) = priv_.reactions.borrow_mut().shift_remove_full(key).unwrap();
+        let (pos, ..) = self
+            .imp()
+            .reactions
+            .borrow_mut()
+            .shift_remove_full(key)
+            .unwrap();
         self.items_changed(pos as u32, 1, 0);
     }
 }
diff --git a/src/session/room/timeline.rs b/src/session/room/timeline.rs
index be132702..8f0acfc5 100644
--- a/src/session/room/timeline.rs
+++ b/src/session/room/timeline.rs
@@ -172,7 +172,7 @@ impl Timeline {
     }
 
     fn items_changed(&self, position: u32, removed: u32, added: u32) {
-        let priv_ = imp::Timeline::from_instance(self);
+        let priv_ = self.imp();
 
         let last_new_message_date;
 
@@ -323,9 +323,7 @@ impl Timeline {
     }
 
     fn add_hidden_events(&self, events: Vec<Event>, at_front: bool) {
-        let priv_ = imp::Timeline::from_instance(self);
-
-        let mut relates_to_events = priv_.relates_to_events.borrow_mut();
+        let mut relates_to_events = self.imp().relates_to_events.borrow_mut();
 
         // Group events by related event
         let mut new_relations: HashMap<Box<EventId>, Vec<Event>> = HashMap::new();
@@ -419,7 +417,7 @@ impl Timeline {
     /// Append the new events
     // TODO: This should be lazy, for inspiration see: 
https://blogs.gnome.org/ebassi/documentation/lazy-loading/
     pub fn append(&self, batch: Vec<Event>) {
-        let priv_ = imp::Timeline::from_instance(self);
+        let priv_ = self.imp();
 
         if batch.is_empty() {
             return;
@@ -485,7 +483,7 @@ impl Timeline {
 
     /// Append an event that wasn't yet fully sent and received via a sync
     pub fn append_pending(&self, txn_id: Uuid, event: Event) {
-        let priv_ = imp::Timeline::from_instance(self);
+        let priv_ = self.imp();
 
         priv_
             .event_map
@@ -520,8 +518,7 @@ impl Timeline {
     /// Use this method if you are sure the event has already been received.
     /// Otherwise use `fetch_event_by_id`.
     pub fn event_by_id(&self, event_id: &EventId) -> Option<Event> {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_.event_map.borrow().get(event_id).cloned()
+        self.imp().event_map.borrow().get(event_id).cloned()
     }
 
     /// Fetch the event with the given id.
@@ -554,7 +551,7 @@ impl Timeline {
     /// Prepends a batch of events
     // TODO: This should be lazy, see: https://blogs.gnome.org/ebassi/documentation/lazy-loading/
     pub fn prepend(&self, batch: Vec<Event>) {
-        let priv_ = imp::Timeline::from_instance(self);
+        let priv_ = self.imp();
         let mut added = batch.len();
 
         priv_
@@ -589,17 +586,15 @@ impl Timeline {
     }
 
     fn set_room(&self, room: Room) {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_.room.set(room.downgrade()).unwrap();
+        self.imp().room.set(room.downgrade()).unwrap();
     }
 
     pub fn room(&self) -> Room {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_.room.get().unwrap().upgrade().unwrap()
+        self.imp().room.get().unwrap().upgrade().unwrap()
     }
 
     fn set_loading(&self, loading: bool) {
-        let priv_ = imp::Timeline::from_instance(self);
+        let priv_ = self.imp();
 
         if loading == priv_.loading.get() {
             return;
@@ -611,7 +606,7 @@ impl Timeline {
     }
 
     fn set_complete(&self, complete: bool) {
-        let priv_ = imp::Timeline::from_instance(self);
+        let priv_ = self.imp();
 
         if complete == priv_.complete.get() {
             return;
@@ -623,27 +618,23 @@ impl Timeline {
 
     // Whether the timeline is fully loaded
     pub fn is_complete(&self) -> bool {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_.complete.get()
+        self.imp().complete.get()
     }
 
     pub fn loading(&self) -> bool {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_.loading.get()
+        self.imp().loading.get()
     }
 
     pub fn is_empty(&self) -> bool {
-        let priv_ = imp::Timeline::from_instance(self);
+        let priv_ = self.imp();
         priv_.list.borrow().is_empty() || (priv_.list.borrow().len() == 1 && self.loading())
     }
 
     fn oldest_event(&self) -> Option<Box<EventId>> {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_.oldest_event.borrow().clone()
+        self.imp().oldest_event.borrow().clone()
     }
     fn add_loading_spinner(&self) {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_
+        self.imp()
             .list
             .borrow_mut()
             .push_front(Item::for_loading_spinner());
@@ -651,8 +642,7 @@ impl Timeline {
     }
 
     fn remove_loading_spinner(&self) {
-        let priv_ = imp::Timeline::from_instance(self);
-        priv_.list.borrow_mut().pop_front();
+        self.imp().list.borrow_mut().pop_front();
         self.upcast_ref::<gio::ListModel>().items_changed(0, 1, 0);
     }
 
@@ -707,16 +697,12 @@ impl Timeline {
     }
 
     fn set_verification(&self, verification: IdentityVerification) {
-        let priv_ = imp::Timeline::from_instance(self);
-
-        priv_.verification.replace(Some(verification));
+        self.imp().verification.replace(Some(verification));
         self.notify("verification");
     }
 
     pub fn verification(&self) -> Option<IdentityVerification> {
-        let priv_ = imp::Timeline::from_instance(self);
-
-        priv_.verification.borrow().clone()
+        self.imp().verification.borrow().clone()
     }
 
     fn handle_verification(&self, event: &Event) {
diff --git a/src/session/room_creation/mod.rs b/src/session/room_creation/mod.rs
index 752200cc..5bbab830 100644
--- a/src/session/room_creation/mod.rs
+++ b/src/session/room_creation/mod.rs
@@ -172,8 +172,7 @@ impl RoomCreation {
     }
 
     pub fn session(&self) -> Option<Session> {
-        let priv_ = imp::RoomCreation::from_instance(self);
-        priv_
+        self.imp()
             .session
             .borrow()
             .as_ref()
@@ -181,7 +180,7 @@ impl RoomCreation {
     }
 
     fn set_session(&self, session: Option<Session>) {
-        let priv_ = imp::RoomCreation::from_instance(self);
+        let priv_ = self.imp();
 
         if self.session() == session {
             return;
@@ -200,7 +199,7 @@ impl RoomCreation {
     }
 
     fn create_room(&self) -> Option<()> {
-        let priv_ = imp::RoomCreation::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.create_button.set_loading(true);
         priv_.content.set_sensitive(false);
@@ -260,7 +259,7 @@ impl RoomCreation {
 
     /// Display the error that occurred during creation
     fn handle_error(&self, error: HttpError) {
-        let priv_ = imp::RoomCreation::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.create_button.set_loading(false);
         priv_.content.set_sensitive(true);
@@ -288,7 +287,7 @@ impl RoomCreation {
     }
 
     fn validate_input(&self) {
-        let priv_ = imp::RoomCreation::from_instance(self);
+        let priv_ = self.imp();
 
         // Validate room name
         let (is_name_valid, has_error) =
@@ -362,9 +361,7 @@ impl RoomCreation {
     }
 
     fn cancel(&self) {
-        let priv_ = imp::RoomCreation::from_instance(self);
-
-        if priv_.cancel_button.is_sensitive() {
+        if self.imp().cancel_button.is_sensitive() {
             self.close();
         }
     }
diff --git a/src/session/room_list.rs b/src/session/room_list.rs
index 6fbb07db..5aaac3bc 100644
--- a/src/session/room_list.rs
+++ b/src/session/room_list.rs
@@ -123,31 +123,26 @@ impl RoomList {
     }
 
     pub fn session(&self) -> Session {
-        let priv_ = imp::RoomList::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     pub fn is_pending_room(&self, identifier: &RoomOrAliasId) -> bool {
-        let priv_ = imp::RoomList::from_instance(self);
-        priv_.pending_rooms.borrow().contains(identifier)
+        self.imp().pending_rooms.borrow().contains(identifier)
     }
 
     fn pending_rooms_remove(&self, identifier: &RoomOrAliasId) {
-        let priv_ = imp::RoomList::from_instance(self);
-        priv_.pending_rooms.borrow_mut().remove(identifier);
+        self.imp().pending_rooms.borrow_mut().remove(identifier);
         self.emit_by_name::<()>("pending-rooms-changed", &[]);
     }
 
     fn pending_rooms_insert(&self, identifier: Box<RoomOrAliasId>) {
-        let priv_ = imp::RoomList::from_instance(self);
-        priv_.pending_rooms.borrow_mut().insert(identifier);
+        self.imp().pending_rooms.borrow_mut().insert(identifier);
         self.emit_by_name::<()>("pending-rooms-changed", &[]);
     }
 
     fn pending_rooms_replace_or_remove(&self, identifier: &RoomOrAliasId, room_id: &RoomId) {
-        let priv_ = imp::RoomList::from_instance(self);
         {
-            let mut pending_rooms = priv_.pending_rooms.borrow_mut();
+            let mut pending_rooms = self.imp().pending_rooms.borrow_mut();
             pending_rooms.remove(identifier);
             if !self.contains_key(room_id) {
                 pending_rooms.insert(room_id.to_owned().into());
@@ -157,14 +152,12 @@ impl RoomList {
     }
 
     pub fn get(&self, room_id: &RoomId) -> Option<Room> {
-        let priv_ = imp::RoomList::from_instance(self);
-        priv_.list.borrow().get(room_id).cloned()
+        self.imp().list.borrow().get(room_id).cloned()
     }
 
     /// Waits till the Room becomes available
     pub async fn get_wait(&self, room_id: Box<RoomId>) -> Option<Room> {
-        let priv_ = imp::RoomList::from_instance(self);
-        if let Some(room) = priv_.list.borrow().get(&*room_id) {
+        if let Some(room) = self.imp().list.borrow().get(&*room_id) {
             Some(room.clone())
         } else {
             let (sender, receiver) = futures::channel::oneshot::channel();
@@ -186,8 +179,7 @@ impl RoomList {
     }
 
     fn get_full(&self, room_id: &RoomId) -> Option<(usize, Box<RoomId>, Room)> {
-        let priv_ = imp::RoomList::from_instance(self);
-        priv_
+        self.imp()
             .list
             .borrow()
             .get_full(room_id)
@@ -195,15 +187,12 @@ impl RoomList {
     }
 
     pub fn contains_key(&self, room_id: &RoomId) -> bool {
-        let priv_ = imp::RoomList::from_instance(self);
-        priv_.list.borrow().contains_key(room_id)
+        self.imp().list.borrow().contains_key(room_id)
     }
 
     pub fn remove(&self, room_id: &RoomId) {
-        let priv_ = imp::RoomList::from_instance(self);
-
         let removed = {
-            let mut list = priv_.list.borrow_mut();
+            let mut list = self.imp().list.borrow_mut();
 
             list.shift_remove_full(room_id)
         };
@@ -214,9 +203,7 @@ impl RoomList {
     }
 
     fn items_added(&self, added: usize) {
-        let priv_ = imp::RoomList::from_instance(self);
-
-        let list = priv_.list.borrow();
+        let list = self.imp().list.borrow();
 
         let position = list.len() - added;
 
@@ -239,7 +226,6 @@ impl RoomList {
     /// Note that the `Store` currently doesn't store all events, therefore, we
     /// aren't really loading much via this function.
     pub fn load(&self) {
-        let priv_ = imp::RoomList::from_instance(self);
         let session = self.session();
         let client = session.client();
         let matrix_rooms = client.rooms();
@@ -247,7 +233,7 @@ impl RoomList {
 
         if added > 0 {
             {
-                let mut list = priv_.list.borrow_mut();
+                let mut list = self.imp().list.borrow_mut();
                 for matrix_room in matrix_rooms {
                     let room_id = matrix_room.room_id().to_owned();
                     let room = Room::new(&session, &room_id);
@@ -260,7 +246,7 @@ impl RoomList {
     }
 
     pub fn handle_response_rooms(&self, rooms: ResponseRooms) {
-        let priv_ = imp::RoomList::from_instance(self);
+        let priv_ = self.imp();
         let session = self.session();
 
         let mut added = 0;
diff --git a/src/session/sidebar/account_switcher/avatar_with_selection.rs 
b/src/session/sidebar/account_switcher/avatar_with_selection.rs
index 8af94144..53917240 100644
--- a/src/session/sidebar/account_switcher/avatar_with_selection.rs
+++ b/src/session/sidebar/account_switcher/avatar_with_selection.rs
@@ -107,7 +107,7 @@ impl AvatarWithSelection {
     }
 
     pub fn set_selected(&self, selected: bool) {
-        let priv_ = imp::AvatarWithSelection::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.checkmark.set_visible(selected);
 
@@ -119,8 +119,7 @@ impl AvatarWithSelection {
     }
 
     pub fn avatar(&self) -> &Avatar {
-        let priv_ = imp::AvatarWithSelection::from_instance(self);
-        &priv_.child_avatar
+        &self.imp().child_avatar
     }
 }
 
diff --git a/src/session/sidebar/account_switcher/item.rs b/src/session/sidebar/account_switcher/item.rs
index ea845a89..d84b2c87 100644
--- a/src/session/sidebar/account_switcher/item.rs
+++ b/src/session/sidebar/account_switcher/item.rs
@@ -100,9 +100,7 @@ impl ExtraItemObj {
     }
 
     pub fn get(&self) -> ExtraItem {
-        let priv_ = imp::ExtraItemObj::from_instance(self);
-
-        priv_.0.get()
+        self.imp().0.get()
     }
 
     pub fn is_separator(&self) -> bool {
diff --git a/src/session/sidebar/account_switcher/mod.rs b/src/session/sidebar/account_switcher/mod.rs
index 56c13cfd..756d4a40 100644
--- a/src/session/sidebar/account_switcher/mod.rs
+++ b/src/session/sidebar/account_switcher/mod.rs
@@ -93,7 +93,7 @@ impl AccountSwitcher {
         sessions_stack_pages: &SelectionModel,
         session_root: &Session,
     ) {
-        let entries = imp::AccountSwitcher::from_instance(self).entries.get();
+        let entries = self.imp().entries.get();
 
         // There is no permanent stuff to take care of,
         // so only bind and unbind are connected.
diff --git a/src/session/sidebar/account_switcher/user_entry.rs 
b/src/session/sidebar/account_switcher/user_entry.rs
index f71494d4..6074c544 100644
--- a/src/session/sidebar/account_switcher/user_entry.rs
+++ b/src/session/sidebar/account_switcher/user_entry.rs
@@ -114,7 +114,7 @@ impl UserEntryRow {
     }
 
     pub fn set_hint(&self, hinted: bool) {
-        let priv_ = imp::UserEntryRow::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.account_avatar.set_selected(hinted);
         priv_
@@ -123,9 +123,8 @@ impl UserEntryRow {
     }
 
     pub fn show_account_settings(&self) {
-        let priv_ = imp::UserEntryRow::from_instance(self);
-
-        let session = priv_
+        let session = self
+            .imp()
             .session_page
             .borrow()
             .as_ref()
diff --git a/src/session/sidebar/category.rs b/src/session/sidebar/category.rs
index f64b141e..9483c0ca 100644
--- a/src/session/sidebar/category.rs
+++ b/src/session/sidebar/category.rs
@@ -122,12 +122,10 @@ impl Category {
     }
 
     pub fn type_(&self) -> CategoryType {
-        let priv_ = imp::Category::from_instance(self);
-        priv_.type_.get()
+        self.imp().type_.get()
     }
 
     fn set_model(&self, model: gio::ListModel) {
-        let priv_ = imp::Category::from_instance(self);
         let type_ = self.type_();
 
         // Special case room lists so that they are sorted and in the right category
@@ -158,21 +156,19 @@ impl Category {
         );
 
         self.set_is_empty(model.n_items() == 0);
-        priv_.model.set(model).unwrap();
+        self.imp().model.set(model).unwrap();
     }
 
     fn set_is_empty(&self, is_empty: bool) {
-        let priv_ = imp::Category::from_instance(self);
         if is_empty == self.is_empty() {
             return;
         }
 
-        priv_.is_empty.set(is_empty);
+        self.imp().is_empty.set(is_empty);
         self.notify("empty");
     }
 
     pub fn is_empty(&self) -> bool {
-        let priv_ = imp::Category::from_instance(self);
-        priv_.is_empty.get()
+        self.imp().is_empty.get()
     }
 }
diff --git a/src/session/sidebar/category_row.rs b/src/session/sidebar/category_row.rs
index 519d89e9..be7d33a1 100644
--- a/src/session/sidebar/category_row.rs
+++ b/src/session/sidebar/category_row.rs
@@ -120,30 +120,24 @@ impl CategoryRow {
     }
 
     pub fn category(&self) -> Option<Category> {
-        let priv_ = imp::CategoryRow::from_instance(self);
-        priv_.category.borrow().clone()
+        self.imp().category.borrow().clone()
     }
 
     pub fn set_category(&self, category: Option<Category>) {
-        let priv_ = imp::CategoryRow::from_instance(self);
-
         if self.category() == category {
             return;
         }
 
-        priv_.category.replace(category);
+        self.imp().category.replace(category);
         self.notify("category");
         self.notify("label");
     }
 
     fn expanded(&self) -> bool {
-        let priv_ = imp::CategoryRow::from_instance(self);
-        priv_.expanded.get()
+        self.imp().expanded.get()
     }
 
     fn set_expanded(&self, expanded: bool) {
-        let priv_ = imp::CategoryRow::from_instance(self);
-
         if self.expanded() == expanded {
             return;
         }
@@ -154,7 +148,7 @@ impl CategoryRow {
             self.unset_state_flags(gtk::StateFlags::CHECKED);
         }
 
-        priv_.expanded.set(expanded);
+        self.imp().expanded.set(expanded);
         self.notify("expanded");
     }
 
@@ -201,18 +195,15 @@ impl CategoryRow {
     }
 
     pub fn show_label_for_category(&self) -> CategoryType {
-        let priv_ = imp::CategoryRow::from_instance(self);
-        priv_.show_label_for_category.get()
+        self.imp().show_label_for_category.get()
     }
 
     pub fn set_show_label_for_category(&self, category: CategoryType) {
-        let priv_ = imp::CategoryRow::from_instance(self);
-
         if category == self.show_label_for_category() {
             return;
         }
 
-        priv_.show_label_for_category.set(category);
+        self.imp().show_label_for_category.set(category);
 
         self.notify("show-label-for-category");
         self.notify("label");
diff --git a/src/session/sidebar/entry.rs b/src/session/sidebar/entry.rs
index 8bb50f0f..d649c144 100644
--- a/src/session/sidebar/entry.rs
+++ b/src/session/sidebar/entry.rs
@@ -96,8 +96,7 @@ impl Entry {
     }
 
     pub fn type_(&self) -> EntryType {
-        let priv_ = imp::Entry::from_instance(self);
-        priv_.type_.get()
+        self.imp().type_.get()
     }
 
     pub fn icon_name(&self) -> Option<&str> {
diff --git a/src/session/sidebar/entry_row.rs b/src/session/sidebar/entry_row.rs
index 4af617ce..b957a1f4 100644
--- a/src/session/sidebar/entry_row.rs
+++ b/src/session/sidebar/entry_row.rs
@@ -83,18 +83,15 @@ impl EntryRow {
     }
 
     pub fn entry(&self) -> Option<Entry> {
-        let priv_ = imp::EntryRow::from_instance(self);
-        priv_.entry.borrow().clone()
+        self.imp().entry.borrow().clone()
     }
 
     pub fn set_entry(&self, entry: Option<Entry>) {
-        let priv_ = imp::EntryRow::from_instance(self);
-
         if self.entry() == entry {
             return;
         }
 
-        priv_.entry.replace(entry);
+        self.imp().entry.replace(entry);
         self.notify("entry");
     }
 }
diff --git a/src/session/sidebar/item_list.rs b/src/session/sidebar/item_list.rs
index 809ffbf1..77a5632b 100644
--- a/src/session/sidebar/item_list.rs
+++ b/src/session/sidebar/item_list.rs
@@ -186,7 +186,7 @@ impl ItemList {
     }
 
     fn update_item(&self, position: usize) {
-        let priv_ = imp::ItemList::from_instance(self);
+        let priv_ = self.imp();
         let (item, old_visible) = priv_.list.get().unwrap().get(position).unwrap();
 
         let visible = if let Some(category) = item.downcast_ref::<Category>() {
@@ -228,12 +228,11 @@ impl ItemList {
     }
 
     pub fn show_all_for_category(&self) -> CategoryType {
-        let priv_ = imp::ItemList::from_instance(self);
-        priv_.show_all_for_category.get()
+        self.imp().show_all_for_category.get()
     }
 
     pub fn set_show_all_for_category(&self, category: CategoryType) {
-        let priv_ = imp::ItemList::from_instance(self);
+        let priv_ = self.imp();
 
         if category == self.show_all_for_category() {
             return;
@@ -248,22 +247,18 @@ impl ItemList {
     }
 
     fn set_room_list(&self, room_list: RoomList) {
-        let priv_ = imp::ItemList::from_instance(self);
-        priv_.room_list.set(room_list).unwrap();
+        self.imp().room_list.set(room_list).unwrap();
     }
 
     fn set_verification_list(&self, verification_list: VerificationList) {
-        let priv_ = imp::ItemList::from_instance(self);
-        priv_.verification_list.set(verification_list).unwrap();
+        self.imp().verification_list.set(verification_list).unwrap();
     }
 
     pub fn room_list(&self) -> &RoomList {
-        let priv_ = imp::ItemList::from_instance(self);
-        priv_.room_list.get().unwrap()
+        self.imp().room_list.get().unwrap()
     }
 
     pub fn verification_list(&self) -> &VerificationList {
-        let priv_ = imp::ItemList::from_instance(self);
-        priv_.verification_list.get().unwrap()
+        self.imp().verification_list.get().unwrap()
     }
 }
diff --git a/src/session/sidebar/mod.rs b/src/session/sidebar/mod.rs
index 603c16ac..212593d0 100644
--- a/src/session/sidebar/mod.rs
+++ b/src/session/sidebar/mod.rs
@@ -238,17 +238,15 @@ impl Sidebar {
     }
 
     pub fn selected_item(&self) -> Option<glib::Object> {
-        let priv_ = imp::Sidebar::from_instance(self);
-        priv_.selected_item.borrow().clone()
+        self.imp().selected_item.borrow().clone()
     }
 
     pub fn room_search_bar(&self) -> gtk::SearchBar {
-        let priv_ = imp::Sidebar::from_instance(self);
-        priv_.room_search.clone()
+        self.imp().room_search.clone()
     }
 
     pub fn set_item_list(&self, item_list: Option<ItemList>) {
-        let priv_ = imp::Sidebar::from_instance(self);
+        let priv_ = self.imp();
 
         if let Some(binding) = priv_.drop_binding.take() {
             binding.unbind();
@@ -302,29 +300,24 @@ impl Sidebar {
     }
 
     pub fn set_selected_item(&self, selected_item: Option<glib::Object>) {
-        let priv_ = imp::Sidebar::from_instance(self);
-
         if self.selected_item() == selected_item {
             return;
         }
 
-        priv_.selected_item.replace(selected_item);
+        self.imp().selected_item.replace(selected_item);
         self.notify("selected-item");
     }
 
     pub fn user(&self) -> Option<User> {
-        let priv_ = &imp::Sidebar::from_instance(self);
-        priv_.user.borrow().clone()
+        self.imp().user.borrow().clone()
     }
 
     fn set_user(&self, user: Option<User>) {
-        let priv_ = imp::Sidebar::from_instance(self);
-
         if self.user() == user {
             return;
         }
 
-        priv_.user.replace(user);
+        self.imp().user.replace(user);
         self.notify("user");
     }
 
@@ -333,18 +326,17 @@ impl Sidebar {
         sessions_stack_pages: &SelectionModel,
         session_root: &Session,
     ) {
-        imp::Sidebar::from_instance(self)
+        self.imp()
             .account_switcher
             .set_logged_in_users(sessions_stack_pages, session_root);
     }
 
     pub fn drop_source_type(&self) -> Option<RoomType> {
-        let priv_ = imp::Sidebar::from_instance(self);
-        priv_.drop_source_type.get()
+        self.imp().drop_source_type.get()
     }
 
     pub fn set_drop_source_type(&self, source_type: Option<RoomType>) {
-        let priv_ = imp::Sidebar::from_instance(self);
+        let priv_ = self.imp();
 
         if self.drop_source_type() == source_type {
             return;
@@ -364,8 +356,7 @@ impl Sidebar {
 
     /// Update the disabled or empty state of drop targets.
     fn update_drop_targets(&self) {
-        let priv_ = imp::Sidebar::from_instance(self);
-        let mut child = priv_.listview.first_child();
+        let mut child = self.imp().listview.first_child();
 
         while let Some(widget) = child {
             if let Some(row) = widget
@@ -426,8 +417,7 @@ impl Sidebar {
 
     /// Update the active state of drop targets.
     fn update_active_drop_targets(&self, target_type: Option<RoomType>) {
-        let priv_ = imp::Sidebar::from_instance(self);
-        let mut child = priv_.listview.first_child();
+        let mut child = self.imp().listview.first_child();
 
         while let Some(widget) = child {
             if let Some((row, row_type)) = widget
diff --git a/src/session/sidebar/room_row.rs b/src/session/sidebar/room_row.rs
index 25f5ee70..1301559c 100644
--- a/src/session/sidebar/room_row.rs
+++ b/src/session/sidebar/room_row.rs
@@ -152,12 +152,11 @@ impl RoomRow {
     }
 
     pub fn room(&self) -> Option<Room> {
-        let priv_ = imp::RoomRow::from_instance(self);
-        priv_.room.borrow().clone()
+        self.imp().room.borrow().clone()
     }
 
     pub fn set_room(&self, room: Option<Room>) {
-        let priv_ = imp::RoomRow::from_instance(self);
+        let priv_ = self.imp();
 
         if self.room() == room {
             return;
@@ -205,7 +204,7 @@ impl RoomRow {
     }
 
     fn set_highlight(&self) {
-        let priv_ = imp::RoomRow::from_instance(self);
+        let priv_ = self.imp();
         if let Some(room) = &*priv_.room.borrow() {
             match room.highlight() {
                 HighlightFlags::NONE => {
diff --git a/src/session/sidebar/row.rs b/src/session/sidebar/row.rs
index 3accd405..0a17f6e4 100644
--- a/src/session/sidebar/row.rs
+++ b/src/session/sidebar/row.rs
@@ -124,12 +124,11 @@ impl Row {
     }
 
     pub fn list_row(&self) -> Option<gtk::TreeListRow> {
-        let priv_ = imp::Row::from_instance(self);
-        priv_.list_row.borrow().clone()
+        self.imp().list_row.borrow().clone()
     }
 
     pub fn set_list_row(&self, list_row: Option<gtk::TreeListRow>) {
-        let priv_ = imp::Row::from_instance(self);
+        let priv_ = self.imp();
 
         if self.list_row() == list_row {
             return;
diff --git a/src/session/sidebar/selection.rs b/src/session/sidebar/selection.rs
index 87684ea6..68bb5ce9 100644
--- a/src/session/sidebar/selection.rs
+++ b/src/session/sidebar/selection.rs
@@ -145,22 +145,19 @@ impl Selection {
     }
 
     pub fn model(&self) -> Option<gio::ListModel> {
-        let priv_ = imp::Selection::from_instance(self);
-        priv_.model.borrow().clone()
+        self.imp().model.borrow().clone()
     }
 
     pub fn selected(&self) -> u32 {
-        let priv_ = imp::Selection::from_instance(self);
-        priv_.selected.get()
+        self.imp().selected.get()
     }
 
     pub fn selected_item(&self) -> Option<glib::Object> {
-        let priv_ = imp::Selection::from_instance(self);
-        priv_.selected_item.borrow().clone()
+        self.imp().selected_item.borrow().clone()
     }
 
     pub fn set_model<P: IsA<gio::ListModel>>(&self, model: Option<&P>) {
-        let priv_ = imp::Selection::from_instance(self);
+        let priv_ = self.imp();
 
         let _guard = self.freeze_notify();
 
@@ -211,7 +208,7 @@ impl Selection {
     }
 
     pub fn set_selected(&self, position: u32) {
-        let priv_ = imp::Selection::from_instance(self);
+        let priv_ = self.imp();
 
         let old_selected = self.selected();
         if old_selected == position {
@@ -252,7 +249,7 @@ impl Selection {
     }
 
     fn set_selected_item(&self, item: Option<glib::Object>) {
-        let priv_ = imp::Selection::from_instance(self);
+        let priv_ = self.imp();
 
         let selected_item = self.selected_item();
         if selected_item == item {
@@ -299,7 +296,7 @@ impl Selection {
     }
 
     fn items_changed_cb(&self, model: &gio::ListModel, position: u32, removed: u32, added: u32) {
-        let priv_ = imp::Selection::from_instance(self);
+        let priv_ = self.imp();
 
         let _guard = self.freeze_notify();
 
diff --git a/src/session/sidebar/verification_row.rs b/src/session/sidebar/verification_row.rs
index 7236b927..f271bc5b 100644
--- a/src/session/sidebar/verification_row.rs
+++ b/src/session/sidebar/verification_row.rs
@@ -83,18 +83,15 @@ impl VerificationRow {
     }
 
     pub fn identity_verification(&self) -> Option<IdentityVerification> {
-        let priv_ = imp::VerificationRow::from_instance(self);
-        priv_.verification.borrow().clone()
+        self.imp().verification.borrow().clone()
     }
 
     pub fn set_identity_verification(&self, verification: Option<IdentityVerification>) {
-        let priv_ = imp::VerificationRow::from_instance(self);
-
         if self.identity_verification() == verification {
             return;
         }
 
-        priv_.verification.replace(verification);
+        self.imp().verification.replace(verification);
         self.notify("identity-verification");
     }
 }
diff --git a/src/session/user.rs b/src/session/user.rs
index b31237b6..cfeef041 100644
--- a/src/session/user.rs
+++ b/src/session/user.rs
@@ -196,21 +196,18 @@ impl User {
     }
 
     pub fn is_verified(&self) -> bool {
-        let priv_ = imp::User::from_instance(self);
-
-        priv_.is_verified.get()
+        self.imp().is_verified.get()
     }
 
     fn init_is_verified(&self) {
         spawn!(clone!(@weak self as obj => async move {
-            let priv_ = imp::User::from_instance(&obj);
             let is_verified = obj.crypto_identity().await.map_or(false, |i| i.verified());
 
             if is_verified == obj.is_verified() {
                 return;
             }
 
-            priv_.is_verified.set(is_verified);
+            obj.imp().is_verified.set(is_verified);
             obj.notify("verified");
             obj.notify("allowed-actions");
         }));
@@ -219,17 +216,21 @@ impl User {
 
 pub trait UserExt: IsA<User> {
     fn session(&self) -> Session {
-        let priv_ = imp::User::from_instance(self.upcast_ref());
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.upcast_ref()
+            .imp()
+            .session
+            .get()
+            .unwrap()
+            .upgrade()
+            .unwrap()
     }
 
     fn user_id(&self) -> Arc<UserId> {
-        let priv_ = imp::User::from_instance(self.upcast_ref());
-        priv_.user_id.get().unwrap().clone()
+        self.upcast_ref().imp().user_id.get().unwrap().clone()
     }
 
     fn display_name(&self) -> String {
-        let priv_ = imp::User::from_instance(self.upcast_ref());
+        let priv_ = self.upcast_ref().imp();
 
         if let Some(display_name) = priv_.display_name.borrow().to_owned() {
             display_name
@@ -242,14 +243,12 @@ pub trait UserExt: IsA<User> {
         if Some(self.display_name()) == display_name {
             return;
         }
-        let priv_ = imp::User::from_instance(self.upcast_ref());
-        priv_.display_name.replace(display_name);
+        self.upcast_ref().imp().display_name.replace(display_name);
         self.notify("display-name");
     }
 
     fn avatar(&self) -> &Avatar {
-        let priv_ = imp::User::from_instance(self.upcast_ref());
-        priv_.avatar.get().unwrap()
+        self.upcast_ref().imp().avatar.get().unwrap()
     }
 
     fn set_avatar_url(&self, url: Option<Box<MxcUri>>) {
diff --git a/src/session/verification/identity_verification.rs 
b/src/session/verification/identity_verification.rs
index 4ca1fe21..64230e72 100644
--- a/src/session/verification/identity_verification.rs
+++ b/src/session/verification/identity_verification.rs
@@ -270,7 +270,7 @@ mod imp {
             main_receiver.attach(
                 None,
                 clone!(@weak obj => @default-return glib::Continue(false), move |message| {
-                    let priv_ = imp::IdentityVerification::from_instance(&obj);
+                    let priv_ = obj.imp();
                     match message {
                         MainMessage::QrCode(data) => { let _ = priv_.qr_code.set(data); },
                         MainMessage::CancelInfo(data) => priv_.cancel_info.set(data).unwrap(),
@@ -390,7 +390,7 @@ impl IdentityVerification {
     }
 
     fn start_handler(&self) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
+        let priv_ = self.imp();
 
         let main_sender = if let Some(main_sender) = priv_.main_sender.take() {
             main_sender
@@ -421,7 +421,6 @@ impl IdentityVerification {
         spawn!(async move {
             let result = handle.await.unwrap();
             if let Some(obj) = weak_obj.upgrade() {
-                let priv_ = imp::IdentityVerification::from_instance(&obj);
                 match result {
                     Ok(result) => obj.set_state(result),
                     Err(error) => {
@@ -430,31 +429,27 @@ impl IdentityVerification {
                         obj.set_state(State::Error);
                     }
                 }
-                priv_.sync_sender.take();
+                obj.imp().sync_sender.take();
             }
         });
     }
 
     /// The user to be verified.
     pub fn user(&self) -> &User {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.user.get().unwrap()
+        self.imp().user.get().unwrap()
     }
 
     fn set_user(&self, user: User) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.user.set(user).unwrap()
+        self.imp().user.set(user).unwrap()
     }
 
     /// The current `Session`.
     pub fn session(&self) -> Session {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     fn set_session(&self, session: Session) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.session.set(session.downgrade()).unwrap()
+        self.imp().session.set(session.downgrade()).unwrap()
     }
 
     fn setup_timeout(&self) {
@@ -492,30 +487,24 @@ impl IdentityVerification {
 
     /// The time and date when this verification request was started.
     pub fn start_time(&self) -> &glib::DateTime {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.start_time.get().unwrap()
+        self.imp().start_time.get().unwrap()
     }
 
     fn set_start_time(&self, time: glib::DateTime) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.start_time.set(time).unwrap();
+        self.imp().start_time.set(time).unwrap();
     }
 
     pub fn receive_time(&self) -> &glib::DateTime {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.receive_time.get().unwrap()
+        self.imp().receive_time.get().unwrap()
     }
 
     fn supported_methods(&self) -> SupportedMethods {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.supported_methods.get()
+        self.imp().supported_methods.get()
     }
 
     pub fn emoji_match(&self) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
         if self.state() == State::SasV1 {
-            if let Some(sync_sender) = &*priv_.sync_sender.borrow() {
+            if let Some(sync_sender) = &*self.imp().sync_sender.borrow() {
                 let result = sync_sender.try_send(Message::UserAction(UserAction::Match));
 
                 if let Err(error) = result {
@@ -526,10 +515,8 @@ impl IdentityVerification {
     }
 
     pub fn emoji_not_match(&self) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
         if self.state() == State::SasV1 {
-            if let Some(sync_sender) = &*priv_.sync_sender.borrow() {
+            if let Some(sync_sender) = &*self.imp().sync_sender.borrow() {
                 let result = sync_sender.try_send(Message::UserAction(UserAction::NotMatch));
 
                 if let Err(error) = result {
@@ -540,13 +527,10 @@ impl IdentityVerification {
     }
 
     pub fn state(&self) -> State {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.state.get()
+        self.imp().state.get()
     }
 
     fn set_state(&self, state: State) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
         if self.state() == state {
             return;
         }
@@ -556,13 +540,12 @@ impl IdentityVerification {
             _ => {}
         }
 
-        priv_.state.set(state);
+        self.imp().state.set(state);
         self.notify("state");
     }
 
     pub fn mode(&self) -> Mode {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        *priv_.mode.get_or_init(|| {
+        *self.imp().mode.get_or_init(|| {
             let session = self.session();
             let our_user = session.user().unwrap();
             if our_user.user_id() == self.user().user_id() {
@@ -574,9 +557,7 @@ impl IdentityVerification {
     }
 
     fn set_mode(&self, mode: Mode) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
-        priv_.mode.set(mode).unwrap();
+        self.imp().mode.set(mode).unwrap();
     }
 
     /// Whether this request is finished
@@ -588,8 +569,7 @@ impl IdentityVerification {
     }
 
     fn hide_error(&self) -> bool {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_.hide_error.get()
+        self.imp().hide_error.get()
     }
 
     fn show_error(&self) {
@@ -642,17 +622,14 @@ impl IdentityVerification {
     }
 
     pub fn flow_id(&self) -> &str {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-        priv_
+        self.imp()
             .flow_id
             .get()
             .expect("Flow Id isn't always set on verifications with error state.")
     }
 
     fn set_flow_id(&self, flow_id: String) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
-        priv_.flow_id.set(flow_id).unwrap();
+        self.imp().flow_id.set(flow_id).unwrap();
     }
 
     /// Get the QrCode for this verification request
@@ -660,9 +637,7 @@ impl IdentityVerification {
     /// This is only set once the request reached the `State::Ready`
     /// and if QrCode verification is possible
     pub fn qr_code(&self) -> Option<&QrCode> {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
-        priv_.qr_code.get()
+        self.imp().qr_code.get()
     }
 
     /// Get the Emojis for this verification request
@@ -670,16 +645,12 @@ impl IdentityVerification {
     /// This is only set once the request reached the `State::Ready`
     /// and if a Sas verification was started
     pub fn sas_data(&self) -> Option<&SasData> {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
-        priv_.sas_data.get()
+        self.imp().sas_data.get()
     }
 
     pub fn start_sas(&self) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
         if self.state() != State::SasV1 {
-            if let Some(sync_sender) = &*priv_.sync_sender.borrow() {
+            if let Some(sync_sender) = &*self.imp().sync_sender.borrow() {
                 let result = sync_sender.try_send(Message::UserAction(UserAction::StartSas));
 
                 if let Err(error) = result {
@@ -690,9 +661,7 @@ impl IdentityVerification {
     }
 
     pub fn scanned_qr_code(&self, data: QrVerificationData) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
-        if let Some(sync_sender) = &*priv_.sync_sender.borrow() {
+        if let Some(sync_sender) = &*self.imp().sync_sender.borrow() {
             let result = sync_sender.try_send(Message::UserAction(UserAction::Scanned(data)));
 
             if let Err(error) = result {
@@ -703,9 +672,8 @@ impl IdentityVerification {
 
     /// Accept an incoming request
     pub fn accept(&self) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
         if self.state() == State::Requested {
-            if let Some(sync_sender) = &*priv_.sync_sender.borrow() {
+            if let Some(sync_sender) = &*self.imp().sync_sender.borrow() {
                 let result = sync_sender.try_send(Message::UserAction(UserAction::Accept));
                 if let Err(error) = result {
                     error!("Failed to send message to tokio runtime: {}", error);
@@ -715,7 +683,7 @@ impl IdentityVerification {
     }
 
     pub fn cancel(&self, hide_error: bool) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.hide_error.set(hide_error);
 
@@ -733,15 +701,11 @@ impl IdentityVerification {
 
     /// Get information about why the request was cancelled
     pub fn cancel_info(&self) -> Option<&CancelInfo> {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
-        priv_.cancel_info.get()
+        self.imp().cancel_info.get()
     }
 
     pub fn notify_state(&self) {
-        let priv_ = imp::IdentityVerification::from_instance(self);
-
-        if let Some(sync_sender) = &*priv_.sync_sender.borrow() {
+        if let Some(sync_sender) = &*self.imp().sync_sender.borrow() {
             let result = sync_sender.try_send(Message::NotifyState);
             if let Err(error) = result {
                 error!("Failed to send message to tokio runtime: {}", error);
diff --git a/src/session/verification/verification_list.rs b/src/session/verification/verification_list.rs
index f5872f7d..abef25a3 100644
--- a/src/session/verification/verification_list.rs
+++ b/src/session/verification/verification_list.rs
@@ -131,8 +131,7 @@ impl VerificationList {
     }
 
     pub fn session(&self) -> Session {
-        let priv_ = imp::VerificationList::from_instance(self);
-        priv_.session.get().unwrap().upgrade().unwrap()
+        self.imp().session.get().unwrap().upgrade().unwrap()
     }
 
     pub fn handle_response_to_device(&self, to_device: ToDevice) {
@@ -221,15 +220,13 @@ impl VerificationList {
 
     /// Add a new `IdentityVerification` request
     pub fn add(&self, request: IdentityVerification) {
-        let priv_ = imp::VerificationList::from_instance(self);
-
         // Don't add requests that are already finished
         if request.is_finished() {
             return;
         }
 
         let length = {
-            let mut list = priv_.list.borrow_mut();
+            let mut list = self.imp().list.borrow_mut();
             let length = list.len();
             request.connect_notify_local(
                 Some("state"),
@@ -250,10 +247,8 @@ impl VerificationList {
     }
 
     pub fn remove(&self, request: &IdentityVerification) {
-        let priv_ = imp::VerificationList::from_instance(self);
-
         let position = if let Some((position, ..)) =
-            priv_
+            self.imp()
                 .list
                 .borrow_mut()
                 .shift_remove_full(&FlowIdUnowned::new(
@@ -273,9 +268,7 @@ impl VerificationList {
         user_id: &UserId,
         flow_id: &impl AsRef<str>,
     ) -> Option<IdentityVerification> {
-        let priv_ = imp::VerificationList::from_instance(self);
-
         let flow_id = FlowIdUnowned::new(user_id, flow_id.as_ref());
-        priv_.list.borrow().get(&flow_id).cloned()
+        self.imp().list.borrow().get(&flow_id).cloned()
     }
 }
diff --git a/src/window.rs b/src/window.rs
index c13b3404..5e84a1f1 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -113,7 +113,7 @@ impl Window {
     }
 
     fn add_session(&self, session: &Session) {
-        let priv_ = &imp::Window::from_instance(self);
+        let priv_ = &self.imp();
         session.set_logged_in_users(&priv_.sessions.pages());
         priv_.sessions.add_child(session);
         priv_.sessions.set_visible_child(session);
@@ -126,7 +126,7 @@ impl Window {
     }
 
     fn remove_session(&self, session: &Session) {
-        let priv_ = imp::Window::from_instance(self);
+        let priv_ = self.imp();
 
         priv_.sessions.remove(session);
 
@@ -193,7 +193,7 @@ impl Window {
     /// If the login screen is visible, its login button becomes the default
     /// widget
     fn set_default_by_child(&self) {
-        let priv_ = imp::Window::from_instance(self);
+        let priv_ = self.imp();
         if priv_.main_stack.visible_child() == Some(priv_.login.get().upcast()) {
             self.set_default_widget(Some(&priv_.login.default_widget()));
         } else {
@@ -202,12 +202,12 @@ impl Window {
     }
 
     pub fn switch_to_sessions_page(&self) {
-        let priv_ = imp::Window::from_instance(self);
+        let priv_ = self.imp();
         priv_.main_stack.set_visible_child(&priv_.sessions.get());
     }
 
     pub fn switch_to_login_page(&self, clean: bool) {
-        let priv_ = imp::Window::from_instance(self);
+        let priv_ = self.imp();
         if clean {
             priv_.login.clean();
         }
@@ -219,7 +219,6 @@ impl Window {
 
     /// This appends a new error to the list of errors
     pub fn append_error(&self, error: &Error) {
-        let priv_ = imp::Window::from_instance(self);
-        priv_.error_list.append(error);
+        self.imp().error_list.append(error);
     }
 }


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