mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
filter FS entities from subject filename, rename new
constructor to build
This commit is contained in:
parent
bb4ddbdddd
commit
2f84c2b86e
@ -66,7 +66,10 @@ impl Save {
|
|||||||
.filters(&filters)
|
.filters(&filters)
|
||||||
.initial_name(format!(
|
.initial_name(format!(
|
||||||
"{}.pem",
|
"{}.pem",
|
||||||
certificate.name.replace(MAIN_SEPARATOR, "-")
|
certificate
|
||||||
|
.name
|
||||||
|
.trim_matches(MAIN_SEPARATOR)
|
||||||
|
.replace(MAIN_SEPARATOR, "-")
|
||||||
))
|
))
|
||||||
.build()
|
.build()
|
||||||
.save(Window::NONE, Cancellable::NONE, {
|
.save(Window::NONE, Cancellable::NONE, {
|
||||||
|
@ -27,7 +27,7 @@ use gtk::{
|
|||||||
prelude::{EditableExt, FileExt},
|
prelude::{EditableExt, FileExt},
|
||||||
};
|
};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::{cell::RefCell, rc::Rc, time::Duration};
|
use std::{cell::RefCell, path::MAIN_SEPARATOR, rc::Rc, time::Duration};
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
id: Rc<GString>,
|
id: Rc<GString>,
|
||||||
@ -331,7 +331,8 @@ impl Page {
|
|||||||
Response::Download { base, cancellable, stream } => {
|
Response::Download { base, cancellable, stream } => {
|
||||||
// Init download widget
|
// Init download widget
|
||||||
let status_page = content.to_status_download(
|
let status_page = content.to_status_download(
|
||||||
&uri_to_title(&base), // grab default filename from base URI
|
uri_to_title(&base).trim_matches(MAIN_SEPARATOR), // grab default filename from base URI,
|
||||||
|
// format FS entities
|
||||||
&cancellable,
|
&cancellable,
|
||||||
{
|
{
|
||||||
let cancellable = cancellable.clone();
|
let cancellable = cancellable.clone();
|
||||||
@ -609,19 +610,17 @@ pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function, extract readable title from [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
/// Helper function, extract readable title from [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
||||||
///
|
/// * useful as common placeholder when page title could not be detected
|
||||||
/// Useful as common placeholder when page title could not be detected
|
|
||||||
///
|
|
||||||
/// * this feature may be improved and moved outside @TODO
|
/// * this feature may be improved and moved outside @TODO
|
||||||
fn uri_to_title(uri: &Uri) -> GString {
|
fn uri_to_title(uri: &Uri) -> GString {
|
||||||
let title = uri.path();
|
let path = uri.path();
|
||||||
if title.split('/').last().unwrap_or_default().is_empty() {
|
if path.split('/').last().unwrap_or_default().is_empty() {
|
||||||
match uri.host() {
|
match uri.host() {
|
||||||
Some(host) => host,
|
Some(host) => host,
|
||||||
None => gformat!("Untitled"),
|
None => "Untitled".into(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
title
|
path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ impl Content {
|
|||||||
on_choose: impl Fn(File, Rc<status::download::Action>) + 'static,
|
on_choose: impl Fn(File, Rc<status::download::Action>) + 'static,
|
||||||
) -> StatusPage {
|
) -> StatusPage {
|
||||||
self.clean();
|
self.clean();
|
||||||
let status = status::download::new(initial_filename, cancellable, on_choose);
|
let status = status::download::build(initial_filename, cancellable, on_choose);
|
||||||
self.g_box.append(&status);
|
self.g_box.append(&status);
|
||||||
status
|
status
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ const TITLE: &str = "Download";
|
|||||||
/// preset with children widget contain download UI
|
/// preset with children widget contain download UI
|
||||||
/// * apply callback function on destination [File](https://docs.gtk.org/gio/iface.File.html) selected
|
/// * apply callback function on destination [File](https://docs.gtk.org/gio/iface.File.html) selected
|
||||||
/// * require external IOStream read/write implementation (depending of protocol)
|
/// * require external IOStream read/write implementation (depending of protocol)
|
||||||
pub fn new(
|
pub fn build(
|
||||||
initial_filename: &str,
|
initial_filename: &str,
|
||||||
cancellable: &Cancellable,
|
cancellable: &Cancellable,
|
||||||
on_choose: impl Fn(File, Rc<Action>) + 'static,
|
on_choose: impl Fn(File, Rc<Action>) + 'static,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user