mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +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(
|
||||
(action.0.clone(), action.1.clone()),
|
||||
profile.clone(),
|
||||
&auth_url,
|
||||
auth_uri.clone(),
|
||||
));
|
||||
|
||||
// Init events
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use adw::{
|
|||
prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual},
|
||||
AlertDialog, ResponseAppearance,
|
||||
};
|
||||
use gtk::prelude::IsA;
|
||||
use gtk::{glib::Uri, prelude::IsA};
|
||||
use std::rc::Rc;
|
||||
|
||||
// Defaults
|
||||
|
|
@ -38,7 +38,7 @@ impl Widget {
|
|||
pub fn new(
|
||||
action: (Rc<BrowserAction>, Rc<WindowAction>),
|
||||
profile: Rc<Profile>,
|
||||
auth_url: &str,
|
||||
auth_uri: Uri,
|
||||
) -> Self {
|
||||
// Init actions
|
||||
let widget_action = Rc::new(WidgetAction::new());
|
||||
|
|
@ -47,7 +47,7 @@ impl Widget {
|
|||
let form = Rc::new(Form::new(
|
||||
(action.0.clone(), action.1.clone(), widget_action.clone()),
|
||||
profile,
|
||||
auth_url,
|
||||
auth_uri,
|
||||
));
|
||||
|
||||
// Init main widget
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ 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 gtk::{glib::Uri, prelude::BoxExt, Box, Orientation};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Form {
|
||||
|
|
@ -37,15 +37,24 @@ impl Form {
|
|||
pub fn new(
|
||||
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<WidgetAction>),
|
||||
profile: Rc<Profile>,
|
||||
auth_url: &str,
|
||||
auth_uri: Uri,
|
||||
) -> Self {
|
||||
// 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 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(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
|
||||
let g_box = Box::builder().orientation(Orientation::Vertical).build();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use adw::{
|
|||
AlertDialog, ResponseAppearance,
|
||||
};
|
||||
use gtk::{
|
||||
glib::Uri,
|
||||
prelude::{ButtonExt, WidgetExt},
|
||||
Button,
|
||||
};
|
||||
|
|
@ -30,7 +31,12 @@ impl Exit {
|
|||
// Constructors
|
||||
|
||||
/// 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
|
||||
let button = Button::builder()
|
||||
.label(LABEL)
|
||||
|
|
@ -41,6 +47,7 @@ impl Exit {
|
|||
|
||||
// Init events
|
||||
button.connect_clicked({
|
||||
let auth_uri = auth_uri.clone();
|
||||
let button = button.clone();
|
||||
move |_| {
|
||||
// Get selected identity from holder
|
||||
|
|
@ -70,6 +77,7 @@ impl Exit {
|
|||
|
||||
// Connect confirmation event
|
||||
alert_dialog.connect_response(Some(RESPONSE_CONFIRM.0), {
|
||||
let auth_uri = auth_uri.clone();
|
||||
let browser_action = browser_action.clone();
|
||||
let button = button.clone();
|
||||
let list = list.clone();
|
||||
|
|
@ -81,7 +89,10 @@ impl Exit {
|
|||
.auth
|
||||
.remove_ref(profile_identity_gemini_id)
|
||||
{
|
||||
Ok(_) => match list.selected().update(&profile, "") {
|
||||
Ok(_) => match list
|
||||
.selected()
|
||||
.update(&profile, &auth_uri.to_string())
|
||||
{
|
||||
Ok(_) => {
|
||||
button.set_css_classes(&["success"]);
|
||||
button.set_label("Identity successfully disconnected")
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use gtk::{
|
|||
prelude::{Cast, CastNone},
|
||||
ListStore,
|
||||
},
|
||||
glib::Uri,
|
||||
prelude::{BoxExt, ListItemExt, WidgetExt},
|
||||
Align, Box, DropDown, Image, Label, ListItem, Orientation, SignalListItemFactory,
|
||||
};
|
||||
|
|
@ -24,7 +25,7 @@ impl List {
|
|||
// Constructors
|
||||
|
||||
/// 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
|
||||
let list_store = ListStore::new::<Item>();
|
||||
|
||||
|
|
@ -37,7 +38,11 @@ impl List {
|
|||
match profile.identity.gemini.database.records() {
|
||||
Ok(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),
|
||||
Err(_) => todo!(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue