mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
use common helper for duplicated function
This commit is contained in:
parent
6806f1876c
commit
f2cdc7bc52
3 changed files with 20 additions and 36 deletions
15
src/tool.rs
15
src/tool.rs
|
|
@ -26,3 +26,18 @@ impl Format for usize {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function, extract readable title from [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
||||
/// * this feature wants to be improved @TODO
|
||||
pub fn uri_to_title(uri: >k::glib::Uri) -> gtk::glib::GString {
|
||||
let path = uri.path();
|
||||
|
||||
if path.split('/').last().unwrap_or_default().is_empty() {
|
||||
match uri.host() {
|
||||
Some(host) => host,
|
||||
None => "Untitled".into(),
|
||||
}
|
||||
} else {
|
||||
path
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue