Skip to content

Commit

Permalink
Merge pull request #496 from JakeStanger/refactor/general
Browse files Browse the repository at this point in the history
Few small refactors
  • Loading branch information
JakeStanger authored Mar 14, 2024
2 parents 18ee921 + b912619 commit 94f7d87
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/image/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use gtk::{IconLookupFlags, IconTheme};
use std::path::{Path, PathBuf};
#[cfg(feature = "http")]
use tokio::sync::mpsc;
use tracing::warn;
use tracing::{debug, warn};

cfg_if!(
if #[cfg(feature = "http")] {
Expand Down Expand Up @@ -45,6 +45,7 @@ impl<'a> ImageProvider<'a> {
/// but no other check is performed.
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)?;
debug!("Resolved {input} --> {location:?} (size: {size})");

Some(Self { location, size })
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/tray/icon.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use glib::ffi::g_strfreev;
use glib::translate::ToGlibPtr;
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::{gdk_pixbuf, IconLookupFlags, IconTheme, Image};
use gtk::{IconLookupFlags, IconTheme, Image};
use std::collections::HashSet;
use std::ffi::CStr;
use std::os::raw::{c_char, c_int};
Expand Down Expand Up @@ -69,7 +69,7 @@ pub(crate) fn get_image_from_pixmap(item: &StatusNotifierItem) -> Option<Image>
let bytes = glib::Bytes::from(&pixmap.pixels);
let row_stride = pixmap.width * 4; //

let pixbuf = gdk_pixbuf::Pixbuf::from_bytes(
let pixbuf = Pixbuf::from_bytes(
&bytes,
Colorspace::Rgb,
true,
Expand Down
4 changes: 3 additions & 1 deletion src/modules/upower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ impl Module<gtk::Button> for UpowerModule {
let format = format.replace("{percentage}", &properties.percentage.to_string())
.replace("{time_remaining}", &time_remaining)
.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)
.map(|provider| provider.load_into_image(icon.clone()));
Expand Down

0 comments on commit 94f7d87

Please sign in to comment.