mirror of
https://gitlab.gnome.org/julianschacher/top-bar-organizer.git
synced 2025-10-27 15:19:09 +00:00
Update: Show drag icon when reordering PrefsBoxOrderItemRows using DND
The following code from GNOME/gnome-control-center was used as a reference to make this code work: -ab7d752de9/panels/search/cc-search-panel-row.c (L96)-ab7d752de9/panels/search/cc-search-panel-row.c (L84)
This commit is contained in:
parent
249f3554d5
commit
3299686041
@ -46,13 +46,28 @@ var PrefsBoxOrderItemRow = GObject.registerClass({
|
|||||||
// `this`.
|
// `this`.
|
||||||
let dragSource = new Gtk.DragSource();
|
let dragSource = new Gtk.DragSource();
|
||||||
dragSource.set_actions(Gdk.DragAction.MOVE);
|
dragSource.set_actions(Gdk.DragAction.MOVE);
|
||||||
dragSource.connect("prepare", () => {
|
dragSource.connect("prepare", (source, x, y) => {
|
||||||
|
this._drag_starting_point_x = x;
|
||||||
|
this._drag_starting_point_y = y;
|
||||||
return Gdk.ContentProvider.new_for_value(this);
|
return Gdk.ContentProvider.new_for_value(this);
|
||||||
});
|
});
|
||||||
// Stop all scrolling, which is due to this DND operation.
|
// Stop all scrolling, which is due to this DND operation.
|
||||||
dragSource.connect("drag-end", () => {
|
dragSource.connect("drag-end", () => {
|
||||||
scrollManager.stopScrollAll();
|
scrollManager.stopScrollAll();
|
||||||
});
|
});
|
||||||
|
dragSource.connect("drag-begin", (source, drag) => {
|
||||||
|
let dragWidget = new Gtk.ListBox();
|
||||||
|
let allocation = this.get_allocation();
|
||||||
|
dragWidget.set_size_request(allocation.width, allocation.height);
|
||||||
|
|
||||||
|
let dragPrefsBoxOrderItemRow = new PrefsBoxOrderItemRow({}, null, this.item)
|
||||||
|
dragWidget.append(dragPrefsBoxOrderItemRow);
|
||||||
|
dragWidget.drag_highlight_row(dragPrefsBoxOrderItemRow);
|
||||||
|
|
||||||
|
let currentDragIcon = Gtk.DragIcon.get_for_drag(drag);
|
||||||
|
currentDragIcon.set_child(dragWidget);
|
||||||
|
drag.set_hotspot(this._drag_starting_point_x, this._drag_starting_point_y);
|
||||||
|
});
|
||||||
this.add_controller(dragSource);
|
this.add_controller(dragSource);
|
||||||
|
|
||||||
/// Make `this` accept drops by creating a drop target and adding it to
|
/// Make `this` accept drops by creating a drop target and adding it to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user