verification: Move widgets to content and rename some

This commit is contained in:
Julian Sparber 2021-12-17 17:33:57 +01:00
parent b2c9b70673
commit 15afbb7022
12 changed files with 62 additions and 49 deletions

View file

@ -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>

View file

@ -75,7 +75,7 @@
</object>
</child>
<child>
<object class="IncomingVerification" id="incoming_verification"/>
<object class="IdentityVerificationWidget" id="identity_verification_widget"/>
</child>
</object>
</child>

View file

@ -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>

View file

@ -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

View file

@ -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',
)

View file

@ -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);
}
}

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;