diff --git a/Cargo.toml b/Cargo.toml index 8580ef9..907cf0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,13 +15,12 @@ btoi = "0.5.0" memchr = "2.7.6" memmap2 = "0.9" thiserror = "2.0" -tracing = { version = "0.1.41", no-default-features = true } +tracing = { version = "0.1.41", default-features = false } xdg = "3.0" [dev-dependencies] speculoos = "0.13.0" linicon = "2.3.0" -gtk4 = "0.10" criterion = "0.7" [features] diff --git a/benches/tests.rs b/benches/tests.rs index 5eaee3f..27a5e8a 100644 --- a/benches/tests.rs +++ b/benches/tests.rs @@ -1,25 +1,7 @@ use cosmic_freedesktop_icons::lookup; -use gtk4::{IconLookupFlags, IconTheme, TextDirection}; use speculoos::prelude::*; use std::path::PathBuf; -#[test] -fn gtk_lookup() { - gtk4::init().unwrap(); - let theme = IconTheme::new(); - - let x = theme.lookup_icon( - "firefox", - &[], - 24, - 1, - TextDirection::None, - IconLookupFlags::empty(), - ); - - assert!(x.icon_name().is_some()) -} - // Linicon sometimes fails with theme that have unknown parents // This test only ensure we are running the correct function in the benchmarks // And results are identical. diff --git a/src/lib.rs b/src/lib.rs index 964e930..fc9f803 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,58 +110,6 @@ pub fn list_themes() -> Vec { themes } -/// Return the default GTK theme if set. -/// -/// ## Example -/// ```rust, no_run -/// use cosmic_freedesktop_icons::default_theme_gtk; -/// -/// let theme = default_theme_gtk(); -/// -/// assert_eq!(Some("Adwaita"), theme.as_deref()); -/// ``` -pub fn default_theme_gtk() -> Option { - // Calling gsettings is the simplest way to retrieve the default icon theme without adding - // GTK as a dependency. There seems to be several ways to set the default GTK theme - // including a file in XDG_CONFIG_HOME as well as an env var. Gsettings is the most - // straightforward method. - let gsettings = std::process::Command::new("gsettings") - .args(["get", "org.gnome.desktop.interface", "icon-theme"]) - .output() - .ok()?; - - // Only return the theme if it's in the cache. - if gsettings.status.success() { - let name = String::from_utf8(gsettings.stdout).ok()?; - let name = name.trim().trim_matches('\''); - THEMES.get(name.as_bytes()).and_then(|themes| { - themes.first().and_then(|path| { - let file = std::fs::File::open(&path.index) - .and_then(|file| unsafe { Mmap::map(&file) }) - .ok()?; - let mut reader = std::io::Cursor::new(file.as_ref()); - - let mut line = String::new(); - while let Ok(read) = reader.read_line(&mut line) { - if read == 0 { - break; - } - - if let Some(name) = line.strip_prefix("Name=") { - return Some(name.trim().to_owned()); - } - - line.clear(); - } - - None - }) - }) - } else { - None - } -} - /// The lookup builder struct, holding all the lookup query parameters. pub struct LookupBuilder<'a> { name: &'a str,