Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Files drag&drop support #37

Open
pavel-krivanek opened this issue Feb 19, 2020 · 1 comment
Open

Files drag&drop support #37

pavel-krivanek opened this issue Feb 19, 2020 · 1 comment

Comments

@pavel-krivanek
Copy link
Contributor

I created small example of drag&drop support of external files on a Gtk widget. We need to make it more robust.

dragAndDrop.st.txt

app := SpApplication new.
app useBackend: #Gtk.
p := SpButtonPresenter newApplication: app.
p label: 'label'.
p openWithSpec.
button := p adapter widget.
targetEntry := GtkTargetEntry newTarget: 'text/uri-list' flags: 0 info: 3.
button dragDestSetFlags: GtkDestDefaults GTK_DEST_DEFAULT_ALL targetsTypes: targetEntry getHandle targetsAmount: 1 actions: GdkDragAction GDK_ACTION_DEFAULT.

(GDragDataReceivedCallback do: [ :widget :dragContext :x :y :selectionData :info :time |
	| resutl pointers |
	result := GDragDataReceivedCallback gtk_selection_data_get_uris: selectionData.
	pointers := (result readArrayOf: (GObject resolveType: #gpointer)
		until: [ :each | each isNull ]).
	(pointers collect: [ :p | p readStringUTF8 ]) inspect.
	]) connectTo: button
@pavel-krivanek
Copy link
Contributor Author

the Strings are actually encoded in URL encoding (like file:///D:/Downloads/web/1%20-%20Copy%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88.html)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant