mirror of
https://github.com/JakeStanger/ironbar.git
synced 2024-11-22 23:16:46 +03:00
Merge pull request #496 from JakeStanger/refactor/general
Few small refactors
This commit is contained in:
commit
94f7d873f4
@ -11,7 +11,7 @@ use gtk::{IconLookupFlags, IconTheme};
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http")]
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tracing::warn;
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
cfg_if!(
|
cfg_if!(
|
||||||
if #[cfg(feature = "http")] {
|
if #[cfg(feature = "http")] {
|
||||||
@ -45,6 +45,7 @@ impl<'a> ImageProvider<'a> {
|
|||||||
/// but no other check is performed.
|
/// but no other check is performed.
|
||||||
pub fn parse(input: &str, theme: &'a IconTheme, use_fallback: bool, size: i32) -> Option<Self> {
|
pub fn parse(input: &str, theme: &'a IconTheme, use_fallback: bool, size: i32) -> Option<Self> {
|
||||||
let location = Self::get_location(input, theme, size, use_fallback, 0)?;
|
let location = Self::get_location(input, theme, size, use_fallback, 0)?;
|
||||||
|
debug!("Resolved {input} --> {location:?} (size: {size})");
|
||||||
|
|
||||||
Some(Self { location, size })
|
Some(Self { location, size })
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use glib::ffi::g_strfreev;
|
use glib::ffi::g_strfreev;
|
||||||
use glib::translate::ToGlibPtr;
|
use glib::translate::ToGlibPtr;
|
||||||
use gtk::ffi::gtk_icon_theme_get_search_path;
|
use gtk::ffi::gtk_icon_theme_get_search_path;
|
||||||
use gtk::gdk_pixbuf::{Colorspace, InterpType};
|
use gtk::gdk_pixbuf::{Colorspace, InterpType, Pixbuf};
|
||||||
use gtk::prelude::IconThemeExt;
|
use gtk::prelude::IconThemeExt;
|
||||||
use gtk::{gdk_pixbuf, IconLookupFlags, IconTheme, Image};
|
use gtk::{IconLookupFlags, IconTheme, Image};
|
||||||
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};
|
||||||
@ -69,7 +69,7 @@ pub(crate) fn get_image_from_pixmap(item: &StatusNotifierItem) -> Option<Image>
|
|||||||
let bytes = glib::Bytes::from(&pixmap.pixels);
|
let bytes = glib::Bytes::from(&pixmap.pixels);
|
||||||
let row_stride = pixmap.width * 4; //
|
let row_stride = pixmap.width * 4; //
|
||||||
|
|
||||||
let pixbuf = gdk_pixbuf::Pixbuf::from_bytes(
|
let pixbuf = Pixbuf::from_bytes(
|
||||||
&bytes,
|
&bytes,
|
||||||
Colorspace::Rgb,
|
Colorspace::Rgb,
|
||||||
true,
|
true,
|
||||||
|
@ -199,7 +199,9 @@ impl Module<gtk::Button> for UpowerModule {
|
|||||||
let format = format.replace("{percentage}", &properties.percentage.to_string())
|
let format = format.replace("{percentage}", &properties.percentage.to_string())
|
||||||
.replace("{time_remaining}", &time_remaining)
|
.replace("{time_remaining}", &time_remaining)
|
||||||
.replace("{state}", battery_state_to_string(state));
|
.replace("{state}", battery_state_to_string(state));
|
||||||
let icon_name = String::from("icon:") + &properties.icon_name;
|
|
||||||
|
let mut icon_name = String::from("icon:");
|
||||||
|
icon_name.push_str(&properties.icon_name);
|
||||||
|
|
||||||
ImageProvider::parse(&icon_name, &icon_theme, false, self.icon_size)
|
ImageProvider::parse(&icon_name, &icon_theme, false, self.icon_size)
|
||||||
.map(|provider| provider.load_into_image(icon.clone()));
|
.map(|provider| provider.load_into_image(icon.clone()));
|
||||||
|
Loading…
Reference in New Issue
Block a user