WIP
This commit is contained in:
parent
8aa0fb0943
commit
69c213f9ba
@ -5,7 +5,7 @@ use std::env;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct DesktopEntry {
|
pub struct DesktopEntry {
|
||||||
id: String,
|
id: String,
|
||||||
name: String,
|
name: String,
|
||||||
generic_name: Option<glib::GString>,
|
generic_name: Option<glib::GString>,
|
||||||
@ -17,6 +17,12 @@ struct DesktopEntry {
|
|||||||
is_terminal_app: bool,
|
is_terminal_app: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DesktopEntry {
|
||||||
|
pub fn path(&self) -> PathBuf {
|
||||||
|
self.path.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl LauncherListItem for DesktopEntry {
|
impl LauncherListItem for DesktopEntry {
|
||||||
fn title(&self) -> String {
|
fn title(&self) -> String {
|
||||||
return self.name.to_owned();
|
return self.name.to_owned();
|
||||||
@ -89,8 +95,8 @@ fn get_desktop_files() -> Vec<PathBuf> {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all() -> Vec<Box<dyn LauncherListItem>> {
|
pub fn get_desktop_entries() -> Vec<DesktopEntry> {
|
||||||
let mut entries: Vec<Box<dyn LauncherListItem>> = Vec::new();
|
let mut entries = Vec::new();
|
||||||
|
|
||||||
for f in get_desktop_files() {
|
for f in get_desktop_files() {
|
||||||
if let Some(info) = DesktopAppInfo::from_filename(&f) {
|
if let Some(info) = DesktopAppInfo::from_filename(&f) {
|
||||||
@ -110,9 +116,19 @@ pub fn all() -> Vec<Box<dyn LauncherListItem>> {
|
|||||||
is_terminal_app: info.boolean("Terminal"),
|
is_terminal_app: info.boolean("Terminal"),
|
||||||
};
|
};
|
||||||
|
|
||||||
entries.push(Box::new(de));
|
entries.push(de);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entries
|
entries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn all() -> Vec<Box<dyn LauncherListItem>> {
|
||||||
|
let mut entries: Vec<Box<dyn LauncherListItem>> = Vec::new();
|
||||||
|
|
||||||
|
for e in get_desktop_entries() {
|
||||||
|
entries.push(Box::new(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
entries
|
||||||
|
}
|
||||||
|
33
src/main.rs
33
src/main.rs
@ -29,16 +29,33 @@ impl ListItem {
|
|||||||
fn create_widget(&self) -> GtkBox {
|
fn create_widget(&self) -> GtkBox {
|
||||||
let container = GtkBox::new(Orientation::Horizontal, 10);
|
let container = GtkBox::new(Orientation::Horizontal, 10);
|
||||||
|
|
||||||
let image = Image::new();
|
// let icon = if self.icon.eq("com.discordapp.Discord")
|
||||||
image.set_pixel_size(50);
|
// || self.icon.eq("preferences-desktop-theme")
|
||||||
image.set_icon_name(Some(&self.icon));
|
// || self.icon.eq("solaar")
|
||||||
|
// || self.icon.eq("kvantum")
|
||||||
|
// {
|
||||||
|
// println!("Failed: {}", self.icon);
|
||||||
|
// gio::Icon::for_string("vscode")
|
||||||
|
// } else {
|
||||||
|
// let x = String::from(self.icon.clone());
|
||||||
|
// gio::Icon::for_string(&x)
|
||||||
|
// };
|
||||||
|
// // let icon = gio::Icon::for_string("kvantum");
|
||||||
|
// let image: Image = match icon {
|
||||||
|
// Ok(ic) => Image::from_gicon(&ic),
|
||||||
|
// Err(_) => Image::from_icon_name("vscode"),
|
||||||
|
// };
|
||||||
|
// let image = Image::from_icon_name("vscode");
|
||||||
|
let image = gtk::Image::from_icon_name(&self.icon);
|
||||||
|
image.set_pixel_size(32);
|
||||||
|
// image.set_icon_name(Some("application-x-executable")); // Safe fallback
|
||||||
|
|
||||||
let label = Label::new(Some(&self.text));
|
let label = Label::new(Some(&self.text));
|
||||||
label.set_xalign(0.0);
|
label.set_xalign(0.0);
|
||||||
|
|
||||||
// container.append(&image);
|
container.append(&image);
|
||||||
container.append(&label);
|
container.append(&label);
|
||||||
|
println!("Icon: {}", self.icon);
|
||||||
container
|
container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,4 +171,10 @@ fn main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.run();
|
app.run();
|
||||||
|
// for e in drun::get_desktop_entries() {
|
||||||
|
// println!("---");
|
||||||
|
// println!("Icon: {}", e.icon());
|
||||||
|
// println!("Path: {}", e.path().to_string_lossy());
|
||||||
|
// println!("---");
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user