mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
implement auth_url for exit action
This commit is contained in:
parent
080c2fc51a
commit
26e0a35d94
5 changed files with 37 additions and 12 deletions
|
|
@ -28,7 +28,7 @@ impl Gemini {
|
||||||
let widget = Rc::new(Widget::new(
|
let widget = Rc::new(Widget::new(
|
||||||
(action.0.clone(), action.1.clone()),
|
(action.0.clone(), action.1.clone()),
|
||||||
profile.clone(),
|
profile.clone(),
|
||||||
&auth_url,
|
auth_uri.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use adw::{
|
||||||
prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual},
|
prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual},
|
||||||
AlertDialog, ResponseAppearance,
|
AlertDialog, ResponseAppearance,
|
||||||
};
|
};
|
||||||
use gtk::prelude::IsA;
|
use gtk::{glib::Uri, prelude::IsA};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
|
|
@ -38,7 +38,7 @@ impl Widget {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
action: (Rc<BrowserAction>, Rc<WindowAction>),
|
action: (Rc<BrowserAction>, Rc<WindowAction>),
|
||||||
profile: Rc<Profile>,
|
profile: Rc<Profile>,
|
||||||
auth_url: &str,
|
auth_uri: Uri,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init actions
|
// Init actions
|
||||||
let widget_action = Rc::new(WidgetAction::new());
|
let widget_action = Rc::new(WidgetAction::new());
|
||||||
|
|
@ -47,7 +47,7 @@ impl Widget {
|
||||||
let form = Rc::new(Form::new(
|
let form = Rc::new(Form::new(
|
||||||
(action.0.clone(), action.1.clone(), widget_action.clone()),
|
(action.0.clone(), action.1.clone(), widget_action.clone()),
|
||||||
profile,
|
profile,
|
||||||
auth_url,
|
auth_uri,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Init main widget
|
// Init main widget
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use super::WidgetAction;
|
||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
use crate::app::browser::window::action::Action as WindowAction;
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use crate::profile::Profile;
|
use crate::profile::Profile;
|
||||||
use gtk::{prelude::BoxExt, Box, Orientation};
|
use gtk::{glib::Uri, prelude::BoxExt, Box, Orientation};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Form {
|
pub struct Form {
|
||||||
|
|
@ -37,15 +37,24 @@ impl Form {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<WidgetAction>),
|
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<WidgetAction>),
|
||||||
profile: Rc<Profile>,
|
profile: Rc<Profile>,
|
||||||
auth_url: &str,
|
auth_uri: Uri,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let list = Rc::new(List::new(action.2.clone(), profile.clone(), auth_url));
|
let list = Rc::new(List::new(
|
||||||
|
action.2.clone(),
|
||||||
|
profile.clone(),
|
||||||
|
auth_uri.clone(),
|
||||||
|
));
|
||||||
let file = Rc::new(File::new(action.2.clone()));
|
let file = Rc::new(File::new(action.2.clone()));
|
||||||
let name = Rc::new(Name::new(action.2.clone()));
|
let name = Rc::new(Name::new(action.2.clone()));
|
||||||
let save = Rc::new(Save::new(profile.clone(), list.clone()));
|
let save = Rc::new(Save::new(profile.clone(), list.clone()));
|
||||||
let drop = Rc::new(Drop::new(profile.clone(), list.clone()));
|
let drop = Rc::new(Drop::new(profile.clone(), list.clone()));
|
||||||
let exit = Rc::new(Exit::new(action.0.clone(), profile.clone(), list.clone()));
|
let exit = Rc::new(Exit::new(
|
||||||
|
action.0.clone(),
|
||||||
|
profile.clone(),
|
||||||
|
list.clone(),
|
||||||
|
auth_uri.clone(),
|
||||||
|
));
|
||||||
|
|
||||||
// Init main container
|
// Init main container
|
||||||
let g_box = Box::builder().orientation(Orientation::Vertical).build();
|
let g_box = Box::builder().orientation(Orientation::Vertical).build();
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use adw::{
|
||||||
AlertDialog, ResponseAppearance,
|
AlertDialog, ResponseAppearance,
|
||||||
};
|
};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
|
glib::Uri,
|
||||||
prelude::{ButtonExt, WidgetExt},
|
prelude::{ButtonExt, WidgetExt},
|
||||||
Button,
|
Button,
|
||||||
};
|
};
|
||||||
|
|
@ -30,7 +31,12 @@ impl Exit {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn new(browser_action: Rc<BrowserAction>, profile: Rc<Profile>, list: Rc<List>) -> Self {
|
pub fn new(
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
|
profile: Rc<Profile>,
|
||||||
|
list: Rc<List>,
|
||||||
|
auth_uri: Uri,
|
||||||
|
) -> Self {
|
||||||
// Init main widget
|
// Init main widget
|
||||||
let button = Button::builder()
|
let button = Button::builder()
|
||||||
.label(LABEL)
|
.label(LABEL)
|
||||||
|
|
@ -41,6 +47,7 @@ impl Exit {
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
button.connect_clicked({
|
button.connect_clicked({
|
||||||
|
let auth_uri = auth_uri.clone();
|
||||||
let button = button.clone();
|
let button = button.clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
// Get selected identity from holder
|
// Get selected identity from holder
|
||||||
|
|
@ -70,6 +77,7 @@ impl Exit {
|
||||||
|
|
||||||
// Connect confirmation event
|
// Connect confirmation event
|
||||||
alert_dialog.connect_response(Some(RESPONSE_CONFIRM.0), {
|
alert_dialog.connect_response(Some(RESPONSE_CONFIRM.0), {
|
||||||
|
let auth_uri = auth_uri.clone();
|
||||||
let browser_action = browser_action.clone();
|
let browser_action = browser_action.clone();
|
||||||
let button = button.clone();
|
let button = button.clone();
|
||||||
let list = list.clone();
|
let list = list.clone();
|
||||||
|
|
@ -81,7 +89,10 @@ impl Exit {
|
||||||
.auth
|
.auth
|
||||||
.remove_ref(profile_identity_gemini_id)
|
.remove_ref(profile_identity_gemini_id)
|
||||||
{
|
{
|
||||||
Ok(_) => match list.selected().update(&profile, "") {
|
Ok(_) => match list
|
||||||
|
.selected()
|
||||||
|
.update(&profile, &auth_uri.to_string())
|
||||||
|
{
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
button.set_css_classes(&["success"]);
|
button.set_css_classes(&["success"]);
|
||||||
button.set_label("Identity successfully disconnected")
|
button.set_label("Identity successfully disconnected")
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use gtk::{
|
||||||
prelude::{Cast, CastNone},
|
prelude::{Cast, CastNone},
|
||||||
ListStore,
|
ListStore,
|
||||||
},
|
},
|
||||||
|
glib::Uri,
|
||||||
prelude::{BoxExt, ListItemExt, WidgetExt},
|
prelude::{BoxExt, ListItemExt, WidgetExt},
|
||||||
Align, Box, DropDown, Image, Label, ListItem, Orientation, SignalListItemFactory,
|
Align, Box, DropDown, Image, Label, ListItem, Orientation, SignalListItemFactory,
|
||||||
};
|
};
|
||||||
|
|
@ -24,7 +25,7 @@ impl List {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn new(widget_action: Rc<WidgetAction>, profile: Rc<Profile>, auth_url: &str) -> Self {
|
pub fn new(widget_action: Rc<WidgetAction>, profile: Rc<Profile>, auth_uri: Uri) -> Self {
|
||||||
// Init model
|
// Init model
|
||||||
let list_store = ListStore::new::<Item>();
|
let list_store = ListStore::new::<Item>();
|
||||||
|
|
||||||
|
|
@ -37,7 +38,11 @@ impl List {
|
||||||
match profile.identity.gemini.database.records() {
|
match profile.identity.gemini.database.records() {
|
||||||
Ok(identities) => {
|
Ok(identities) => {
|
||||||
for identity in identities {
|
for identity in identities {
|
||||||
match Item::new_profile_identity_gemini_id(&profile, identity.id, auth_url) {
|
match Item::new_profile_identity_gemini_id(
|
||||||
|
&profile,
|
||||||
|
identity.id,
|
||||||
|
&auth_uri.to_string(),
|
||||||
|
) {
|
||||||
Ok(item) => list_store.append(&item),
|
Ok(item) => list_store.append(&item),
|
||||||
Err(_) => todo!(),
|
Err(_) => todo!(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue