mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
add file validate option
This commit is contained in:
parent
ae24a727c8
commit
e49a607e78
@ -74,6 +74,7 @@ impl Form {
|
||||
pub fn is_valid(&self) -> bool {
|
||||
match self.list.selected() {
|
||||
Value::GENERATE_NEW_AUTH => self.name.is_valid(),
|
||||
Value::IMPORT_PEM => self.file.is_valid(),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ use gtk::{
|
||||
Button,
|
||||
};
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
const LABEL: &str = "Select file..";
|
||||
const MARGIN: i32 = 8;
|
||||
|
||||
pub struct File {
|
||||
pem: RefCell<Option<String>>,
|
||||
pub gobject: Button,
|
||||
}
|
||||
|
||||
@ -18,6 +19,9 @@ impl File {
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(action: Rc<Action>) -> Self {
|
||||
// Init PEM
|
||||
let pem = RefCell::new(None);
|
||||
|
||||
// Init `GObject`
|
||||
let gobject = Button::builder()
|
||||
.label(LABEL)
|
||||
@ -29,7 +33,7 @@ impl File {
|
||||
gobject.connect_clicked(move |_| todo!());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
Self { pem, gobject }
|
||||
}
|
||||
|
||||
// Actions
|
||||
@ -42,4 +46,10 @@ impl File {
|
||||
self.gobject.grab_focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn is_valid(&self) -> bool {
|
||||
self.pem.borrow().is_some()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user