Mercurial > gftp.yaz
comparison src/gtk/dnd.c @ 48:e5f6054590b5
2002-11-5 Brian Masney <masneyb@gftp.org>
* lib/*.c src/gtk/*.c - removed function declarations for the static
functions from the top of the file. I had to rearrange the order of a
bunch of functions to avoid compiler warnings
* lib/gftp.h - include sys/sysmacros.h. If major() and minor() isn't
defined, give a compiler warning and define our own
* lib/local.c (local_get_next_file) - if this file is a device, store
the major/minor number in the file size
* src/gtk/misc-gtk.c (add_file_listbox) - if this file is a device,
use the major() and minor() macros to display the major and minor number
author | masneyb |
---|---|
date | Wed, 06 Nov 2002 02:20:25 +0000 |
parents | c8ec7877432e |
children | d433c1417d7d |
comparison
equal
deleted
inserted
replaced
47:eec25f215772 | 48:e5f6054590b5 |
---|---|
18 /*****************************************************************************/ | 18 /*****************************************************************************/ |
19 | 19 |
20 #include "gftp-gtk.h" | 20 #include "gftp-gtk.h" |
21 static const char cvsid[] = "$Id$"; | 21 static const char cvsid[] = "$Id$"; |
22 | 22 |
23 static int dnd_remote_file ( char *url, | 23 |
24 GList ** transfers, | 24 static int |
25 gftp_window_data * wdata ); | 25 dnd_remote_file (char *url, GList ** transfers, gftp_window_data * wdata) |
26 { | |
27 gftp_request * current_ftpdata; | |
28 gftp_window_data * fromwdata; | |
29 gftp_transfer * tdata; | |
30 gftp_file * newfle; | |
31 GList * templist; | |
32 char *str, *pos; | |
33 int i; | |
34 | |
35 newfle = g_malloc0 (sizeof (*newfle)); | |
36 newfle->shown = 1; | |
37 if (url[strlen (url) - 1] == '/') | |
38 { | |
39 newfle->isdir = 1; | |
40 url[strlen (url) - 1] = '\0'; | |
41 } | |
42 | |
43 current_ftpdata = gftp_request_new (); | |
44 current_ftpdata->logging_function = ftp_log; | |
45 | |
46 if (gftp_parse_url (current_ftpdata, url) != 0) | |
47 { | |
48 ftp_log (gftp_logging_misc, NULL, | |
49 _("Drag-N-Drop: Ignoring url %s: Not a valid url\n"), url); | |
50 gftp_request_destroy (current_ftpdata); | |
51 free_fdata (newfle); | |
52 return (0); | |
53 } | |
54 | |
55 if ((str = GFTP_GET_DIRECTORY (current_ftpdata)) != NULL) | |
56 { | |
57 if ((pos = strrchr (str, '/')) == NULL) | |
58 pos = str; | |
59 else pos++; | |
60 *(pos - 1) = '\0'; | |
61 i = 1; | |
62 } | |
63 else | |
64 { | |
65 pos = str = GFTP_GET_DIRECTORY (current_ftpdata); | |
66 i = 0; | |
67 } | |
68 | |
69 if (compare_request (current_ftpdata, wdata->request, 1)) | |
70 return (0); | |
71 | |
72 if (i) | |
73 { | |
74 *(pos - 1) = '/'; | |
75 newfle->file = g_malloc (strlen (str) + 1); | |
76 strcpy (newfle->file, str); | |
77 *(pos - 1) = '\0'; | |
78 } | |
79 else | |
80 { | |
81 newfle->file = g_malloc (strlen (str) + 1); | |
82 strcpy (newfle->file, str); | |
83 } | |
84 | |
85 newfle->destfile = g_strconcat (GFTP_GET_DIRECTORY (wdata->request), | |
86 "/", pos, NULL); | |
87 newfle->ascii = gftp_get_file_transfer_mode (newfle->file, | |
88 wdata->request->data_type) == GFTP_TYPE_ASCII; | |
89 | |
90 tdata = NULL; | |
91 templist = *transfers; | |
92 while (templist != NULL) | |
93 { | |
94 tdata = templist->data; | |
95 if (compare_request (tdata->fromreq, current_ftpdata, 1)) | |
96 break; | |
97 templist = templist->next; | |
98 } | |
99 | |
100 if (tdata == NULL) | |
101 { | |
102 tdata = g_malloc0 (sizeof (*tdata)); | |
103 tdata->towdata = wdata == &window1 ? &window1 : &window2; | |
104 fromwdata = wdata == &window1 ? &window2 : &window1; | |
105 if (fromwdata->request != NULL && | |
106 compare_request (fromwdata->request, current_ftpdata, 1)) | |
107 { | |
108 if (fromwdata->request->password != NULL) | |
109 gftp_set_password (current_ftpdata, fromwdata->request->password); | |
110 tdata->fromwdata = fromwdata; | |
111 } | |
112 tdata->fromreq = current_ftpdata; | |
113 tdata->toreq = gftp_request_new (); | |
114 tdata->toreq->logging_function = ftp_log; | |
115 tdata->toreq = copy_request (wdata->request); | |
116 *transfers = g_list_append (*transfers, tdata); | |
117 } | |
118 else | |
119 gftp_request_destroy (current_ftpdata); | |
120 | |
121 if (newfle->isdir) | |
122 { | |
123 /* FIXME - need to fix this | |
124 add_entire_directory (tdata, newfle, | |
125 GFTP_GET_DIRECTORY (tdata->fromhdata->ftpdata), | |
126 GFTP_GET_DIRECTORY (tdata->tohdata->ftpdata), | |
127 tdata->fromhdata->ftpdata); | |
128 */ | |
129 } | |
130 else | |
131 { | |
132 tdata->files = g_list_append (tdata->files, newfle); | |
133 if (tdata->curfle == NULL) | |
134 tdata->curfle = tdata->files; | |
135 } | |
136 return (1); | |
137 } | |
138 | |
26 | 139 |
27 void | 140 void |
28 openurl_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x, | 141 openurl_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x, |
29 gint y, GtkSelectionData * selection_data, guint info, | 142 gint y, GtkSelectionData * selection_data, guint info, |
30 guint32 clk_time, gpointer data) | 143 guint32 clk_time, gpointer data) |
182 } | 295 } |
183 } | 296 } |
184 gtk_drag_finish (context, finish_drag, FALSE, clk_time); | 297 gtk_drag_finish (context, finish_drag, FALSE, clk_time); |
185 } | 298 } |
186 | 299 |
187 | |
188 static int | |
189 dnd_remote_file (char *url, GList ** transfers, gftp_window_data * wdata) | |
190 { | |
191 gftp_request * current_ftpdata; | |
192 gftp_window_data * fromwdata; | |
193 gftp_transfer * tdata; | |
194 gftp_file * newfle; | |
195 GList * templist; | |
196 char *str, *pos; | |
197 int i; | |
198 | |
199 newfle = g_malloc0 (sizeof (*newfle)); | |
200 newfle->shown = 1; | |
201 if (url[strlen (url) - 1] == '/') | |
202 { | |
203 newfle->isdir = 1; | |
204 url[strlen (url) - 1] = '\0'; | |
205 } | |
206 | |
207 current_ftpdata = gftp_request_new (); | |
208 current_ftpdata->logging_function = ftp_log; | |
209 | |
210 if (gftp_parse_url (current_ftpdata, url) != 0) | |
211 { | |
212 ftp_log (gftp_logging_misc, NULL, | |
213 _("Drag-N-Drop: Ignoring url %s: Not a valid url\n"), url); | |
214 gftp_request_destroy (current_ftpdata); | |
215 free_fdata (newfle); | |
216 return (0); | |
217 } | |
218 | |
219 if ((str = GFTP_GET_DIRECTORY (current_ftpdata)) != NULL) | |
220 { | |
221 if ((pos = strrchr (str, '/')) == NULL) | |
222 pos = str; | |
223 else pos++; | |
224 *(pos - 1) = '\0'; | |
225 i = 1; | |
226 } | |
227 else | |
228 { | |
229 pos = str = GFTP_GET_DIRECTORY (current_ftpdata); | |
230 i = 0; | |
231 } | |
232 | |
233 if (compare_request (current_ftpdata, wdata->request, 1)) | |
234 return (0); | |
235 | |
236 if (i) | |
237 { | |
238 *(pos - 1) = '/'; | |
239 newfle->file = g_malloc (strlen (str) + 1); | |
240 strcpy (newfle->file, str); | |
241 *(pos - 1) = '\0'; | |
242 } | |
243 else | |
244 { | |
245 newfle->file = g_malloc (strlen (str) + 1); | |
246 strcpy (newfle->file, str); | |
247 } | |
248 | |
249 newfle->destfile = g_strconcat (GFTP_GET_DIRECTORY (wdata->request), | |
250 "/", pos, NULL); | |
251 newfle->ascii = gftp_get_file_transfer_mode (newfle->file, | |
252 wdata->request->data_type) == GFTP_TYPE_ASCII; | |
253 | |
254 tdata = NULL; | |
255 templist = *transfers; | |
256 while (templist != NULL) | |
257 { | |
258 tdata = templist->data; | |
259 if (compare_request (tdata->fromreq, current_ftpdata, 1)) | |
260 break; | |
261 templist = templist->next; | |
262 } | |
263 | |
264 if (tdata == NULL) | |
265 { | |
266 tdata = g_malloc0 (sizeof (*tdata)); | |
267 tdata->towdata = wdata == &window1 ? &window1 : &window2; | |
268 fromwdata = wdata == &window1 ? &window2 : &window1; | |
269 if (fromwdata->request != NULL && | |
270 compare_request (fromwdata->request, current_ftpdata, 1)) | |
271 { | |
272 if (fromwdata->request->password != NULL) | |
273 gftp_set_password (current_ftpdata, fromwdata->request->password); | |
274 tdata->fromwdata = fromwdata; | |
275 } | |
276 tdata->fromreq = current_ftpdata; | |
277 tdata->toreq = gftp_request_new (); | |
278 tdata->toreq->logging_function = ftp_log; | |
279 tdata->toreq = copy_request (wdata->request); | |
280 *transfers = g_list_append (*transfers, tdata); | |
281 } | |
282 else | |
283 gftp_request_destroy (current_ftpdata); | |
284 | |
285 if (newfle->isdir) | |
286 { | |
287 /* FIXME - need to fix this | |
288 add_entire_directory (tdata, newfle, | |
289 GFTP_GET_DIRECTORY (tdata->fromhdata->ftpdata), | |
290 GFTP_GET_DIRECTORY (tdata->tohdata->ftpdata), | |
291 tdata->fromhdata->ftpdata); | |
292 */ | |
293 } | |
294 else | |
295 { | |
296 tdata->files = g_list_append (tdata->files, newfle); | |
297 if (tdata->curfle == NULL) | |
298 tdata->curfle = tdata->files; | |
299 } | |
300 return (1); | |
301 } | |
302 |