Skip to content
Draft
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
1 change: 1 addition & 0 deletions libcore/AbstractSlot.vala
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ public abstract class Files.AbstractSlot : GLib.Object {
public virtual string? get_root_uri () { return directory.file.uri; }
public virtual string? get_tip_uri () { return null; }
public virtual bool get_realized () { return content_box.get_realized (); }
public virtual void handle_drop_on_tab (Gdk.DragContext ctx, Gtk.SelectionData data, uint info, uint time) {}
}
12 changes: 12 additions & 0 deletions src/View/AbstractDirectoryView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,18 @@ namespace Files {
return true;
}

public void handle_drop_on_tab (
Gdk.DragContext ctx,
Gtk.SelectionData data,
uint info,
uint time
) {
drop_occurred = true;
drop_target_file = slot.file;
current_actions = Gdk.DragAction.COPY;
current_suggested_action = Gdk.DragAction.COPY;
on_drag_data_received (ctx, 0, 0, data, info, time);
}

/* Signal emitted on destination when selection data received from source
* either during drag motion or on dropping */
Expand Down
9 changes: 9 additions & 0 deletions src/View/Slot.vala
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,14 @@ namespace Files.View {

return msg;
}

public override void handle_drop_on_tab (
Gdk.DragContext ctx,
Gtk.SelectionData data,
uint info,
uint time) {

dir_view.handle_drop_on_tab (ctx, data, info, time);
}
}
}
21 changes: 21 additions & 0 deletions src/View/Window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ public class Files.View.Window : Hdy.ApplicationWindow {
view = tab_view
};

Gtk.TargetEntry uris = {"text/uri-list", 0, Files.TargetType.TEXT_URI_LIST};
// Handle Drag-and-drop of directory files onto tab to open in that tab
tab_bar.extra_drag_dest_targets = new Gtk.TargetList ({uris});
tab_bar.extra_drag_data_received.connect (on_extra_drag_data_received);

var tab_box = new Gtk.Box (VERTICAL, 0);
tab_box.add (tab_bar);
tab_box.add (tab_view);
Expand Down Expand Up @@ -412,6 +417,22 @@ public class Files.View.Window : Hdy.ApplicationWindow {
sidebar.path_change_request.connect (uri_path_change_request);
}

private void on_extra_drag_data_received (
Hdy.TabBar tab_bar,
Hdy.TabPage page,
Gdk.DragContext ctx,
Gtk.SelectionData data,
uint info,
uint time) {

var child = page.get_child ();
if (child is ViewContainer) {
((ViewContainer)child).slot.handle_drop_on_tab (ctx, data, info, time);
}

Gtk.drag_finish (ctx, true, false, time);
}

private bool tab_view_close_page (Hdy.TabPage page) {
var view_container = (ViewContainer) page.child;

Expand Down