mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-28 12:04:13 +00:00
emit update action on identity logout
This commit is contained in:
parent
483be18b17
commit
e8638a8f24
@ -25,7 +25,11 @@ impl Gemini {
|
||||
let auth_url = auth_uri.to_string();
|
||||
|
||||
// Init widget
|
||||
let widget = Rc::new(Widget::new(profile.clone(), &auth_url));
|
||||
let widget = Rc::new(Widget::new(
|
||||
(action.0.clone(), action.1.clone()),
|
||||
profile.clone(),
|
||||
&auth_url,
|
||||
));
|
||||
|
||||
// Init events
|
||||
widget.on_cancel({
|
||||
|
@ -1,10 +1,12 @@
|
||||
mod action;
|
||||
pub mod form;
|
||||
|
||||
use action::Action;
|
||||
use form::{list::item::value::Value, Form};
|
||||
|
||||
use crate::app::browser::action::Action as BrowserAction;
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use crate::profile::Profile;
|
||||
use action::Action as WidgetAction;
|
||||
use adw::{
|
||||
prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual},
|
||||
AlertDialog, ResponseAppearance,
|
||||
@ -33,12 +35,20 @@ impl Widget {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(profile: Rc<Profile>, auth_url: &str) -> Self {
|
||||
pub fn new(
|
||||
action: (Rc<BrowserAction>, Rc<WindowAction>),
|
||||
profile: Rc<Profile>,
|
||||
auth_url: &str,
|
||||
) -> Self {
|
||||
// Init actions
|
||||
let action = Rc::new(Action::new());
|
||||
let widget_action = Rc::new(WidgetAction::new());
|
||||
|
||||
// Init child container
|
||||
let form = Rc::new(Form::new(profile, action.clone(), auth_url));
|
||||
let form = Rc::new(Form::new(
|
||||
(action.0.clone(), action.1.clone(), widget_action.clone()),
|
||||
profile,
|
||||
auth_url,
|
||||
));
|
||||
|
||||
// Init main widget
|
||||
let alert_dialog = AlertDialog::builder()
|
||||
@ -64,7 +74,7 @@ impl Widget {
|
||||
alert_dialog.set_response_appearance(RESPONSE_CANCEL.0, ResponseAppearance::Destructive);
|
||||
|
||||
// Init events
|
||||
action.update.connect_activate({
|
||||
widget_action.update.connect_activate({
|
||||
let form = form.clone();
|
||||
let alert_dialog = alert_dialog.clone();
|
||||
move || {
|
||||
|
@ -12,7 +12,9 @@ use list::{item::value::Value, List};
|
||||
use name::Name;
|
||||
use save::Save;
|
||||
|
||||
use super::Action;
|
||||
use super::WidgetAction;
|
||||
use crate::app::browser::action::Action as BrowserAction;
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use crate::profile::Profile;
|
||||
use gtk::{prelude::BoxExt, Box, Orientation};
|
||||
use std::rc::Rc;
|
||||
@ -32,14 +34,18 @@ impl Form {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(profile: Rc<Profile>, action_widget: Rc<Action>, auth_url: &str) -> Self {
|
||||
pub fn new(
|
||||
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<WidgetAction>),
|
||||
profile: Rc<Profile>,
|
||||
auth_url: &str,
|
||||
) -> Self {
|
||||
// Init components
|
||||
let list = Rc::new(List::new(action_widget.clone(), profile.clone(), auth_url));
|
||||
let file = Rc::new(File::new(action_widget.clone()));
|
||||
let name = Rc::new(Name::new(action_widget.clone()));
|
||||
let list = Rc::new(List::new(action.2.clone(), profile.clone(), auth_url));
|
||||
let file = Rc::new(File::new(action.2.clone()));
|
||||
let name = Rc::new(Name::new(action.2.clone()));
|
||||
let save = Rc::new(Save::new(profile.clone(), list.clone()));
|
||||
let drop = Rc::new(Drop::new(profile.clone(), list.clone()));
|
||||
let exit = Rc::new(Exit::new(profile.clone(), list.clone()));
|
||||
let exit = Rc::new(Exit::new(action.0.clone(), profile.clone(), list.clone()));
|
||||
|
||||
// Init main container
|
||||
let g_box = Box::builder().orientation(Orientation::Vertical).build();
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::list::{item::Value, List};
|
||||
use crate::app::browser::action::Action as BrowserAction;
|
||||
use crate::profile::Profile;
|
||||
use adw::{
|
||||
prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual},
|
||||
@ -29,7 +30,7 @@ impl Exit {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(profile: Rc<Profile>, list: Rc<List>) -> Self {
|
||||
pub fn new(browser_action: Rc<BrowserAction>, profile: Rc<Profile>, list: Rc<List>) -> Self {
|
||||
// Init main widget
|
||||
let button = Button::builder()
|
||||
.label(LABEL)
|
||||
@ -69,29 +70,33 @@ impl Exit {
|
||||
|
||||
// Connect confirmation event
|
||||
alert_dialog.connect_response(Some(RESPONSE_CONFIRM.0), {
|
||||
let browser_action = browser_action.clone();
|
||||
let button = button.clone();
|
||||
let list = list.clone();
|
||||
let profile = profile.clone();
|
||||
move |_, _| match profile
|
||||
.identity
|
||||
.gemini
|
||||
.auth
|
||||
.remove_ref(profile_identity_gemini_id)
|
||||
{
|
||||
Ok(_) => match list.selected().update(&profile, "") {
|
||||
Ok(_) => {
|
||||
button.set_css_classes(&["success"]);
|
||||
button.set_label("Identity successfully disconnected")
|
||||
}
|
||||
move |_, _| {
|
||||
match profile
|
||||
.identity
|
||||
.gemini
|
||||
.auth
|
||||
.remove_ref(profile_identity_gemini_id)
|
||||
{
|
||||
Ok(_) => match list.selected().update(&profile, "") {
|
||||
Ok(_) => {
|
||||
button.set_css_classes(&["success"]);
|
||||
button.set_label("Identity successfully disconnected")
|
||||
}
|
||||
Err(e) => {
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label(&e.to_string())
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label(&e.to_string())
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label(&e.to_string())
|
||||
}
|
||||
browser_action.update.activate(None)
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::Action;
|
||||
use super::WidgetAction;
|
||||
use gtk::{
|
||||
gio::{Cancellable, ListStore, TlsCertificate},
|
||||
glib::{gformat, GString},
|
||||
@ -21,7 +21,7 @@ impl File {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(action_widget: Rc<Action>) -> Self {
|
||||
pub fn new(widget_action: Rc<WidgetAction>) -> Self {
|
||||
// Init PEM
|
||||
let pem = Rc::new(RefCell::new(None));
|
||||
|
||||
@ -35,7 +35,7 @@ impl File {
|
||||
|
||||
// Init events
|
||||
button.connect_clicked({
|
||||
let action_widget = action_widget.clone();
|
||||
let widget_action = widget_action.clone();
|
||||
let button = button.clone();
|
||||
let pem = pem.clone();
|
||||
move |_| {
|
||||
@ -61,7 +61,7 @@ impl File {
|
||||
.default_filter(&filter_pem)
|
||||
.build()
|
||||
.open(None::<&Window>, None::<&Cancellable>, {
|
||||
let action_widget = action_widget.clone();
|
||||
let widget_action = widget_action.clone();
|
||||
let button = button.clone();
|
||||
let pem = pem.clone();
|
||||
move |result| {
|
||||
@ -89,7 +89,7 @@ impl File {
|
||||
}
|
||||
}
|
||||
button.set_sensitive(true); // unlock
|
||||
action_widget.update.activate()
|
||||
widget_action.update.activate()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||
|
||||
use item::Item;
|
||||
|
||||
use super::Action;
|
||||
use super::WidgetAction;
|
||||
use crate::profile::Profile;
|
||||
use gtk::{
|
||||
gdk::Cursor,
|
||||
@ -24,7 +24,7 @@ impl List {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(action_widget: Rc<Action>, profile: Rc<Profile>, auth_url: &str) -> Self {
|
||||
pub fn new(widget_action: Rc<WidgetAction>, profile: Rc<Profile>, auth_url: &str) -> Self {
|
||||
// Init model
|
||||
let list_store = ListStore::new::<Item>();
|
||||
|
||||
@ -133,7 +133,7 @@ impl List {
|
||||
.build();
|
||||
|
||||
// Connect events
|
||||
dropdown.connect_selected_notify(move |_| action_widget.update.activate());
|
||||
dropdown.connect_selected_notify(move |_| widget_action.update.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::Action;
|
||||
use super::WidgetAction;
|
||||
use gtk::{
|
||||
glib::GString,
|
||||
prelude::{EditableExt, EntryExt, WidgetExt},
|
||||
@ -19,7 +19,7 @@ impl Name {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(action_widget: Rc<Action>) -> Self {
|
||||
pub fn new(widget_action: Rc<WidgetAction>) -> Self {
|
||||
// Init main gobject
|
||||
let entry = Entry::builder()
|
||||
.margin_top(MARGIN)
|
||||
@ -29,7 +29,7 @@ impl Name {
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
entry.connect_changed(move |_| action_widget.update.activate());
|
||||
entry.connect_changed(move |_| widget_action.update.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { entry }
|
||||
|
Loading…
x
Reference in New Issue
Block a user