From 5db04fa3f24bc6e7613ca2ed5eb5314faa3b8d36 Mon Sep 17 00:00:00 2001 From: Huan Nguyen Date: Tue, 8 Aug 2023 09:25:20 +0200 Subject: [PATCH] Args: --and-exit working again. --- src/compact_view.rs | 5 ++++- src/list_view.rs | 5 ++++- src/util.rs | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/compact_view.rs b/src/compact_view.rs index b86fbda..ffe3505 100644 --- a/src/compact_view.rs +++ b/src/compact_view.rs @@ -5,13 +5,16 @@ use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::{glib, CssProvider, DragSource, Label, Widget}; -use crate::util::{generate_file_model, setup_drag_source_all, setup_drop_target, ListWidget}; +use crate::util::{generate_file_model, setup_drag_source_all, setup_drop_target, ListWidget, drag_source_and_exit}; pub fn generate_compact_view() -> ListWidget { let file_model = generate_file_model(); let drag_source = DragSource::new(); setup_drag_source_all(&drag_source, &file_model); + if ARGS.get().unwrap().and_exit { + drag_source_and_exit(&drag_source); + } let obj = CompactLabel::new(file_model); let model = obj.model(); diff --git a/src/list_view.rs b/src/list_view.rs index 0a9090c..7ecec4a 100644 --- a/src/list_view.rs +++ b/src/list_view.rs @@ -13,7 +13,7 @@ use gtk::{ use crate::file_object::FileObject; use crate::util::{ generate_content_provider, generate_file_model, setup_drag_source_all, setup_drop_target, - ListWidget, + ListWidget, drag_source_and_exit, }; use crate::{ARGS, CURRENT_DIRECTORY}; @@ -78,6 +78,9 @@ fn create_drag_source(row: &CenterBox, selection: &MultiSelection) -> DragSource })); } + if ARGS.get().unwrap().and_exit { + drag_source_and_exit(&drag_source); + } drag_source } diff --git a/src/util.rs b/src/util.rs index 7437eeb..cc21f58 100644 --- a/src/util.rs +++ b/src/util.rs @@ -91,3 +91,9 @@ pub fn setup_drop_target(model: &ListStore, widget: &Widget) { widget.add_controller(drop_target); } + +pub fn drag_source_and_exit(drag_source: &DragSource) { + drag_source.connect_drag_end(|_, _, _|{ + std::process::exit(0); + }); +} \ No newline at end of file