annotate src/gtk/dnd.c @ 85:1ee3c21c1291

Removed this file
author masneyb
date Mon, 30 Dec 2002 01:10:34 +0000
parents e2b30d0c97a4
children fe0b21c006f6
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 */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */
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 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
55 ftp_log (gftp_logging_misc, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
56 _("Drag-N-Drop: Ignoring url %s: Not a valid url\n"), url);
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
57 gftp_request_destroy (current_ftpdata, 1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
58 free_fdata (newfle);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
59 return (0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
60 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
61
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
62 *pos++ = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
63 if (compare_request (current_ftpdata, wdata->request, 1))
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
64 {
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
65 gftp_request_destroy (current_ftpdata, 1);
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
66 return (0);
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
67 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
68
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
69 if (other_wdata != NULL &&
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
70 compare_request (current_ftpdata, other_wdata->request, 1))
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
71 {
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
72 if (other_wdata->request->password != NULL)
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
73 gftp_set_password (current_ftpdata, other_wdata->request->password);
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
74
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
75 fromwdata = other_wdata;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
76 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
77 else
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
78 fromwdata = NULL;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
79
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
80 *(pos - 1) = '/';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
81 newfle->file = g_malloc (strlen (current_ftpdata->directory) + 1);
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
82 strcpy (newfle->file, current_ftpdata->directory);
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
83 *(pos - 1) = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
84
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
85 newfle->destfile = g_strconcat (GFTP_GET_DIRECTORY (wdata->request),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
86 "/", pos, NULL);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
87 templist = g_malloc0 (sizeof (*templist));
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
88 templist->data = newfle;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
89 templist->next = NULL;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
90 add_file_transfer (current_ftpdata, wdata->request, fromwdata,
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
91 wdata, templist, 1);
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
92 gftp_request_destroy (current_ftpdata, 1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
93
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
94 /* FIXME resume files and download entire directories */
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
95
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
96 return (1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
97 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
98
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101 openurl_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 if (gftp_parse_url (current_wdata->request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 (char *) selection_data->data) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110 if (GFTP_IS_CONNECTED (current_wdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111 disconnect (current_wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 ftp_connect (current_wdata, current_wdata->request, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117 ftp_log (gftp_logging_misc, NULL, _("Could not parse URL %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 selection_data->data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 listbox_drag (GtkWidget * widget, GdkDragContext * context,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 GtkSelectionData * selection_data, guint info, guint32 clk_time,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130 char *tempstr, *str, *pos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 size_t totlen, oldlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 int curpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 totlen = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137 str = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142 filelist = wdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
143 templist = GTK_CLIST (wdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 curpos = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
145 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
146 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
147 templist = get_next_selection (templist, &filelist, &curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
148 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
150 if (strcmp (tempfle->file, "..") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 oldlen = totlen;
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
154 if (GFTP_GET_HOSTNAME (wdata->request) == NULL ||
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
155 wdata->request->protonum == GFTP_LOCAL_NUM)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 {
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
157 tempstr = g_strdup_printf ("%s://%s/%s ",
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 GFTP_GET_URL_PREFIX (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159 GFTP_GET_DIRECTORY (wdata->request),
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
160 tempfle->file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 else if (GFTP_GET_USERNAME (wdata->request) == NULL
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 || *GFTP_GET_USERNAME (wdata->request) == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 {
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
165 tempstr = g_strdup_printf ("%s://%s:%d%s/%s ",
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 GFTP_GET_URL_PREFIX (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 GFTP_GET_HOSTNAME (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 GFTP_GET_PORT (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 GFTP_GET_DIRECTORY (wdata->request),
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
170 tempfle->file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 {
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
174 tempstr = g_strdup_printf ("%s://%s@%s:%d%s/%s ",
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 GFTP_GET_URL_PREFIX (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 GFTP_GET_USERNAME (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 GFTP_GET_HOSTNAME (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 GFTP_GET_PORT (wdata->request),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 GFTP_GET_DIRECTORY (wdata->request),
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
180 tempfle->file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 }
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
182
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 if ((pos = strchr (tempstr, ':')) != NULL)
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
184 pos += 3;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 pos = tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 remove_double_slashes (pos);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
188
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
189 /* 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
190 at the end of the g_strdup_printf() format argument */
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
191 if (tempfle->isdir)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
192 tempstr[strlen (tempstr) - 1] = '/';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
193 else
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
194 tempstr[strlen (tempstr) - 1] = '\0';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
195
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 totlen += strlen (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 totlen++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 str = g_realloc (str, totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 strcpy (str + oldlen, "\n");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 strcpy (str + oldlen + 1, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 str = g_malloc (totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 strcpy (str, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 gtk_selection_data_set (selection_data, selection_data->target, 8,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215 (unsigned char *) str, strlen (str));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 g_free (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 listbox_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
226 char *newpos, *oldpos, tempchar;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 int finish_drag;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 0, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 finish_drag = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 oldpos = (char *) selection_data->data;
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
238 while ((newpos = strchr (oldpos, '\n')) ||
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
239 (newpos = strchr (oldpos, '\0')))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 tempchar = *newpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 *newpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 ftp_log (gftp_logging_misc, NULL, _("Received URL %s\n"), oldpos);
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
244 if (dnd_remote_file (oldpos, wdata))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 finish_drag = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 if (*newpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 oldpos = newpos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 gtk_drag_finish (context, finish_drag, FALSE, clk_time);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255