1
|
1 /*****************************************************************************/
|
|
2 /* delete_dialog.c - the delete dialog */
|
255
|
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
|
1
|
4 /* */
|
|
5 /* This program is free software; you can redistribute it and/or modify */
|
|
6 /* it under the terms of the GNU General Public License as published by */
|
|
7 /* the Free Software Foundation; either version 2 of the License, or */
|
|
8 /* (at your option) any later version. */
|
|
9 /* */
|
|
10 /* This program is distributed in the hope that it will be useful, */
|
|
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
13 /* GNU General Public License for more details. */
|
|
14 /* */
|
|
15 /* You should have received a copy of the GNU General Public License */
|
|
16 /* along with this program; if not, write to the Free Software */
|
|
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
|
|
18 /*****************************************************************************/
|
|
19
|
|
20 #include "gftp-gtk.h"
|
33
|
21 static const char cvsid[] = "$Id$";
|
1
|
22
|
48
|
23 static void
|
|
24 yesCB (gftp_transfer * transfer, gftp_dialog_data * ddata)
|
|
25 {
|
507
|
26 gftpui_callback_data * cdata;
|
48
|
27 gftp_window_data * wdata;
|
|
28
|
|
29 g_return_if_fail (transfer != NULL);
|
|
30 g_return_if_fail (transfer->files != NULL);
|
|
31
|
|
32 wdata = transfer->fromwdata;
|
|
33
|
507
|
34 cdata = g_malloc0 (sizeof (*cdata));
|
|
35 cdata->request = wdata->request;
|
|
36 cdata->files = transfer->files;
|
|
37 cdata->uidata = wdata;
|
|
38 cdata->run_function = gftpui_common_run_delete;
|
48
|
39
|
507
|
40 gftpui_common_run_callback_function (cdata);
|
|
41
|
|
42 g_free (cdata);
|
511
|
43 /* FIXME free_tdata (transfer); */
|
48
|
44 }
|
|
45
|
|
46
|
|
47 static void
|
|
48 askdel (gftp_transfer * transfer)
|
|
49 {
|
|
50 char *tempstr;
|
|
51
|
507
|
52 if (transfer->numfiles > 0 && transfer->numdirs > 0)
|
|
53 {
|
|
54 tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld files and %ld directories"), transfer->numfiles, transfer->numdirs);
|
|
55 }
|
|
56 else if (transfer->numfiles > 0)
|
|
57 {
|
|
58 tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld files"), transfer->numfiles, transfer->numdirs);
|
|
59 }
|
|
60 else if (transfer->numdirs > 0)
|
|
61 {
|
|
62 tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld directories"), transfer->numfiles, transfer->numdirs);
|
|
63 }
|
|
64 else
|
|
65 return;
|
48
|
66
|
|
67 MakeYesNoDialog (_("Delete Files/Directories"), tempstr,
|
|
68 yesCB, transfer, NULL, NULL);
|
|
69 g_free (tempstr);
|
|
70 }
|
|
71
|
1
|
72
|
|
73 void
|
|
74 delete_dialog (gpointer data)
|
|
75 {
|
|
76 gftp_file * tempfle, * newfle;
|
|
77 GList * templist, * filelist;
|
|
78 gftp_transfer * transfer;
|
|
79 gftp_window_data * wdata;
|
506
|
80 int num, ret;
|
1
|
81
|
|
82 wdata = data;
|
511
|
83 if (!check_status (_("Delete"), wdata,
|
|
84 gftpui_common_use_threads (wdata->request), 0, 1, 1))
|
1
|
85 return;
|
|
86
|
|
87 transfer = g_malloc0 (sizeof (*transfer));
|
368
|
88 transfer->fromreq = gftp_copy_request (wdata->request);
|
1
|
89 transfer->fromwdata = wdata;
|
|
90
|
|
91 num = 0;
|
|
92 templist = GTK_CLIST (wdata->listbox)->selection;
|
|
93 filelist = wdata->files;
|
|
94 while (templist != NULL)
|
|
95 {
|
|
96 templist = get_next_selection (templist, &filelist, &num);
|
|
97 tempfle = filelist->data;
|
|
98 if (strcmp (tempfle->file, "..") == 0 ||
|
|
99 strcmp (tempfle->file, ".") == 0)
|
|
100 continue;
|
|
101 newfle = copy_fdata (tempfle);
|
|
102 transfer->files = g_list_append (transfer->files, newfle);
|
|
103 }
|
|
104
|
|
105 if (transfer->files == NULL)
|
|
106 {
|
|
107 free_tdata (transfer);
|
|
108 return;
|
|
109 }
|
|
110
|
63
|
111 gftp_swap_socks (transfer->fromreq, wdata->request);
|
1
|
112
|
506
|
113 ret = gftp_gtk_get_subdirs (transfer, &wdata->tid);
|
1
|
114
|
|
115 if (!GFTP_IS_CONNECTED (transfer->fromreq))
|
|
116 {
|
380
|
117 gftpui_disconnect (wdata);
|
1
|
118 return;
|
|
119 }
|
|
120
|
63
|
121 gftp_swap_socks (wdata->request, transfer->fromreq);
|
1
|
122
|
506
|
123 if (!ret)
|
|
124 return;
|
|
125
|
1
|
126 askdel (transfer);
|
|
127 }
|
|
128
|
|
129
|