Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ["/.vscode"]

[dependencies]
clap = { version = "4.5.51", features = ["derive"] }
gtk = { version = "0.10.1", package = "gtk4", features = ["v4_6"] }
gtk = { version = "0.10.1", package = "gtk4", features = ["v4_8"] }
glib-macros = "0.21.2"
opener = "0.8.3"
async-channel = "2.5.0"
Expand Down
17 changes: 6 additions & 11 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gtk::gdk::{ContentProvider, DragAction, FileList};
use gtk::gio::{self, File, ListStore};
use gtk::glib::{clone, Bytes};
use gtk::glib::clone;
use gtk::prelude::*;
use gtk::{gdk, glib, DragSource, DropTarget, EventSequenceState, Widget};

Expand Down Expand Up @@ -33,19 +33,14 @@ pub fn generate_file_model() -> ListStore {
pub fn generate_content_provider<'a>(
paths: impl IntoIterator<Item = &'a String>,
) -> Option<ContentProvider> {
let mut uri_list = paths
.into_iter()
.cloned()
.collect::<Vec<String>>()
.join("\r\n");
let files: Vec<File> = paths.into_iter().map(|p| File::for_uri(p)).collect();

if uri_list.is_empty() {
if files.is_empty() {
return None;
} else {
uri_list += "\r\n";
let bytes = Bytes::from(uri_list.as_bytes());
Some(ContentProvider::for_bytes("text/uri-list", &bytes))
}
let files_list = FileList::from_array(&files);

Some(ContentProvider::for_value(&files_list.to_value()))
}
/// For the -a or -A flag.
pub fn setup_drag_source_all(drag_source: &DragSource, list_model: &ListStore) {
Expand Down
Loading