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: 2 additions & 0 deletions io.github.wpkelso.slate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ finish-args:
- --socket=wayland
# GPU acceleration if needed
- --device=dri
# Access files dropped from documents
- --filesystem=xdg-documents

modules:
- name: slate
Expand Down
2 changes: 1 addition & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public class Application : Gtk.Application {
var error_dialog = new
Granite.MessageDialog.with_image_from_icon_name (
"Couldn't open file",
"The specified file is not a valid text file",
"The specified file is not a valid text file, or Slate could not access it",
"dialog-error"
) {
transient_for = window
Expand Down
18 changes: 18 additions & 0 deletions src/Window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public class AppWindow : Gtk.Window {
this.close_request.connect (on_close);
buf.changed.connect (on_buffer_changed);

var drop_target = new Gtk.DropTarget (typeof (Gdk.FileList), Gdk.DragAction.COPY);
text_view.add_controller (drop_target);
drop_target.drop.connect (on_dropped);
}


Expand Down Expand Up @@ -205,4 +208,19 @@ public class AppWindow : Gtk.Window {

return false;
}

public bool on_dropped (Gtk.DropTarget target, GLib.Value value, double x, double y) {
if (value.type () == typeof (Gdk.FileList)) {
var list = (Gdk.FileList)value;
File[] file_array = {};

foreach (unowned var file in list.get_files ()) {
file_array += file;
}

application.open (file_array, "");
return true;
}
return false;
}
}