Add file manager integration install/uninstall logic
Implements actual extension file creation for Nautilus (Python extension), Nemo (.nemo_action files), Thunar (custom actions XML), and Dolphin (KDE service menu .desktop). Each extension creates a "Process with Pixstrip" submenu with all presets listed. Toggle switches in welcome wizard and settings now call install/uninstall.
This commit is contained in:
@@ -85,15 +85,16 @@ pub fn build_settings_dialog() -> adw::PreferencesDialog {
|
||||
.description("Add 'Process with Pixstrip' to your file manager's right-click menu")
|
||||
.build();
|
||||
|
||||
use pixstrip_core::fm_integration::FileManager;
|
||||
let file_managers = [
|
||||
("Nautilus", "org.gnome.Nautilus"),
|
||||
("Nemo", "org.nemo.Nemo"),
|
||||
("Thunar", "thunar"),
|
||||
("Dolphin", "org.kde.dolphin"),
|
||||
(FileManager::Nautilus, "org.gnome.Nautilus"),
|
||||
(FileManager::Nemo, "org.nemo.Nemo"),
|
||||
(FileManager::Thunar, "thunar"),
|
||||
(FileManager::Dolphin, "org.kde.dolphin"),
|
||||
];
|
||||
|
||||
let mut found_fm = false;
|
||||
for (name, desktop_id) in &file_managers {
|
||||
for (fm, desktop_id) in &file_managers {
|
||||
let is_installed = gtk::gio::AppInfo::all()
|
||||
.iter()
|
||||
.any(|info| {
|
||||
@@ -104,11 +105,22 @@ pub fn build_settings_dialog() -> adw::PreferencesDialog {
|
||||
|
||||
if is_installed {
|
||||
found_fm = true;
|
||||
let already_installed = fm.is_installed();
|
||||
let row = adw::SwitchRow::builder()
|
||||
.title(*name)
|
||||
.subtitle(format!("Add right-click menu to {}", name))
|
||||
.active(false)
|
||||
.title(fm.name())
|
||||
.subtitle(format!("Add right-click menu to {}", fm.name()))
|
||||
.active(already_installed)
|
||||
.build();
|
||||
|
||||
let fm_copy = *fm;
|
||||
row.connect_active_notify(move |row| {
|
||||
if row.is_active() {
|
||||
let _ = fm_copy.install();
|
||||
} else {
|
||||
let _ = fm_copy.uninstall();
|
||||
}
|
||||
});
|
||||
|
||||
fm_group.add(&row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,16 +197,16 @@ fn build_file_manager_page(nav_view: &adw::NavigationView) -> adw::NavigationPag
|
||||
.build();
|
||||
|
||||
// Detect installed file managers
|
||||
use pixstrip_core::fm_integration::FileManager;
|
||||
let file_managers = [
|
||||
("Nautilus", "org.gnome.Nautilus", "system-file-manager-symbolic"),
|
||||
("Nemo", "org.nemo.Nemo", "system-file-manager-symbolic"),
|
||||
("Thunar", "thunar", "system-file-manager-symbolic"),
|
||||
("Dolphin", "org.kde.dolphin", "system-file-manager-symbolic"),
|
||||
(FileManager::Nautilus, "org.gnome.Nautilus", "system-file-manager-symbolic"),
|
||||
(FileManager::Nemo, "org.nemo.Nemo", "system-file-manager-symbolic"),
|
||||
(FileManager::Thunar, "thunar", "system-file-manager-symbolic"),
|
||||
(FileManager::Dolphin, "org.kde.dolphin", "system-file-manager-symbolic"),
|
||||
];
|
||||
|
||||
let mut found_any = false;
|
||||
for (name, desktop_id, icon) in &file_managers {
|
||||
// Check if the file manager is installed by looking for its .desktop file
|
||||
for (fm, desktop_id, icon) in &file_managers {
|
||||
let is_installed = gtk::gio::AppInfo::all()
|
||||
.iter()
|
||||
.any(|info| {
|
||||
@@ -217,12 +217,23 @@ fn build_file_manager_page(nav_view: &adw::NavigationView) -> adw::NavigationPag
|
||||
|
||||
if is_installed {
|
||||
found_any = true;
|
||||
let already_installed = fm.is_installed();
|
||||
let row = adw::SwitchRow::builder()
|
||||
.title(*name)
|
||||
.subtitle(format!("Add right-click menu to {}", name))
|
||||
.active(false)
|
||||
.title(fm.name())
|
||||
.subtitle(format!("Add right-click menu to {}", fm.name()))
|
||||
.active(already_installed)
|
||||
.build();
|
||||
row.add_prefix(>k::Image::from_icon_name(icon));
|
||||
|
||||
let fm_copy = *fm;
|
||||
row.connect_active_notify(move |row| {
|
||||
if row.is_active() {
|
||||
let _ = fm_copy.install();
|
||||
} else {
|
||||
let _ = fm_copy.uninstall();
|
||||
}
|
||||
});
|
||||
|
||||
group.add(&row);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user