implement existing certificate selection

This commit is contained in:
yggverse 2024-11-19 13:46:55 +02:00
parent 10cf4fc6a1
commit 728a9c06d5
9 changed files with 189 additions and 41 deletions

View file

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

View file

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

View file

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