more cleanup and fix save/restore dock items

This commit is contained in:
Ashley Wulber 2021-12-27 18:33:17 -05:00
parent fb6bbb79a7
commit be9ee81967
5 changed files with 85 additions and 138 deletions

View file

@ -5,6 +5,7 @@ use gdk4::glib::Object;
use gio::DesktopAppInfo;
use gtk4::glib;
use gtk4::prelude::AppInfoExt;
use std::path::Path;
glib::wrapper! {
pub struct DockObject(ObjectSubclass<imp::DockObject>);
@ -17,12 +18,16 @@ impl DockObject {
}
pub fn from_app_info_path(path: &str) -> Option<Self> {
if let Some(appinfo) = gio::DesktopAppInfo::new(path) {
if appinfo.should_show() {
return Some(
Object::new(&[("appinfo", &Some(appinfo)), ("saved", &true)])
.expect("Failed to create `DockObject`."),
);
if let Some(path) = Path::new(path).file_name() {
if let Some(path) = path.to_str() {
if let Some(appinfo) = gio::DesktopAppInfo::new(path) {
if appinfo.should_show() {
return Some(
Object::new(&[("appinfo", &Some(appinfo)), ("saved", &true)])
.expect("Failed to create `DockObject`."),
);
}
}
}
}
None