Compare commits
3 commits
38a7f97cad
...
56e4431a58
Author | SHA1 | Date | |
---|---|---|---|
56e4431a58 | |||
5a85e4f6c3 | |||
0659698f19 |
7 changed files with 61 additions and 30 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
@ -2224,6 +2224,7 @@ dependencies = [
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"toml",
|
"toml",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
|
"winresource",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2285,6 +2286,12 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
|
checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "want"
|
name = "want"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
@ -2700,6 +2707,16 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winresource"
|
||||||
|
version = "0.1.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba4a67c78ee5782c0c1cb41bebc7e12c6e79644daa1650ebbc1de5d5b08593f7"
|
||||||
|
dependencies = [
|
||||||
|
"toml",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-bindgen-rt"
|
name = "wit-bindgen-rt"
|
||||||
version = "0.39.0"
|
version = "0.39.0"
|
||||||
|
|
|
@ -23,3 +23,6 @@ opt-level = "z"
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
strip = true
|
strip = true
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
winresource = "0.1.20"
|
||||||
|
|
13
build.rs
Normal file
13
build.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
use std::{env, io};
|
||||||
|
|
||||||
|
use winresource::WindowsResource;
|
||||||
|
|
||||||
|
fn main() -> Result<(), io::Error> {
|
||||||
|
if env::var_os("CARGO_CFG_WINDOWS").is_some() {
|
||||||
|
WindowsResource::new()
|
||||||
|
.set_icon("res/tyrolienne.ico")
|
||||||
|
.compile()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
BIN
res/tyrolienne.ico
Normal file
BIN
res/tyrolienne.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
|
@ -159,6 +159,8 @@ impl AsyncComponent for Tyrolienne {
|
||||||
gtk::ListBox {
|
gtk::ListBox {
|
||||||
set_selection_mode: gtk::SelectionMode::None,
|
set_selection_mode: gtk::SelectionMode::None,
|
||||||
set_css_classes: &["boxed-list"],
|
set_css_classes: &["boxed-list"],
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: matches!(model.step, Step::Waiting),
|
||||||
|
|
||||||
adw::ActionRow {
|
adw::ActionRow {
|
||||||
set_activatable: true,
|
set_activatable: true,
|
||||||
|
@ -391,7 +393,6 @@ impl AsyncComponent for Tyrolienne {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO app icon (windows)
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match ffmpeg::check().and_then(|_| get_config()) {
|
match ffmpeg::check().and_then(|_| get_config()) {
|
||||||
Ok(config) => RelmApp::new("net.uku3lig.tyrolienne").run_async::<Tyrolienne>(config),
|
Ok(config) => RelmApp::new("net.uku3lig.tyrolienne").run_async::<Tyrolienne>(config),
|
||||||
|
|
|
@ -150,7 +150,6 @@ impl SimpleComponent for Toast {
|
||||||
|
|
||||||
pub struct StandaloneDialog;
|
pub struct StandaloneDialog;
|
||||||
|
|
||||||
// TODO: don't open a window, just give a HeaderBar to the dialog
|
|
||||||
impl SimpleComponent for StandaloneDialog {
|
impl SimpleComponent for StandaloneDialog {
|
||||||
type Init = String;
|
type Init = String;
|
||||||
type Input = ();
|
type Input = ();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{path::Path, sync::LazyLock};
|
use std::{error::Error, fmt::Display, path::Path, sync::LazyLock};
|
||||||
|
|
||||||
use anyhow::{Result, bail};
|
use anyhow::Result;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use relm4::Sender;
|
use relm4::Sender;
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
|
@ -47,6 +47,25 @@ pub struct ZiplineShortUrl {
|
||||||
url: String,
|
url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct ZiplineError {
|
||||||
|
error: String,
|
||||||
|
status_code: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for ZiplineError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"An error occurred ({}): {}",
|
||||||
|
self.status_code, self.error
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for ZiplineError {}
|
||||||
|
|
||||||
impl ZiplineFileInfo {
|
impl ZiplineFileInfo {
|
||||||
pub fn thumbnail_url(&self, config: &Config) -> Option<String> {
|
pub fn thumbnail_url(&self, config: &Config) -> Option<String> {
|
||||||
self.thumbnail
|
self.thumbnail
|
||||||
|
@ -80,7 +99,6 @@ async fn wrap_file(path: &Path, sender: Sender<ProgressMessage>) -> Result<Part>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make a ZiplineError type
|
|
||||||
pub async fn get_folders(config: &Config) -> Result<Vec<ZiplineFolder>> {
|
pub async fn get_folders(config: &Config) -> Result<Vec<ZiplineFolder>> {
|
||||||
let url = format!("{}api/user/folders?noincl=true", config.fixed_url());
|
let url = format!("{}api/user/folders?noincl=true", config.fixed_url());
|
||||||
|
|
||||||
|
@ -91,11 +109,7 @@ pub async fn get_folders(config: &Config) -> Result<Vec<ZiplineFolder>> {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if res.status() != StatusCode::OK {
|
if res.status() != StatusCode::OK {
|
||||||
bail!(
|
Err(res.json::<ZiplineError>().await?.into())
|
||||||
"an error occurred ({}): {}",
|
|
||||||
res.status(),
|
|
||||||
res.text().await?
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
res.json().await.map_err(Into::into)
|
res.json().await.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
@ -125,11 +139,7 @@ pub async fn upload_file(
|
||||||
let res = req.send().await?;
|
let res = req.send().await?;
|
||||||
|
|
||||||
if res.status() != StatusCode::OK {
|
if res.status() != StatusCode::OK {
|
||||||
bail!(
|
Err(res.json::<ZiplineError>().await?.into())
|
||||||
"an error occurred ({}): {}",
|
|
||||||
res.status(),
|
|
||||||
res.text().await?
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
res.json().await.map_err(Into::into)
|
res.json().await.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
@ -146,11 +156,7 @@ pub async fn recalc_thumbnails(config: &Config) -> Result<()> {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if res.status() != StatusCode::OK {
|
if res.status() != StatusCode::OK {
|
||||||
bail!(
|
Err(res.json::<ZiplineError>().await?.into())
|
||||||
"an error occurred ({}): {}",
|
|
||||||
res.status(),
|
|
||||||
res.text().await?
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -166,11 +172,7 @@ pub async fn get_file_details(config: &Config, id: &str) -> Result<ZiplineFileIn
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if res.status() != StatusCode::OK {
|
if res.status() != StatusCode::OK {
|
||||||
bail!(
|
Err(res.json::<ZiplineError>().await?.into())
|
||||||
"an error occurred ({}): {}",
|
|
||||||
res.status(),
|
|
||||||
res.text().await?
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
res.json().await.map_err(Into::into)
|
res.json().await.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
@ -193,11 +195,7 @@ pub async fn shorten_url(config: &Config, to_shorten: &str) -> Result<String> {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if res.status() != StatusCode::OK {
|
if res.status() != StatusCode::OK {
|
||||||
bail!(
|
Err(res.json::<ZiplineError>().await?.into())
|
||||||
"an error occurred ({}): {}",
|
|
||||||
res.status(),
|
|
||||||
res.text().await?
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
let out: ZiplineShortUrl = res.json().await?;
|
let out: ZiplineShortUrl = res.json().await?;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue