Skip to content

Commit

Permalink
misc: some fixes
Browse files Browse the repository at this point in the history
Signed-off-by: tsukinaha <[email protected]>
  • Loading branch information
tsukinaha committed Feb 21, 2025
1 parent 0788038 commit 843930e
Show file tree
Hide file tree
Showing 71 changed files with 278 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cargo_clippy_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- name: Run Clippy
run: |
docker run --rm -v ${{ github.workspace }}:/app -v ./entrypoint.sh:/entrypoint.sh ghcr.io/kosette/ubuntu-rust-gtk4:latest
docker run --rm -v ${{ github.workspace }}:/app -v ./entrypoint.sh:/entrypoint.sh ghcr.io/tsukinaha/ubuntu-rust-gtk4:latest
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use gtk::glib;
mod imp {

use gtk::{
gdk::Display,
CssProvider,
gdk::Display,
};

use crate::ui::SETTINGS;
Expand Down
12 changes: 6 additions & 6 deletions src/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Args {
}
}

fn init_gilb_to_tracing(&self) {
fn init_glib_to_tracing(&self) {
gtk::glib::log_set_writer_func(|level, x| {
let domain = x
.iter()
Expand Down Expand Up @@ -130,33 +130,33 @@ impl Args {
fn init_config_dirs(&self) {
if let Some(xdg_cache_home) = self.xdg_cache_home.as_deref() {
info!("Windows: Setting XDG_CACHE_HOME to {}", xdg_cache_home);
std::env::set_var("XDG_CACHE_HOME", xdg_cache_home);
unsafe { std::env::set_var("XDG_CACHE_HOME", xdg_cache_home) };
}

if std::env::var("XDG_CACHE_HOME").is_err() {
info!("Windows: Falling back to default XDG_CACHE_HOME: %LOCALAPPDATA%");
let config_local_dir = dirs::config_local_dir().expect("Failed to get %LOCALAPPDATA%");
std::env::set_var("XDG_CACHE_HOME", config_local_dir);
unsafe { std::env::set_var("XDG_CACHE_HOME", config_local_dir) };
}
}

#[cfg(target_os = "windows")]
fn init_gdk_scale(&self) {
if let Some(scale) = self.gdk_scale {
info!("Windows: Setting GDK_SCALE to {}", scale);
std::env::set_var("GDK_SCALE", scale.to_string());
unsafe { std::env::set_var("GDK_SCALE", scale.to_string()) };
}

if std::env::var("GDK_SCALE").is_err() {
info!("Windows: Falling back to default GDK_SCALE: 1");
std::env::set_var("GDK_SCALE", "1");
unsafe { std::env::set_var("GDK_SCALE", "1") };
}
}

pub fn init(&self) {
self.init_tracing_subscriber();
self.init_gsk_renderer();
self.init_gilb_to_tracing();
self.init_glib_to_tracing();

#[cfg(target_os = "windows")]
self.init_config_dirs();
Expand Down
35 changes: 18 additions & 17 deletions src/client/emby_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ use std::{
};

use anyhow::{
anyhow,
Result,
anyhow,
};
use once_cell::sync::Lazy;
use reqwest::{
header::HeaderValue,
Client,
Method,
RequestBuilder,
Response,
header::HeaderValue,
};
use serde::{
de::DeserializeOwned,
Deserialize,
Serialize,
de::DeserializeOwned,
};
use serde_json::{
json,
Value,
json,
};
use tokio::sync::Mutex;
use tracing::{
Expand All @@ -35,6 +35,8 @@ use uuid::Uuid;
#[cfg(target_os = "windows")]
use super::windows_compat::xattr;
use super::{
Account,
ReqClient,
error::UserFacingError,
structs::{
ActivityLogs,
Expand All @@ -55,21 +57,19 @@ use super::{
ServerInfo,
SimpleListItem,
},
Account,
ReqClient,
};
use crate::{
CLIENT_ID,
config::VERSION,
ui::{
SETTINGS,
emby_cache_path,
widgets::{
filter_panel::FiltersList,
single_grid::imp::ListType,
},
SETTINGS,
},
utils::spawn_tokio_without_await,
CLIENT_ID,
};

pub static EMBY_CLIENT: Lazy<EmbyClient> = Lazy::new(EmbyClient::default);
Expand Down Expand Up @@ -801,7 +801,11 @@ impl EmbyClient {
("SortBy", sortby),
("SortOrder", sort_order),
("EnableImageTypes", "Primary,Backdrop,Thumb,Banner"),
if list_type == ListType::Liked {("Filters", "IsFavorite")} else {("", "")},
if list_type == ListType::Liked {
("Filters", "IsFavorite")
} else {
("", "")
},
]
}
ListType::Resume => {
Expand All @@ -813,13 +817,10 @@ impl EmbyClient {
("ParentId", id),
("EnableImageTypes", "Primary,Backdrop,Thumb,Banner"),
("ImageTypeLimit", "1"),
(
"IncludeItemTypes",
match include_item_type {
"Series" => "Episode",
_ => include_item_type,
},
),
("IncludeItemTypes", match include_item_type {
"Series" => "Episode",
_ => include_item_type,
}),
("Limit", "30"),
]
}
Expand Down Expand Up @@ -1419,8 +1420,8 @@ mod tests {

let image = std::fs::read("/home/inaha/Works/tsukimi/target/debug/test.jpg").unwrap();
use base64::{
engine::general_purpose::STANDARD,
Engine as _,
engine::general_purpose::STANDARD,
};
let image = STANDARD.encode(&image);
match EMBY_CLIENT
Expand Down
22 changes: 11 additions & 11 deletions src/client/windows_compat.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod xattr {
#[cfg(target_os = "windows")]
use anyhow::{
anyhow,
Result,
anyhow,
};

/// Implementing xattr-like feature on Windows using Alternate Data Streams(ADS)
Expand All @@ -17,24 +17,24 @@ pub mod xattr {
str,
};
use windows::{
core::{
Error,
PCWSTR,
},
Win32::{
Foundation::{
CloseHandle,
INVALID_HANDLE_VALUE,
},
Storage::FileSystem::{
CreateFileW,
GetFileInformationByHandle,
ReadFile,
BY_HANDLE_FILE_INFORMATION,
CreateFileW,
FILE_ATTRIBUTE_NORMAL,
GetFileInformationByHandle,
OPEN_EXISTING,
ReadFile,
},
},
core::{
Error,
PCWSTR,
},
};

let full_path = format!("{}:{}", path.display(), attr_name);
Expand Down Expand Up @@ -104,19 +104,19 @@ pub mod xattr {
os::windows::ffi::OsStrExt,
};
use windows::{
core::PCWSTR,
Win32::{
Foundation::{
CloseHandle,
INVALID_HANDLE_VALUE,
},
Storage::FileSystem::{
CreateFileW,
WriteFile,
CREATE_ALWAYS,
CreateFileW,
FILE_ATTRIBUTE_NORMAL,
WriteFile,
},
},
core::PCWSTR,
};

let full_path = format!("{}:{}", path.display(), attr_name);
Expand Down
10 changes: 6 additions & 4 deletions src/gstl/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ pub mod imp {

use anyhow::Result;
use flume::{
unbounded,
Receiver,
Sender,
unbounded,
};
use glib::subclass::Signal;
use gst::ClockTime;
Expand Down Expand Up @@ -194,9 +194,11 @@ pub mod imp {
fn signals() -> &'static [Signal] {
static SIGNALS: OnceLock<Vec<Signal>> = OnceLock::new();
SIGNALS.get_or_init(|| {
vec![Signal::builder("stream-start")
.param_types([ClockTime::static_type()])
.build()]
vec![
Signal::builder("stream-start")
.param_types([ClockTime::static_type()])
.build(),
]
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod provider;
pub mod widgets;

pub use models::{
emby_cache_path,
SETTINGS,
emby_cache_path,
};
pub use widgets::window::Window;
2 changes: 1 addition & 1 deletion src/ui/models/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use gtk::{
};

use crate::{
APP_ID,
client::Account,
ui::provider::descriptor::{
Descriptor,
VecSerialize,
},
APP_ID,
};

pub struct Settings(ThreadGuard<gio::Settings>);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/mpv/control_sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use adw::{
};
use gettextrs::gettext;
use gtk::{
CompositeTemplate,
gio,
glib,
template_callbacks,
CompositeTemplate,
};
use libmpv2::SetData;

Expand Down
2 changes: 1 addition & 1 deletion src/ui/mpv/menu_actions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use adw::subclass::prelude::*;
use gtk::{
glib,
CompositeTemplate,
glib,
};

mod imp {
Expand Down
21 changes: 9 additions & 12 deletions src/ui/mpv/mpvglarea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use libmpv2::SetData;
use tracing::info;

use super::tsukimi_mpv::{
TrackSelection,
ACTIVE,
TrackSelection,
};
use crate::{
client::emby_client::EMBY_CLIENT,
Expand All @@ -36,9 +36,9 @@ mod imp {
use crate::{
close_on_error,
ui::mpv::tsukimi_mpv::{
TsukimiMPV,
RENDER_UPDATE,
SHUTDOWN,
TsukimiMPV,
},
};

Expand Down Expand Up @@ -119,16 +119,13 @@ mod imp {
fn setup_mpv(&self, gl_context: GLContext) {
let tmpv = self.mpv();
let mut handle = tmpv.mpv.ctx;
let mut ctx = RenderContext::new(
unsafe { handle.as_mut() },
vec![
RenderParam::ApiType(RenderParamApiType::OpenGl),
RenderParam::InitParams(OpenGLInitParams {
get_proc_address,
ctx: gl_context,
}),
],
)
let mut ctx = RenderContext::new(unsafe { handle.as_mut() }, vec![
RenderParam::ApiType(RenderParamApiType::OpenGl),
RenderParam::InitParams(OpenGLInitParams {
get_proc_address,
ctx: gl_context,
}),
])
.expect("Failed creating render context");

ctx.set_update_callback(|| {
Expand Down
Loading

0 comments on commit 843930e

Please sign in to comment.