Had claude fix an issue

This commit is contained in:
Javier Feliz 2025-09-04 20:52:39 -04:00
parent 2e2676acd5
commit 1673f54609
3 changed files with 11 additions and 5 deletions

View File

@ -21,7 +21,7 @@ fn main() {
let ui = GtkLauncherUI::new(app); let ui = GtkLauncherUI::new(app);
// Create and run the controller // Create and run the controller
let controller = LauncherController::new(launcher, ui); let controller = LauncherController::new(launcher, ui, app.clone());
controller.run(); controller.run();
}); });

View File

@ -30,9 +30,10 @@ impl LauncherListItem for FileEntry {
fn execute(&self) -> Result<(), LaunchError> { fn execute(&self) -> Result<(), LaunchError> {
let file_uri = gio::File::for_path(&self.path); let file_uri = gio::File::for_path(&self.path);
let ctx = gio::AppLaunchContext::new();
match gio::AppInfo::launch_default_for_uri( match gio::AppInfo::launch_default_for_uri(
file_uri.uri().as_str(), file_uri.uri().as_str(),
None::<&gio::AppLaunchContext>, Some(&ctx),
) { ) {
Err(_) => Err(LaunchError::CouldNotLaunch( Err(_) => Err(LaunchError::CouldNotLaunch(
"Error opening file".to_string(), "Error opening file".to_string(),

View File

@ -1,6 +1,7 @@
use super::gtk::GtkLauncherUI; use super::gtk::GtkLauncherUI;
use super::traits::{LauncherUI, UIEvent}; use super::traits::{LauncherUI, UIEvent};
use crate::{LaunchError, launcher::WaycastLauncher}; use crate::{LaunchError, launcher::WaycastLauncher};
use gio::prelude::ApplicationExt;
use gtk::glib; use gtk::glib;
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
@ -11,10 +12,11 @@ pub struct LauncherController {
launcher: Rc<RefCell<WaycastLauncher>>, launcher: Rc<RefCell<WaycastLauncher>>,
ui: GtkLauncherUI, ui: GtkLauncherUI,
event_receiver: Receiver<UIEvent>, event_receiver: Receiver<UIEvent>,
app: gtk::Application,
} }
impl LauncherController { impl LauncherController {
pub fn new(launcher: WaycastLauncher, mut ui: GtkLauncherUI) -> Self { pub fn new(launcher: WaycastLauncher, mut ui: GtkLauncherUI, app: gtk::Application) -> Self {
let (event_sender, event_receiver) = mpsc::channel(); let (event_sender, event_receiver) = mpsc::channel();
// Set up the event sender in the UI // Set up the event sender in the UI
@ -24,6 +26,7 @@ impl LauncherController {
launcher: Rc::new(RefCell::new(launcher)), launcher: Rc::new(RefCell::new(launcher)),
ui, ui,
event_receiver, event_receiver,
app,
} }
} }
@ -52,7 +55,8 @@ impl LauncherController {
UIEvent::ItemActivated(index) => match self.launcher.borrow().execute_item(index) { UIEvent::ItemActivated(index) => match self.launcher.borrow().execute_item(index) {
Ok(_) => { Ok(_) => {
self.ui.hide(); // Exit the application completely instead of just hiding
self.app.quit();
} }
Err(e) => { Err(e) => {
eprintln!("Failed to launch item: {:?}", e); eprintln!("Failed to launch item: {:?}", e);
@ -66,7 +70,8 @@ impl LauncherController {
} }
UIEvent::CloseRequested => { UIEvent::CloseRequested => {
self.ui.hide(); // Exit the application completely instead of just hiding
self.app.quit();
} }
} }