annotate src/gtk/gtkui.c @ 767:49cfbe02926b

2006-7-13 Brian Masney <masneyb@gftp.org> * src/gtk/bookmarks.c src/gtk/delete_dialog.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/gtkui.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/options_dialog.c src/gtk/transfer.c src/gtk/view_dialog.c - fixed a few minor warnings from splint.
author masneyb
date Fri, 14 Jul 2006 01:53:42 +0000
parents 6d19d4a8adee
children c1144630c4f4
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,
755
6d19d4a8adee 2006-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 679
diff changeset
98 1, 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 &&
767
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 755
diff changeset
256 !ftp_connect (wdata, wdata->request) ? -1 : 0);
342
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 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 633
diff changeset
273 ftp_log (gftp_logging_error, NULL,
342
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
679
f41c33110f8e 2005-1-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
286 gtk_widget_destroy (ddata->dialog);
f41c33110f8e 2005-1-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
287 ddata->dialog = NULL;
f41c33110f8e 2005-1-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
288
517
648bf2825ea9 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 514
diff changeset
289 gftpui_common_run_callback_function (cdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
290 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
291
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
292
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
293 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
294 gftpui_run_function_cancel_callback (gftp_window_data * wdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
295 gftp_dialog_data * ddata)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
296 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
297 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
298
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
299 cdata = ddata->yespointer;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
300 if (cdata->input_string != NULL)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
301 g_free (cdata->input_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
302 if (cdata->source_string != NULL)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
303 g_free (cdata->source_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
304 g_free (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
305 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
306
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 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
309 gftpui_mkdir_dialog (gpointer data)
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 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
312 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
313
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
314 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
315 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
316 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
317 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
318 cdata->run_function = gftpui_common_run_mkdir;
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 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
321 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
322
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
323 MakeEditDialog (_("Make Directory"), _("Enter name of directory to create"),
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
324 NULL, 1, NULL, gftp_dialog_button_create,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
325 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
326 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
327 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
328
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 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
331 gftpui_rename_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
332 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
333 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
334 GList *templist, *filelist;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
335 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
336 gftp_file * curfle;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
337 char *tempstr;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
338 int num;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
339
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
340 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
341 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
342 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
343 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
344 cdata->run_function = gftpui_common_run_rename;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
345
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
346 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
347 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
348
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
349 templist = gftp_gtk_get_list_selection (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
350 num = 0;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
351 filelist = wdata->files;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
352 templist = get_next_selection (templist, &filelist, &num);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
353 curfle = filelist->data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
354 cdata->source_string = g_strdup (curfle->file);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
355
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
356 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
357 cdata->source_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
358 MakeEditDialog (_("Rename"), tempstr, cdata->source_string, 1, NULL,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
359 gftp_dialog_button_rename,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
360 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
361 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
362 g_free (tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
363 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
364
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 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
367 gftpui_site_dialog (gpointer data)
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 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
370 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
371
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
372 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
373 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
374 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
375 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
376 cdata->run_function = gftpui_common_run_site;
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 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
379 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
380
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
381 MakeEditDialog (_("Site"), _("Enter site-specific command"), NULL, 1,
633
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
382 _("Prepend with SITE"), gftp_dialog_button_ok,
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
383 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
384 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
385 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
386
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 int
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
389 gftpui_run_chdir (gpointer uidata, char *directory)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
390 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
391 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
392 gftp_window_data * wdata;
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
393 char *tempstr;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
394 int ret;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
395
556
017b1108305b 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
396 wdata = uidata;
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
397 if ((tempstr = gftp_expand_path (wdata->request, directory)) == NULL)
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
398 return (FALSE);
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
399
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
400 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
401 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
402 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
403 cdata->run_function = gftpui_common_run_chdir;
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
404 cdata->input_string = tempstr;
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 496
diff changeset
405 cdata->dont_clear_cache = 1;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
406
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
407 ret = gftpui_common_run_callback_function (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
408
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
409 g_free(tempstr);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
410 g_free (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
411 return (ret);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
412 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
413
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 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
416 gftpui_chdir_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
417 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
418 GList *templist, *filelist;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
419 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
420 gftp_file * curfle;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
421 char *tempstr;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
422 int num;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
423
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
424 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
425 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
426 wdata->request->chdir != NULL))
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
427 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
428
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
429 templist = gftp_gtk_get_list_selection (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
430 num = 0;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
431 filelist = wdata->files;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
432 templist = get_next_selection (templist, &filelist, &num);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
433 curfle = filelist->data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
434
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
435 tempstr = gftp_build_path (wdata->request, wdata->request->directory,
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
436 curfle->file, NULL);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
437 gftpui_run_chdir (wdata, tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
438 g_free (tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
439 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
440
380
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 void
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
443 gftpui_disconnect (void *uidata)
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
444 {
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
445 gftp_window_data * wdata;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
446
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
447 wdata = uidata;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
448 gftp_delete_cache_entry (wdata->request, NULL, 1);
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
449 gftp_disconnect (wdata->request);
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
450 remove_files_window (wdata);
604
5df5eac28f47 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 556
diff changeset
451 update_window_info ();
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
452 }
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
453
397
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 *
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
456 gftpui_gtk_get_utf8_file_pos (gftp_file * fle)
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
457 {
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
458 char *disp_item, *pos;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
459
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
460 if (fle->utf8_file != NULL)
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
461 disp_item = fle->utf8_file;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
462 else
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
463 disp_item = fle->file;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
464
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
465 if ((pos = strrchr (disp_item, '/')) != NULL)
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
466 pos++;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
467 else
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
468 pos = disp_item;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
469
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
470 return (pos);
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
471 }
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
472
460
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 static void
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
475 _protocol_yes_answer (gpointer answer, gftp_dialog_data * ddata)
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 *(int *) answer = 1;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
478 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
479
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 static void
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
482 _protocol_no_answer (gpointer answer, gftp_dialog_data * ddata)
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 *(int *) answer = 0;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
485 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
486
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
487
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
488 int
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
489 gftpui_protocol_ask_yes_no (gftp_request * request, char *title,
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
490 char *question)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
491 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
492 int answer = -1;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
493
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
494 GDK_THREADS_ENTER ();
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 MakeYesNoDialog (title, question, _protocol_yes_answer, &answer,
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
497 _protocol_no_answer, &answer);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
498
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
499 if (gftp_protocols[request->protonum].use_threads)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
500 {
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
501 /* 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
502 GDK_THREADS_LEAVE ();
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
503
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
504 while (answer == -1)
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 sleep (1);
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 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
509 else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
510 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
511 while (answer == -1)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
512 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
513 GDK_THREADS_LEAVE ();
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
514 #if GTK_MAJOR_VERSION == 1
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
515 g_main_iteration (TRUE);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
516 #else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
517 g_main_context_iteration (NULL, TRUE);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
518 #endif
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
519 }
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
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
522 return (answer);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
523 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
524
484
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 static void
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
527 _protocol_ok_answer (char *buf, gftp_dialog_data * ddata)
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 buf[1] = ' '; /* In case this is an empty string entered */
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
530 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
531 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
532
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 static void
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
535 _protocol_cancel_answer (char *buf, gftp_dialog_data * ddata)
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 buf[0] = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
538 buf[1] = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
539 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
540
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
541
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
542 char *
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
543 gftpui_protocol_ask_user_input (gftp_request * request, char *title,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
544 char *question, int shown)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
545 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
546 char buf[BUFSIZ];
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
547
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
548 GDK_THREADS_ENTER ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
549
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
550 *buf = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
551 *(buf + 1) = ' ';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
552 MakeEditDialog (title, question, NULL, shown, NULL, gftp_dialog_button_ok,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
553 _protocol_ok_answer, &buf, _protocol_cancel_answer, &buf);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
554
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
555 if (gftp_protocols[request->protonum].use_threads)
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 /* 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
558 GDK_THREADS_LEAVE ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
559
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
560 while (*buf == '\0' && *(buf + 1) == ' ')
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 sleep (1);
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 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
565 else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
566 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
567 while (*buf == '\0' && *(buf + 1) == ' ')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
568 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
569 GDK_THREADS_LEAVE ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
570 #if GTK_MAJOR_VERSION == 1
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
571 g_main_iteration (TRUE);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
572 #else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
573 g_main_context_iteration (NULL, TRUE);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
574 #endif
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
575 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
576 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
577
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
578 if (*buf != '\0')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
579 return (g_strdup (buf));
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
580 else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
581 return (NULL);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
582 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
583