Skip to content

Commit

Permalink
Merge pull request #27 from huanie/master
Browse files Browse the repository at this point in the history
Args: --and-exit working again.
  • Loading branch information
nik012003 authored Aug 8, 2023
2 parents eda9715 + 5db04fa commit b0622b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/compact_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 6 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

0 comments on commit b0622b7

Please sign in to comment.