mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 08:44:40 +01:00
Update gtk-rs crates
This commit is contained in:
parent
b636361b02
commit
e271feb4e0
24 changed files with 615 additions and 696 deletions
1144
Cargo.lock
generated
1144
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
14
Cargo.toml
14
Cargo.toml
|
@ -4,18 +4,18 @@ name = "authenticator"
|
|||
version = "4.2.0"
|
||||
|
||||
[dependencies]
|
||||
adw = {package = "libadwaita", version = "0.2", features = ["v1_2"]}
|
||||
adw = {package = "libadwaita", version = "0.3", features = ["v1_2"]}
|
||||
anyhow = "1.0"
|
||||
ashpd = {version = "0.4.0-alpha.1", features = ["pipewire", "gtk4", "tracing"]}
|
||||
ashpd = {version = "0.4.0-alpha.4", features = ["pipewire", "gtk4", "tracing"]}
|
||||
binascii = "0.1"
|
||||
diesel = {version = "2.0", features = ["sqlite", "r2d2"]}
|
||||
diesel_migrations = {version = "2.0", features = ["sqlite"]}
|
||||
gettext-rs = {version = "0.7", features = ["gettext-system"]}
|
||||
gst = {package = "gstreamer", version = "0.19"}
|
||||
gst4gtk = { package = "gst-plugin-gtk4", version = "0.9", features = ["wayland", "x11egl", "x11glx"]}
|
||||
gtk = {package = "gtk4", version = "0.5", features = ["v4_10"]}
|
||||
gst = {package = "gstreamer", version = "0.20"}
|
||||
gst4gtk = { package = "gst-plugin-gtk4", version = "0.10", features = ["wayland", "x11egl", "x11glx"]}
|
||||
gtk = {package = "gtk4", version = "0.6", features = ["v4_10"]}
|
||||
gtk-macros = "0.3"
|
||||
search-provider = "0.4"
|
||||
search-provider = "0.5"
|
||||
hex = { version = "0.4.3", features = [ "serde" ] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
|
@ -25,7 +25,7 @@ qrcode = {version = "0.12", features = ["image"]}
|
|||
rand = "0.8"
|
||||
ring = "0.16"
|
||||
rust-argon2 = "1.0"
|
||||
oo7 = {version = "0.1.0-alpha.4", default-features = false, features = ["tokio_runtime", "tracing"]}
|
||||
oo7 = {version = "0.1.0-beta.3", default-features = false, features = ["tokio", "native_crypto", "tracing"]}
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
unicase = "2.6"
|
||||
|
|
|
@ -100,7 +100,7 @@ mod imp {
|
|||
preferences.set_has_set_password(app.can_be_locked());
|
||||
preferences.connect_restore_completed(clone!(@weak window =>move |_| {
|
||||
window.providers().refilter();
|
||||
window.imp().toast_overlay.add_toast(&adw::Toast::new(&gettext("Accounts restored successfully")));
|
||||
window.imp().toast_overlay.add_toast(adw::Toast::new(&gettext("Accounts restored successfully")));
|
||||
}));
|
||||
preferences.connect_has_set_password_notify(clone!(@weak app => move |_, state| {
|
||||
app.set_can_be_locked(state);
|
||||
|
@ -161,8 +161,7 @@ mod imp {
|
|||
lock_action,
|
||||
providers_action,
|
||||
preferences_action,
|
||||
])
|
||||
.unwrap();
|
||||
]);
|
||||
app.bind_property("can-be-locked", &get_action!(app, @lock), "enabled")
|
||||
.sync_create()
|
||||
.build();
|
||||
|
@ -317,13 +316,13 @@ impl Application {
|
|||
|
||||
let has_set_password =
|
||||
spawn_tokio_blocking(async { keyring::has_set_password().await.unwrap_or(false) });
|
||||
let app = glib::Object::new::<Application>(&[
|
||||
("application-id", &Some(config::APP_ID)),
|
||||
("flags", &gio::ApplicationFlags::HANDLES_OPEN),
|
||||
("resource-base-path", &"/com/belmoussaoui/Authenticator"),
|
||||
("is-locked", &has_set_password),
|
||||
("can-be-locked", &has_set_password),
|
||||
]);
|
||||
let app = glib::Object::builder::<Application>()
|
||||
.property("application-id", &Some(config::APP_ID))
|
||||
.property("flags", &gio::ApplicationFlags::HANDLES_OPEN)
|
||||
.property("resource-base-path", &"/com/belmoussaoui/Authenticator")
|
||||
.property("is-locked", &has_set_password)
|
||||
.property("can-be-locked", &has_set_password)
|
||||
.build();
|
||||
// Only load the model if the app is not locked
|
||||
if !has_set_password {
|
||||
app.imp().model.load();
|
||||
|
|
|
@ -234,13 +234,13 @@ impl Account {
|
|||
provider: Provider,
|
||||
token: Option<&str>,
|
||||
) -> Result<Account> {
|
||||
let account = glib::Object::new::<Self>(&[
|
||||
("id", &id),
|
||||
("name", &name),
|
||||
("token-id", &token_id),
|
||||
("provider", &provider),
|
||||
("counter", &counter),
|
||||
]);
|
||||
let account = glib::Object::builder::<Self>()
|
||||
.property("id", &id)
|
||||
.property("name", &name)
|
||||
.property("token-id", &token_id)
|
||||
.property("provider", &provider)
|
||||
.property("counter", &counter)
|
||||
.build();
|
||||
|
||||
let token = if let Some(t) = token {
|
||||
t.to_string()
|
||||
|
|
|
@ -35,6 +35,6 @@ glib::wrapper! {
|
|||
|
||||
impl Default for AccountSorter {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,6 @@ impl AccountsModel {
|
|||
|
||||
impl Default for AccountsModel {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ mod imp {
|
|||
image_uri: RefCell::default(),
|
||||
method: RefCell::new(OTPMethod::default().to_string()),
|
||||
period: Cell::new(otp::TOTP_DEFAULT_PERIOD),
|
||||
filter_model: gtk::FilterListModel::new(Some(&model), gtk::Filter::NONE),
|
||||
filter_model: gtk::FilterListModel::new(Some(model.clone()), None::<gtk::Filter>),
|
||||
accounts: model,
|
||||
tick_callback: RefCell::default(),
|
||||
remaining_time: Cell::default(),
|
||||
|
@ -307,18 +307,18 @@ impl Provider {
|
|||
help_url: Option<String>,
|
||||
image_uri: Option<String>,
|
||||
) -> Provider {
|
||||
glib::Object::new(&[
|
||||
("id", &id),
|
||||
("name", &name),
|
||||
("website", &website),
|
||||
("help-url", &help_url),
|
||||
("image-uri", &image_uri),
|
||||
("period", &period),
|
||||
("method", &method.to_string()),
|
||||
("algorithm", &algorithm.to_string()),
|
||||
("digits", &digits),
|
||||
("default-counter", &default_counter),
|
||||
])
|
||||
glib::Object::builder()
|
||||
.property("id", &id)
|
||||
.property("name", &name)
|
||||
.property("website", &website)
|
||||
.property("help-url", &help_url)
|
||||
.property("image-uri", &image_uri)
|
||||
.property("period", &period)
|
||||
.property("method", &method.to_string())
|
||||
.property("algorithm", &algorithm.to_string())
|
||||
.property("digits", &digits)
|
||||
.property("default-counter", &default_counter)
|
||||
.build()
|
||||
}
|
||||
|
||||
pub async fn favicon(
|
||||
|
|
|
@ -36,6 +36,6 @@ glib::wrapper! {
|
|||
|
||||
impl Default for ProviderSorter {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,6 +229,6 @@ impl ProvidersModel {
|
|||
|
||||
impl Default for ProvidersModel {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ glib::wrapper! {
|
|||
#[gtk::template_callbacks]
|
||||
impl AccountAddDialog {
|
||||
pub fn new(model: ProvidersModel) -> Self {
|
||||
let dialog = glib::Object::new::<Self>(&[]);
|
||||
let dialog = glib::Object::new::<Self>();
|
||||
|
||||
dialog.imp().model.set(model).unwrap();
|
||||
dialog.setup_widget();
|
||||
|
|
|
@ -104,6 +104,6 @@ impl QRCodePaintable {
|
|||
|
||||
impl Default for QRCodePaintable {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,9 @@ glib::wrapper! {
|
|||
|
||||
impl AccountRow {
|
||||
pub fn new(account: Account) -> Self {
|
||||
glib::Object::new(&[("account", &account)])
|
||||
glib::Object::builder()
|
||||
.property("account", &account)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn account(&self) -> Account {
|
||||
|
|
|
@ -15,7 +15,7 @@ use image::GenericImageView;
|
|||
use once_cell::sync::Lazy;
|
||||
|
||||
use super::{CameraItem, CameraRow};
|
||||
use crate::widgets::CameraPaintable;
|
||||
use crate::{utils::spawn_tokio, widgets::CameraPaintable};
|
||||
|
||||
mod screenshot {
|
||||
use super::*;
|
||||
|
@ -46,14 +46,18 @@ mod screenshot {
|
|||
} else {
|
||||
ashpd::WindowIdentifier::default()
|
||||
};
|
||||
let uri = ScreenshotRequest::default()
|
||||
.identifier(identifier)
|
||||
.modal(true)
|
||||
.interactive(true)
|
||||
.build()
|
||||
.await?;
|
||||
let uri = spawn_tokio(async {
|
||||
ScreenshotRequest::default()
|
||||
.identifier(identifier)
|
||||
.modal(true)
|
||||
.interactive(true)
|
||||
.build()
|
||||
.await?
|
||||
.response()
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(gio::File::for_uri(uri.as_str()))
|
||||
Ok(gio::File::for_uri(uri.uri().as_str()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +235,7 @@ impl Camera {
|
|||
|
||||
pub fn scan_from_camera(&self) {
|
||||
spawn!(clone!(@weak self as camera => async move {
|
||||
match ashpd::desktop::camera::request().await {
|
||||
match spawn_tokio(async {ashpd::desktop::camera::request().await }).await {
|
||||
Ok(Some((stream_fd, nodes_id))) => {
|
||||
match camera.imp().paintable.set_pipewire_fd(stream_fd) {
|
||||
Ok(_) => {
|
||||
|
@ -330,7 +334,7 @@ impl Camera {
|
|||
}
|
||||
}));
|
||||
}));
|
||||
let list_view = gtk::ListView::new(Some(&imp.selection), Some(&factory));
|
||||
let list_view = gtk::ListView::new(Some(imp.selection.clone()), Some(factory));
|
||||
popover.set_child(Some(&list_view));
|
||||
|
||||
imp.selection.connect_selected_item_notify(glib::clone!(@weak self as obj, @weak popover => move |selection| {
|
||||
|
@ -366,6 +370,6 @@ impl Camera {
|
|||
|
||||
impl Default for Camera {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ glib::wrapper! {
|
|||
|
||||
impl CameraPaintable {
|
||||
pub fn new(sender: Sender<CameraEvent>) -> Self {
|
||||
let paintable = glib::Object::new::<Self>(&[]);
|
||||
let paintable = glib::Object::new::<Self>();
|
||||
paintable.imp().sender.replace(Some(sender));
|
||||
paintable
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ glib::wrapper! {
|
|||
|
||||
impl Default for CameraRow {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ glib::wrapper! {
|
|||
|
||||
impl CameraPage {
|
||||
pub fn new(actions: gio::SimpleActionGroup) -> Self {
|
||||
let page = glib::Object::new::<Self>(&[]);
|
||||
let page = glib::Object::new::<Self>();
|
||||
page.imp().actions.set(actions).unwrap();
|
||||
page.setup_widget();
|
||||
page
|
||||
|
|
|
@ -107,7 +107,7 @@ glib::wrapper! {
|
|||
#[gtk::template_callbacks]
|
||||
impl PasswordPage {
|
||||
pub fn new(actions: gio::SimpleActionGroup) -> Self {
|
||||
let page = glib::Object::new::<Self>(&[]);
|
||||
let page = glib::Object::new::<Self>();
|
||||
page.imp().actions.set(actions).unwrap();
|
||||
page.setup_actions();
|
||||
page
|
||||
|
|
|
@ -147,7 +147,7 @@ glib::wrapper! {
|
|||
|
||||
impl PreferencesWindow {
|
||||
pub fn new(model: ProvidersModel) -> Self {
|
||||
let window = glib::Object::new::<Self>(&[]);
|
||||
let window = glib::Object::new::<Self>();
|
||||
window.imp().model.set(model).unwrap();
|
||||
window.setup_widget();
|
||||
window
|
||||
|
@ -403,7 +403,7 @@ impl PreferencesWindow {
|
|||
|
||||
get_action!(win.imp().actions, @close_page).activate(None);
|
||||
|
||||
win.add_toast(&adw::Toast::new(&gettext("Unable to restore accounts")));
|
||||
win.add_toast(adw::Toast::new(&gettext("Unable to restore accounts")));
|
||||
},
|
||||
},
|
||||
Err(error) => {
|
||||
|
@ -414,7 +414,7 @@ impl PreferencesWindow {
|
|||
|
||||
get_action!(win.imp().actions, @close_page).activate(None);
|
||||
|
||||
win.add_toast(&adw::Toast::new(&gettext("Something went wrong")));
|
||||
win.add_toast(adw::Toast::new(&gettext("Something went wrong")));
|
||||
},
|
||||
}
|
||||
});
|
||||
|
@ -436,13 +436,13 @@ impl PreferencesWindow {
|
|||
"scanned QR code: {}",
|
||||
), error);
|
||||
|
||||
win.add_toast(&adw::Toast::new(&gettext("Unable to restore accounts")));
|
||||
win.add_toast(adw::Toast::new(&gettext("Unable to restore accounts")));
|
||||
},
|
||||
},
|
||||
Err(error) => {
|
||||
tracing::error!("Encountered an error while trying to scan from the screenshot: {}", error);
|
||||
|
||||
win.add_toast(&adw::Toast::new(&gettext("Couldn't find a QR code")));
|
||||
win.add_toast(adw::Toast::new(&gettext("Couldn't find a QR code")));
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
@ -99,7 +99,7 @@ glib::wrapper! {
|
|||
#[gtk::template_callbacks]
|
||||
impl ProvidersDialog {
|
||||
pub fn new(model: ProvidersModel) -> Self {
|
||||
let dialog = glib::Object::new::<ProvidersDialog>(&[]);
|
||||
let dialog = glib::Object::new::<Self>();
|
||||
|
||||
dialog.setup_widget(model);
|
||||
dialog
|
||||
|
@ -133,9 +133,9 @@ impl ProvidersDialog {
|
|||
);
|
||||
|
||||
let sorter = ProviderSorter::default();
|
||||
let sort_model = gtk::SortListModel::new(Some(&imp.filter_model), Some(&sorter));
|
||||
let sort_model = gtk::SortListModel::new(Some(imp.filter_model.clone()), Some(sorter));
|
||||
|
||||
let selection_model = gtk::NoSelection::new(Some(&sort_model));
|
||||
let selection_model = gtk::NoSelection::new(Some(sort_model));
|
||||
imp.providers_list
|
||||
.bind_model(Some(&selection_model), move |obj| {
|
||||
let provider = obj.clone().downcast::<Provider>().unwrap();
|
||||
|
@ -241,7 +241,7 @@ impl ProvidersDialog {
|
|||
self.emit_by_name::<()>("changed", &[]);
|
||||
self.imp()
|
||||
.toast_overlay
|
||||
.add_toast(&adw::Toast::new(&gettext("Provider created successfully")));
|
||||
.add_toast(adw::Toast::new(&gettext("Provider created successfully")));
|
||||
self.set_view(View::Placeholder);
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ impl ProvidersDialog {
|
|||
self.emit_by_name::<()>("changed", &[]);
|
||||
self.imp()
|
||||
.toast_overlay
|
||||
.add_toast(&adw::Toast::new(&gettext("Provider updated successfully")));
|
||||
.add_toast(adw::Toast::new(&gettext("Provider updated successfully")));
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
|
@ -268,7 +268,7 @@ impl ProvidersDialog {
|
|||
self.emit_by_name::<()>("changed", &[]);
|
||||
self.imp()
|
||||
.toast_overlay
|
||||
.add_toast(&adw::Toast::new(&gettext("Provider removed successfully")));
|
||||
.add_toast(adw::Toast::new(&gettext("Provider removed successfully")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ mod row {
|
|||
|
||||
impl Default for ProviderActionRow {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ impl ProvidersList {
|
|||
fn setup_widget(&self) {
|
||||
let imp = self.imp();
|
||||
|
||||
let sort_model = gtk::SortListModel::new(Some(&imp.filter_model), Some(&imp.sorter));
|
||||
let sort_model =
|
||||
gtk::SortListModel::new(Some(imp.filter_model.clone()), Some(imp.sorter.clone()));
|
||||
|
||||
imp.providers_list.bind_model(
|
||||
Some(&sort_model),
|
||||
|
|
|
@ -408,6 +408,6 @@ impl ProviderPage {
|
|||
|
||||
impl Default for ProviderPage {
|
||||
fn default() -> Self {
|
||||
glib::Object::new(&[])
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,9 @@ glib::wrapper! {
|
|||
|
||||
impl ProviderRow {
|
||||
pub fn new(provider: Provider) -> Self {
|
||||
glib::Object::new(&[("provider", &provider)])
|
||||
glib::Object::builder()
|
||||
.property("provider", &provider)
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn connect_changed<F>(&self, callback: F) -> glib::SignalHandlerId
|
||||
|
@ -177,7 +179,8 @@ impl ProviderRow {
|
|||
.build();
|
||||
|
||||
let sorter = AccountSorter::default();
|
||||
let sort_model = gtk::SortListModel::new(Some(provider.accounts()), Some(&sorter));
|
||||
let sort_model =
|
||||
gtk::SortListModel::new(Some(provider.accounts().clone()), Some(sorter.clone()));
|
||||
|
||||
let create_callback = clone!(@strong self as provider_row, @strong sorter, @strong provider => move |account: &glib::Object| {
|
||||
let account = account.clone().downcast::<Account>().unwrap();
|
||||
|
|
|
@ -67,7 +67,7 @@ mod imp {
|
|||
};
|
||||
}));
|
||||
|
||||
obj.add_controller(&gesture);
|
||||
obj.add_controller(gesture);
|
||||
|
||||
let image_suffix = gtk::Image::from_icon_name("link-symbolic");
|
||||
image_suffix.add_css_class("dim-label");
|
||||
|
|
|
@ -146,7 +146,9 @@ glib::wrapper! {
|
|||
#[gtk::template_callbacks]
|
||||
impl Window {
|
||||
pub fn new(model: ProvidersModel, app: &Application) -> Self {
|
||||
let window = glib::Object::new::<Window>(&[("application", app)]);
|
||||
let window = glib::Object::builder::<Window>()
|
||||
.property("application", app)
|
||||
.build();
|
||||
app.add_window(&window);
|
||||
|
||||
if config::PROFILE == "Devel" {
|
||||
|
@ -201,7 +203,7 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn add_toast(&self, toast: adw::Toast) {
|
||||
self.imp().toast_overlay.add_toast(&toast);
|
||||
self.imp().toast_overlay.add_toast(toast);
|
||||
}
|
||||
|
||||
pub fn open_add_account(&self, otp_uri: Option<&OTPUri>) {
|
||||
|
|
Loading…
Add table
Reference in a new issue