annotate src/gtk/dnd.c @ 303:3b9d5797050f

2003-11-2 Brian Masney <masneyb@gftp.org> * lib/rfc2068.c (rfc2068_chunked_read) - more improvements to this function so that it will parse more chunked file transfers correctly. * lib/misc.c lib/gftp.h lib/rfc2068.c src/gtk/bookmarks.c src/gtk/dnd.c - removed remove_double_slashes(). Call gftp_build_path() to build the paths. This now allows Novell directory listings with //server * lib/protocols.c src/gtk/transfer.c lib/gftp.h - added variable conn_error_no_timeout to gftp_transfer structure. If this is enabled, if the remote connection to the server timed out, don't wait and immediately reconnect. So far, the only time this is used is when the user was editing a file and it is to be uploaded back to the server. * src/gtk/gftp-gtk.h src/gtk/transfer.c - add_file_transfer() now returns the struct gftp_transfer that was just added. * src/gtk/misc-gtk.c (update_directory_download_progress) - don't make the window a popup and remove the window decorations * src/text/gftp-text.c - don't populate the transfer_direction variable in struct gftp_transfer. This is only needed by the GTK+ port and will hopefully be taken out soon. * lib/gftp.h - remove gftp_transfer_type enum. It wasn't used anymore.
author masneyb
date Mon, 03 Nov 2003 02:14:05 +0000
parents 51725086634d
children df4c91bf4adf
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;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
86 add_file_transfer (current_ftpdata, wdata->request, fromwdata,
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
87 wdata, templist, 1);
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 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 if (gftp_parse_url (current_wdata->request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104 (char *) selection_data->data) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 if (GFTP_IS_CONNECTED (current_wdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 disconnect (current_wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109 ftp_connect (current_wdata, current_wdata->request, 1);
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
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 listbox_drag (GtkWidget * widget, GdkDragContext * context,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117 GtkSelectionData * selection_data, guint info, guint32 clk_time,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 GList * templist, * filelist;
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
121 char *tempstr, *str, *df;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123 size_t totlen, oldlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 int curpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 totlen = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 str = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 filelist = wdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 templist = GTK_CLIST (wdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 curpos = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138 templist = get_next_selection (templist, &filelist, &curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141 if (strcmp (tempfle->file, "..") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
143
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 oldlen = totlen;
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
145 df = gftp_build_path (wdata->request->directory, tempfle->file, NULL);
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
146
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
147 if (wdata->request->hostname == NULL ||
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
148 wdata->request->protonum == GFTP_LOCAL_NUM)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
150 tempstr = g_strdup_printf ("%s://%s ",
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
151 wdata->request->url_prefix, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 }
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
153 else if (wdata->request->username == NULL ||
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
154 *wdata->request->username == '\0')
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
156 tempstr = g_strdup_printf ("%s://%s:%d%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
157 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
158 wdata->request->hostname,
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
159 wdata->request->port, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
163 tempstr = g_strdup_printf ("%s://%s@%s:%d%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
164 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
165 wdata->request->username,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
166 wdata->request->hostname,
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
167 wdata->request->port, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 }
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
169
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
170 g_free (df);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
171
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
172 /* 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
173 at the end of the g_strdup_printf() format argument */
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
174 if (tempfle->isdir)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
175 tempstr[strlen (tempstr) - 1] = '/';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
176 else
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
177 tempstr[strlen (tempstr) - 1] = '\0';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
178
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 totlen += strlen (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 totlen++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 str = g_realloc (str, totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184 strcpy (str + oldlen, "\n");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 strcpy (str + oldlen + 1, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 str = g_malloc (totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 strcpy (str, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 gtk_selection_data_set (selection_data, selection_data->target, 8,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 (unsigned char *) str, strlen (str));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 g_free (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 listbox_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 {
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
209 char *newpos, *oldpos, *tempstr;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 int finish_drag;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
212 size_t len;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 0, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 finish_drag = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 oldpos = (char *) selection_data->data;
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
222 while ((newpos = strchr (oldpos, '\n')) ||
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
223 (newpos = strchr (oldpos, '\0')))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224 {
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
225 len = newpos - oldpos;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
226 if (oldpos[len - 1] == '\r')
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
227 len--;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
228
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
229 if (len == 0)
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
230 break;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
231
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
232 tempstr = g_malloc (len + 1);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
233 memcpy (tempstr, oldpos, len);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
234 tempstr[len] = '\0';
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 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
237
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
238 if (dnd_remote_file (tempstr, wdata))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 finish_drag = 1;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
240 g_free (tempstr);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
241
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 if (*newpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 break;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
244
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 oldpos = newpos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 gtk_drag_finish (context, finish_drag, FALSE, clk_time);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 }