[fractal/fractal-next] verification: Move widgets to content and rename some



commit 15afbb7022d8ff78a0c8d39f5dfbe7bec13bd091
Author: Julian Sparber <julian sparber net>
Date:   Fri Dec 17 17:33:57 2021 +0100

    verification: Move widgets to content and rename some

 data/resources/resources.gresource.xml             |  2 +-
 data/resources/ui/content.ui                       |  2 +-
 ...fication.ui => identity-verification-widget.ui} |  2 +-
 po/POTFILES.in                                     |  6 ++-
 src/meson.build                                    |  7 +--
 src/session/content/mod.rs                         | 13 +++--
 src/session/{ => content}/verification/emoji.rs    |  0
 .../verification/identity_verification_widget.rs}  | 60 +++++++++++-----------
 src/session/content/verification/mod.rs            |  7 +++
 .../verification/session_verification.rs           |  3 +-
 src/session/mod.rs                                 |  3 +-
 src/session/verification/mod.rs                    |  6 ---
 12 files changed, 62 insertions(+), 49 deletions(-)
---
diff --git a/data/resources/resources.gresource.xml b/data/resources/resources.gresource.xml
index 4841e5be..a1600b22 100644
--- a/data/resources/resources.gresource.xml
+++ b/data/resources/resources.gresource.xml
@@ -54,7 +54,7 @@
     <file compressed="true" preprocess="xml-stripblanks" alias="room-creation.ui">ui/room-creation.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="session-verification.ui">ui/session-verification.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="verification-emoji.ui">ui/verification-emoji.ui</file>
-    <file compressed="true" preprocess="xml-stripblanks" 
alias="incoming-verification.ui">ui/incoming-verification.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks" 
alias="identity-verification-widget.ui">ui/identity-verification-widget.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="qr-code-scanner.ui">ui/qr-code-scanner.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="components-video-player.ui">ui/components-video-player.ui</file>
     <file compressed="true">style.css</file>
diff --git a/data/resources/ui/content.ui b/data/resources/ui/content.ui
index e8b6156a..d8e7b62c 100644
--- a/data/resources/ui/content.ui
+++ b/data/resources/ui/content.ui
@@ -75,7 +75,7 @@
               </object>
             </child>
             <child>
-              <object class="IncomingVerification" id="incoming_verification"/>
+              <object class="IdentityVerificationWidget" id="identity_verification_widget"/>
             </child>
           </object>
         </child>
diff --git a/data/resources/ui/incoming-verification.ui b/data/resources/ui/identity-verification-widget.ui
similarity index 99%
rename from data/resources/ui/incoming-verification.ui
rename to data/resources/ui/identity-verification-widget.ui
index 284dc426..32e690c2 100644
--- a/data/resources/ui/incoming-verification.ui
+++ b/data/resources/ui/identity-verification-widget.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="IncomingVerification" parent="AdwBin">
+  <template class="IdentityVerificationWidget" parent="AdwBin">
     <style>
       <class name="incoming-verification"/>
     </style>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2ebe8994..e3af9408 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -31,6 +31,7 @@ data/resources/ui/event-menu.ui
 data/resources/ui/event-source-dialog.ui
 data/resources/ui/login.ui
 data/resources/ui/in-app-notification.ui
+data/resources/ui/identity-verification-widget.ui
 data/resources/ui/media-viewer.ui
 data/resources/ui/room-creation.ui
 data/resources/ui/session.ui
@@ -96,6 +97,9 @@ src/session/content/room_history/message_row/text.rs
 src/session/content/room_history/mod.rs
 src/session/content/room_history/state_row.rs
 src/session/content/room_history/state_row/mod.rs
+src/session/content/verification/emoji.rs
+src/session/content/verification/identity_verification_widget.rs
+src/session/content/verification/session_verification.rs
 src/session/media_viewer.rs
 src/session/mod.rs
 src/session/room_creation/mod.rs
@@ -124,10 +128,8 @@ src/session/sidebar/mod.rs
 src/session/sidebar/room_row.rs
 src/session/sidebar/row.rs
 src/session/sidebar/selection.rs
-src/session/verification/emoji.rs
 src/session/verification/identity_verification.rs
 src/session/verification/mod.rs
-src/session/verification/session_verification.rs
 src/session/verification/verification_list.rs
 src/session/user.rs
 src/user_facing_error.rs
diff --git a/src/meson.build b/src/meson.build
index aa389a35..794f42c6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -79,6 +79,10 @@ sources = files(
   'session/content/room_details/member_page/mod.rs',
   'session/content/room_details/member_page/member_row.rs',
   'session/content/room_details/mod.rs',
+  'session/content/verification/emoji.rs',
+  'session/content/verification/mod.rs',
+  'session/content/verification/identity_verification_widget.rs',
+  'session/content/verification/session_verification.rs',
   'session/media_viewer.rs',
   'session/room/event.rs',
   'session/room/event_actions.rs',
@@ -111,10 +115,7 @@ sources = files(
   'session/sidebar/account_switcher/user_entry.rs',
   'session/sidebar/category_type.rs',
   'session/verification/mod.rs',
-  'session/verification/emoji.rs',
   'session/verification/identity_verification.rs',
-  'session/verification/incoming_verification.rs',
-  'session/verification/session_verification.rs',
   'session/verification/verification_list.rs',
 )
 
diff --git a/src/session/content/mod.rs b/src/session/content/mod.rs
index bef5ea22..bafe566e 100644
--- a/src/session/content/mod.rs
+++ b/src/session/content/mod.rs
@@ -3,15 +3,18 @@ mod invite;
 mod markdown_popover;
 mod room_details;
 mod room_history;
+pub mod verification;
 
 use self::explore::Explore;
 use self::invite::Invite;
 use self::markdown_popover::MarkdownPopover;
 use self::room_details::RoomDetails;
 use self::room_history::RoomHistory;
+use self::verification::IdentityVerificationWidget;
+
 use crate::session::sidebar::{Entry, EntryType};
 
-use crate::session::verification::{IdentityVerification, IncomingVerification, VerificationMode};
+use crate::session::verification::{IdentityVerification, VerificationMode};
 
 use adw::subclass::prelude::*;
 use gtk::{gio, glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
@@ -47,7 +50,7 @@ mod imp {
         #[template_child]
         pub verification_page: TemplateChild<gtk::Box>,
         #[template_child]
-        pub incoming_verification: TemplateChild<IncomingVerification>,
+        pub identity_verification_widget: TemplateChild<IdentityVerificationWidget>,
     }
 
     #[glib::object_subclass]
@@ -148,7 +151,7 @@ mod imp {
                 .connect_visible_child_notify(clone!(@weak obj => move |stack| {
                     let priv_ = imp::Content::from_instance(&obj);
                     if stack.visible_child().as_ref() != 
Some(priv_.verification_page.upcast_ref::<gtk::Widget>()) {
-                        priv_.incoming_verification.set_request(None);
+                        priv_.identity_verification_widget.set_request(None);
                     }
                 }));
         }
@@ -273,7 +276,9 @@ impl Content {
                     .as_ref()
                     .and_then(|item| item.downcast_ref::<IdentityVerification>())
                 {
-                    priv_.incoming_verification.set_request(Some(item.clone()));
+                    priv_
+                        .identity_verification_widget
+                        .set_request(Some(item.clone()));
                     priv_.stack.set_visible_child(&*priv_.verification_page);
                 }
             }
diff --git a/src/session/verification/emoji.rs b/src/session/content/verification/emoji.rs
similarity index 100%
rename from src/session/verification/emoji.rs
rename to src/session/content/verification/emoji.rs
diff --git a/src/session/verification/incoming_verification.rs 
b/src/session/content/verification/identity_verification_widget.rs
similarity index 86%
rename from src/session/verification/incoming_verification.rs
rename to src/session/content/verification/identity_verification_widget.rs
index a4bfad7e..9ee9c651 100644
--- a/src/session/verification/incoming_verification.rs
+++ b/src/session/content/verification/identity_verification_widget.rs
@@ -2,12 +2,13 @@ use adw::subclass::prelude::*;
 use gtk::{glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
 use log::warn;
 
+use super::Emoji;
 use crate::components::SpinnerButton;
 use crate::contrib::screenshot;
 use crate::contrib::QRCode;
 use crate::contrib::QRCodeExt;
 use crate::contrib::QrCodeScanner;
-use crate::session::verification::{Emoji, IdentityVerification, SasData, VerificationMode};
+use crate::session::verification::{IdentityVerification, SasData, VerificationMode};
 use crate::spawn;
 use gettextrs::gettext;
 use matrix_sdk::encryption::verification::QrVerificationData;
@@ -19,8 +20,8 @@ mod imp {
     use std::cell::RefCell;
 
     #[derive(Debug, Default, CompositeTemplate)]
-    #[template(resource = "/org/gnome/FractalNext/incoming-verification.ui")]
-    pub struct IncomingVerification {
+    #[template(resource = "/org/gnome/FractalNext/identity-verification-widget.ui")]
+    pub struct IdentityVerificationWidget {
         pub request: RefCell<Option<IdentityVerification>>,
         #[template_child]
         pub qrcode: TemplateChild<QRCode>,
@@ -58,9 +59,9 @@ mod imp {
     }
 
     #[glib::object_subclass]
-    impl ObjectSubclass for IncomingVerification {
-        const NAME: &'static str = "IncomingVerification";
-        type Type = super::IncomingVerification;
+    impl ObjectSubclass for IdentityVerificationWidget {
+        const NAME: &'static str = "IdentityVerificationWidget";
+        type Type = super::IdentityVerificationWidget;
         type ParentType = adw::Bin;
 
         fn class_init(klass: &mut Self::Class) {
@@ -81,7 +82,7 @@ mod imp {
         }
     }
 
-    impl ObjectImpl for IncomingVerification {
+    impl ObjectImpl for IdentityVerificationWidget {
         fn properties() -> &'static [glib::ParamSpec] {
             use once_cell::sync::Lazy;
             static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
@@ -121,7 +122,7 @@ mod imp {
             self.parent_constructed(obj);
             self.accept_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.dismiss_btn.set_sensitive(false);
                     obj.accept();
@@ -129,7 +130,7 @@ mod imp {
 
             self.emoji_match_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.emoji_not_match_btn.set_sensitive(false);
                     if let Some(request) = obj.request() {
@@ -139,7 +140,7 @@ mod imp {
 
             self.emoji_not_match_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.emoji_match_btn.set_sensitive(false);
                     if let Some(request) = obj.request() {
@@ -149,7 +150,7 @@ mod imp {
 
             self.start_emoji_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.scan_qr_code_btn.set_sensitive(false);
                     if let Some(request) = obj.request() {
@@ -158,7 +159,7 @@ mod imp {
                 }));
             self.start_emoji_btn2
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.take_screenshot_btn2.set_sensitive(false);
                     if let Some(request) = obj.request() {
@@ -167,7 +168,7 @@ mod imp {
                 }));
             self.start_emoji_btn3
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.take_screenshot_btn3.set_sensitive(false);
                     if let Some(request) = obj.request() {
@@ -177,7 +178,7 @@ mod imp {
 
             self.scan_qr_code_btn
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.start_emoji_btn.set_sensitive(false);
                     if priv_.qr_code_scanner.has_camera() {
@@ -189,7 +190,7 @@ mod imp {
 
             self.take_screenshot_btn2
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.start_emoji_btn2.set_sensitive(false);
                     obj.take_screenshot();
@@ -197,7 +198,7 @@ mod imp {
 
             self.take_screenshot_btn3
                 .connect_clicked(clone!(@weak obj => move |button| {
-                    let priv_ = imp::IncomingVerification::from_instance(&obj);
+                    let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
                     button.set_loading(true);
                     priv_.start_emoji_btn3.set_sensitive(false);
                     obj.take_screenshot();
@@ -230,32 +231,33 @@ mod imp {
         }
     }
 
-    impl WidgetImpl for IncomingVerification {
+    impl WidgetImpl for IdentityVerificationWidget {
         fn map(&self, widget: &Self::Type) {
             self.parent_map(widget);
             widget.update_view();
         }
     }
-    impl BinImpl for IncomingVerification {}
+    impl BinImpl for IdentityVerificationWidget {}
 }
 
 glib::wrapper! {
-    pub struct IncomingVerification(ObjectSubclass<imp::IncomingVerification>)
+    pub struct IdentityVerificationWidget(ObjectSubclass<imp::IdentityVerificationWidget>)
         @extends gtk::Widget, adw::Bin, @implements gtk::Accessible;
 }
 
-impl IncomingVerification {
+impl IdentityVerificationWidget {
     pub fn new(request: &IdentityVerification) -> Self {
-        glib::Object::new(&[("request", request)]).expect("Failed to create IncomingVerification")
+        glib::Object::new(&[("request", request)])
+            .expect("Failed to create IdentityVerificationWidget")
     }
 
     pub fn request(&self) -> Option<IdentityVerification> {
-        let priv_ = imp::IncomingVerification::from_instance(self);
+        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
         priv_.request.borrow().clone()
     }
 
     pub fn set_request(&self, request: Option<IdentityVerification>) {
-        let priv_ = imp::IncomingVerification::from_instance(self);
+        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
         let previous_request = self.request();
 
         if previous_request == request {
@@ -287,7 +289,7 @@ impl IncomingVerification {
     }
 
     fn reset(&self) {
-        let priv_ = imp::IncomingVerification::from_instance(self);
+        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
         priv_.accept_btn.set_loading(false);
         priv_.accept_btn.set_sensitive(true);
         priv_.dismiss_btn.set_sensitive(true);
@@ -312,7 +314,7 @@ impl IncomingVerification {
     }
 
     fn clean_emoji(&self) {
-        let priv_ = imp::IncomingVerification::from_instance(self);
+        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
 
         while let Some(child) = priv_.emoji_row_1.first_child() {
             priv_.emoji_row_1.remove(&child);
@@ -336,7 +338,7 @@ impl IncomingVerification {
     }
 
     fn update_view(&self) {
-        let priv_ = imp::IncomingVerification::from_instance(self);
+        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
         if let Some(request) = self.request() {
             match request.mode() {
                 VerificationMode::Requested => {
@@ -378,7 +380,7 @@ impl IncomingVerification {
 
     fn start_scanning(&self) {
         spawn!(clone!(@weak self as obj => async move {
-            let priv_ = imp::IncomingVerification::from_instance(&obj);
+            let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
             if priv_.qr_code_scanner.start().await {
                 priv_.main_stack.set_visible_child_name("scan-qr-code");
             } else {
@@ -399,7 +401,7 @@ impl IncomingVerification {
     }
 
     fn finish_scanning(&self, data: QrVerificationData) {
-        let priv_ = imp::IncomingVerification::from_instance(self);
+        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
         priv_.qr_code_scanner.stop();
         if let Some(request) = self.request() {
             request.scanned_qr_code(data);
@@ -408,7 +410,7 @@ impl IncomingVerification {
     }
 
     fn update_camera_state(&self) {
-        let priv_ = imp::IncomingVerification::from_instance(self);
+        let priv_ = imp::IdentityVerificationWidget::from_instance(self);
         if priv_.qr_code_scanner.has_camera() {
             priv_
                 .scan_qr_code_btn
diff --git a/src/session/content/verification/mod.rs b/src/session/content/verification/mod.rs
new file mode 100644
index 00000000..b2afd487
--- /dev/null
+++ b/src/session/content/verification/mod.rs
@@ -0,0 +1,7 @@
+mod emoji;
+mod identity_verification_widget;
+mod session_verification;
+
+pub use self::emoji::Emoji;
+pub use self::identity_verification_widget::IdentityVerificationWidget;
+pub use self::session_verification::SessionVerification;
diff --git a/src/session/verification/session_verification.rs 
b/src/session/content/verification/session_verification.rs
similarity index 99%
rename from src/session/verification/session_verification.rs
rename to src/session/content/verification/session_verification.rs
index d89df362..fa14ca35 100644
--- a/src/session/verification/session_verification.rs
+++ b/src/session/content/verification/session_verification.rs
@@ -3,12 +3,13 @@ use gettextrs::gettext;
 use gtk::{glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
 use log::{debug, error, warn};
 
+use super::Emoji;
 use crate::components::{AuthDialog, SpinnerButton};
 use crate::contrib::screenshot;
 use crate::contrib::QRCode;
 use crate::contrib::QRCodeExt;
 use crate::contrib::QrCodeScanner;
-use crate::session::verification::{Emoji, IdentityVerification, SasData, VerificationMode};
+use crate::session::verification::{IdentityVerification, SasData, VerificationMode};
 use crate::session::Session;
 use crate::spawn;
 use crate::Error;
diff --git a/src/session/mod.rs b/src/session/mod.rs
index c78e0647..6662d464 100644
--- a/src/session/mod.rs
+++ b/src/session/mod.rs
@@ -12,6 +12,7 @@ pub mod verification;
 
 use self::account_settings::AccountSettings;
 pub use self::avatar::Avatar;
+use self::content::verification::SessionVerification;
 use self::content::Content;
 use self::media_viewer::MediaViewer;
 pub use self::room::{Event, Item, Room};
@@ -19,7 +20,7 @@ pub use self::room_creation::RoomCreation;
 use self::room_list::RoomList;
 use self::sidebar::Sidebar;
 pub use self::user::{User, UserExt};
-use self::verification::{IdentityVerification, SessionVerification, VerificationList};
+use self::verification::{IdentityVerification, VerificationList};
 use crate::session::sidebar::ItemList;
 
 use crate::secret;
diff --git a/src/session/verification/mod.rs b/src/session/verification/mod.rs
index f886f63d..bdc24bdd 100644
--- a/src/session/verification/mod.rs
+++ b/src/session/verification/mod.rs
@@ -1,13 +1,7 @@
-mod emoji;
 mod identity_verification;
-mod incoming_verification;
-mod session_verification;
 mod verification_list;
 
-pub use self::emoji::Emoji;
 pub use self::identity_verification::{IdentityVerification, Mode as VerificationMode, SasData};
-pub use self::incoming_verification::IncomingVerification;
-pub use self::session_verification::SessionVerification;
 pub use self::verification_list::VerificationList;
 
 use std::time::Duration;


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