mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 14:21:03 +02:00
chore(tray): remove unneeded png image code
This commit is contained in:
parent
42e25f5ef2
commit
48dc65f60b
3 changed files with 2 additions and 101 deletions
66
Cargo.lock
generated
66
Cargo.lock
generated
|
@ -17,12 +17,6 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "adler2"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ahash"
|
name = "ahash"
|
||||||
version = "0.8.3"
|
version = "0.8.3"
|
||||||
|
@ -285,7 +279,7 @@ dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"miniz_oxide 0.6.2",
|
"miniz_oxide",
|
||||||
"object",
|
"object",
|
||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
]
|
]
|
||||||
|
@ -567,15 +561,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crc32fast"
|
|
||||||
version = "1.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.5.8"
|
version = "0.5.8"
|
||||||
|
@ -904,15 +889,6 @@ version = "2.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fdeflate"
|
|
||||||
version = "0.3.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb"
|
|
||||||
dependencies = [
|
|
||||||
"simd-adler32",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "field-offset"
|
name = "field-offset"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
|
@ -935,16 +911,6 @@ dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "flate2"
|
|
||||||
version = "1.0.34"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
|
|
||||||
dependencies = [
|
|
||||||
"crc32fast",
|
|
||||||
"miniz_oxide 0.8.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
@ -1733,7 +1699,6 @@ dependencies = [
|
||||||
"mpris",
|
"mpris",
|
||||||
"nix 0.29.0",
|
"nix 0.29.0",
|
||||||
"notify",
|
"notify",
|
||||||
"png",
|
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"schemars",
|
"schemars",
|
||||||
|
@ -1958,16 +1923,6 @@ dependencies = [
|
||||||
"adler",
|
"adler",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "miniz_oxide"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
|
||||||
dependencies = [
|
|
||||||
"adler2",
|
|
||||||
"simd-adler32",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -2402,19 +2357,6 @@ version = "0.3.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "png"
|
|
||||||
version = "0.17.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
"crc32fast",
|
|
||||||
"fdeflate",
|
|
||||||
"flate2",
|
|
||||||
"miniz_oxide 0.8.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polling"
|
name = "polling"
|
||||||
version = "2.7.0"
|
version = "2.7.0"
|
||||||
|
@ -3046,12 +2988,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "simd-adler32"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
|
|
@ -68,7 +68,7 @@ notifications = ["zbus"]
|
||||||
|
|
||||||
sys_info = ["sysinfo", "regex"]
|
sys_info = ["sysinfo", "regex"]
|
||||||
|
|
||||||
tray = ["system-tray", "png"]
|
tray = ["system-tray"]
|
||||||
|
|
||||||
upower = ["upower_dbus", "zbus", "futures-lite"]
|
upower = ["upower_dbus", "zbus", "futures-lite"]
|
||||||
|
|
||||||
|
@ -149,7 +149,6 @@ sysinfo = { version = "0.29.11", optional = true }
|
||||||
|
|
||||||
# tray
|
# tray
|
||||||
system-tray = { version = "0.4.0", features = ["dbusmenu-gtk3"], optional = true }
|
system-tray = { version = "0.4.0", features = ["dbusmenu-gtk3"], optional = true }
|
||||||
png = { version = "0.17.14", optional = true }
|
|
||||||
|
|
||||||
# upower
|
# upower
|
||||||
upower_dbus = { version = "0.3.2", optional = true }
|
upower_dbus = { version = "0.3.2", optional = true }
|
||||||
|
|
|
@ -7,7 +7,6 @@ use gtk::ffi::gtk_icon_theme_get_search_path;
|
||||||
use gtk::gdk_pixbuf::{Colorspace, InterpType, Pixbuf};
|
use gtk::gdk_pixbuf::{Colorspace, InterpType, Pixbuf};
|
||||||
use gtk::prelude::IconThemeExt;
|
use gtk::prelude::IconThemeExt;
|
||||||
use gtk::{IconLookupFlags, IconTheme, Image};
|
use gtk::{IconLookupFlags, IconTheme, Image};
|
||||||
use png::ColorType;
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::os::raw::{c_char, c_int};
|
use std::os::raw::{c_char, c_int};
|
||||||
|
@ -126,36 +125,3 @@ fn get_image_from_pixmap(item: &TrayMenu, size: u32) -> Result<Image> {
|
||||||
ImageProvider::create_and_load_surface(&pixbuf, &image)?;
|
ImageProvider::create_and_load_surface(&pixbuf, &image)?;
|
||||||
Ok(image)
|
Ok(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PngData<'a>(pub &'a [u8]);
|
|
||||||
impl TryFrom<PngData<'_>> for Image {
|
|
||||||
type Error = Report;
|
|
||||||
|
|
||||||
fn try_from(value: PngData) -> std::result::Result<Self, Self::Error> {
|
|
||||||
let data = value.0;
|
|
||||||
|
|
||||||
let decoder = png::Decoder::new(data);
|
|
||||||
let mut reader = decoder.read_info()?;
|
|
||||||
let mut buf = vec![0; reader.output_buffer_size()];
|
|
||||||
|
|
||||||
let info = reader.next_frame(&mut buf)?;
|
|
||||||
let bytes = glib::Bytes::from(&buf[..info.buffer_size()]);
|
|
||||||
|
|
||||||
let has_alpha = matches!(info.color_type, ColorType::Rgba | ColorType::GrayscaleAlpha);
|
|
||||||
let row_stride_multiplier = if has_alpha { 4 } else { 3 };
|
|
||||||
|
|
||||||
let pixbuf = Pixbuf::from_bytes(
|
|
||||||
&bytes,
|
|
||||||
Colorspace::Rgb,
|
|
||||||
has_alpha,
|
|
||||||
info.bit_depth as i32,
|
|
||||||
info.width as i32,
|
|
||||||
info.height as i32,
|
|
||||||
(info.width * row_stride_multiplier) as i32,
|
|
||||||
);
|
|
||||||
|
|
||||||
let image = Image::new();
|
|
||||||
ImageProvider::create_and_load_surface(&pixbuf, &image)?;
|
|
||||||
Ok(image)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue