annotate src/gtk/gtkui.c @ 633:05c67a33b071

2004-12-2 Brian Masney <masneyb@gftp.org> * src/gtk/gtkui.c (gftpui_run_function_callback) src/uicommon/gftpui.h - added toggled variable to the gftpui_callback_data structure. If the edit dialog had a checkbox in it, then put the checkbox value in the toggled variable * src/gtk/gtkui.c (gftpui_site_dialog) src/uicommon/gftpuicallbacks.c (gftpui_common_run_site) - allow the user to not send the prepend the command with the SITE keyword * docs/website/index.html.in docs/website/bats.gif docs/website/generate-gftp-website.pl - updated bug reporting section. Added link and graphic for the National Speleological Society (NSS)
author masneyb
date Thu, 02 Dec 2004 23:19:31 +0000
parents 5df5eac28f47
children 8990a8a26ccf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1 /*****************************************************************************/
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
2 /* gtkui.c - GTK+ UI related functions for gFTP */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
4 /* */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
9 /* */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
14 /* */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
18 /*****************************************************************************/
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
19
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
20 #include "gftp-gtk.h"
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
21 static const char cvsid[] = "$Id$";
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
22
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
23
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
24 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
25 gftpui_lookup_file_colors (gftp_file * fle, char **start_color,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
26 char ** end_color)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
27 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
28 *start_color = GFTPUI_COMMON_COLOR_NONE;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
29 *end_color = GFTPUI_COMMON_COLOR_NONE;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
30 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
31
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
32
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
33 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
34 gftpui_run_command (GtkWidget * widget, gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
35 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
36 const char *txt;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
37
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
38 txt = gtk_entry_get_text (GTK_ENTRY (gftpui_command_widget));
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
39 gftpui_common_process_command (&window1, window1.request,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
40 &window2, window2.request, txt);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
41 gtk_entry_set_text (GTK_ENTRY (gftpui_command_widget), "");
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
42 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
43
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
44
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
45 void
521
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 518
diff changeset
46 gftpui_refresh (void *uidata, int clear_cache_entry)
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
47 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
48 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
49
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
50 wdata = uidata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
51 if (!check_status (_("Refresh"), wdata, 0, 0, 0, 1))
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
52 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
53
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
54 if (check_reconnect (wdata) < 0)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
55 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
56
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
57 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
58 remove_files_window (wdata);
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 496
diff changeset
59
521
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 518
diff changeset
60 if (clear_cache_entry)
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 496
diff changeset
61 gftp_delete_cache_entry (wdata->request, NULL, 0);
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 496
diff changeset
62
496
937f2b75bbee 2004-7-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
63 ftp_list_files (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
64 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
65 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
66
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
67
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
68 #define _GFTPUI_GTK_USER_PW_SIZE 256
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
69
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
70 static void
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
71 _gftpui_gtk_set_username (gftp_request * request, gftp_dialog_data * ddata)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
72 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
73 gftp_set_username (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit)));
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
74 request->stopable = 0;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
75 }
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
76
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
77
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
78 static void
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
79 _gftpui_gtk_set_password (gftp_request * request, gftp_dialog_data * ddata)
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
80 {
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
81 gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit)));
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
82 request->stopable = 0;
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
83 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
84
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
85
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
86 static void
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
87 _gftpui_gtk_abort (gftp_request * request, gftp_dialog_data * ddata)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
88 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
89 request->stopable = 0;
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
90 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
91
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
92
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
93 void
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
94 gftpui_prompt_username (void *uidata, gftp_request * request)
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
95 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
96 MakeEditDialog (_("Enter Username"),
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
97 _("Please enter your username for this site"), NULL,
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
98 0, NULL, gftp_dialog_button_connect,
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
99 _gftpui_gtk_set_username, request,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
100 _gftpui_gtk_abort, request);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
101
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
102 request->stopable = 1;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
103 while (request->stopable)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
104 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
105 GDK_THREADS_LEAVE ();
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
106 #if GTK_MAJOR_VERSION == 1
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
107 g_main_iteration (TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
108 #else
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
109 g_main_context_iteration (NULL, TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
110 #endif
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
111 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
112 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
113
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
114
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
115 void
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
116 gftpui_prompt_password (void *uidata, gftp_request * request)
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
117 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
118 MakeEditDialog (_("Enter Password"),
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
119 _("Please enter your password for this site"), NULL,
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
120 0, NULL, gftp_dialog_button_connect,
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
121 _gftpui_gtk_set_password, request,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
122 _gftpui_gtk_abort, request);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
123
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
124 request->stopable = 1;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
125 while (request->stopable)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
126 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
127 GDK_THREADS_LEAVE ();
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
128 #if GTK_MAJOR_VERSION == 1
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
129 g_main_iteration (TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
130 #else
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
131 g_main_context_iteration (NULL, TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
132 #endif
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
133 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
134 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
135
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
136
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
137 /* The wakeup main thread functions are so that after the thread terminates
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
138 there won't be a delay in updating the GUI */
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
139 static void
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
140 _gftpui_wakeup_main_thread (gpointer data, gint source,
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
141 GdkInputCondition condition)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
142 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
143 gftp_request * request;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
144 char c;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
145
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
146 request = data;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
147 if (request->wakeup_main_thread[0] > 0)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
148 read (request->wakeup_main_thread[0], &c, 1);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
149 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
150
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
151
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
152 static gint
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
153 _gftpui_setup_wakeup_main_thread (gftp_request * request)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
154 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
155 gint handler;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
156
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
157 if (socketpair (AF_UNIX, SOCK_STREAM, 0, request->wakeup_main_thread) == 0)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
158 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
159 handler = gdk_input_add (request->wakeup_main_thread[0],
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
160 GDK_INPUT_READ, _gftpui_wakeup_main_thread,
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
161 request);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
162 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
163 else
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
164 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
165 request->wakeup_main_thread[0] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
166 request->wakeup_main_thread[1] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
167 handler = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
168 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
169
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
170 return (handler);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
171 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
172
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
173
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
174 static void
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
175 _gftpui_teardown_wakeup_main_thread (gftp_request * request, gint handler)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
176 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
177 if (request->wakeup_main_thread[0] > 0 && request->wakeup_main_thread[1] > 0)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
178 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
179 gdk_input_remove (handler);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
180 close (request->wakeup_main_thread[0]);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
181 close (request->wakeup_main_thread[1]);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
182 request->wakeup_main_thread[0] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
183 request->wakeup_main_thread[1] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
184 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
185 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
186
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
187 static void *
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
188 _gftpui_gtk_thread_func (void *data)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
189 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
190 gftpui_gtk_thread_data * thread_data;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
191 void *ret;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
192
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
193 thread_data = data;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
194 ret = thread_data->func (thread_data->cdata);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
195
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
196 if (thread_data->cdata->request->wakeup_main_thread[1] > 0)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
197 write (thread_data->cdata->request->wakeup_main_thread[1], " ", 1);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
198
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
199 return (ret);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
200 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
201
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
202
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
203 void *
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
204 gftpui_generic_thread (void * (*func) (void *), void *data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
205 {
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
206 gftpui_gtk_thread_data * thread_data;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
207 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
208 gftp_window_data * wdata;
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
209 gint handler;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
210 void * ret;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
211
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
212 cdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
213 wdata = cdata->uidata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
214
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
215 wdata->request->stopable = 1;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
216 gtk_widget_set_sensitive (stop_btn, 1);
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
217
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
218 thread_data = g_malloc0 (sizeof (*thread_data));
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
219 thread_data->func = func;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
220 thread_data->cdata = cdata;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
221
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
222 handler = _gftpui_setup_wakeup_main_thread (cdata->request);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
223 pthread_create (&wdata->tid, NULL, _gftpui_gtk_thread_func, thread_data);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
224
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
225 while (wdata->request->stopable)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
226 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
227 GDK_THREADS_LEAVE ();
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
228 #if GTK_MAJOR_VERSION == 1
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
229 g_main_iteration (TRUE);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
230 #else
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
231 g_main_context_iteration (NULL, TRUE);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
232 #endif
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
233 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
234
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
235 _gftpui_teardown_wakeup_main_thread (cdata->request, handler);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
236 g_free (thread_data);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
237
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
238 pthread_join (wdata->tid, &ret);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
239 gtk_widget_set_sensitive (stop_btn, 0);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
240
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
241 if (!GFTP_IS_CONNECTED (wdata->request))
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
242 gftpui_disconnect (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
243
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
244 return (ret);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
245 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
246
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
247
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
248 int
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
249 gftpui_check_reconnect (gftpui_callback_data * cdata)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
250 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
251 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
252
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
253 wdata = cdata->uidata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
254 return (wdata->request->cached && wdata->request->datafd < 0 &&
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
255 !wdata->request->always_connected &&
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
256 !ftp_connect (wdata, wdata->request, 0) ? -1 : 0);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
257 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
258
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
259
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
260 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
261 gftpui_run_function_callback (gftp_window_data * wdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
262 gftp_dialog_data * ddata)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
263 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
264 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
265 const char *edttext;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
266
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
267 cdata = ddata->yespointer;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
268 if (ddata->edit != NULL)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
269 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
270 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
271 if (*edttext == '\0')
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
272 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
273 ftp_log (gftp_logging_misc, NULL,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
274 _("Operation canceled...you must enter a string\n"));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
275 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
276 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
277
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
278 cdata->input_string = g_strdup (edttext);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
279 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
280
633
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
281 if (ddata->checkbox != NULL)
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
282 cdata->toggled = GTK_TOGGLE_BUTTON (ddata->checkbox)->active;
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
283 else
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
284 cdata->toggled = 0;
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
285
517
648bf2825ea9 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 514
diff changeset
286 gftpui_common_run_callback_function (cdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
287 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
288
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
289
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
290 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
291 gftpui_run_function_cancel_callback (gftp_window_data * wdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
292 gftp_dialog_data * ddata)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
293 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
294 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
295
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
296 cdata = ddata->yespointer;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
297 if (cdata->input_string != NULL)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
298 g_free (cdata->input_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
299 if (cdata->source_string != NULL)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
300 g_free (cdata->source_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
301 g_free (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
302 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
303
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
304
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
305 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
306 gftpui_mkdir_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
307 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
308 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
309 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
310
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
311 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
312 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
313 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
314 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
315 cdata->run_function = gftpui_common_run_mkdir;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
316
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
317 if (!check_status (_("Mkdir"), wdata, gftpui_common_use_threads (wdata->request), 0, 0, wdata->request->mkdir != NULL))
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
318 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
319
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
320 MakeEditDialog (_("Make Directory"), _("Enter name of directory to create"),
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
321 NULL, 1, NULL, gftp_dialog_button_create,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
322 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
323 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
324 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
325
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
326
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
327 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
328 gftpui_rename_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
329 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
330 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
331 GList *templist, *filelist;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
332 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
333 gftp_file * curfle;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
334 char *tempstr;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
335 int num;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
336
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
337 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
338 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
339 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
340 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
341 cdata->run_function = gftpui_common_run_rename;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
343 if (!check_status (_("Rename"), wdata, gftpui_common_use_threads (wdata->request), 1, 1, wdata->request->rename != NULL))
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
344 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
345
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
346 templist = gftp_gtk_get_list_selection (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
347 num = 0;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
348 filelist = wdata->files;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
349 templist = get_next_selection (templist, &filelist, &num);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
350 curfle = filelist->data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
351 cdata->source_string = g_strdup (curfle->file);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
352
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
353 tempstr = g_strdup_printf (_("What would you like to rename %s to?"),
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
354 cdata->source_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
355 MakeEditDialog (_("Rename"), tempstr, cdata->source_string, 1, NULL,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
356 gftp_dialog_button_rename,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
357 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
358 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
359 g_free (tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
360 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
361
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
362
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
363 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
364 gftpui_site_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
365 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
366 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
367 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
368
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
369 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
370 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
371 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
372 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
373 cdata->run_function = gftpui_common_run_site;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
374
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
375 if (!check_status (_("Site"), wdata, 0, 0, 0, wdata->request->site != NULL))
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
376 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
377
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
378 MakeEditDialog (_("Site"), _("Enter site-specific command"), NULL, 1,
633
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
379 _("Prepend with SITE"), gftp_dialog_button_ok,
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
380 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
381 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
382 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
383
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
384
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
385 int
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
386 gftpui_run_chdir (gpointer uidata, char *directory)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
387 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
388 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
389 gftp_window_data * wdata;
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
390 char *tempstr;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
391 int ret;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
392
556
017b1108305b 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
393 wdata = uidata;
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
394 if ((tempstr = gftp_expand_path (wdata->request, directory)) == NULL)
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
395 return (FALSE);
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
396
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
397 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
398 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
399 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
400 cdata->run_function = gftpui_common_run_chdir;
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
401 cdata->input_string = tempstr;
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 496
diff changeset
402 cdata->dont_clear_cache = 1;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
403
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
404 ret = gftpui_common_run_callback_function (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
405
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
406 g_free(tempstr);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
407 g_free (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
408 return (ret);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
409 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
410
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
411
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
412 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
413 gftpui_chdir_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
414 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
415 GList *templist, *filelist;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
416 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
417 gftp_file * curfle;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
418 char *tempstr;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
419 int num;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
420
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
421 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
422 if (!check_status (_("Chdir"), wdata, gftpui_common_use_threads (wdata->request), 1, 0,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
423 wdata->request->chdir != NULL))
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
424 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
425
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
426 templist = gftp_gtk_get_list_selection (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
427 num = 0;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
428 filelist = wdata->files;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
429 templist = get_next_selection (templist, &filelist, &num);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
430 curfle = filelist->data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
431
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
432 tempstr = gftp_build_path (wdata->request, wdata->request->directory,
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
433 curfle->file, NULL);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
434 gftpui_run_chdir (wdata, tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
435 g_free (tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
436 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
437
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
438
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
439 void
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
440 gftpui_disconnect (void *uidata)
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
441 {
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
442 gftp_window_data * wdata;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
443
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
444 wdata = uidata;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
445 gftp_delete_cache_entry (wdata->request, NULL, 1);
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
446 gftp_disconnect (wdata->request);
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
447 remove_files_window (wdata);
604
5df5eac28f47 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 556
diff changeset
448 update_window_info ();
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
449 }
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
450
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
451
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
452 char *
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
453 gftpui_gtk_get_utf8_file_pos (gftp_file * fle)
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
454 {
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
455 char *disp_item, *pos;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
456
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
457 if (fle->utf8_file != NULL)
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
458 disp_item = fle->utf8_file;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
459 else
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
460 disp_item = fle->file;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
461
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
462 if ((pos = strrchr (disp_item, '/')) != NULL)
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
463 pos++;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
464 else
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
465 pos = disp_item;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
466
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
467 return (pos);
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
468 }
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
469
460
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
470
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
471 static void
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
472 _protocol_yes_answer (gpointer answer, gftp_dialog_data * ddata)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
473 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
474 *(int *) answer = 1;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
475 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
476
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
477
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
478 static void
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
479 _protocol_no_answer (gpointer answer, gftp_dialog_data * ddata)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
480 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
481 *(int *) answer = 0;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
482 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
483
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
484
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
485 int
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
486 gftpui_protocol_ask_yes_no (gftp_request * request, char *title,
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
487 char *question)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
488 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
489 int answer = -1;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
490
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
491 GDK_THREADS_ENTER ();
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
492
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
493 MakeYesNoDialog (title, question, _protocol_yes_answer, &answer,
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
494 _protocol_no_answer, &answer);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
495
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
496 if (gftp_protocols[request->protonum].use_threads)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
497 {
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
498 /* Let the main loop in the main thread run the events */
460
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
499 GDK_THREADS_LEAVE ();
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
500
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
501 while (answer == -1)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
502 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
503 sleep (1);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
504 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
505 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
506 else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
507 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
508 while (answer == -1)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
509 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
510 GDK_THREADS_LEAVE ();
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
511 #if GTK_MAJOR_VERSION == 1
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
512 g_main_iteration (TRUE);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
513 #else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
514 g_main_context_iteration (NULL, TRUE);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
515 #endif
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
516 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
517 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
518
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
519 return (answer);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
520 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
521
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
522
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
523 static void
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
524 _protocol_ok_answer (char *buf, gftp_dialog_data * ddata)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
525 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
526 buf[1] = ' '; /* In case this is an empty string entered */
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
527 strncpy (buf, gtk_entry_get_text (GTK_ENTRY (ddata->edit)), BUFSIZ);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
528 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
529
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
530
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
531 static void
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
532 _protocol_cancel_answer (char *buf, gftp_dialog_data * ddata)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
533 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
534 buf[0] = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
535 buf[1] = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
536 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
537
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
538
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
539 char *
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
540 gftpui_protocol_ask_user_input (gftp_request * request, char *title,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
541 char *question, int shown)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
542 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
543 char buf[BUFSIZ];
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
544
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
545 GDK_THREADS_ENTER ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
546
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
547 *buf = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
548 *(buf + 1) = ' ';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
549 MakeEditDialog (title, question, NULL, shown, NULL, gftp_dialog_button_ok,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
550 _protocol_ok_answer, &buf, _protocol_cancel_answer, &buf);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
551
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
552 if (gftp_protocols[request->protonum].use_threads)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
553 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
554 /* Let the main loop in the main thread run the events */
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
555 GDK_THREADS_LEAVE ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
556
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
557 while (*buf == '\0' && *(buf + 1) == ' ')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
558 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
559 sleep (1);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
560 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
561 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
562 else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
563 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
564 while (*buf == '\0' && *(buf + 1) == ' ')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
565 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
566 GDK_THREADS_LEAVE ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
567 #if GTK_MAJOR_VERSION == 1
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
568 g_main_iteration (TRUE);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
569 #else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
570 g_main_context_iteration (NULL, TRUE);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
571 #endif
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
572 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
573 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
574
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
575 if (*buf != '\0')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
576 return (g_strdup (buf));
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
577 else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
578 return (NULL);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
579 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
580