annotate src/gtk/delete_dialog.c @ 514:e55d8b35d809

2004-7-25 Brian Masney <masneyb@gftp.org> * src/gtk/bookmarks.c src/gtk/gftp-gtk.c src/gtk/gtkui.c src/gtk/transfer.c src/text/textui.c src/uicommon/gftpui.c src/uicommon/gftpui.h - added clear_cache argument to gftpui_refresh() Don't clear the cache when changing directories * src/uicommon/gftpuicallbacks.c (_gftpui_common_rm_list) - return 0 on success * src/gtk/delete_dialog.c - refresh the directory listing after the operation was successful
author masneyb
date Sun, 25 Jul 2004 15:48:25 +0000
parents c3ff4479a92d
children 7262851e3ae8
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 /* delete_dialog.c - the delete dialog */
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 253
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: 31
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: 47
diff changeset
23 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
24 yesCB (gftp_transfer * transfer, gftp_dialog_data * ddata)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
25 {
507
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
26 gftpui_callback_data * cdata;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
27 gftp_window_data * wdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
28
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
29 g_return_if_fail (transfer != NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
30 g_return_if_fail (transfer->files != NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
31
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
32 wdata = transfer->fromwdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
33
507
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
34 cdata = g_malloc0 (sizeof (*cdata));
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
35 cdata->request = wdata->request;
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
36 cdata->files = transfer->files;
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
37 cdata->uidata = wdata;
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
38 cdata->run_function = gftpui_common_run_delete;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
39
507
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
40 gftpui_common_run_callback_function (cdata);
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
41
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
42 g_free (cdata);
511
c3ff4479a92d 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 507
diff changeset
43 /* FIXME free_tdata (transfer); */
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
44 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
45
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
46
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
47 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
48 askdel (gftp_transfer * transfer)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
49 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
50 char *tempstr;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
51
507
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
52 if (transfer->numfiles > 0 && transfer->numdirs > 0)
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
53 {
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
54 tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld files and %ld directories"), transfer->numfiles, transfer->numdirs);
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
55 }
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
56 else if (transfer->numfiles > 0)
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
57 {
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
58 tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld files"), transfer->numfiles, transfer->numdirs);
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
59 }
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
60 else if (transfer->numdirs > 0)
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
61 {
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
62 tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld directories"), transfer->numfiles, transfer->numdirs);
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
63 }
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
64 else
34a4c6ec453c 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 506
diff changeset
65 return;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
66
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
67 MakeYesNoDialog (_("Delete Files/Directories"), tempstr,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
68 yesCB, transfer, NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
69 g_free (tempstr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
70 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
71
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
72
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
73 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
74 delete_dialog (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
75 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
76 gftp_file * tempfle, * newfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 gftp_window_data * wdata;
506
5944bd059ae0 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
80 int num, ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
82 wdata = data;
511
c3ff4479a92d 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 507
diff changeset
83 if (!check_status (_("Delete"), wdata,
c3ff4479a92d 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 507
diff changeset
84 gftpui_common_use_threads (wdata->request), 0, 1, 1))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87 transfer = g_malloc0 (sizeof (*transfer));
368
af541d789f4c 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
88 transfer->fromreq = gftp_copy_request (wdata->request);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
89 transfer->fromwdata = wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
90
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
91 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
92 templist = GTK_CLIST (wdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93 filelist = wdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
94 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
95 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
96 templist = get_next_selection (templist, &filelist, &num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
97 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
98 if (strcmp (tempfle->file, "..") == 0 ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99 strcmp (tempfle->file, ".") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101 newfle = copy_fdata (tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102 transfer->files = g_list_append (transfer->files, newfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 if (transfer->files == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 free_tdata (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
111 gftp_swap_socks (transfer->fromreq, wdata->request);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112
506
5944bd059ae0 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
113 ret = gftp_gtk_get_subdirs (transfer, &wdata->tid);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 if (!GFTP_IS_CONNECTED (transfer->fromreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
117 gftpui_disconnect (wdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
121 gftp_swap_socks (wdata->request, transfer->fromreq);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122
506
5944bd059ae0 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
123 if (!ret)
5944bd059ae0 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
124 return;
5944bd059ae0 2004-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
125
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 askdel (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129