mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
remove async dependencies
This commit is contained in:
parent
e2b0cd6b0d
commit
b187f36028
33 changed files with 120 additions and 129 deletions
|
|
@ -9,21 +9,21 @@ use gtk::{
|
|||
glib::{Uri, UriFlags},
|
||||
prelude::CancellableExt,
|
||||
};
|
||||
use std::{cell::Cell, rc::Rc, sync::Arc};
|
||||
use std::{cell::Cell, rc::Rc};
|
||||
|
||||
/// Multi-protocol client API for tab `Item`
|
||||
pub struct Client {
|
||||
cancellable: Cell<Cancellable>,
|
||||
driver: Rc<Driver>,
|
||||
page: Rc<Page>,
|
||||
profile: Arc<Profile>,
|
||||
profile: Rc<Profile>,
|
||||
}
|
||||
|
||||
impl Client {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn init(profile: &Arc<Profile>, page: &Rc<Page>) -> Self {
|
||||
pub fn init(profile: &Rc<Profile>, page: &Rc<Page>) -> Self {
|
||||
Self {
|
||||
cancellable: Cell::new(Cancellable::new()),
|
||||
driver: Rc::new(Driver::build(page)),
|
||||
|
|
@ -118,7 +118,7 @@ impl Client {
|
|||
/// Create request using async DNS resolver (slow method)
|
||||
/// * return suggestion [Uri](https://docs.gtk.org/glib/struct.Uri.html) on failure (to handle as redirect)
|
||||
fn lookup(
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
query: &str,
|
||||
cancellable: Cancellable,
|
||||
callback: impl FnOnce(Rc<Feature>, Cancellable, Result<Uri, String>) + 'static,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ use input::Input;
|
|||
use navigation::Navigation;
|
||||
use search::Search;
|
||||
use sqlite::Transaction;
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Page {
|
||||
pub profile: Arc<Profile>,
|
||||
pub profile: Rc<Profile>,
|
||||
// Actions
|
||||
pub item_action: Rc<ItemAction>,
|
||||
pub window_action: Rc<WindowAction>,
|
||||
|
|
@ -38,7 +38,7 @@ impl Page {
|
|||
// Constructors
|
||||
|
||||
pub fn build(
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
(window_action, tab_action, item_action): (
|
||||
&Rc<WindowAction>,
|
||||
&Rc<TabAction>,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use home::Home;
|
|||
use reload::Reload;
|
||||
use request::Request;
|
||||
use sqlite::Transaction;
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
const MARGIN: i32 = 6;
|
||||
const SPACING: i32 = 6;
|
||||
|
|
@ -31,7 +31,7 @@ pub struct Navigation {
|
|||
|
||||
impl Navigation {
|
||||
pub fn build(
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
(window_action, tab_action, item_action): (
|
||||
&Rc<WindowAction>,
|
||||
&Rc<TabAction>,
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@ use gtk::{
|
|||
Button, Entry,
|
||||
prelude::{ActionExt, ButtonExt, EditableExt, WidgetExt},
|
||||
};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
const ICON_NAME: (&str, &str) = ("non-starred-symbolic", "starred-symbolic");
|
||||
const TOOLTIP_TEXT: (&str, &str) = ("Add Bookmark", "Remove Bookmark");
|
||||
|
||||
pub struct Bookmark {
|
||||
profile: Arc<Profile>,
|
||||
profile: Rc<Profile>,
|
||||
request: Entry,
|
||||
pub button: Button,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
pub fn build(action: &Rc<WindowAction>, profile: &Arc<Profile>, request: &Entry) -> Self {
|
||||
pub fn build(action: &Rc<WindowAction>, profile: &Rc<Profile>, request: &Entry) -> Self {
|
||||
let button = Button::builder()
|
||||
.action_name(format!(
|
||||
"{}.{}",
|
||||
|
|
@ -65,7 +65,7 @@ fn icon_name(has_bookmark: bool) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
fn update(profile: &Arc<Profile>, button: &Button, request: gtk::glib::GString) {
|
||||
fn update(profile: &Rc<Profile>, button: &Button, request: gtk::glib::GString) {
|
||||
let profile = profile.clone();
|
||||
let button = button.clone();
|
||||
gtk::glib::spawn_future_local(async move {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use sqlite::Transaction;
|
|||
use std::{
|
||||
cell::{Cell, RefCell},
|
||||
rc::Rc,
|
||||
sync::Arc,
|
||||
};
|
||||
use suggestion::Suggestion;
|
||||
|
||||
|
|
@ -30,14 +29,14 @@ pub struct Request {
|
|||
pub entry: Entry,
|
||||
pub info: Rc<RefCell<Info>>,
|
||||
suggestion: Rc<Suggestion>,
|
||||
profile: Arc<Profile>,
|
||||
profile: Rc<Profile>,
|
||||
}
|
||||
|
||||
impl Request {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(item_action: &Rc<ItemAction>, profile: &Arc<Profile>) -> Self {
|
||||
pub fn build(item_action: &Rc<ItemAction>, profile: &Rc<Profile>) -> Self {
|
||||
// Init components
|
||||
let info = Rc::new(RefCell::new(Info::new()));
|
||||
|
||||
|
|
@ -364,7 +363,7 @@ fn is_focused(entry: &Entry) -> bool {
|
|||
}
|
||||
|
||||
/// Present Identity [AlertDialog](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.AlertDialog.html) for `Self`
|
||||
fn show_identity_dialog(entry: &Entry, profile: &Arc<Profile>) {
|
||||
fn show_identity_dialog(entry: &Entry, profile: &Rc<Profile>) {
|
||||
// connect identity traits
|
||||
use identity::{Common, Unsupported};
|
||||
if let Some(uri) = uri(entry) {
|
||||
|
|
@ -390,7 +389,7 @@ fn show_identity_dialog(entry: &Entry, profile: &Arc<Profile>) {
|
|||
}
|
||||
|
||||
/// Present Search providers [AlertDialog](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.AlertDialog.html) for `Self`
|
||||
fn show_search_dialog(entry: &Entry, profile: &Arc<Profile>) {
|
||||
fn show_search_dialog(entry: &Entry, profile: &Rc<Profile>) {
|
||||
use search::Search;
|
||||
AlertDialog::search(profile).present(Some(entry))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,16 +5,13 @@ use crate::Profile;
|
|||
use action::Action as WidgetAction;
|
||||
use adw::AlertDialog;
|
||||
use gtk::{glib::Uri, prelude::EditableExt};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
// Select options
|
||||
|
||||
pub trait Common {
|
||||
fn common(
|
||||
profile: &Arc<Profile>,
|
||||
request: &Uri,
|
||||
callback: &Rc<impl Fn(bool) + 'static>,
|
||||
) -> Self;
|
||||
fn common(profile: &Rc<Profile>, request: &Uri, callback: &Rc<impl Fn(bool) + 'static>)
|
||||
-> Self;
|
||||
}
|
||||
|
||||
impl Common for AlertDialog {
|
||||
|
|
@ -22,7 +19,7 @@ impl Common for AlertDialog {
|
|||
|
||||
/// Create new `Self`
|
||||
fn common(
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
request: &Uri,
|
||||
callback: &Rc<impl Fn(bool) + 'static>,
|
||||
) -> Self {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use gtk::{
|
|||
glib::Uri,
|
||||
prelude::{BoxExt, WidgetExt},
|
||||
};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Form {
|
||||
// pub action_widget: Rc<Action>,
|
||||
|
|
@ -30,14 +30,14 @@ pub struct Form {
|
|||
pub name: Entry,
|
||||
pub save: Rc<Save>,
|
||||
pub g_box: Box,
|
||||
profile: Arc<Profile>,
|
||||
profile: Rc<Profile>,
|
||||
}
|
||||
|
||||
impl Form {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(widget_action: &Rc<WidgetAction>, profile: &Arc<Profile>, request: &Uri) -> Self {
|
||||
pub fn build(widget_action: &Rc<WidgetAction>, profile: &Rc<Profile>, request: &Uri) -> Self {
|
||||
// Init components
|
||||
let list = Rc::new(List::build(widget_action, profile, request));
|
||||
let file = Rc::new(File::build(widget_action));
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use gtk::{
|
|||
glib::timeout_add_seconds_local_once,
|
||||
prelude::{ButtonExt, WidgetExt},
|
||||
};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
// Defaults
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ impl Drop {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(profile: &Arc<Profile>, list: &Rc<List>) -> Self {
|
||||
pub fn build(profile: &Rc<Profile>, list: &Rc<List>) -> Self {
|
||||
// Init main widget
|
||||
let button = Button::builder()
|
||||
.label(LABEL)
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ use gtk::{
|
|||
glib::{Uri, timeout_add_seconds_local_once},
|
||||
prelude::{ButtonExt, WidgetExt},
|
||||
};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub trait Exit {
|
||||
fn exit(
|
||||
widget_action: &Rc<WidgetAction>,
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
list: &Rc<List>,
|
||||
request: &Uri,
|
||||
) -> Self;
|
||||
|
|
@ -25,7 +25,7 @@ impl Exit for Button {
|
|||
/// Create new `Self`
|
||||
fn exit(
|
||||
widget_action: &Rc<WidgetAction>,
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
list: &Rc<List>,
|
||||
request: &Uri,
|
||||
) -> Self {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
pub mod item;
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
use item::Item;
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ impl List {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(widget_action: &Rc<WidgetAction>, profile: &Arc<Profile>, request: &Uri) -> Self {
|
||||
pub fn build(widget_action: &Rc<WidgetAction>, profile: &Rc<Profile>, request: &Uri) -> Self {
|
||||
// Init dropdown items
|
||||
let guest_session = Item::new_guest_session();
|
||||
let generate_pem = Item::new_generate_pem();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use gtk::{
|
|||
gio::TlsCertificate,
|
||||
glib::{self, Object},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use std::rc::Rc;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Item(ObjectSubclass<imp::Item>);
|
||||
|
|
@ -54,7 +54,7 @@ impl Item {
|
|||
}
|
||||
|
||||
pub fn new_profile_identity_id(
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
profile_identity_id: i64,
|
||||
auth_url: &str,
|
||||
) -> Result<Self, Error> {
|
||||
|
|
@ -96,7 +96,7 @@ impl Item {
|
|||
// Actions
|
||||
|
||||
/// Update properties for `Self` for given `Profile` and `auth_url`
|
||||
pub fn update(&self, profile: &Arc<Profile>, auth_url: &str) -> Result<(), Error> {
|
||||
pub fn update(&self, profile: &Rc<Profile>, auth_url: &str) -> Result<(), Error> {
|
||||
// Update item depending on value type
|
||||
match self.value_enum() {
|
||||
Value::ProfileIdentityId(profile_identity_id) => {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::profile::Profile;
|
||||
use std::sync::Arc;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub fn new_for_profile_identity_id(
|
||||
profile: &Arc<Profile>,
|
||||
profile: &Rc<Profile>,
|
||||
profile_identity_id: i64,
|
||||
auth_url: &str,
|
||||
) -> bool {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use gtk::{
|
|||
glib::{Priority, timeout_add_seconds_local_once},
|
||||
prelude::{ButtonExt, FileExt, OutputStreamExtManual, WidgetExt},
|
||||
};
|
||||
use std::{path::MAIN_SEPARATOR, rc::Rc, sync::Arc};
|
||||
use std::{path::MAIN_SEPARATOR, rc::Rc};
|
||||
|
||||
const LABEL: &str = "Export";
|
||||
const TOOLTIP_TEXT: &str = "Export selected identity to file";
|
||||
|
|
@ -24,7 +24,7 @@ impl Save {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(profile: &Arc<Profile>, list: &Rc<List>) -> Self {
|
||||
pub fn build(profile: &Rc<Profile>, list: &Rc<List>) -> Self {
|
||||
// Init main widget
|
||||
let button = Button::builder()
|
||||
.label(LABEL)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use anyhow::{Result, bail};
|
|||
|
||||
use crate::profile::Profile;
|
||||
use gtk::{gio::TlsCertificate, prelude::TlsCertificateExt};
|
||||
use std::sync::Arc;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// Certificate details holder for export to file action
|
||||
pub struct Certificate {
|
||||
|
|
@ -14,7 +14,7 @@ impl Certificate {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(profile: &Arc<Profile>, profile_identity_id: i64) -> Result<Self> {
|
||||
pub fn build(profile: &Rc<Profile>, profile_identity_id: i64) -> Result<Self> {
|
||||
let record = profile.identity.database.record(profile_identity_id)?;
|
||||
match record {
|
||||
Some(identity) => Ok(Self {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use form::{Form, Query, list::Item, list::item::Value};
|
|||
use gtk::prelude::{EditableExt, WidgetExt};
|
||||
use sourceview::prelude::CastNone;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
// Response variants
|
||||
const RESPONSE_APPLY: (&str, &str) = ("apply", "Apply");
|
||||
|
|
@ -18,14 +17,14 @@ const RESPONSE_CANCEL: (&str, &str) = ("cancel", "Cancel");
|
|||
// const RESPONSE_MANAGE: (&str, &str) = ("manage", "Manage");
|
||||
|
||||
pub trait Search {
|
||||
fn search(profile: &Arc<Profile>) -> Self;
|
||||
fn search(profile: &Rc<Profile>) -> Self;
|
||||
}
|
||||
|
||||
impl Search for AlertDialog {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
fn search(profile: &Arc<Profile>) -> Self {
|
||||
fn search(profile: &Rc<Profile>) -> Self {
|
||||
// Init child container
|
||||
let form = Rc::new(Form::build(profile));
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use drop::Drop;
|
|||
use gtk::{Box, Button, Entry, Orientation, prelude::BoxExt};
|
||||
use list::List;
|
||||
pub use query::Query;
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Form {
|
||||
pub drop: Button,
|
||||
|
|
@ -20,7 +20,7 @@ impl Form {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(profile: &Arc<Profile>) -> Self {
|
||||
pub fn build(profile: &Rc<Profile>) -> Self {
|
||||
// Init components
|
||||
let list = Rc::new(List::build(profile));
|
||||
let query = Entry::query();
|
||||
|
|
|
|||
|
|
@ -9,17 +9,17 @@ use gtk::{
|
|||
glib::timeout_add_seconds_local_once,
|
||||
prelude::{ButtonExt, WidgetExt},
|
||||
};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub trait Drop {
|
||||
fn drop(profile: &Arc<Profile>, list: &Rc<List>) -> Self;
|
||||
fn drop(profile: &Rc<Profile>, list: &Rc<List>) -> Self;
|
||||
}
|
||||
|
||||
impl Drop for Button {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
fn drop(profile: &Arc<Profile>, list: &Rc<List>) -> Self {
|
||||
fn drop(profile: &Rc<Profile>, list: &Rc<List>) -> Self {
|
||||
// Defaults
|
||||
|
||||
const LABEL: &str = "Delete";
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use gtk::{
|
|||
prelude::{BoxExt, ListItemExt, ObjectExt, WidgetExt},
|
||||
};
|
||||
pub use item::Item;
|
||||
use std::sync::Arc;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct List {
|
||||
pub dropdown: DropDown,
|
||||
|
|
@ -21,7 +21,7 @@ impl List {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(profile: &Arc<Profile>) -> Self {
|
||||
pub fn build(profile: &Rc<Profile>) -> Self {
|
||||
// Init dropdown items
|
||||
let new_search_provider = Item::add();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ use gtk::{
|
|||
};
|
||||
pub use item::Item;
|
||||
use sourceview::prelude::ListModelExt;
|
||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub struct Suggestion {
|
||||
list_store: ListStore,
|
||||
list_view: ListView,
|
||||
single_selection: SingleSelection,
|
||||
entry: Entry,
|
||||
profile: Arc<Profile>,
|
||||
profile: Rc<Profile>,
|
||||
popover: Popover,
|
||||
pub signal_handler_id: Rc<RefCell<Option<SignalHandlerId>>>,
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ impl Suggestion {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn build(profile: &Arc<Profile>, entry: &Entry) -> Self {
|
||||
pub fn build(profile: &Rc<Profile>, entry: &Entry) -> Self {
|
||||
let signal_handler_id = Rc::new(RefCell::new(None));
|
||||
let list_store = ListStore::new::<Item>();
|
||||
let single_selection = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue