fix parsing icons
This commit is contained in:
parent
3945368184
commit
6ebec39f5c
3 changed files with 18 additions and 11 deletions
|
@ -145,7 +145,6 @@ pub fn find_desktop_files() -> Vec<DesktopFile> {
|
|||
.filter_map(|icon_dir| find_file_case_insensitive(&icon_dir, regex))
|
||||
.flat_map(|desktop_files| {
|
||||
desktop_files.into_iter().filter_map(|desktop_file| {
|
||||
log::debug!("loading desktop file {desktop_file:?}");
|
||||
fs::read_to_string(desktop_file)
|
||||
.ok()
|
||||
.and_then(|content| freedesktop_file_parser::parse(&content).ok())
|
||||
|
|
|
@ -819,7 +819,12 @@ fn create_menu_row<T: Clone + 'static>(
|
|||
row.set_child(Some(&row_box));
|
||||
|
||||
if let Some(image_path) = &menu_item.icon_path {
|
||||
let image = Image::from_icon_name(image_path);
|
||||
let image = if image_path.starts_with("/") {
|
||||
Image::from_file(image_path)
|
||||
} else {
|
||||
Image::from_icon_name(image_path)
|
||||
};
|
||||
|
||||
image.set_pixel_size(
|
||||
config
|
||||
.image_size
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use std::collections::HashMap;
|
||||
use std::io::Read;
|
||||
use std::os::unix::prelude::CommandExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::{env, fmt, fs, io};
|
||||
use std::time::Instant;
|
||||
use anyhow::Context;
|
||||
use freedesktop_file_parser::EntryType;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::config::{Config, expand_path};
|
||||
use crate::desktop::{
|
||||
DesktopError, default_icon, find_desktop_files, get_locale_variants, lookup_name_with_locale,
|
||||
default_icon, find_desktop_files, get_locale_variants, lookup_name_with_locale,
|
||||
};
|
||||
use crate::gui;
|
||||
use crate::gui::{ItemProvider, MenuItem};
|
||||
use anyhow::Context;
|
||||
use freedesktop_file_parser::EntryType;
|
||||
use gtk4::AccessibleRole::Menu;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::io::Read;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ModeError {
|
||||
|
@ -60,6 +60,7 @@ impl<T: Clone> DRunProvider<T> {
|
|||
|
||||
let (cache_path, d_run_cache) = load_d_run_cache();
|
||||
|
||||
let start = Instant::now();
|
||||
let mut entries: Vec<MenuItem<T>> = Vec::new();
|
||||
for file in find_desktop_files().iter().filter(|f| {
|
||||
f.entry.hidden.is_none_or(|hidden| !hidden)
|
||||
|
@ -147,6 +148,8 @@ impl<T: Clone> DRunProvider<T> {
|
|||
entries.push(entry);
|
||||
}
|
||||
|
||||
log::info!("parsing desktop files took {}ms", start.elapsed().as_millis());
|
||||
|
||||
gui::sort_menu_items_alphabetically_honor_initial_score(&mut entries);
|
||||
|
||||
DRunProvider {
|
||||
|
@ -370,7 +373,7 @@ impl DMenuProvider {
|
|||
let mut input = String::new();
|
||||
io::stdin()
|
||||
.read_to_string(&mut input)
|
||||
.map_err(|e| ModeError::StdInReadFail)?;
|
||||
.map_err(|_| ModeError::StdInReadFail)?;
|
||||
|
||||
let items: Vec<MenuItem<String>> = input
|
||||
.lines()
|
||||
|
|
Loading…
Add table
Reference in a new issue