ui/gtk/dnd.c

Sun, 22 Dec 2024 11:49:59 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 22 Dec 2024 11:49:59 +0100
branch
newapi
changeset 420
28a5920bebe0
parent 394
bedd499b640d
permissions
-rw-r--r--

implement menu itemlist (Motif)

147
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "dnd.h"
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
34 #include <cx/buffer.h>
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
35 #include <cx/array_list.h>
151
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
36
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
37 #ifdef UI_GTK2LEGACY
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
38 static gboolean selection_data_set_uris(GtkSelectionData *selection_data, char **uris) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
39 CxBuffer *buf = cxBufferCreate(NULL, 1024, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
151
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
40 char *uri;
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
41 int i = 0;
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
42 while((uri = uris[i]) != NULL) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
43 cxBufferPutString(buf, uri);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
44 cxBufferPutString(buf, "\r\n");
151
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
45 }
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
46 GdkAtom type = gdk_atom_intern("text/uri-list", FALSE);
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
47 gtk_selection_data_set(selection_data, type, 8, (guchar*)buf->space, buf->pos);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
48 cxBufferFree(buf);
151
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
49 return TRUE;
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
50 }
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
51 static char** selection_data_get_uris(GtkSelectionData *selection_data) {
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
52 // TODO: implement
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
53 return NULL;
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
54 }
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
55 #define gtk_selection_data_set_uris selection_data_set_uris
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
56 #define gtk_selection_data_get_uris selection_data_get_uris
11f3bb408051 fixes gtk2legacy build
Olaf Wintermanm <olaf.wintermann@gmail.com>
parents: 147
diff changeset
57 #endif
147
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
59 /*
147
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 void ui_selection_settext(UiSelection *sel, char *str, int len) {
164
1d912f78fd1d fix some warnings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
61 // TODO: handle error?
1d912f78fd1d fix some warnings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
62 gtk_selection_data_set_text(sel->data, str, len);
147
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 void ui_selection_seturis(UiSelection *sel, char **uris, int nelm) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 char **uriarray = calloc(nelm+1, sizeof(char*));
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 for(int i=0;i<nelm;i++) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 uriarray[i] = uris[i];
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 uriarray[nelm] = NULL;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 gtk_selection_data_set_uris(sel->data, uriarray);
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 char* ui_selection_gettext(UiSelection *sel) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 guchar *text = gtk_selection_data_get_text(sel->data);
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 if(text) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 char *textcp = strdup((char*)text);
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 g_free(text);
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 return textcp;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 return NULL;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 char** ui_selection_geturis(UiSelection *sel, size_t *nelm) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 gchar **uris = gtk_selection_data_get_uris(sel->data);
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 if(uris) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 size_t al = 32;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 char **array = malloc(al * sizeof(char*));
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 size_t i = 0;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 while(uris[i] != NULL) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 if(i >= al) {
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 al *= 2;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 array = realloc(array, al * sizeof(char*));
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 array[i] = strdup((char*)uris[i]);
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 i++;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 *nelm = i;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 g_strfreev(uris);
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 return array;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 }
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 return NULL;
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 }
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
104 */
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
105
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
106 #if GTK_MAJOR_VERSION >= 4
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
107
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
108 void ui_selection_settext(UiDnD *sel, char *str, int len) {
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
109 if(!sel->providers) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
110 return;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
111 }
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
112
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
113 if(len == -1) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
114 len = strlen(str);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
115 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
116 GBytes *bytes = g_bytes_new(str, len);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
117 GdkContentProvider *provider = gdk_content_provider_new_for_bytes("text/plain;charset=utf-8", bytes);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
118 g_bytes_unref(bytes);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
119
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
120 cxListAdd(sel->providers, &provider);
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
121 }
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
122
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
123 void ui_selection_seturis(UiDnD *sel, char **uris, int nelm) {
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
124 if(!sel->providers) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
125 return;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
126 }
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
127
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
128 GFile **files = calloc(nelm, sizeof(GFile*));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
129 for(int i=0;i<nelm;i++) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
130 GFile *file = uris[i][0] == '/' ? g_file_new_for_path(uris[i]) : g_file_new_for_uri(uris[i]);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
131 files[i] = file;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
132 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
133 GdkFileList *list = gdk_file_list_new_from_array(files, nelm);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
134
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
135 GdkContentProvider *provider = gdk_content_provider_new_typed(GDK_TYPE_FILE_LIST, list);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
136 cxListAdd(sel->providers, &provider);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
137
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
138 g_slist_free_full ((GSList*)list, g_object_unref);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
139 free(files);
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
140 }
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
141
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
142 char* ui_selection_gettext(UiDnD *sel) {
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
143 if(!sel->value) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
144 return NULL;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
145 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
146
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
147 if(G_VALUE_HOLDS(sel->value, G_TYPE_STRING)) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
148 const char *str = g_value_get_string(sel->value);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
149 return str ? strdup(str) : NULL;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
150 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
151
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
152 return NULL;
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
153 }
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
154
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
155 UiFileList ui_selection_geturis(UiDnD *sel) {
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
156 if(!sel->value) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
157 return (UiFileList){NULL,0};
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
158 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
159
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
160 if(G_VALUE_HOLDS(sel->value, GDK_TYPE_FILE_LIST)) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
161 GSList *list = g_value_get_boxed(sel->value);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
162 if(!list) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
163 return (UiFileList){NULL,0};
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
164 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
165 guint size = g_slist_length(list);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
166
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
167 UiFileList flist;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
168 flist.nfiles = size;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
169 flist.files = calloc(size, sizeof(char*));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
170 int i=0;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
171 while(list) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
172 GFile *file = list->data;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
173 char *uri = g_file_get_uri(file);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
174 flist.files[i++] = strdup(uri);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
175 g_free(uri);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
176 list = list->next;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
177 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
178 return flist;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
179 }
283
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
180 return (UiFileList){NULL,0};
bb0b8927f5c0 add dnd selection functions (unimplemented) (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
181 }
394
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
182
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
183
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
184 UiDnD* ui_create_dnd(void) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
185 UiDnD *dnd = malloc(sizeof(UiDnD));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
186 memset(dnd, 0, sizeof(UiDnD));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
187 dnd->providers = cxArrayListCreateSimple(sizeof(void*), 16);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
188 dnd->selected_action = 0;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
189 dnd->delete = FALSE;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
190 return dnd;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
191 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
192
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
193 void ui_dnd_free(UiDnD *dnd) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
194 cxListDestroy(dnd->providers);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
195 free(dnd);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
196 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
197
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
198 UiDnDAction ui_dnd_result(UiDnD *dnd) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
199 switch(dnd->selected_action) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
200 case 0: return UI_DND_ACTION_NONE;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
201 case GDK_ACTION_COPY: return UI_DND_ACTION_COPY;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
202 case GDK_ACTION_MOVE: return UI_DND_ACTION_MOVE;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
203 case GDK_ACTION_LINK: return UI_DND_ACTION_LINK;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
204 default: break;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
205 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
206 return UI_DND_ACTION_CUSTOM;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
207 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
208
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
209 #else
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
210
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
211 void ui_selection_settext(UiDnD *sel, char *str, int len) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
212 gtk_selection_data_set_text(sel->data, str, len);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
213 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
214
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
215 void ui_selection_seturis(UiDnD *sel, char **uris, int nelm) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
216 char **uriarray = calloc(nelm+1, sizeof(char*));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
217 for(int i=0;i<nelm;i++) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
218 uriarray[i] = uris[i];
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
219 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
220 uriarray[nelm] = NULL;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
221 gtk_selection_data_set_uris(sel->data, uriarray);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
222 free(uriarray);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
223 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
224
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
225 char* ui_selection_gettext(UiDnD *sel) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
226 if(!sel->data) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
227 return NULL;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
228 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
229
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
230 guchar *text = gtk_selection_data_get_text(sel->data);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
231 if(text) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
232 char *textcp = strdup((char*)text);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
233 g_free(text);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
234 return textcp;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
235 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
236 return NULL;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
237 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
238
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
239 UiFileList ui_selection_geturis(UiDnD *sel) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
240 if(!sel->data) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
241 return (UiFileList){NULL,0};
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
242 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
243
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
244 gchar **uris = gtk_selection_data_get_uris(sel->data);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
245 if(uris) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
246 size_t al = 32;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
247 char **array = malloc(al * sizeof(char*));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
248 size_t i = 0;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
249 while(uris[i] != NULL) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
250 if(i >= al) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
251 al *= 2;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
252 array = realloc(array, al * sizeof(char*));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
253 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
254 array[i] = strdup((char*)uris[i]);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
255 i++;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
256 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
257 g_strfreev(uris);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
258 return (UiFileList){array,i};
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
259 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
260
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
261 return (UiFileList){NULL,0};
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
262 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
263
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
264 UiDnDAction ui_dnd_result(UiDnD *dnd) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
265 switch(dnd->selected_action) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
266 case 0: return UI_DND_ACTION_NONE;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
267 case GDK_ACTION_COPY: return UI_DND_ACTION_COPY;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
268 case GDK_ACTION_MOVE: return UI_DND_ACTION_MOVE;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
269 case GDK_ACTION_LINK: return UI_DND_ACTION_LINK;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
270 default: break;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
271 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
272 return UI_DND_ACTION_CUSTOM;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
273 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
274
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
275
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
276 UiDnD* ui_create_dnd(void) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
277 UiDnD *dnd = malloc(sizeof(UiDnD));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
278 memset(dnd, 0, sizeof(UiDnD));
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
279 return dnd;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
280 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
281
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
282 void ui_dnd_free(UiDnD *dnd) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
283 free(dnd);
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
284 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
285
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
286 #endif
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
287
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
288 UiBool ui_dnd_need_delete(UiDnD *dnd) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
289 return dnd->delete;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
290 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
291
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
292 void ui_dnd_accept(UiDnD *dnd, UiBool accept) {
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
293 dnd->accept = accept;
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
294 }
bedd499b640d implement table dnd (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 283
diff changeset
295

mercurial