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)
|
||||
.initial_name(format!(
|
||||
"{}.pem",
|
||||
certificate.name.replace(MAIN_SEPARATOR, "-")
|
||||
certificate
|
||||
.name
|
||||
.trim_matches(MAIN_SEPARATOR)
|
||||
.replace(MAIN_SEPARATOR, "-")
|
||||
))
|
||||
.build()
|
||||
.save(Window::NONE, Cancellable::NONE, {
|
||||
|
@ -27,7 +27,7 @@ use gtk::{
|
||||
prelude::{EditableExt, FileExt},
|
||||
};
|
||||
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 {
|
||||
id: Rc<GString>,
|
||||
@ -331,7 +331,8 @@ impl Page {
|
||||
Response::Download { base, cancellable, stream } => {
|
||||
// Init download widget
|
||||
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,
|
||||
{
|
||||
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)
|
||||
///
|
||||
/// 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
|
||||
fn uri_to_title(uri: &Uri) -> GString {
|
||||
let title = uri.path();
|
||||
if title.split('/').last().unwrap_or_default().is_empty() {
|
||||
let path = uri.path();
|
||||
if path.split('/').last().unwrap_or_default().is_empty() {
|
||||
match uri.host() {
|
||||
Some(host) => host,
|
||||
None => gformat!("Untitled"),
|
||||
None => "Untitled".into(),
|
||||
}
|
||||
} else {
|
||||
title
|
||||
path
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ impl Content {
|
||||
on_choose: impl Fn(File, Rc<status::download::Action>) + 'static,
|
||||
) -> StatusPage {
|
||||
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);
|
||||
status
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ const TITLE: &str = "Download";
|
||||
/// preset with children widget contain download UI
|
||||
/// * apply callback function on destination [File](https://docs.gtk.org/gio/iface.File.html) selected
|
||||
/// * require external IOStream read/write implementation (depending of protocol)
|
||||
pub fn new(
|
||||
pub fn build(
|
||||
initial_filename: &str,
|
||||
cancellable: &Cancellable,
|
||||
on_choose: impl Fn(File, Rc<Action>) + 'static,
|
||||
|
Loading…
x
Reference in New Issue
Block a user