mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 16:54:45 +01:00
adapt per latest gtk-rs api changes
This commit is contained in:
parent
b867c5c19b
commit
9e78e50a09
19 changed files with 183 additions and 302 deletions
|
@ -11,7 +11,7 @@ use gtk_macros::{action, get_action};
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use glib::{ParamSpec, WeakRef};
|
use glib::{ParamSpec, ParamSpecBoolean, Value, WeakRef};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
|
||||||
// The basic struct that holds our state and widgets
|
// The basic struct that holds our state and widgets
|
||||||
|
@ -54,14 +54,14 @@ mod imp {
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
ParamSpec::new_boolean(
|
ParamSpecBoolean::new(
|
||||||
"locked",
|
"locked",
|
||||||
"locked",
|
"locked",
|
||||||
"locked",
|
"locked",
|
||||||
false,
|
false,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_boolean(
|
ParamSpecBoolean::new(
|
||||||
"can-be-locked",
|
"can-be-locked",
|
||||||
"can_be_locked",
|
"can_be_locked",
|
||||||
"can be locked",
|
"can be locked",
|
||||||
|
@ -72,13 +72,7 @@ mod imp {
|
||||||
});
|
});
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"locked" => {
|
"locked" => {
|
||||||
let locked = value.get().unwrap();
|
let locked = value.get().unwrap();
|
||||||
|
@ -92,7 +86,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"locked" => self.locked.get().to_value(),
|
"locked" => self.locked.get().to_value(),
|
||||||
"can-be-locked" => self.can_be_locked.get().to_value(),
|
"can-be-locked" => self.can_be_locked.get().to_value(),
|
||||||
|
@ -136,7 +130,7 @@ mod imp {
|
||||||
"about",
|
"about",
|
||||||
clone!(@weak app => move |_, _| {
|
clone!(@weak app => move |_, _| {
|
||||||
let window = app.active_window().unwrap();
|
let window = app.active_window().unwrap();
|
||||||
let about_dialog = gtk::AboutDialogBuilder::new()
|
gtk::AboutDialog::builder()
|
||||||
.program_name(&gettext("Authenticator"))
|
.program_name(&gettext("Authenticator"))
|
||||||
.modal(true)
|
.modal(true)
|
||||||
.version(config::VERSION)
|
.version(config::VERSION)
|
||||||
|
@ -148,9 +142,8 @@ mod imp {
|
||||||
.logo_icon_name(config::APP_ID)
|
.logo_icon_name(config::APP_ID)
|
||||||
.license_type(gtk::License::Gpl30)
|
.license_type(gtk::License::Gpl30)
|
||||||
.transient_for(&window)
|
.transient_for(&window)
|
||||||
.build();
|
.build()
|
||||||
|
.show();
|
||||||
about_dialog.show();
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
action!(
|
action!(
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub struct DiAccount {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::ParamSpec;
|
use glib::{ParamSpec, ParamSpecObject, ParamSpecString, ParamSpecUInt, Value};
|
||||||
|
|
||||||
pub struct Account {
|
pub struct Account {
|
||||||
pub id: Cell<u32>,
|
pub id: Cell<u32>,
|
||||||
|
@ -75,7 +75,7 @@ mod imp {
|
||||||
|
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
ParamSpec::new_uint(
|
ParamSpecUInt::new(
|
||||||
"id",
|
"id",
|
||||||
"id",
|
"id",
|
||||||
"Id",
|
"Id",
|
||||||
|
@ -84,7 +84,7 @@ mod imp {
|
||||||
0,
|
0,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_uint(
|
ParamSpecUInt::new(
|
||||||
"counter",
|
"counter",
|
||||||
"counter",
|
"counter",
|
||||||
"Counter",
|
"Counter",
|
||||||
|
@ -93,28 +93,22 @@ mod imp {
|
||||||
otp::HOTP_DEFAULT_COUNTER,
|
otp::HOTP_DEFAULT_COUNTER,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new("name", "name", "Name", None, glib::ParamFlags::READWRITE),
|
||||||
"name",
|
ParamSpecString::new(
|
||||||
"name",
|
|
||||||
"Name",
|
|
||||||
None,
|
|
||||||
glib::ParamFlags::READWRITE,
|
|
||||||
),
|
|
||||||
ParamSpec::new_string(
|
|
||||||
"token-id",
|
"token-id",
|
||||||
"token-id",
|
"token-id",
|
||||||
"token id",
|
"token id",
|
||||||
None,
|
None,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"otp",
|
"otp",
|
||||||
"otp",
|
"otp",
|
||||||
"The One Time Password",
|
"The One Time Password",
|
||||||
None,
|
None,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_object(
|
ParamSpecObject::new(
|
||||||
"provider",
|
"provider",
|
||||||
"provider",
|
"provider",
|
||||||
"The account provider",
|
"The account provider",
|
||||||
|
@ -126,13 +120,7 @@ mod imp {
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"id" => {
|
"id" => {
|
||||||
let id = value.get().unwrap();
|
let id = value.get().unwrap();
|
||||||
|
@ -162,7 +150,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"id" => self.id.get().to_value(),
|
"id" => self.id.get().to_value(),
|
||||||
"name" => self.name.borrow().to_value(),
|
"name" => self.name.borrow().to_value(),
|
||||||
|
@ -250,7 +238,7 @@ impl Account {
|
||||||
provider: Provider,
|
provider: Provider,
|
||||||
token: Option<&str>,
|
token: Option<&str>,
|
||||||
) -> Result<Account> {
|
) -> Result<Account> {
|
||||||
let account = glib::Object::new(&[
|
let account = glib::Object::new::<Self>(&[
|
||||||
("id", &id),
|
("id", &id),
|
||||||
("name", &name),
|
("name", &name),
|
||||||
("token-id", &token_id),
|
("token-id", &token_id),
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
use gettextrs::gettext;
|
use gettextrs::gettext;
|
||||||
use gtk::{glib, glib::GEnum};
|
use gtk::glib;
|
||||||
use ring::hmac;
|
use ring::hmac;
|
||||||
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize};
|
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize};
|
||||||
use std::{str::FromStr, string::ToString};
|
use std::{str::FromStr, string::ToString};
|
||||||
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, GEnum)]
|
#[derive(Debug, Eq, PartialEq, Clone, Copy, glib::Enum)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[genum(type_name = "OTPMethod")]
|
#[enum_type(name = "OTPMethod")]
|
||||||
pub enum OTPMethod {
|
pub enum OTPMethod {
|
||||||
#[genum(name = "TOTP")]
|
#[enum_value(name = "TOTP")]
|
||||||
TOTP = 0,
|
TOTP = 0,
|
||||||
#[genum(name = "HOTP")]
|
#[enum_value(name = "HOTP")]
|
||||||
HOTP = 1,
|
HOTP = 1,
|
||||||
Steam = 2,
|
Steam = 2,
|
||||||
}
|
}
|
||||||
|
@ -85,15 +85,15 @@ impl ToString for OTPMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, GEnum)]
|
#[derive(Debug, Eq, PartialEq, Clone, Copy, glib::Enum)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[genum(type_name = "Algorithm")]
|
#[enum_type(name = "Algorithm")]
|
||||||
pub enum Algorithm {
|
pub enum Algorithm {
|
||||||
#[genum(name = "SHA1")]
|
#[enum_value(name = "SHA1")]
|
||||||
SHA1 = 0,
|
SHA1 = 0,
|
||||||
#[genum(name = "SHA256")]
|
#[enum_value(name = "SHA256")]
|
||||||
SHA256 = 1,
|
SHA256 = 1,
|
||||||
#[genum(name = "SHA512")]
|
#[enum_value(name = "SHA512")]
|
||||||
SHA512 = 2,
|
SHA512 = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub struct DiProvider {
|
||||||
}
|
}
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::ParamSpec;
|
use glib::{ParamSpec, ParamSpecObject, ParamSpecString, ParamSpecUInt, Value};
|
||||||
|
|
||||||
pub struct Provider {
|
pub struct Provider {
|
||||||
pub id: Cell<u32>,
|
pub id: Cell<u32>,
|
||||||
|
@ -109,7 +109,7 @@ mod imp {
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
ParamSpec::new_uint(
|
ParamSpecUInt::new(
|
||||||
"id",
|
"id",
|
||||||
"id",
|
"id",
|
||||||
"Id",
|
"Id",
|
||||||
|
@ -118,21 +118,15 @@ mod imp {
|
||||||
0,
|
0,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new("name", "name", "Name", None, glib::ParamFlags::READWRITE),
|
||||||
"name",
|
ParamSpecObject::new(
|
||||||
"name",
|
|
||||||
"Name",
|
|
||||||
None,
|
|
||||||
glib::ParamFlags::READWRITE,
|
|
||||||
),
|
|
||||||
ParamSpec::new_object(
|
|
||||||
"accounts",
|
"accounts",
|
||||||
"accounts",
|
"accounts",
|
||||||
"accounts",
|
"accounts",
|
||||||
AccountsModel::static_type(),
|
AccountsModel::static_type(),
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_uint(
|
ParamSpecUInt::new(
|
||||||
"period",
|
"period",
|
||||||
"period",
|
"period",
|
||||||
"Period",
|
"Period",
|
||||||
|
@ -141,7 +135,7 @@ mod imp {
|
||||||
otp::TOTP_DEFAULT_PERIOD,
|
otp::TOTP_DEFAULT_PERIOD,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_uint(
|
ParamSpecUInt::new(
|
||||||
"digits",
|
"digits",
|
||||||
"digits",
|
"digits",
|
||||||
"Digits",
|
"Digits",
|
||||||
|
@ -150,7 +144,7 @@ mod imp {
|
||||||
otp::DEFAULT_DIGITS,
|
otp::DEFAULT_DIGITS,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_uint(
|
ParamSpecUInt::new(
|
||||||
"default-counter",
|
"default-counter",
|
||||||
"default_counter",
|
"default_counter",
|
||||||
"default_counter",
|
"default_counter",
|
||||||
|
@ -159,35 +153,35 @@ mod imp {
|
||||||
otp::HOTP_DEFAULT_COUNTER,
|
otp::HOTP_DEFAULT_COUNTER,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"algorithm",
|
"algorithm",
|
||||||
"algorithm",
|
"algorithm",
|
||||||
"Algorithm",
|
"Algorithm",
|
||||||
Some(&Algorithm::default().to_string()),
|
Some(&Algorithm::default().to_string()),
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"method",
|
"method",
|
||||||
"method",
|
"method",
|
||||||
"Method",
|
"Method",
|
||||||
Some(&OTPMethod::default().to_string()),
|
Some(&OTPMethod::default().to_string()),
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"website",
|
"website",
|
||||||
"website",
|
"website",
|
||||||
"Website",
|
"Website",
|
||||||
None,
|
None,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"help-url",
|
"help-url",
|
||||||
"help url",
|
"help url",
|
||||||
"Help URL",
|
"Help URL",
|
||||||
None,
|
None,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"image-uri",
|
"image-uri",
|
||||||
"image uri",
|
"image uri",
|
||||||
"Image URI",
|
"Image URI",
|
||||||
|
@ -199,13 +193,7 @@ mod imp {
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"id" => {
|
"id" => {
|
||||||
let id = value.get().unwrap();
|
let id = value.get().unwrap();
|
||||||
|
@ -251,7 +239,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"id" => self.id.get().to_value(),
|
"id" => self.id.get().to_value(),
|
||||||
"name" => self.name.borrow().to_value(),
|
"name" => self.name.borrow().to_value(),
|
||||||
|
|
|
@ -120,7 +120,7 @@ glib::wrapper! {
|
||||||
|
|
||||||
impl AccountAddDialog {
|
impl AccountAddDialog {
|
||||||
pub fn new(model: ProvidersModel) -> Self {
|
pub fn new(model: ProvidersModel) -> Self {
|
||||||
let dialog = glib::Object::new(&[]).expect("Failed to create AccountAddDialog");
|
let dialog = glib::Object::new::<Self>(&[]).expect("Failed to create AccountAddDialog");
|
||||||
|
|
||||||
dialog.imp().model.set(model).unwrap();
|
dialog.imp().model.set(model).unwrap();
|
||||||
dialog.setup_actions();
|
dialog.setup_actions();
|
||||||
|
@ -141,11 +141,9 @@ impl AccountAddDialog {
|
||||||
fn setup_signals(&self) {
|
fn setup_signals(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
imp
|
imp.username_entry
|
||||||
.username_entry
|
|
||||||
.connect_changed(clone!(@weak self as win => move |_| win.validate()));
|
.connect_changed(clone!(@weak self as win => move |_| win.validate()));
|
||||||
imp
|
imp.token_entry
|
||||||
.token_entry
|
|
||||||
.connect_changed(clone!(@weak self as win => move |_| win.validate()));
|
.connect_changed(clone!(@weak self as win => move |_| win.validate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +199,7 @@ impl AccountAddDialog {
|
||||||
let account = Account::create(&username, &token, provider)?;
|
let account = Account::create(&username, &token, provider)?;
|
||||||
|
|
||||||
imp.model.get().unwrap().add_account(&account, &provider);
|
imp.model.get().unwrap().add_account(&account, &provider);
|
||||||
self.emit_by_name("added", &[]);
|
self.emit_by_name::<()>("added", &[]);
|
||||||
// TODO: display an error message saying there was an error form keyring
|
// TODO: display an error message saying there was an error form keyring
|
||||||
} else {
|
} else {
|
||||||
anyhow::bail!("Could not find provider");
|
anyhow::bail!("Could not find provider");
|
||||||
|
@ -218,12 +216,10 @@ impl AccountAddDialog {
|
||||||
|
|
||||||
imp.image.set_provider(Some(&provider));
|
imp.image.set_provider(Some(&provider));
|
||||||
|
|
||||||
imp
|
imp.method_label
|
||||||
.method_label
|
|
||||||
.set_text(&provider.method().to_locale_string());
|
.set_text(&provider.method().to_locale_string());
|
||||||
|
|
||||||
imp
|
imp.algorithm_label
|
||||||
.algorithm_label
|
|
||||||
.set_text(&provider.algorithm().to_locale_string());
|
.set_text(&provider.algorithm().to_locale_string());
|
||||||
|
|
||||||
imp.digits_label.set_text(&provider.digits().to_string());
|
imp.digits_label.set_text(&provider.digits().to_string());
|
||||||
|
@ -297,8 +293,7 @@ impl AccountAddDialog {
|
||||||
|
|
||||||
fn setup_widgets(&self) {
|
fn setup_widgets(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
imp
|
imp.provider_completion
|
||||||
.provider_completion
|
|
||||||
.set_model(Some(&imp.model.get().unwrap().completion_model()));
|
.set_model(Some(&imp.model.get().unwrap().completion_model()));
|
||||||
|
|
||||||
imp.provider_completion.connect_match_selected(
|
imp.provider_completion.connect_match_selected(
|
||||||
|
|
|
@ -69,8 +69,7 @@ impl AccountDetailsPage {
|
||||||
|
|
||||||
fn init_widgets(&self) {
|
fn init_widgets(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
imp
|
imp.qrcode_picture
|
||||||
.qrcode_picture
|
|
||||||
.set_paintable(Some(&imp.qrcode_paintable));
|
.set_paintable(Some(&imp.qrcode_paintable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::{
|
use glib::{
|
||||||
subclass::{self, Signal},
|
subclass::{self, Signal},
|
||||||
ParamSpec,
|
ParamSpec, ParamSpecObject, Value,
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ mod imp {
|
||||||
|
|
||||||
fn properties() -> &'static [ParamSpec] {
|
fn properties() -> &'static [ParamSpec] {
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![ParamSpec::new_object(
|
vec![ParamSpecObject::new(
|
||||||
"account",
|
"account",
|
||||||
"Account",
|
"Account",
|
||||||
"The account",
|
"The account",
|
||||||
|
@ -69,13 +69,7 @@ mod imp {
|
||||||
});
|
});
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"account" => {
|
"account" => {
|
||||||
let account = value.get().unwrap();
|
let account = value.get().unwrap();
|
||||||
|
@ -85,7 +79,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"account" => self.account.borrow().to_value(),
|
"account" => self.account.borrow().to_value(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
|
@ -118,7 +112,7 @@ impl AccountRow {
|
||||||
fn setup_widgets(&self) {
|
fn setup_widgets(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
self.connect_activate(move |row| {
|
self.connect_activate(move |row| {
|
||||||
row.activate_action("account.details", None);
|
row.activate_action("account.details", None).unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.account()
|
self.account()
|
||||||
|
@ -141,14 +135,12 @@ impl AccountRow {
|
||||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
imp
|
imp.name_entry
|
||||||
.name_entry
|
|
||||||
.connect_changed(clone!(@weak imp.actions as actions => move |entry| {
|
.connect_changed(clone!(@weak imp.actions as actions => move |entry| {
|
||||||
let name = entry.text();
|
let name = entry.text();
|
||||||
get_action!(actions, @save).set_enabled(!name.is_empty());
|
get_action!(actions, @save).set_enabled(!name.is_empty());
|
||||||
}));
|
}));
|
||||||
imp
|
imp.name_entry
|
||||||
.name_entry
|
|
||||||
.connect_activate(clone!(@weak imp.actions as actions => move |_| {
|
.connect_activate(clone!(@weak imp.actions as actions => move |_| {
|
||||||
actions.activate_action("save", None);
|
actions.activate_action("save", None);
|
||||||
}));
|
}));
|
||||||
|
@ -169,7 +161,7 @@ impl AccountRow {
|
||||||
imp.actions,
|
imp.actions,
|
||||||
"details",
|
"details",
|
||||||
clone!(@weak self as row => move |_, _| {
|
clone!(@weak self as row => move |_, _| {
|
||||||
row.emit_by_name("shared", &[]);
|
row.emit_by_name::<()>("shared", &[]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -177,7 +169,7 @@ impl AccountRow {
|
||||||
imp.actions,
|
imp.actions,
|
||||||
"delete",
|
"delete",
|
||||||
clone!(@weak self as row => move |_, _| {
|
clone!(@weak self as row => move |_, _| {
|
||||||
row.emit_by_name("removed", &[]);
|
row.emit_by_name::<()>("removed", &[]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -212,8 +212,7 @@ impl Camera {
|
||||||
let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap();
|
let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap();
|
||||||
glsinkbin.set_property("sink", &imp.sink);
|
glsinkbin.set_property("sink", &imp.sink);
|
||||||
|
|
||||||
imp
|
imp.pipeline
|
||||||
.pipeline
|
|
||||||
.add_many(&[
|
.add_many(&[
|
||||||
&source_element,
|
&source_element,
|
||||||
&tee,
|
&tee,
|
||||||
|
@ -298,7 +297,7 @@ impl Camera {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
match event {
|
match event {
|
||||||
CameraEvent::CodeDetected(code) => {
|
CameraEvent::CodeDetected(code) => {
|
||||||
self.emit_by_name("code-detected", &[&code]);
|
self.emit_by_name::<()>("code-detected", &[&code]);
|
||||||
}
|
}
|
||||||
CameraEvent::DeviceAdded(device) => {
|
CameraEvent::DeviceAdded(device) => {
|
||||||
info!("Camera source added: {}", device.display_name());
|
info!("Camera source added: {}", device.display_name());
|
||||||
|
|
|
@ -2,18 +2,18 @@ mod accounts;
|
||||||
mod camera;
|
mod camera;
|
||||||
mod error_revealer;
|
mod error_revealer;
|
||||||
mod preferences;
|
mod preferences;
|
||||||
|
mod progress_icon;
|
||||||
mod providers;
|
mod providers;
|
||||||
mod url_row;
|
mod url_row;
|
||||||
mod window;
|
mod window;
|
||||||
mod progress_icon;
|
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
accounts::{AccountAddDialog, QRCodeData},
|
accounts::{AccountAddDialog, QRCodeData},
|
||||||
camera::Camera,
|
camera::Camera,
|
||||||
error_revealer::ErrorRevealer,
|
error_revealer::ErrorRevealer,
|
||||||
preferences::PreferencesWindow,
|
preferences::PreferencesWindow,
|
||||||
|
progress_icon::{ProgressIcon, ProgressIconExt},
|
||||||
providers::{ProviderImage, ProvidersDialog, ProvidersList},
|
providers::{ProviderImage, ProvidersDialog, ProvidersList},
|
||||||
url_row::UrlRow,
|
url_row::UrlRow,
|
||||||
progress_icon::{ProgressIcon, ProgressIconExt},
|
|
||||||
window::{View, Window},
|
window::{View, Window},
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::cell::Cell;
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::{subclass, ParamSpec};
|
use glib::{subclass, ParamSpec, ParamSpecBoolean, Value};
|
||||||
use gtk::subclass::widget::WidgetImplExt;
|
use gtk::subclass::widget::WidgetImplExt;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ mod imp {
|
||||||
fn properties() -> &'static [ParamSpec] {
|
fn properties() -> &'static [ParamSpec] {
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![ParamSpec::new_boolean(
|
vec![ParamSpecBoolean::new(
|
||||||
"has-set-password",
|
"has-set-password",
|
||||||
"has set password",
|
"has set password",
|
||||||
"Has Set Password",
|
"Has Set Password",
|
||||||
|
@ -75,13 +75,7 @@ mod imp {
|
||||||
});
|
});
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"has-set-password" => {
|
"has-set-password" => {
|
||||||
let has_set_password = value.get().unwrap();
|
let has_set_password = value.get().unwrap();
|
||||||
|
@ -91,7 +85,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"has-set-password" => self.has_set_password.get().to_value(),
|
"has-set-password" => self.has_set_password.get().to_value(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
|
@ -113,7 +107,7 @@ glib::wrapper! {
|
||||||
|
|
||||||
impl PasswordPage {
|
impl PasswordPage {
|
||||||
pub fn new(actions: gio::SimpleActionGroup) -> Self {
|
pub fn new(actions: gio::SimpleActionGroup) -> Self {
|
||||||
let page = glib::Object::new(&[]).expect("Failed to create PasswordPage");
|
let page = glib::Object::new::<Self>(&[]).expect("Failed to create PasswordPage");
|
||||||
page.imp().actions.set(actions).unwrap();
|
page.imp().actions.set(actions).unwrap();
|
||||||
page.setup_widgets();
|
page.setup_widgets();
|
||||||
page.setup_actions();
|
page.setup_actions();
|
||||||
|
@ -149,11 +143,9 @@ impl PasswordPage {
|
||||||
|
|
||||||
imp.status_page.set_icon_name(Some(config::APP_ID));
|
imp.status_page.set_icon_name(Some(config::APP_ID));
|
||||||
|
|
||||||
imp
|
imp.password_entry
|
||||||
.password_entry
|
|
||||||
.connect_changed(clone!(@weak self as page=> move |_| page.validate()));
|
.connect_changed(clone!(@weak self as page=> move |_| page.validate()));
|
||||||
imp
|
imp.confirm_password_entry
|
||||||
.confirm_password_entry
|
|
||||||
.connect_changed(clone!(@weak self as page => move |_| page.validate()));
|
.connect_changed(clone!(@weak self as page => move |_| page.validate()));
|
||||||
|
|
||||||
self.reset_validation();
|
self.reset_validation();
|
||||||
|
@ -171,8 +163,7 @@ impl PasswordPage {
|
||||||
fn reset_validation(&self) {
|
fn reset_validation(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
if self.has_set_password() {
|
if self.has_set_password() {
|
||||||
imp
|
imp.current_password_entry
|
||||||
.current_password_entry
|
|
||||||
.connect_changed(clone!(@weak self as page => move |_| page.validate()));
|
.connect_changed(clone!(@weak self as page => move |_| page.validate()));
|
||||||
} else if let Some(handler_id) = imp.default_password_signal.borrow_mut().take() {
|
} else if let Some(handler_id) = imp.default_password_signal.borrow_mut().take() {
|
||||||
imp.current_password_entry.disconnect(handler_id);
|
imp.current_password_entry.disconnect(handler_id);
|
||||||
|
|
|
@ -20,7 +20,7 @@ mod imp {
|
||||||
use adw::subclass::{preferences_window::PreferencesWindowImpl, window::AdwWindowImpl};
|
use adw::subclass::{preferences_window::PreferencesWindowImpl, window::AdwWindowImpl};
|
||||||
use glib::{
|
use glib::{
|
||||||
subclass::{self, Signal},
|
subclass::{self, Signal},
|
||||||
ParamSpec,
|
ParamSpec, ParamSpecBoolean, Value,
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
@ -87,7 +87,7 @@ mod imp {
|
||||||
impl ObjectImpl for PreferencesWindow {
|
impl ObjectImpl for PreferencesWindow {
|
||||||
fn properties() -> &'static [ParamSpec] {
|
fn properties() -> &'static [ParamSpec] {
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![ParamSpec::new_boolean(
|
vec![ParamSpecBoolean::new(
|
||||||
"has-set-password",
|
"has-set-password",
|
||||||
"has set password",
|
"has set password",
|
||||||
"Has Set Password",
|
"Has Set Password",
|
||||||
|
@ -109,13 +109,7 @@ mod imp {
|
||||||
SIGNALS.as_ref()
|
SIGNALS.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"has-set-password" => {
|
"has-set-password" => {
|
||||||
let has_set_password = value.get().unwrap();
|
let has_set_password = value.get().unwrap();
|
||||||
|
@ -125,7 +119,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"has-set-password" => self.has_set_password.get().to_value(),
|
"has-set-password" => self.has_set_password.get().to_value(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
|
@ -150,7 +144,7 @@ glib::wrapper! {
|
||||||
|
|
||||||
impl PreferencesWindow {
|
impl PreferencesWindow {
|
||||||
pub fn new(model: ProvidersModel) -> Self {
|
pub fn new(model: ProvidersModel) -> Self {
|
||||||
let window = glib::Object::new(&[]).expect("Failed to create PreferencesWindow");
|
let window = glib::Object::new::<Self>(&[]).expect("Failed to create PreferencesWindow");
|
||||||
window.imp().model.set(model).unwrap();
|
window.imp().model.set(model).unwrap();
|
||||||
window.setup_widgets();
|
window.setup_widgets();
|
||||||
window
|
window
|
||||||
|
@ -167,21 +161,17 @@ impl PreferencesWindow {
|
||||||
fn setup_widgets(&self) {
|
fn setup_widgets(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
imp
|
imp.settings
|
||||||
.settings
|
|
||||||
.bind("dark-theme", &*imp.dark_theme, "active")
|
.bind("dark-theme", &*imp.dark_theme, "active")
|
||||||
.build();
|
.build();
|
||||||
imp
|
imp.settings
|
||||||
.settings
|
|
||||||
.bind("auto-lock", &*imp.auto_lock, "active")
|
.bind("auto-lock", &*imp.auto_lock, "active")
|
||||||
.build();
|
.build();
|
||||||
imp
|
imp.settings
|
||||||
.settings
|
|
||||||
.bind("auto-lock-timeout", &*imp.lock_timeout, "value")
|
.bind("auto-lock-timeout", &*imp.lock_timeout, "value")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
imp
|
imp.password_page
|
||||||
.password_page
|
|
||||||
.bind_property("has-set-password", self, "has-set-password")
|
.bind_property("has-set-password", self, "has-set-password")
|
||||||
.flags(glib::BindingFlags::BIDIRECTIONAL | glib::BindingFlags::SYNC_CREATE)
|
.flags(glib::BindingFlags::BIDIRECTIONAL | glib::BindingFlags::SYNC_CREATE)
|
||||||
.build();
|
.build();
|
||||||
|
@ -198,7 +188,7 @@ impl PreferencesWindow {
|
||||||
fn register_backup<T: Backupable>(&self, filters: &'static [&str]) {
|
fn register_backup<T: Backupable>(&self, filters: &'static [&str]) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
let row = adw::ActionRowBuilder::new()
|
let row = adw::ActionRow::builder()
|
||||||
.title(&T::title())
|
.title(&T::title())
|
||||||
.subtitle(&T::subtitle())
|
.subtitle(&T::subtitle())
|
||||||
.activatable(true)
|
.activatable(true)
|
||||||
|
@ -229,7 +219,7 @@ impl PreferencesWindow {
|
||||||
fn register_restore<T: Restorable>(&self, filters: &'static [&str]) {
|
fn register_restore<T: Restorable>(&self, filters: &'static [&str]) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
let row = adw::ActionRowBuilder::new()
|
let row = adw::ActionRow::builder()
|
||||||
.title(&T::title())
|
.title(&T::title())
|
||||||
.subtitle(&T::subtitle())
|
.subtitle(&T::subtitle())
|
||||||
.activatable(true)
|
.activatable(true)
|
||||||
|
@ -272,7 +262,7 @@ impl PreferencesWindow {
|
||||||
warn!("Failed to restore item {}", err);
|
warn!("Failed to restore item {}", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.emit_by_name("restore-completed", &[]);
|
self.emit_by_name::<()>("restore-completed", &[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_file(
|
fn select_file(
|
||||||
|
@ -316,14 +306,12 @@ impl PreferencesWindow {
|
||||||
fn setup_actions(&self) {
|
fn setup_actions(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
imp
|
imp.password_page
|
||||||
.password_page
|
|
||||||
.connect_map(clone!(@weak self as win => move |_| {
|
.connect_map(clone!(@weak self as win => move |_| {
|
||||||
win.set_search_enabled(false);
|
win.set_search_enabled(false);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
imp
|
imp.password_page
|
||||||
.password_page
|
|
||||||
.connect_unmap(clone!(@weak self as win => move |_| {
|
.connect_unmap(clone!(@weak self as win => move |_| {
|
||||||
win.set_search_enabled(true);
|
win.set_search_enabled(true);
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
use gtk::{glib, gdk};
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::subclass::prelude::*;
|
use gtk::subclass::prelude::*;
|
||||||
|
use gtk::{gdk, glib};
|
||||||
|
|
||||||
pub(crate) mod imp {
|
pub(crate) mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use glib::{ParamSpec, ParamSpecBoolean, ParamSpecFloat, Value};
|
||||||
use gtk::{graphene, gsk};
|
use gtk::{graphene, gsk};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::cell::RefCell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct ProgressIcon {
|
pub struct ProgressIcon {
|
||||||
pub progress: RefCell<f32>,
|
pub progress: Cell<f32>,
|
||||||
pub inverted: RefCell<bool>,
|
pub inverted: Cell<bool>,
|
||||||
pub clockwise: RefCell<bool>,
|
pub clockwise: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
@ -24,18 +24,18 @@ pub(crate) mod imp {
|
||||||
|
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
progress: RefCell::new(0.0),
|
progress: Cell::new(0.0),
|
||||||
inverted: RefCell::new(false),
|
inverted: Cell::new(false),
|
||||||
clockwise: RefCell::new(true),
|
clockwise: Cell::new(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectImpl for ProgressIcon {
|
impl ObjectImpl for ProgressIcon {
|
||||||
fn properties() -> &'static [glib::ParamSpec] {
|
fn properties() -> &'static [ParamSpec] {
|
||||||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
glib::ParamSpec::new_float(
|
ParamSpecFloat::new(
|
||||||
"progress",
|
"progress",
|
||||||
"Progress",
|
"Progress",
|
||||||
"Progress of the icon",
|
"Progress of the icon",
|
||||||
|
@ -44,14 +44,14 @@ pub(crate) mod imp {
|
||||||
0.0,
|
0.0,
|
||||||
glib::ParamFlags::READWRITE | glib::ParamFlags::EXPLICIT_NOTIFY,
|
glib::ParamFlags::READWRITE | glib::ParamFlags::EXPLICIT_NOTIFY,
|
||||||
),
|
),
|
||||||
glib::ParamSpec::new_boolean(
|
ParamSpecBoolean::new(
|
||||||
"inverted",
|
"inverted",
|
||||||
"Inverted",
|
"Inverted",
|
||||||
"Invert icon colors",
|
"Invert icon colors",
|
||||||
false,
|
false,
|
||||||
glib::ParamFlags::READWRITE | glib::ParamFlags::EXPLICIT_NOTIFY,
|
glib::ParamFlags::READWRITE | glib::ParamFlags::EXPLICIT_NOTIFY,
|
||||||
),
|
),
|
||||||
glib::ParamSpec::new_boolean(
|
ParamSpecBoolean::new(
|
||||||
"clockwise",
|
"clockwise",
|
||||||
"Clockwise",
|
"Clockwise",
|
||||||
"Direction of the icon",
|
"Direction of the icon",
|
||||||
|
@ -63,7 +63,7 @@ pub(crate) mod imp {
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
fn property(&self, obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"progress" => obj.progress().to_value(),
|
"progress" => obj.progress().to_value(),
|
||||||
"inverted" => obj.inverted().to_value(),
|
"inverted" => obj.inverted().to_value(),
|
||||||
|
@ -72,13 +72,7 @@ pub(crate) mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_property(
|
fn set_property(&self, obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &glib::ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"progress" => obj.set_progress(value.get().unwrap()),
|
"progress" => obj.set_progress(value.get().unwrap()),
|
||||||
"inverted" => obj.set_inverted(value.get().unwrap()),
|
"inverted" => obj.set_inverted(value.get().unwrap()),
|
||||||
|
@ -161,7 +155,6 @@ impl Default for ProgressIcon {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProgressIcon {
|
impl ProgressIcon {
|
||||||
|
|
||||||
/// Creates a new [`ProgressIcon`].
|
/// Creates a new [`ProgressIcon`].
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
|
@ -203,7 +196,7 @@ pub trait ProgressIconExt {
|
||||||
|
|
||||||
impl<W: IsA<ProgressIcon>> ProgressIconExt for W {
|
impl<W: IsA<ProgressIcon>> ProgressIconExt for W {
|
||||||
fn progress(&self) -> f32 {
|
fn progress(&self) -> f32 {
|
||||||
*self.as_ref().imp().progress.borrow()
|
self.as_ref().imp().progress.get()
|
||||||
}
|
}
|
||||||
fn set_progress(&self, progress: f32) {
|
fn set_progress(&self, progress: f32) {
|
||||||
if (progress - self.progress()).abs() < f32::EPSILON {
|
if (progress - self.progress()).abs() < f32::EPSILON {
|
||||||
|
@ -216,7 +209,7 @@ impl<W: IsA<ProgressIcon>> ProgressIconExt for W {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inverted(&self) -> bool {
|
fn inverted(&self) -> bool {
|
||||||
*self.as_ref().imp().inverted.borrow()
|
self.as_ref().imp().inverted.get()
|
||||||
}
|
}
|
||||||
fn set_inverted(&self, inverted: bool) {
|
fn set_inverted(&self, inverted: bool) {
|
||||||
if inverted == self.inverted() {
|
if inverted == self.inverted() {
|
||||||
|
@ -228,7 +221,7 @@ impl<W: IsA<ProgressIcon>> ProgressIconExt for W {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clockwise(&self) -> bool {
|
fn clockwise(&self) -> bool {
|
||||||
*self.as_ref().imp().clockwise.borrow()
|
self.as_ref().imp().clockwise.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_clockwise(&self, clockwise: bool) {
|
fn set_clockwise(&self, clockwise: bool) {
|
||||||
|
@ -256,4 +249,3 @@ impl<W: IsA<ProgressIcon>> ProgressIconExt for W {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,7 @@ impl ProvidersDialog {
|
||||||
imp.filter_model.set_model(Some(&model));
|
imp.filter_model.set_model(Some(&model));
|
||||||
|
|
||||||
let stack = &*imp.stack;
|
let stack = &*imp.stack;
|
||||||
imp
|
imp.filter_model
|
||||||
.filter_model
|
|
||||||
.connect_items_changed(clone!(@weak stack => move |model, _, _, _| {
|
.connect_items_changed(clone!(@weak stack => move |model, _, _, _| {
|
||||||
if model.n_items() == 0 {
|
if model.n_items() == 0 {
|
||||||
stack.set_visible_child_name("no-results");
|
stack.set_visible_child_name("no-results");
|
||||||
|
@ -161,8 +160,8 @@ impl ProvidersDialog {
|
||||||
let selection_model = gtk::NoSelection::new(Some(&sort_model));
|
let selection_model = gtk::NoSelection::new(Some(&sort_model));
|
||||||
imp.providers_list.set_model(Some(&selection_model));
|
imp.providers_list.set_model(Some(&selection_model));
|
||||||
|
|
||||||
imp.providers_list.connect_activate(
|
imp.providers_list
|
||||||
clone!(@weak self as dialog => move |listview, pos| {
|
.connect_activate(clone!(@weak self as dialog => move |listview, pos| {
|
||||||
let model = listview.model().unwrap();
|
let model = listview.model().unwrap();
|
||||||
let provider = model
|
let provider = model
|
||||||
.item(pos)
|
.item(pos)
|
||||||
|
@ -170,8 +169,7 @@ impl ProvidersDialog {
|
||||||
.downcast::<Provider>()
|
.downcast::<Provider>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
dialog.edit_provider(provider);
|
dialog.edit_provider(provider);
|
||||||
}),
|
}));
|
||||||
);
|
|
||||||
|
|
||||||
imp.page.connect_local(
|
imp.page.connect_local(
|
||||||
"created",
|
"created",
|
||||||
|
@ -180,7 +178,7 @@ impl ProvidersDialog {
|
||||||
let provider = args.get(1).unwrap().get::<Provider>().unwrap();
|
let provider = args.get(1).unwrap().get::<Provider>().unwrap();
|
||||||
model.add_provider(&provider);
|
model.add_provider(&provider);
|
||||||
dialog.set_view(View::List);
|
dialog.set_view(View::List);
|
||||||
dialog.emit_by_name("changed", &[]);
|
dialog.emit_by_name::<()>("changed", &[]);
|
||||||
None
|
None
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -190,7 +188,7 @@ impl ProvidersDialog {
|
||||||
false,
|
false,
|
||||||
clone!(@weak self as dialog => @default-return None, move |_| {
|
clone!(@weak self as dialog => @default-return None, move |_| {
|
||||||
dialog.set_view(View::List);
|
dialog.set_view(View::List);
|
||||||
dialog.emit_by_name("changed", &[]);
|
dialog.emit_by_name::<()>("changed", &[]);
|
||||||
None
|
None
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -202,11 +200,11 @@ impl ProvidersDialog {
|
||||||
let provider = args.get(1).unwrap().get::<Provider>().unwrap();
|
let provider = args.get(1).unwrap().get::<Provider>().unwrap();
|
||||||
model.delete_provider(&provider);
|
model.delete_provider(&provider);
|
||||||
dialog.set_view(View::List);
|
dialog.set_view(View::List);
|
||||||
dialog.emit_by_name("changed", &[]);
|
dialog.emit_by_name::<()>("changed", &[]);
|
||||||
None
|
None
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let deck_page = imp.deck.append(&imp.page).unwrap();
|
let deck_page = imp.deck.append(&imp.page);
|
||||||
deck_page.set_name(Some("provider"));
|
deck_page.set_name(Some("provider"));
|
||||||
self.set_view(View::List);
|
self.set_view(View::List);
|
||||||
}
|
}
|
||||||
|
@ -284,7 +282,7 @@ mod row {
|
||||||
use super::*;
|
use super::*;
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::ParamSpec;
|
use glib::{ParamSpec, ParamSpecObject, Value};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
pub struct ProviderActionRow {
|
pub struct ProviderActionRow {
|
||||||
|
@ -315,7 +313,7 @@ mod row {
|
||||||
fn properties() -> &'static [ParamSpec] {
|
fn properties() -> &'static [ParamSpec] {
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![ParamSpec::new_object(
|
vec![ParamSpecObject::new(
|
||||||
"provider",
|
"provider",
|
||||||
"Provider",
|
"Provider",
|
||||||
"The Provider",
|
"The Provider",
|
||||||
|
@ -330,7 +328,7 @@ mod row {
|
||||||
&self,
|
&self,
|
||||||
_obj: &Self::Type,
|
_obj: &Self::Type,
|
||||||
_id: usize,
|
_id: usize,
|
||||||
value: &glib::Value,
|
value: &Value,
|
||||||
pspec: &ParamSpec,
|
pspec: &ParamSpec,
|
||||||
) {
|
) {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
|
@ -342,7 +340,7 @@ mod row {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"provider" => self.provider.borrow().to_value(),
|
"provider" => self.provider.borrow().to_value(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
|
@ -370,7 +368,7 @@ mod row {
|
||||||
|
|
||||||
fn setup_widgets(&self) {
|
fn setup_widgets(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
let hbox = gtk::BoxBuilder::new()
|
let hbox = gtk::Box::builder()
|
||||||
.orientation(gtk::Orientation::Horizontal)
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
.margin_bottom(16)
|
.margin_bottom(16)
|
||||||
.margin_end(16)
|
.margin_end(16)
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub enum ImageAction {
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::{subclass, ParamSpec};
|
use glib::{subclass, ParamSpec, ParamSpecObject, ParamSpecUInt, Value};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
|
||||||
#[derive(Debug, CompositeTemplate)]
|
#[derive(Debug, CompositeTemplate)]
|
||||||
|
@ -67,14 +67,14 @@ mod imp {
|
||||||
|
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
ParamSpec::new_object(
|
ParamSpecObject::new(
|
||||||
"provider",
|
"provider",
|
||||||
"provider",
|
"provider",
|
||||||
"Provider",
|
"Provider",
|
||||||
Provider::static_type(),
|
Provider::static_type(),
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_uint(
|
ParamSpecUInt::new(
|
||||||
"size",
|
"size",
|
||||||
"size",
|
"size",
|
||||||
"Image size",
|
"Image size",
|
||||||
|
@ -87,13 +87,7 @@ mod imp {
|
||||||
});
|
});
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"provider" => {
|
"provider" => {
|
||||||
let provider = value.get().unwrap();
|
let provider = value.get().unwrap();
|
||||||
|
@ -107,7 +101,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"provider" => self.provider.borrow().to_value(),
|
"provider" => self.provider.borrow().to_value(),
|
||||||
"size" => self.size.get().to_value(),
|
"size" => self.size.get().to_value(),
|
||||||
|
@ -190,7 +184,9 @@ impl ProviderImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset(&self) {
|
pub fn reset(&self) {
|
||||||
self.imp().image.set_from_icon_name(Some("provider-fallback"));
|
self.imp()
|
||||||
|
.image
|
||||||
|
.set_from_icon_name(Some("provider-fallback"));
|
||||||
self.fetch();
|
self.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl ProvidersList {
|
||||||
row.connect_local("shared", false, clone!(@weak list => @default-return None, move |args| {
|
row.connect_local("shared", false, clone!(@weak list => @default-return None, move |args| {
|
||||||
let account = args.get(1).unwrap().get::<Account>().unwrap();
|
let account = args.get(1).unwrap().get::<Account>().unwrap();
|
||||||
|
|
||||||
list.emit_by_name("shared", &[&account]);
|
list.emit_by_name::<()>("shared", &[&account]);
|
||||||
None
|
None
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -165,51 +165,41 @@ impl ProviderPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
imp.algorithm_comborow.set_selected(
|
imp.algorithm_comborow.set_selected(
|
||||||
imp
|
imp.algorithms_model
|
||||||
.algorithms_model
|
|
||||||
.find_position(provider.algorithm().into_glib()),
|
.find_position(provider.algorithm().into_glib()),
|
||||||
);
|
);
|
||||||
|
|
||||||
imp
|
imp.default_counter_spinbutton
|
||||||
.default_counter_spinbutton
|
|
||||||
.set_value(provider.default_counter() as f64);
|
.set_value(provider.default_counter() as f64);
|
||||||
imp.digits_spinbutton.set_value(provider.digits() as f64);
|
imp.digits_spinbutton.set_value(provider.digits() as f64);
|
||||||
|
|
||||||
imp.method_comborow.set_selected(
|
imp.method_comborow.set_selected(
|
||||||
imp
|
imp.methods_model
|
||||||
.methods_model
|
|
||||||
.find_position(provider.method().into_glib()),
|
.find_position(provider.method().into_glib()),
|
||||||
);
|
);
|
||||||
imp.image.set_provider(Some(&provider));
|
imp.image.set_provider(Some(&provider));
|
||||||
imp
|
imp.title
|
||||||
.title
|
|
||||||
.set_text(&i18n::i18n_f("Editing Provider: {}", &[&provider.name()]));
|
.set_text(&i18n::i18n_f("Editing Provider: {}", &[&provider.name()]));
|
||||||
imp.selected_provider.replace(Some(provider));
|
imp.selected_provider.replace(Some(provider));
|
||||||
} else {
|
} else {
|
||||||
imp.name_entry.set_text("");
|
imp.name_entry.set_text("");
|
||||||
imp.delete_button.hide();
|
imp.delete_button.hide();
|
||||||
imp
|
imp.period_spinbutton
|
||||||
.period_spinbutton
|
|
||||||
.set_value(otp::TOTP_DEFAULT_PERIOD as f64);
|
.set_value(otp::TOTP_DEFAULT_PERIOD as f64);
|
||||||
imp.provider_website_entry.set_text("");
|
imp.provider_website_entry.set_text("");
|
||||||
imp.provider_help_entry.set_text("");
|
imp.provider_help_entry.set_text("");
|
||||||
|
|
||||||
imp.algorithm_comborow.set_selected(
|
imp.algorithm_comborow.set_selected(
|
||||||
imp
|
imp.algorithms_model
|
||||||
.algorithms_model
|
|
||||||
.find_position(Algorithm::default().into_glib()),
|
.find_position(Algorithm::default().into_glib()),
|
||||||
);
|
);
|
||||||
|
|
||||||
imp
|
imp.default_counter_spinbutton
|
||||||
.default_counter_spinbutton
|
|
||||||
.set_value(otp::HOTP_DEFAULT_COUNTER as f64);
|
.set_value(otp::HOTP_DEFAULT_COUNTER as f64);
|
||||||
imp
|
imp.digits_spinbutton.set_value(otp::DEFAULT_DIGITS as f64);
|
||||||
.digits_spinbutton
|
|
||||||
.set_value(otp::DEFAULT_DIGITS as f64);
|
|
||||||
|
|
||||||
imp.method_comborow.set_selected(
|
imp.method_comborow.set_selected(
|
||||||
imp
|
imp.methods_model
|
||||||
.methods_model
|
|
||||||
.find_position(OTPMethod::default().into_glib()),
|
.find_position(OTPMethod::default().into_glib()),
|
||||||
);
|
);
|
||||||
imp.image.set_provider(None);
|
imp.image.set_provider(None);
|
||||||
|
@ -296,7 +286,7 @@ impl ProviderPage {
|
||||||
algorithm: algorithm.to_string(),
|
algorithm: algorithm.to_string(),
|
||||||
method: method.to_string(),
|
method: method.to_string(),
|
||||||
})?;
|
})?;
|
||||||
self.emit_by_name("updated", &[&provider]);
|
self.emit_by_name::<()>("updated", &[&provider]);
|
||||||
} else {
|
} else {
|
||||||
let provider = Provider::create(
|
let provider = Provider::create(
|
||||||
&name,
|
&name,
|
||||||
|
@ -309,7 +299,7 @@ impl ProviderPage {
|
||||||
Some(help_url),
|
Some(help_url),
|
||||||
image_uri,
|
image_uri,
|
||||||
)?;
|
)?;
|
||||||
self.emit_by_name("created", &[&provider]);
|
self.emit_by_name::<()>("created", &[&provider]);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -318,7 +308,7 @@ impl ProviderPage {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
let parent = self.root().unwrap().downcast::<gtk::Window>().unwrap();
|
let parent = self.root().unwrap().downcast::<gtk::Window>().unwrap();
|
||||||
|
|
||||||
let file_chooser = gtk::FileChooserNativeBuilder::new()
|
let file_chooser = gtk::FileChooserNative::builder()
|
||||||
.accept_label(&gettext("Select"))
|
.accept_label(&gettext("Select"))
|
||||||
.cancel_label(&gettext("Cancel"))
|
.cancel_label(&gettext("Cancel"))
|
||||||
.modal(true)
|
.modal(true)
|
||||||
|
@ -365,7 +355,7 @@ impl ProviderPage {
|
||||||
"The provider has accounts assigned to it, please remove them first",
|
"The provider has accounts assigned to it, please remove them first",
|
||||||
));
|
));
|
||||||
} else if provider.delete().is_ok() {
|
} else if provider.delete().is_ok() {
|
||||||
self.emit_by_name("deleted", &[&provider]);
|
self.emit_by_name::<()>("deleted", &[&provider]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
anyhow::bail!("Can't remove a provider as none are selected");
|
anyhow::bail!("Can't remove a provider as none are selected");
|
||||||
|
@ -413,12 +403,10 @@ impl ProviderPage {
|
||||||
|
|
||||||
fn setup_widgets(&self) {
|
fn setup_widgets(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
imp
|
imp.algorithm_comborow
|
||||||
.algorithm_comborow
|
|
||||||
.set_model(Some(&imp.algorithms_model));
|
.set_model(Some(&imp.algorithms_model));
|
||||||
|
|
||||||
imp
|
imp.method_comborow
|
||||||
.method_comborow
|
|
||||||
.connect_selected_item_notify(clone!(@weak self as page => move |_| {
|
.connect_selected_item_notify(clone!(@weak self as page => move |_| {
|
||||||
page.on_method_changed();
|
page.on_method_changed();
|
||||||
}));
|
}));
|
||||||
|
@ -428,8 +416,7 @@ impl ProviderPage {
|
||||||
});
|
});
|
||||||
|
|
||||||
imp.name_entry.connect_changed(validate_cb.clone());
|
imp.name_entry.connect_changed(validate_cb.clone());
|
||||||
imp
|
imp.provider_website_entry
|
||||||
.provider_website_entry
|
|
||||||
.connect_changed(validate_cb.clone());
|
.connect_changed(validate_cb.clone());
|
||||||
imp.provider_help_entry.connect_changed(validate_cb);
|
imp.provider_help_entry.connect_changed(validate_cb);
|
||||||
|
|
||||||
|
@ -444,40 +431,30 @@ impl ProviderPage {
|
||||||
OTPMethod::TOTP => {
|
OTPMethod::TOTP => {
|
||||||
imp.default_counter_row.hide();
|
imp.default_counter_row.hide();
|
||||||
imp.period_row.show();
|
imp.period_row.show();
|
||||||
imp
|
imp.digits_spinbutton.set_value(otp::DEFAULT_DIGITS as f64);
|
||||||
.digits_spinbutton
|
imp.period_spinbutton
|
||||||
.set_value(otp::DEFAULT_DIGITS as f64);
|
|
||||||
imp
|
|
||||||
.period_spinbutton
|
|
||||||
.set_value(otp::TOTP_DEFAULT_PERIOD as f64);
|
.set_value(otp::TOTP_DEFAULT_PERIOD as f64);
|
||||||
}
|
}
|
||||||
OTPMethod::HOTP => {
|
OTPMethod::HOTP => {
|
||||||
imp.default_counter_row.show();
|
imp.default_counter_row.show();
|
||||||
imp.period_row.hide();
|
imp.period_row.hide();
|
||||||
imp
|
imp.default_counter_spinbutton
|
||||||
.default_counter_spinbutton
|
|
||||||
.set_value(otp::HOTP_DEFAULT_COUNTER as f64);
|
.set_value(otp::HOTP_DEFAULT_COUNTER as f64);
|
||||||
imp
|
imp.digits_spinbutton.set_value(otp::DEFAULT_DIGITS as f64);
|
||||||
.digits_spinbutton
|
|
||||||
.set_value(otp::DEFAULT_DIGITS as f64);
|
|
||||||
}
|
}
|
||||||
OTPMethod::Steam => {
|
OTPMethod::Steam => {
|
||||||
imp.default_counter_row.hide();
|
imp.default_counter_row.hide();
|
||||||
imp.period_row.show();
|
imp.period_row.show();
|
||||||
imp
|
imp.digits_spinbutton
|
||||||
.digits_spinbutton
|
|
||||||
.set_value(otp::STEAM_DEFAULT_DIGITS as f64);
|
.set_value(otp::STEAM_DEFAULT_DIGITS as f64);
|
||||||
imp
|
imp.period_spinbutton
|
||||||
.period_spinbutton
|
|
||||||
.set_value(otp::STEAM_DEFAULT_PERIOD as f64);
|
.set_value(otp::STEAM_DEFAULT_PERIOD as f64);
|
||||||
imp
|
imp.algorithm_comborow
|
||||||
.algorithm_comborow
|
|
||||||
.set_selected(Algorithm::default().into_glib() as u32);
|
.set_selected(Algorithm::default().into_glib() as u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imp
|
imp.algorithm_comborow
|
||||||
.algorithm_comborow
|
|
||||||
.set_sensitive(selected != OTPMethod::Steam);
|
.set_sensitive(selected != OTPMethod::Steam);
|
||||||
imp.period_row.set_sensitive(selected != OTPMethod::Steam);
|
imp.period_row.set_sensitive(selected != OTPMethod::Steam);
|
||||||
imp.digits_row.set_sensitive(selected != OTPMethod::Steam);
|
imp.digits_row.set_sensitive(selected != OTPMethod::Steam);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
models::{Account, AccountSorter, OTPMethod, Provider},
|
models::{Account, AccountSorter, OTPMethod, Provider},
|
||||||
widgets::{accounts::AccountRow, ProviderImage, ProgressIcon, ProgressIconExt},
|
widgets::{accounts::AccountRow, ProgressIcon, ProgressIconExt, ProviderImage},
|
||||||
};
|
};
|
||||||
use gtk::{glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
|
use gtk::{glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
@ -9,7 +9,7 @@ mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::{
|
use glib::{
|
||||||
subclass::{self, Signal},
|
subclass::{self, Signal},
|
||||||
ParamSpec,
|
ParamSpec, ParamSpecObject, ParamSpecUInt64, Value,
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
@ -63,14 +63,14 @@ mod imp {
|
||||||
fn properties() -> &'static [ParamSpec] {
|
fn properties() -> &'static [ParamSpec] {
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
ParamSpec::new_object(
|
ParamSpecObject::new(
|
||||||
"provider",
|
"provider",
|
||||||
"Provider",
|
"Provider",
|
||||||
"The accounts provider",
|
"The accounts provider",
|
||||||
Provider::static_type(),
|
Provider::static_type(),
|
||||||
glib::ParamFlags::READWRITE | glib::ParamFlags::CONSTRUCT_ONLY,
|
glib::ParamFlags::READWRITE | glib::ParamFlags::CONSTRUCT_ONLY,
|
||||||
),
|
),
|
||||||
ParamSpec::new_uint64(
|
ParamSpecUInt64::new(
|
||||||
"remaining-time",
|
"remaining-time",
|
||||||
"remaining time",
|
"remaining time",
|
||||||
"the remaining time",
|
"the remaining time",
|
||||||
|
@ -102,13 +102,7 @@ mod imp {
|
||||||
SIGNALS.as_ref()
|
SIGNALS.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"provider" => {
|
"provider" => {
|
||||||
let provider = value.get().unwrap();
|
let provider = value.get().unwrap();
|
||||||
|
@ -122,7 +116,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"provider" => self.provider.borrow().to_value(),
|
"provider" => self.provider.borrow().to_value(),
|
||||||
"remaining-time" => self.remaining_time.get().to_value(),
|
"remaining-time" => self.remaining_time.get().to_value(),
|
||||||
|
@ -235,8 +229,7 @@ impl ProviderRow {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
imp
|
imp.callback_id
|
||||||
.callback_id
|
|
||||||
.replace(Some(self.add_tick_callback(|row, _| {
|
.replace(Some(self.add_tick_callback(|row, _| {
|
||||||
row.tick_progressbar();
|
row.tick_progressbar();
|
||||||
glib::Continue(true)
|
glib::Continue(true)
|
||||||
|
@ -264,7 +257,7 @@ impl ProviderRow {
|
||||||
clone!(@weak provider, @weak account, @weak provider_row => @default-return None, move |_| {
|
clone!(@weak provider, @weak account, @weak provider_row => @default-return None, move |_| {
|
||||||
account.delete().unwrap();
|
account.delete().unwrap();
|
||||||
provider.remove_account(account);
|
provider.remove_account(account);
|
||||||
provider_row.emit_by_name("changed", &[]);
|
provider_row.emit_by_name::<()>("changed", &[]);
|
||||||
None
|
None
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -273,7 +266,7 @@ impl ProviderRow {
|
||||||
"shared",
|
"shared",
|
||||||
false,
|
false,
|
||||||
clone!(@weak account, @weak provider_row => @default-return None, move |_| {
|
clone!(@weak account, @weak provider_row => @default-return None, move |_| {
|
||||||
provider_row.emit_by_name("shared", &[&account]);
|
provider_row.emit_by_name::<()>("shared", &[&account]);
|
||||||
None
|
None
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -283,15 +276,14 @@ impl ProviderRow {
|
||||||
clone!(@weak provider_row, @weak sorter => @default-return None, move |_| {
|
clone!(@weak provider_row, @weak sorter => @default-return None, move |_| {
|
||||||
// Re-sort in case the name was updated
|
// Re-sort in case the name was updated
|
||||||
sorter.changed(gtk::SorterChange::Different);
|
sorter.changed(gtk::SorterChange::Different);
|
||||||
provider_row.emit_by_name("changed", &[]);
|
provider_row.emit_by_name::<()>("changed", &[]);
|
||||||
None
|
None
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
row.upcast::<gtk::Widget>()
|
row.upcast::<gtk::Widget>()
|
||||||
});
|
});
|
||||||
|
|
||||||
imp
|
imp.accounts_list
|
||||||
.accounts_list
|
|
||||||
.bind_model(Some(&sort_model), create_callback);
|
.bind_model(Some(&sort_model), create_callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use gtk::{glib, subclass::prelude::*};
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use glib::ParamSpec;
|
use glib::{ParamSpec, ParamSpecString, Value};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
@ -26,14 +26,14 @@ mod imp {
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||||
vec![
|
vec![
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"uri",
|
"uri",
|
||||||
"uri",
|
"uri",
|
||||||
"The Row URI",
|
"The Row URI",
|
||||||
None,
|
None,
|
||||||
glib::ParamFlags::READWRITE,
|
glib::ParamFlags::READWRITE,
|
||||||
),
|
),
|
||||||
ParamSpec::new_string(
|
ParamSpecString::new(
|
||||||
"icon-name",
|
"icon-name",
|
||||||
"icon name",
|
"icon name",
|
||||||
"The Icon Name",
|
"The Icon Name",
|
||||||
|
@ -45,13 +45,7 @@ mod imp {
|
||||||
PROPERTIES.as_ref()
|
PROPERTIES.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_property(
|
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||||
&self,
|
|
||||||
_obj: &Self::Type,
|
|
||||||
_id: usize,
|
|
||||||
value: &glib::Value,
|
|
||||||
pspec: &ParamSpec,
|
|
||||||
) {
|
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"uri" => {
|
"uri" => {
|
||||||
let uri = value.get().unwrap();
|
let uri = value.get().unwrap();
|
||||||
|
@ -65,7 +59,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> glib::Value {
|
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"uri" => self.uri.borrow().to_value(),
|
"uri" => self.uri.borrow().to_value(),
|
||||||
"icon-name" => self.icon_name.borrow().to_value(),
|
"icon-name" => self.icon_name.borrow().to_value(),
|
||||||
|
@ -102,13 +96,13 @@ impl UrlRow {
|
||||||
|
|
||||||
self.add_controller(&gesture);
|
self.add_controller(&gesture);
|
||||||
|
|
||||||
let image_prefix = gtk::Image::from_icon_name(Some("image-missing-symbolic"));
|
let image_prefix = gtk::Image::from_icon_name("image-missing-symbolic");
|
||||||
self.bind_property("icon-name", &image_prefix, "icon-name")
|
self.bind_property("icon-name", &image_prefix, "icon-name")
|
||||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||||
.build();
|
.build();
|
||||||
self.add_prefix(&image_prefix);
|
self.add_prefix(&image_prefix);
|
||||||
|
|
||||||
let image_suffix = gtk::Image::from_icon_name(Some("link-symbolic"));
|
let image_suffix = gtk::Image::from_icon_name("link-symbolic");
|
||||||
image_suffix.add_css_class("dim-label");
|
image_suffix.add_css_class("dim-label");
|
||||||
self.add_suffix(&image_suffix);
|
self.add_suffix(&image_suffix);
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(&self, model: ProvidersModel, app: &Application) {
|
fn init(&self, model: ProvidersModel, app: &Application) {
|
||||||
let imp =self.imp();
|
let imp = self.imp();
|
||||||
imp.model.set(model.clone()).unwrap();
|
imp.model.set(model.clone()).unwrap();
|
||||||
imp.providers.set_model(model);
|
imp.providers.set_model(model);
|
||||||
imp.providers.connect_local(
|
imp.providers.connect_local(
|
||||||
|
@ -217,12 +217,14 @@ impl Window {
|
||||||
// load latest window state
|
// load latest window state
|
||||||
window_state::load(&self, &imp.settings);
|
window_state::load(&self, &imp.settings);
|
||||||
// save window state on delete event
|
// save window state on delete event
|
||||||
self.connect_close_request(clone!(@weak imp.settings as settings => @default-return Inhibit(false), move |window| {
|
self.connect_close_request(
|
||||||
if let Err(err) = window_state::save(&window, &settings) {
|
clone!(@weak imp.settings as settings => @default-return Inhibit(false), move |window| {
|
||||||
warn!("Failed to save window state {:#?}", err);
|
if let Err(err) = window_state::save(&window, &settings) {
|
||||||
}
|
warn!("Failed to save window state {:#?}", err);
|
||||||
Inhibit(false)
|
}
|
||||||
}));
|
Inhibit(false)
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
let search_entry = &*imp.search_entry;
|
let search_entry = &*imp.search_entry;
|
||||||
let search_btn = &*imp.search_btn;
|
let search_btn = &*imp.search_btn;
|
||||||
|
@ -250,8 +252,7 @@ impl Window {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let gtk_settings = gtk::Settings::default().unwrap();
|
let gtk_settings = gtk::Settings::default().unwrap();
|
||||||
imp
|
imp.settings
|
||||||
.settings
|
|
||||||
.bind(
|
.bind(
|
||||||
"dark-theme",
|
"dark-theme",
|
||||||
>k_settings,
|
>k_settings,
|
||||||
|
@ -261,7 +262,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_actions(&self, app: &Application) {
|
fn setup_actions(&self, app: &Application) {
|
||||||
let imp =self.imp();
|
let imp = self.imp();
|
||||||
let search_btn = &*imp.search_btn;
|
let search_btn = &*imp.search_btn;
|
||||||
action!(
|
action!(
|
||||||
self,
|
self,
|
||||||
|
@ -327,17 +328,15 @@ impl Window {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
let imp =self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
imp
|
imp.password_entry
|
||||||
.password_entry
|
|
||||||
.connect_activate(clone!(@weak self as win => move |_| {
|
.connect_activate(clone!(@weak self as win => move |_| {
|
||||||
WidgetExt::activate_action(&win, "win.unlock", None);
|
WidgetExt::activate_action(&win, "win.unlock", None).unwrap();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// On each click or key pressed we restart the timeout.
|
// On each click or key pressed we restart the timeout.
|
||||||
imp
|
imp.click_gesture
|
||||||
.click_gesture
|
|
||||||
.connect_pressed(clone!(@weak app => move |_, _, _, _| {
|
.connect_pressed(clone!(@weak app => move |_, _, _, _| {
|
||||||
app.restart_lock_timeout();
|
app.restart_lock_timeout();
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Reference in a new issue