mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-09-15 19:26:58 +02:00
chore(deps): update system-tray
This commit is contained in:
parent
f1dc35e873
commit
b68e4b4af9
4 changed files with 13 additions and 11 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -3348,10 +3348,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "system-tray"
|
name = "system-tray"
|
||||||
version = "0.7.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c3397841ed755bf361606a845779e0f7333d35fb4e39627ef6f656d7cdad4c73"
|
checksum = "90d5d024b1573d22079347055d817863c21ea0903df404668095499c08800e4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
"dbusmenu-gtk3-sys",
|
"dbusmenu-gtk3-sys",
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"gtk",
|
"gtk",
|
||||||
|
|
|
@ -177,7 +177,7 @@ futures-signals = { version = "0.3.34", optional = true }
|
||||||
sysinfo = { version = "0.36.0", optional = true }
|
sysinfo = { version = "0.36.0", optional = true }
|
||||||
|
|
||||||
# tray
|
# tray
|
||||||
system-tray = { version = "0.7.0", features = ["dbusmenu-gtk3"], optional = true }
|
system-tray = { version = "0.8.1", features = ["dbusmenu-gtk3"], optional = true }
|
||||||
|
|
||||||
# volume
|
# volume
|
||||||
libpulse-binding = { version = "2.30.1", optional = true }
|
libpulse-binding = { version = "2.30.1", optional = true }
|
||||||
|
|
|
@ -11,6 +11,7 @@ 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};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use system_tray::item::IconPixmap;
|
||||||
|
|
||||||
/// Gets the GTK icon theme search paths by calling the FFI function.
|
/// Gets the GTK icon theme search paths by calling the FFI function.
|
||||||
/// Conveniently returns the result as a `HashSet`.
|
/// Conveniently returns the result as a `HashSet`.
|
||||||
|
@ -45,10 +46,10 @@ pub fn get_image(
|
||||||
icon_theme: &IconTheme,
|
icon_theme: &IconTheme,
|
||||||
) -> Result<Image> {
|
) -> Result<Image> {
|
||||||
if !prefer_icons && item.icon_pixmap.is_some() {
|
if !prefer_icons && item.icon_pixmap.is_some() {
|
||||||
get_image_from_pixmap(item, size)
|
get_image_from_pixmap(item.icon_pixmap.as_deref(), size)
|
||||||
} else {
|
} else {
|
||||||
get_image_from_icon_name(item, size, icon_theme)
|
get_image_from_icon_name(item, size, icon_theme)
|
||||||
.or_else(|_| get_image_from_pixmap(item, size))
|
.or_else(|_| get_image_from_pixmap(item.icon_pixmap.as_deref(), size))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +82,10 @@ fn get_image_from_icon_name(item: &TrayMenu, size: u32, icon_theme: &IconTheme)
|
||||||
/// which has 8 bits per sample and a bit stride of `4*width`.
|
/// which has 8 bits per sample and a bit stride of `4*width`.
|
||||||
/// The Pixbuf expects RGBA32 format, so some channel shuffling
|
/// The Pixbuf expects RGBA32 format, so some channel shuffling
|
||||||
/// is required.
|
/// is required.
|
||||||
fn get_image_from_pixmap(item: &TrayMenu, size: u32) -> Result<Image> {
|
fn get_image_from_pixmap(item: Option<&[IconPixmap]>, size: u32) -> Result<Image> {
|
||||||
const BITS_PER_SAMPLE: i32 = 8;
|
const BITS_PER_SAMPLE: i32 = 8;
|
||||||
|
|
||||||
let pixmap = item
|
let pixmap = item
|
||||||
.icon_pixmap
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|pixmap| pixmap.first())
|
.and_then(|pixmap| pixmap.first())
|
||||||
.ok_or_else(|| Report::msg("Failed to get pixmap from tray icon"))?;
|
.ok_or_else(|| Report::msg("Failed to get pixmap from tray icon"))?;
|
||||||
|
|
||||||
|
|
|
@ -181,9 +181,11 @@ fn on_update(
|
||||||
UpdateEvent::AttentionIcon(_icon) => {
|
UpdateEvent::AttentionIcon(_icon) => {
|
||||||
warn!("received unimplemented NewAttentionIcon event");
|
warn!("received unimplemented NewAttentionIcon event");
|
||||||
}
|
}
|
||||||
UpdateEvent::Icon(icon) => {
|
UpdateEvent::Icon { icon_name, icon_pixmap} => {
|
||||||
if icon.as_ref() != menu_item.icon_name() {
|
menu_item.icon_pixmap = icon_pixmap;
|
||||||
menu_item.set_icon_name(icon);
|
|
||||||
|
if icon_name.as_ref() != menu_item.icon_name() {
|
||||||
|
menu_item.set_icon_name(icon_name);
|
||||||
match icon::get_image(menu_item, icon_size, prefer_icons, icon_theme) {
|
match icon::get_image(menu_item, icon_size, prefer_icons, icon_theme) {
|
||||||
Ok(image) => menu_item.set_image(&image),
|
Ok(image) => menu_item.set_image(&image),
|
||||||
Err(_) => menu_item.show_label(),
|
Err(_) => menu_item.show_label(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue