1
|
1 /*****************************************************************************/
|
|
2 /* rename_dialog.c - rename dialog box and ftp routines */
|
|
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */
|
|
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
|
|
23 static const char *edttext;
|
|
24 static gftp_file * curfle;
|
|
25
|
19
|
26
|
1
|
27 static void *
|
|
28 do_rename_thread (void * data)
|
|
29 {
|
|
30 gftp_window_data * wdata;
|
|
31 int success, sj;
|
|
32
|
|
33 wdata = data;
|
|
34
|
|
35 if (wdata->request->use_threads)
|
|
36 {
|
42
|
37 sj = sigsetjmp (jmp_environment, 1);
|
|
38 use_jmp_environment = 1;
|
1
|
39 }
|
|
40 else
|
|
41 sj = 0;
|
|
42
|
|
43 success = 0;
|
|
44 if (sj == 0)
|
|
45 {
|
|
46 if (wdata->request->network_timeout > 0)
|
|
47 alarm (wdata->request->network_timeout);
|
|
48 success = gftp_rename_file (wdata->request, curfle->file, edttext) == 0;
|
|
49 alarm (0);
|
|
50 }
|
|
51 else
|
|
52 {
|
|
53 gftp_disconnect (wdata->request);
|
|
54 wdata->request->logging_function (gftp_logging_error,
|
|
55 wdata->request->user_data,
|
|
56 _("Operation canceled\n"));
|
|
57 }
|
|
58
|
|
59 if (wdata->request->use_threads)
|
42
|
60 use_jmp_environment = 0;
|
1
|
61
|
|
62 wdata->request->stopable = 0;
|
|
63 return ((void *) success);
|
|
64 }
|
|
65
|
|
66
|
19
|
67 static void
|
|
68 dorenCB (gftp_window_data * wdata, gftp_dialog_data * ddata)
|
1
|
69 {
|
19
|
70 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
|
|
71 if (*edttext == '\0')
|
|
72 {
|
|
73 ftp_log (gftp_logging_misc, NULL,
|
|
74 _("Rename: Operation canceled...you must enter a string\n"));
|
|
75 return;
|
|
76 }
|
|
77
|
|
78 if (check_reconnect (wdata) < 0)
|
|
79 return;
|
|
80
|
|
81 if ((int) generic_thread (do_rename_thread, wdata))
|
|
82 refresh ((gpointer) wdata);
|
1
|
83 }
|
|
84
|
19
|
85
|
|
86 void
|
|
87 rename_dialog (gpointer data)
|
|
88 {
|
|
89 GList *templist, *filelist;
|
|
90 gftp_window_data * wdata;
|
|
91 char *tempstr;
|
|
92 int num;
|
|
93
|
|
94 wdata = data;
|
|
95 if (!check_status (_("Rename"), wdata, wdata->request->use_threads, 1, 1,
|
|
96 wdata->request->rename != NULL))
|
|
97 return;
|
|
98
|
|
99 templist = GTK_CLIST (wdata->listbox)->selection;
|
|
100 num = 0;
|
|
101 filelist = wdata->files;
|
|
102 templist = get_next_selection (templist, &filelist, &num);
|
|
103 curfle = filelist->data;
|
|
104
|
|
105 tempstr = g_strdup_printf (_("What would you like to rename %s to?"),
|
|
106 curfle->file);
|
|
107 MakeEditDialog (_("Rename"), tempstr, curfle->file, 1, NULL,
|
|
108 gftp_dialog_button_rename, dorenCB, wdata, NULL, NULL);
|
|
109 g_free (tempstr);
|
|
110 }
|
|
111
|