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