annotate src/gtk/dnd.c @ 289:5f66f09e5194

2003-10-17 Brian Masney <masneyb@gftp.org> * lib/misc.c (insert_commas) - if _GNU_SOURCE is defined, instead of using my builtin function for formatting numbers, use glibc's %'ld (or %'lld) format to print the numbers out. This is more portable for other locales.
author masneyb
date Sat, 18 Oct 2003 14:54:53 +0000
parents 2ad324cf4930
children 51725086634d
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;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 char *tempstr, *str, *pos;
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;
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 {
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
148 tempstr = g_strdup_printf ("%s://%s/%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
149 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
150 wdata->request->directory,
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
151 tempfle->file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
153 else if (wdata->request->username == NULL
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
154 || *wdata->request->username == '\0')
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155 {
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
156 tempstr = g_strdup_printf ("%s://%s:%d%s/%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,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
159 wdata->request->port,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
160 wdata->request->directory,
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
161 tempfle->file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 else
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@%s:%d%s/%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
166 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
167 wdata->request->username,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
168 wdata->request->hostname,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
169 wdata->request->port,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
170 wdata->request->directory,
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
171 tempfle->file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 }
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
173
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 if ((pos = strchr (tempstr, ':')) != NULL)
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
175 pos += 3;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 pos = tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 remove_double_slashes (pos);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
179
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
180 /* 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
181 at the end of the g_strdup_printf() format argument */
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
182 if (tempfle->isdir)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
183 tempstr[strlen (tempstr) - 1] = '/';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
184 else
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
185 tempstr[strlen (tempstr) - 1] = '\0';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
186
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 totlen += strlen (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 totlen++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 str = g_realloc (str, totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 strcpy (str + oldlen, "\n");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 strcpy (str + oldlen + 1, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 str = g_malloc (totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 strcpy (str, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 gtk_selection_data_set (selection_data, selection_data->target, 8,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 (unsigned char *) str, strlen (str));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 g_free (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 listbox_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 char *newpos, *oldpos, tempchar;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 int finish_drag;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 0, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 finish_drag = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
226 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 oldpos = (char *) selection_data->data;
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
229 while ((newpos = strchr (oldpos, '\n')) ||
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
230 (newpos = strchr (oldpos, '\0')))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 tempchar = *newpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233 *newpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 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
235 if (dnd_remote_file (oldpos, wdata))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 finish_drag = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 if (*newpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 oldpos = newpos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 gtk_drag_finish (context, finish_drag, FALSE, clk_time);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 }