Skip to content

Commit

Permalink
More UI improvements with drag area.
Browse files Browse the repository at this point in the history
  • Loading branch information
phase1geo committed Oct 21, 2024
1 parent 8cb2b96 commit df8658f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/CanvasToolbar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,31 @@ public class CanvasToolbar : Box {
margin_start = 20
};

var motion = new EventControllerMotion();
drag_label.add_controller( motion );

motion.enter.connect((x, y) => {
var cursor = new Gdk.Cursor.from_name( "grab", null );
drag_label.set_cursor( cursor );
});

motion.leave.connect(() => {
drag_label.set_cursor( null );
});

var click = new GestureClick();
drag_label.add_controller( click );

click.pressed.connect((x, y) => {
var cursor = new Gdk.Cursor.from_name( "grabbing", null );
drag_label.set_cursor( cursor );
});

click.released.connect(() => {
var cursor = new Gdk.Cursor.from_name( "grab", null );
drag_label.set_cursor( cursor );
});

var drag = new DragSource() {
actions = Gdk.DragAction.MOVE
};
Expand All @@ -749,6 +774,18 @@ public class CanvasToolbar : Box {
return( cp );
});

drag.drag_end.connect((d, delete_data) => {
stdout.printf( "In drag_end, delete_data: %s\n", delete_data.to_string() );
if( !delete_data ) {
var val = Value( typeof(GLib.File) );
var provider = d.get_content();
if( provider.get_value( ref val ) ) {
var file = (GLib.File)val;
FileUtils.remove( file.get_path() );
}
}
});

append( drag_label );

}
Expand Down

0 comments on commit df8658f

Please sign in to comment.