annotate src/gtk/dnd.c @ 367:d5409bf03ff1

2003-1-18 Brian Masney <masneyb@gftp.org> * lib/protocols.c (gftp_parse_url) - if the URL is the local filesystem, skip over the whitespace at the beginning. * lib/rfc959.c (rfc959_syst) - allow the string MVS and OS/MVS for the MVS directory listings. * src/gtk/gtkui_transfer.c src/gtk/transfer.c src/gtk/gftpui.c - started to move the transfer functionality into the uicommon directory. Added the text and GTK+ UI specific transfer functions. * src/gtk/Makefile.am po/POTFILES.in - added gtkui_transfer.c * src/gtk/dnd.c src/gtk/gtkui_transfer.c src/gtk/view_dialog.c - s/add_file_transfer/gtkui_common_add_file_transfer/ * src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h - removed transfer_mutex * src/gtk/gtkui.c src/text/textui.c - added gftpui_add_file_to_transfer() * src/uicommon/gftpui_callbacks.c src/uicommon/gftpui.c - in all of the thread callback functions, don't alter the return value in the function. Return it as is.
author masneyb
date Sun, 18 Jan 2004 20:09:28 +0000
parents df4c91bf4adf
children 05ee37a5558b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2 /* dnd.c - drag and drop functions */
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include "gftp-gtk.h"
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
21 static const char cvsid[] = "$Id$";
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
23
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
24 static int
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
25 dnd_remote_file (char *url, gftp_window_data * wdata)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
26 {
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
27 gftp_window_data * other_wdata, * fromwdata;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
28 gftp_request * current_ftpdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
29 gftp_file * newfle;
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
30 GList * templist;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
31 char *pos;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
32
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
33 if (wdata == &window1)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
34 other_wdata = &window2;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
35 else if (wdata == &window2)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
36 other_wdata = &window1;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
37 else
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
38 other_wdata = NULL;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
39
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
40 newfle = g_malloc0 (sizeof (*newfle));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
41 newfle->shown = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
42 if (url[strlen (url) - 1] == '/')
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
43 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
44 newfle->isdir = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
45 url[strlen (url) - 1] = '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
46 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
47
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
48 current_ftpdata = gftp_request_new ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
49 current_ftpdata->logging_function = ftp_log;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
50
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
51 if (gftp_parse_url (current_ftpdata, url) != 0 ||
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
52 current_ftpdata->directory == NULL ||
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
53 (pos = strrchr (current_ftpdata->directory, '/')) == NULL)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
54 {
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
55 gftp_request_destroy (current_ftpdata, 1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
56 free_fdata (newfle);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
57 return (0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
58 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
59
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
60 *pos++ = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
61 if (compare_request (current_ftpdata, wdata->request, 1))
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
62 {
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
63 gftp_request_destroy (current_ftpdata, 1);
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
64 return (0);
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
65 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
66
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
67 if (other_wdata != NULL &&
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
68 compare_request (current_ftpdata, other_wdata->request, 1))
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
69 {
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
70 if (other_wdata->request->password != NULL)
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
71 gftp_set_password (current_ftpdata, other_wdata->request->password);
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
72
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
73 fromwdata = other_wdata;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
74 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
75 else
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
76 fromwdata = NULL;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
77
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
78 *(pos - 1) = '/';
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
79 newfle->file = g_strdup (current_ftpdata->directory);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
80 *(pos - 1) = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
81
245
41af60bc1f88 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
82 newfle->destfile = gftp_build_path (wdata->request->directory, pos, NULL);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
83 templist = g_malloc0 (sizeof (*templist));
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
84 templist->data = newfle;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
85 templist->next = NULL;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 329
diff changeset
86 gftpui_common_add_file_transfer (current_ftpdata, wdata->request, fromwdata,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 329
diff changeset
87 wdata, templist);
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
88 gftp_request_destroy (current_ftpdata, 1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
89
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
90 /* FIXME resume files and download entire directories */
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
91
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
92 return (1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
93 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
94
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
95
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
96 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
97 openurl_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
98 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102 {
329
df4c91bf4adf 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
103 if (GFTP_IS_CONNECTED (current_wdata->request))
df4c91bf4adf 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
104 disconnect (current_wdata);
df4c91bf4adf 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
105
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 if (gftp_parse_url (current_wdata->request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 (char *) selection_data->data) == 0)
329
df4c91bf4adf 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
108 ftp_connect (current_wdata, current_wdata->request, 1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 listbox_drag (GtkWidget * widget, GdkDragContext * context,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 GtkSelectionData * selection_data, guint info, guint32 clk_time,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 GList * templist, * filelist;
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
119 char *tempstr, *str, *df;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 size_t totlen, oldlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123 int curpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 totlen = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 str = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131 filelist = wdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 templist = GTK_CLIST (wdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 curpos = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 templist = get_next_selection (templist, &filelist, &curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139 if (strcmp (tempfle->file, "..") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142 oldlen = totlen;
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
143 df = gftp_build_path (wdata->request->directory, tempfle->file, NULL);
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
144
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
145 if (wdata->request->hostname == NULL ||
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
146 wdata->request->protonum == GFTP_LOCAL_NUM)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
147 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
148 tempstr = g_strdup_printf ("%s://%s ",
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
149 wdata->request->url_prefix, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
150 }
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
151 else if (wdata->request->username == NULL ||
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
152 *wdata->request->username == '\0')
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
154 tempstr = g_strdup_printf ("%s://%s:%d%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
155 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
156 wdata->request->hostname,
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
157 wdata->request->port, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
161 tempstr = g_strdup_printf ("%s://%s@%s:%d%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
162 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
163 wdata->request->username,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
164 wdata->request->hostname,
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
165 wdata->request->port, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 }
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
167
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
168 g_free (df);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
169
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
170 /* Note, I am allocating memory for this byte above. Note the extra space
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
171 at the end of the g_strdup_printf() format argument */
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
172 if (tempfle->isdir)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
173 tempstr[strlen (tempstr) - 1] = '/';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
174 else
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
175 tempstr[strlen (tempstr) - 1] = '\0';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
176
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 totlen += strlen (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180 totlen++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 str = g_realloc (str, totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 strcpy (str + oldlen, "\n");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 strcpy (str + oldlen + 1, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 str = g_malloc (totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 strcpy (str, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 gtk_selection_data_set (selection_data, selection_data->target, 8,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 (unsigned char *) str, strlen (str));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 g_free (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 listbox_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 {
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
207 char *newpos, *oldpos, *tempstr;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 int finish_drag;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
210 size_t len;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 0, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 finish_drag = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 oldpos = (char *) selection_data->data;
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
220 while ((newpos = strchr (oldpos, '\n')) ||
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
221 (newpos = strchr (oldpos, '\0')))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 {
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
223 len = newpos - oldpos;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
224 if (oldpos[len - 1] == '\r')
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
225 len--;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
226
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
227 if (len == 0)
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
228 break;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
229
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
230 tempstr = g_malloc (len + 1);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
231 memcpy (tempstr, oldpos, len);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
232 tempstr[len] = '\0';
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
233
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
234 ftp_log (gftp_logging_misc, NULL, _("Received URL %s\n"), tempstr);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
235
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
236 if (dnd_remote_file (tempstr, wdata))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 finish_drag = 1;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
238 g_free (tempstr);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
239
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 if (*newpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 break;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
242
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 oldpos = newpos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 gtk_drag_finish (context, finish_drag, FALSE, clk_time);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 }