Skip to content

Commit

Permalink
style tweaks
Browse files Browse the repository at this point in the history
add envs
add tab hotkey
other fix
  • Loading branch information
Kosette committed Nov 6, 2024
1 parent f1fc307 commit 8c39b0e
Show file tree
Hide file tree
Showing 23 changed files with 287 additions and 143 deletions.
34 changes: 16 additions & 18 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
name: Linux CI
on:
workflow_dispatch:
push:
branches:
- "main"
paths-ignore:
- "docs/**"
- "**/.gitignore"
- "**/.dockerignore"
- LICENSE
- "**/*.md"
pull_request:
branches:
- "main"
paths-ignore:
- "docs/**"
- "**/.gitignore"
- "**/.dockerignore"
- LICENSE
- "**/*.md"
# push:
# branches:
# - "dev"
# paths-ignore:
# - "docs/**"
# - ".gitignore"
# - LICENSE
# - "*.md"
# pull_request:
# branches:
# - "dev"
# paths-ignore:
# - "docs/**"
# - ".gitignore"
# - LICENSE
# - "*.md"

jobs:
build:
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: CI Passing
on:
push:
tags:
- v*
workflow_dispatch:
# push:
# branches:
# - "dev"
# paths-ignore:
# - "docs/**"
# - "*.md"
# - LICENSE
# - .gitignore

env:
CARGO_TERM_COLOR: always
Expand All @@ -23,7 +29,7 @@ jobs:
os: ubuntu-latest
target: arm64
# x86_64-windows-gnu
- arch: x86_64-windows-gnu
- arch: ucrt-x86_64-windows-gnu
os: windows-latest
target: amd64

Expand Down Expand Up @@ -189,7 +195,7 @@ jobs:
- name: Get latest tag name
id: tag
run: echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
run: echo "TAG_NAME=v$(date '+%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT

- name: Set prerelease variable
if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-alpha')
Expand Down
31 changes: 14 additions & 17 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ on:
workflow_dispatch:
push:
branches:
- "main"
- "dev"
paths-ignore:
- "docs/**"
- "**/.gitignore"
- "**/.dockerignore"
- ".gitignore"
- LICENSE
- "**/*.md"
pull_request:
branches:
- "main"
paths-ignore:
- "docs/**"
- "**/.gitignore"
- "**/.dockerignore"
- LICENSE
- "**/*.md"
- "*.md"
# pull_request:
# branches:
# - "dev"
# paths-ignore:
# - "docs/**"
# - ".gitignore"
# - LICENSE
# - "*.md"

env:
CARGO_TERM_COLOR: always
Expand All @@ -38,7 +36,6 @@ jobs:
# env: x86_64
- arch: ucrt64-x86_64-windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
msystem: ucrt64
env: ucrt-x86_64

Expand Down Expand Up @@ -72,7 +69,7 @@ jobs:
mingw-w64-${{ matrix.env }}-gst-libav
curl
- name: Build tsukimi-${{ matrix.target }}
- name: Build tsukimi-${{ matrix.arch }}
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
shell: msys2 {0}
run: |
Expand Down Expand Up @@ -151,10 +148,10 @@ jobs:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
with:
name: tsukimi-${{matrix.target}}
name: tsukimi-${{matrix.arch}}
path: |
artifact/*.exe
artifact/*.7z
artifact/*.exe
artifact/*.sha512sum
compression-level: 0
retention-days: 3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/i18n
/.idea
/backup
/.cargo
56 changes: 34 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ gtk = { version = "0.9", package = "gtk4", features = ["v4_16"] }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
tokio = { version = "1.41", features = ["full"] }
reqwest = { version = "0.12", default-features = false, features = ["http2", "native-tls", "native-tls-alpn", "json", "gzip"] }
reqwest = { version = "0.12", default-features = false, features = [
"http2",
"native-tls",
"native-tls-alpn",
"json",
"gzip",
] }
async-channel = "2.3.1"
once_cell = "1.20.2"
dirs = "5.0.1"
adw = { version = "0.7", package = "libadwaita", features = [
"v1_6",
] }
adw = { version = "0.7", package = "libadwaita", features = ["v1_6"] }
cargo-deb = "2.7.0"
bytefmt = "0.1.7"
libc = "0.2.159"
Expand All @@ -38,13 +42,19 @@ atomic-wait = "1.1.0"
flume = "0.11.1"
derive_builder = "0.20.2"
anyhow = "1.0.91"
windows = { version = "0.58.0", features = ["Win32_Foundation", "Win32_Networking_WinHttp", "Win32_System_Power", "Win32_System_Registry", "Win32_UI_WindowsAndMessaging"] }
tracing-subscriber = { version="0.3.18", features = ["chrono"] }
windows = { version = "0.58.0", features = [
"Win32_Foundation",
"Win32_Networking_WinHttp",
"Win32_System_Power",
"Win32_System_Registry",
"Win32_UI_WindowsAndMessaging",
] }
tracing-subscriber = { version = "0.3.18", features = ["chrono"] }
gdk4-x11 = { version = "0.9", optional = true }
gdk4-win32 = { version = "0.9", optional = true }
regex = "1.11.1"
strsim = "0.11.1"
clap = { version="4.5.20", features = ["derive"] }
clap = { version = "4.5.20", features = ["derive"] }
fnv = "1.0.7"
md-5 = "0.10.6"
unicode-segmentation = "1.12.0"
Expand All @@ -56,12 +66,11 @@ embed-resource = "2.5.0"
glib-build-tools = "0.20.0"

[features]
console = [] # Enable console logging
console = [] # Enable console logging
default = ["protocols", "render"]
protocols = [] # Enable custom protocol callbacks
render = [] # Enable custom rendering
build_libmpv = [
] # build libmpv automatically, provided MPV_SOURCE is set
protocols = [] # Enable custom protocol callbacks
render = [] # Enable custom rendering
build_libmpv = [] # build libmpv automatically, provided MPV_SOURCE is set
x11 = ["gdk4-x11"]
win32 = ["gdk4-win32"]

Expand All @@ -82,20 +91,23 @@ depends = "$auto"
section = "utility"
priority = "optional"
assets = [
[
"target/release/tsukimi",
"usr/bin/",
"755",
],
[
"README.md",
"usr/share/doc/tsukimi/README",
"644",
],
[
"target/release/tsukimi",
"usr/bin/",
"755",
],
[
"README.md",
"usr/share/doc/tsukimi/README",
"644",
],
]

[profile.release]
lto = true
codegen-units = 1
opt-level = "s"
strip = true

[profile.dev]
debug = true
36 changes: 33 additions & 3 deletions src/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing_subscriber::fmt::time::ChronoLocal;

use crate::dyn_event;

const DEFAULT_RENDERER: &str = "gl";
const DEFAULT_RENDERER: &str = "ngl";

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
Expand Down Expand Up @@ -42,6 +42,27 @@ pub struct Args {
gdk_scale: Option<i8>,
}

struct Envs {
log_level: LevelFilter,
log_file: Option<String>,
}

impl Envs {
fn load() -> Self {
Self {
log_level: match std::env::var("TSUKIMI_LOG_LEVEL").as_deref() {
Ok("ERROR") => LevelFilter::ERROR,
Ok("WARN") => LevelFilter::WARN,
Ok("INFO") => LevelFilter::INFO,
Ok("DEBUG") => LevelFilter::DEBUG,
Ok("TRACE") => LevelFilter::TRACE,
_ => LevelFilter::INFO,
},
log_file: std::env::var("TSUKIMI_LOG_FILE").ok(),
}
}
}

impl Args {
/// Build the tracing subscriber using parameters from the command line
/// arguments
Expand All @@ -58,11 +79,20 @@ impl Args {
Some("info") => builder.with_max_level(LevelFilter::INFO),
Some("debug") => builder.with_max_level(LevelFilter::DEBUG),
Some("trace") => builder.with_max_level(LevelFilter::TRACE),
_ => builder.with_max_level(LevelFilter::INFO),
_ => builder.with_max_level(Envs::load().log_level),
};

match &self.log_file {
None => builder.with_writer(io::stderr).init(),
None => {
if let Some(f) = Envs::load().log_file {
builder
.with_ansi(false)
.with_writer(Mutex::new(File::create(f).unwrap()))
.init()
} else {
builder.with_writer(io::stderr).init()
}
}
Some(f) => {
let tracing_writer = match File::create(f) {
Ok(f) => f,
Expand Down
4 changes: 3 additions & 1 deletion src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ use serde_json::{
Value,
};
use tracing::{
debug, info, warn
debug,
info,
warn,
};
use url::Url;
use uuid::Uuid;
Expand Down
11 changes: 6 additions & 5 deletions src/client/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ impl Default for IdType {
}
}

impl ToString for IdType {
fn to_string(&self) -> String {
return match self {
impl std::fmt::Display for IdType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
IdType::String(s) => s.to_string(),
IdType::Int(i) => i.to_string()
}
IdType::Int(i) => i.to_string(),
};
write!(f, "{}", str)
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn load_css() {
border-radius: 999px;
margin: 3px;
}}
box>overlay>image {{
background-color: {};
border-radius: 999px;
Expand All @@ -70,6 +70,9 @@ pub fn load_css() {
accent_color
));

#[cfg(target_os = "windows")]
styles.push_str("window {box-shadow: 0px 0px 5px 0px rgba(5, 5, 5, 0.4);}");

provider.load_from_string(&styles);

gtk::style_context_add_provider_for_display(
Expand Down
2 changes: 1 addition & 1 deletion src/ui/mpv/mpvglarea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod imp {
}

fn dispose(&self) {
if let Some(mpv) = self.mpv.mpv.lock().ok() {
if let Ok(mpv) = self.mpv.mpv.lock() {
drop(mpv);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/mpv/tsukimi_mpv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ const KEYSTRING_MAP: &[(&str, &str)] = &[
("", "Shift_R"),
("", "grave"),
("SPACE", " "),
("TAB", "\t"),
];

fn keyval_to_keystr(keyval: u32) -> Option<String> {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/provider/tu_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use crate::{
},
toast,
ui::widgets::{
other::OtherPage,
item::ItemPage,
list::ListPage,
music_album::AlbumPage,
other::OtherPage,
single_grid::SingleGrid,
window::Window,
},
Expand Down Expand Up @@ -331,7 +331,7 @@ impl TuItem {
_ => {
let page = OtherPage::new(self);
push_page_with_tag(window, page, self.name());
},
}
}
}

Expand Down
Loading

0 comments on commit 8c39b0e

Please sign in to comment.