drag and drop basics
This commit is contained in:
parent
ba1a5f3f39
commit
8966c5fff4
2 changed files with 26 additions and 1 deletions
|
@ -10,6 +10,16 @@ class Ui.PlayQueueSong : Gtk.ListBoxRow {
|
||||||
[GtkCallback] private string star_button_icon_name (DateTime? starred) {
|
[GtkCallback] private string star_button_icon_name (DateTime? starred) {
|
||||||
return starred == null ? "non-starred" : "starred";
|
return starred == null ? "non-starred" : "starred";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GtkCallback] private Gdk.ContentProvider? on_drag_prepare (double x, double y) {
|
||||||
|
return new Gdk.ContentProvider.for_value (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
[GtkCallback] private bool on_drop (Value value, double x, double y) {
|
||||||
|
var source = value as PlayQueueSong;
|
||||||
|
print ("dropped %u on %u", source.position, this.position);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue.ui")]
|
[GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue.ui")]
|
||||||
|
|
|
@ -8,7 +8,7 @@ template $UiPlayQueueSong: ListBoxRow {
|
||||||
spacing: 6;
|
spacing: 6;
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
visible: false;
|
//visible: false;
|
||||||
icon-name: "list-drag-handle";
|
icon-name: "list-drag-handle";
|
||||||
styles [ "drag-handle" ]
|
styles [ "drag-handle" ]
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,21 @@ template $UiPlayQueueSong: ListBoxRow {
|
||||||
styles [ "flat" ]
|
styles [ "flat" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DragSource {
|
||||||
|
actions: move;
|
||||||
|
propagation-phase: capture;
|
||||||
|
|
||||||
|
prepare => $on_drag_prepare ();
|
||||||
|
}
|
||||||
|
|
||||||
|
DropTarget {
|
||||||
|
actions: move;
|
||||||
|
formats: UiPlayQueueSong;
|
||||||
|
preload: true;
|
||||||
|
|
||||||
|
drop => $on_drop ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeGroup {
|
SizeGroup {
|
||||||
|
|
Loading…
Reference in a new issue