mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
implement existing certificate selection
This commit is contained in:
parent
10cf4fc6a1
commit
728a9c06d5
9 changed files with 189 additions and 41 deletions
|
|
@ -57,18 +57,18 @@ impl Gemini {
|
|||
}
|
||||
|
||||
// Init events
|
||||
widget.connect_response({
|
||||
let profile = profile.clone();
|
||||
move |value| {
|
||||
match value {
|
||||
Some(id) => {
|
||||
// Activate selected identity ID
|
||||
}
|
||||
None => {
|
||||
// Create and select new identity
|
||||
}
|
||||
} // @TODO handle result
|
||||
widget.on_apply(move |response| match response {
|
||||
// Apply selected identity for `auth_uri`
|
||||
Some(profile_identity_gemini_id) => {
|
||||
profile
|
||||
.identity
|
||||
.gemini
|
||||
.auth
|
||||
.apply(profile_identity_gemini_id, auth_uri.to_string().as_str())
|
||||
.unwrap(); //@TODO handle errors
|
||||
}
|
||||
// Create new certificate, then apply it to the new identity for `auth_uri`
|
||||
None => {}
|
||||
});
|
||||
|
||||
// Return activated `Self`
|
||||
|
|
|
|||
|
|
@ -62,15 +62,12 @@ impl Widget {
|
|||
|
||||
// Actions
|
||||
|
||||
/// Wrapper for default [response](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/signal.AlertDialog.response.html) signal
|
||||
/// Callback wrapper for `apply` [response](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/signal.AlertDialog.response.html)
|
||||
/// * return `profile_identity_gemini_id` or new record request on `None`
|
||||
pub fn connect_response(&self, callback: impl Fn(Option<i64>) + 'static) {
|
||||
self.gobject.connect_response(None, move |_, response| {
|
||||
if response == RESPONSE_APPLY.0 {
|
||||
callback(None)
|
||||
} else {
|
||||
callback(None)
|
||||
} // @TODO
|
||||
pub fn on_apply(&self, callback: impl Fn(Option<i64>) + 'static) {
|
||||
self.gobject.connect_response(Some(RESPONSE_APPLY.0), {
|
||||
let form = self.form.clone();
|
||||
move |_, _| callback(form.list.selected())
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ impl Form {
|
|||
gobject.append(&name.gobject);
|
||||
|
||||
// Connect events
|
||||
list.connect_selected_notify(move |key| name.gobject.set_visible(key.is_none()));
|
||||
list.on_select(move |key| name.gobject.set_visible(key.is_none()));
|
||||
|
||||
// Return activated `Self`
|
||||
Self {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ impl List {
|
|||
// Events
|
||||
|
||||
/// Run callback function on `connect_selected_notify` event
|
||||
/// * return formatted `profile_identity_gemini_id` match selected
|
||||
pub fn connect_selected_notify(&self, callback: impl Fn(Option<i64>) + 'static) {
|
||||
/// * return formatted `profile_identity_gemini_id` match selected item
|
||||
pub fn on_select(&self, callback: impl Fn(Option<i64>) + 'static) {
|
||||
self.gobject.connect_selected_notify(move |list| {
|
||||
callback(
|
||||
list.selected_item()
|
||||
|
|
@ -70,4 +70,15 @@ impl List {
|
|||
)
|
||||
});
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get formatted `profile_identity_gemini_id` **option** match selected item
|
||||
pub fn selected(&self) -> Option<i64> {
|
||||
self.gobject
|
||||
.selected_item()
|
||||
.and_downcast::<Item>()
|
||||
.unwrap()
|
||||
.profile_identity_gemini_id_option()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue