annotate src/gtk/gtkui.c @ 955:a470d2f7a995

2008-05-21 Jonh Wendell <jwendell@gnome.org> * pt_BR.po: Brazilian Portuguese translation updated by Henrique Machado.
author jwendell
date Wed, 21 May 2008 16:39:19 +0000
parents f37091406523
children
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 */
885
1808cebed602 2007-3-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 884
diff changeset
3 /* Copyright (C) 1998-2007 Brian Masney <masneyb@gftp.org> */
342
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;
879
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
51 wdata->request->refreshing = 1;
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
52
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
53 if (!check_status (_("Refresh"), wdata, 0, 0, 0, 1))
879
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
54 {
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
55 wdata->request->refreshing = 0;
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
56 return;
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
57 }
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
58
807
a3fd5e501513 2006-8-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 775
diff changeset
59 if (clear_cache_entry)
a3fd5e501513 2006-8-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 775
diff changeset
60 gftp_delete_cache_entry (wdata->request, NULL, 0);
a3fd5e501513 2006-8-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 775
diff changeset
61
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
62 if (check_reconnect (wdata) < 0)
879
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
63 {
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
64 wdata->request->refreshing = 0;
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
65 return;
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
66 }
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
67
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
68 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
69 remove_files_window (wdata);
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 496
diff changeset
70
496
937f2b75bbee 2004-7-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
71 ftp_list_files (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
72 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
879
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
73
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
74 wdata->request->refreshing = 0;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
75 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
76
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
77
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
78 #define _GFTPUI_GTK_USER_PW_SIZE 256
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
79
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
80 static void
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
81 _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
82 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
83 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
84 request->stopable = 0;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
85 }
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
86
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
87
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
88 static void
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
89 _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
90 {
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
91 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
92 request->stopable = 0;
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
93 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
94
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 static void
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
97 _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
98 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
99 request->stopable = 0;
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
100 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
101
775
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
102 void
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
103 gftpui_show_busy (gboolean busy)
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
104 {
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
105 GtkWidget * toplevel = gtk_widget_get_toplevel (openurl_btn);
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
106 GdkDisplay * display = gtk_widget_get_display (toplevel);
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
107
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
108 GdkCursor * busyCursor =
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
109 (busy) ? (gdk_cursor_new_for_display (display, GDK_WATCH)) : NULL;
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
110
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
111 gdk_window_set_cursor (toplevel->window, busyCursor);
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
112
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
113 if (busy)
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
114 gdk_cursor_unref (busyCursor);
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
115 }
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
116
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
117 void
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
118 gftpui_prompt_username (void *uidata, gftp_request * request)
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
119 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
120 MakeEditDialog (_("Enter Username"),
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
121 _("Please enter your username for this site"), NULL,
755
6d19d4a8adee 2006-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 679
diff changeset
122 1, NULL, gftp_dialog_button_connect,
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
123 _gftpui_gtk_set_username, request,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
124 _gftpui_gtk_abort, request);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
125
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
126 request->stopable = 1;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
127 while (request->stopable)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
128 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
129 GDK_THREADS_LEAVE ();
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
130 #if GTK_MAJOR_VERSION == 1
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
131 g_main_iteration (TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
132 #else
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
133 g_main_context_iteration (NULL, TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
134 #endif
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 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
137
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
138
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
139 void
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
140 gftpui_prompt_password (void *uidata, gftp_request * request)
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
141 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
142 MakeEditDialog (_("Enter Password"),
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
143 _("Please enter your password for this site"), NULL,
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
144 0, NULL, gftp_dialog_button_connect,
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
145 _gftpui_gtk_set_password, request,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
146 _gftpui_gtk_abort, request);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
147
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
148 request->stopable = 1;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
149 while (request->stopable)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
150 {
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
151 GDK_THREADS_LEAVE ();
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
152 #if GTK_MAJOR_VERSION == 1
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
153 g_main_iteration (TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
154 #else
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
155 g_main_context_iteration (NULL, TRUE);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
156 #endif
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
157 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
158 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
159
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
160
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
161 /* 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
162 there won't be a delay in updating the GUI */
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
163 static void
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
164 _gftpui_wakeup_main_thread (gpointer data, gint source,
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
165 GdkInputCondition condition)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
166 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
167 gftp_request * request;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
168 char c;
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 request = data;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
171 if (request->wakeup_main_thread[0] > 0)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
172 read (request->wakeup_main_thread[0], &c, 1);
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
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
175
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
176 static gint
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
177 _gftpui_setup_wakeup_main_thread (gftp_request * request)
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 gint handler;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
180
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
181 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
182 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
183 handler = gdk_input_add (request->wakeup_main_thread[0],
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
184 GDK_INPUT_READ, _gftpui_wakeup_main_thread,
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
185 request);
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 else
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
188 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
189 request->wakeup_main_thread[0] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
190 request->wakeup_main_thread[1] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
191 handler = 0;
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
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
194 return (handler);
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
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
197
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
198 static void
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
199 _gftpui_teardown_wakeup_main_thread (gftp_request * request, gint handler)
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 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
202 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
203 gdk_input_remove (handler);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
204 close (request->wakeup_main_thread[0]);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
205 close (request->wakeup_main_thread[1]);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
206 request->wakeup_main_thread[0] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
207 request->wakeup_main_thread[1] = 0;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
208 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
209 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
210
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
211 static void *
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
212 _gftpui_gtk_thread_func (void *data)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
213 {
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
214 gftpui_gtk_thread_data * thread_data;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
215 void *ret;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
216
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
217 thread_data = data;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
218 ret = thread_data->func (thread_data->cdata);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
219
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
220 if (thread_data->cdata->request->wakeup_main_thread[1] > 0)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
221 write (thread_data->cdata->request->wakeup_main_thread[1], " ", 1);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
222
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
223 return (ret);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
224 }
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
225
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
226
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
227 void *
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
228 gftpui_generic_thread (void * (*func) (void *), void *data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
229 {
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
230 gftpui_gtk_thread_data * thread_data;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
231 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
232 gftp_window_data * wdata;
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
233 gint handler;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
234 void * ret;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
235
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
236 cdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
237 wdata = cdata->uidata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
238
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
239 wdata->request->stopable = 1;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
240 gtk_widget_set_sensitive (stop_btn, 1);
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
241
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
242 thread_data = g_malloc0 (sizeof (*thread_data));
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
243 thread_data->func = func;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
244 thread_data->cdata = cdata;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
245
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
246 handler = _gftpui_setup_wakeup_main_thread (cdata->request);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
247 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
248
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
249 while (wdata->request->stopable)
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 GDK_THREADS_LEAVE ();
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
252 #if GTK_MAJOR_VERSION == 1
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
253 g_main_iteration (TRUE);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
254 #else
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
255 g_main_context_iteration (NULL, TRUE);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
256 #endif
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
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
259 _gftpui_teardown_wakeup_main_thread (cdata->request, handler);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
260 g_free (thread_data);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
261
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
262 pthread_join (wdata->tid, &ret);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
263 gtk_widget_set_sensitive (stop_btn, 0);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
264
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
265 if (!GFTP_IS_CONNECTED (wdata->request))
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
266 gftpui_disconnect (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
267
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
268 return (ret);
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
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
271
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
272 int
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
273 gftpui_check_reconnect (gftpui_callback_data * cdata)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
274 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
275 gftp_window_data * wdata;
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 wdata = cdata->uidata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
278 return (wdata->request->cached && wdata->request->datafd < 0 &&
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
279 !wdata->request->always_connected &&
767
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 755
diff changeset
280 !ftp_connect (wdata, wdata->request) ? -1 : 0);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
281 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
282
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
283
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
284 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
285 gftpui_run_function_callback (gftp_window_data * wdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
286 gftp_dialog_data * ddata)
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 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
289 const char *edttext;
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 cdata = ddata->yespointer;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
292 if (ddata->edit != NULL)
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 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
295 if (*edttext == '\0')
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
296 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 633
diff changeset
297 ftp_log (gftp_logging_error, NULL,
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
298 _("Operation canceled...you must enter a string\n"));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
299 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
300 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
301
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
302 cdata->input_string = g_strdup (edttext);
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
633
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
305 if (ddata->checkbox != NULL)
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
306 cdata->toggled = GTK_TOGGLE_BUTTON (ddata->checkbox)->active;
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
307 else
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
308 cdata->toggled = 0;
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
309
679
f41c33110f8e 2005-1-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
310 gtk_widget_destroy (ddata->dialog);
f41c33110f8e 2005-1-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
311 ddata->dialog = NULL;
f41c33110f8e 2005-1-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
312
517
648bf2825ea9 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 514
diff changeset
313 gftpui_common_run_callback_function (cdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
314 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
315
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 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
318 gftpui_run_function_cancel_callback (gftp_window_data * wdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
319 gftp_dialog_data * ddata)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
320 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
321 gftpui_callback_data * cdata;
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 cdata = ddata->yespointer;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
324 if (cdata->input_string != NULL)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
325 g_free (cdata->input_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
326 if (cdata->source_string != NULL)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
327 g_free (cdata->source_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
328 g_free (cdata);
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
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
331
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
332 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
333 gftpui_mkdir_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
334 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
335 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
336 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
337
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
338 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
339 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
340 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
341 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
342 cdata->run_function = gftpui_common_run_mkdir;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
343
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
344 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
345 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
346
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
347 MakeEditDialog (_("Make Directory"), _("Enter name of directory to create"),
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
348 NULL, 1, NULL, gftp_dialog_button_create,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
349 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
350 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
351 }
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
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
354 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
355 gftpui_rename_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
356 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
357 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
358 GList *templist, *filelist;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
359 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
360 gftp_file * curfle;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
361 char *tempstr;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
362 int num;
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 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
365 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
366 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
367 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
368 cdata->run_function = gftpui_common_run_rename;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
369
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
370 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
371 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
372
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
373 templist = gftp_gtk_get_list_selection (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
374 num = 0;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
375 filelist = wdata->files;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
376 templist = get_next_selection (templist, &filelist, &num);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
377 curfle = filelist->data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
378 cdata->source_string = g_strdup (curfle->file);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
379
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
380 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
381 cdata->source_string);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
382 MakeEditDialog (_("Rename"), tempstr, cdata->source_string, 1, NULL,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
383 gftp_dialog_button_rename,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
384 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
385 gftpui_run_function_cancel_callback, cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
386 g_free (tempstr);
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
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
389
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
390 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
391 gftpui_site_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
392 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
393 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
394 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
395
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
396 wdata = data;
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_site;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
401
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
402 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
403 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
404
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
405 MakeEditDialog (_("Site"), _("Enter site-specific command"), NULL, 1,
633
05c67a33b071 2004-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 604
diff changeset
406 _("Prepend with SITE"), gftp_dialog_button_ok,
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
407 gftpui_run_function_callback, cdata,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
408 gftpui_run_function_cancel_callback, cdata);
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 int
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
413 gftpui_run_chdir (gpointer uidata, char *directory)
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 gftpui_callback_data * cdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
416 gftp_window_data * wdata;
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
417 char *tempstr;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
418 int ret;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
419
556
017b1108305b 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
420 wdata = uidata;
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
421 if ((tempstr = gftp_expand_path (wdata->request, directory)) == NULL)
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
422 return (FALSE);
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
423
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
424 cdata = g_malloc0 (sizeof (*cdata));
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
425 cdata->request = wdata->request;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
426 cdata->uidata = wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
427 cdata->run_function = gftpui_common_run_chdir;
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
428 cdata->input_string = tempstr;
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 496
diff changeset
429 cdata->dont_clear_cache = 1;
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
430
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
431 ret = gftpui_common_run_callback_function (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
432
470
a68273d9725a 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
433 g_free(tempstr);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
434 g_free (cdata);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
435 return (ret);
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
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
438
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
439 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
440 gftpui_chdir_dialog (gpointer data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
441 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
442 GList *templist, *filelist;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
443 gftp_window_data * wdata;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
444 gftp_file * curfle;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
445 char *tempstr;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
446 int num;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
447
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
448 wdata = data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
449 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
450 wdata->request->chdir != NULL))
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
451 return;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
452
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
453 templist = gftp_gtk_get_list_selection (wdata);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
454 num = 0;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
455 filelist = wdata->files;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
456 templist = get_next_selection (templist, &filelist, &num);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
457 curfle = filelist->data;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
458
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
459 tempstr = gftp_build_path (wdata->request, wdata->request->directory,
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
460 curfle->file, NULL);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
461 gftpui_run_chdir (wdata, tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
462 g_free (tempstr);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
463 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
464
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
465
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
466 void
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
467 gftpui_disconnect (void *uidata)
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
468 {
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
469 gftp_window_data * wdata;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
470
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
471 wdata = uidata;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
472 gftp_delete_cache_entry (wdata->request, NULL, 1);
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
473 gftp_disconnect (wdata->request);
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
474 remove_files_window (wdata);
912
1f9c6baa458c 2007-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
475
1f9c6baa458c 2007-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
476 /* Free the request structure so that all old settings are purged. */
924
f37091406523 2007-5-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 912
diff changeset
477 gftp_request_destroy (wdata->request, 0);
912
1f9c6baa458c 2007-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
478 gftp_gtk_init_request (wdata);
1f9c6baa458c 2007-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
479
604
5df5eac28f47 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 556
diff changeset
480 update_window_info ();
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
481 }
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
482
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
483
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
484 char *
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
485 gftpui_gtk_get_utf8_file_pos (gftp_file * fle)
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
486 {
830
afbe37351940 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 807
diff changeset
487 char *pos;
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
488
830
afbe37351940 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 807
diff changeset
489 if ((pos = strrchr (fle->file, '/')) != NULL)
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
490 pos++;
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
491 else
830
afbe37351940 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 807
diff changeset
492 pos = fle->file;
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
493
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
494 return (pos);
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
495 }
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
496
460
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
497
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
498 static void
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
499 _protocol_yes_answer (gpointer answer, gftp_dialog_data * ddata)
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 *(int *) 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
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 static void
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
506 _protocol_no_answer (gpointer answer, gftp_dialog_data * ddata)
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 *(int *) answer = 0;
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
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
511
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
512 int
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
513 gftpui_protocol_ask_yes_no (gftp_request * request, char *title,
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
514 char *question)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
515 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
516 int answer = -1;
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 GDK_THREADS_ENTER ();
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 MakeYesNoDialog (title, question, _protocol_yes_answer, &answer,
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
521 _protocol_no_answer, &answer);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
522
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
523 if (gftp_protocols[request->protonum].use_threads)
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 /* 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
526 GDK_THREADS_LEAVE ();
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
527
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
528 while (answer == -1)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
529 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
530 sleep (1);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
531 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
532 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
533 else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
534 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
535 while (answer == -1)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
536 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
537 GDK_THREADS_LEAVE ();
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
538 #if GTK_MAJOR_VERSION == 1
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
539 g_main_iteration (TRUE);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
540 #else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
541 g_main_context_iteration (NULL, TRUE);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
542 #endif
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
543 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
544 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
545
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
546 return (answer);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
547 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
548
484
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 static void
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
551 _protocol_ok_answer (char *buf, gftp_dialog_data * ddata)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
552 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
553 buf[1] = ' '; /* In case this is an empty string entered */
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
554 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
555 }
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
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
558 static void
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
559 _protocol_cancel_answer (char *buf, gftp_dialog_data * ddata)
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 buf[0] = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
562 buf[1] = '\0';
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
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
566 char *
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
567 gftpui_protocol_ask_user_input (gftp_request * request, char *title,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
568 char *question, int shown)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
569 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
570 char buf[BUFSIZ];
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
571
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
572 GDK_THREADS_ENTER ();
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 *buf = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
575 *(buf + 1) = ' ';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
576 MakeEditDialog (title, question, NULL, shown, NULL, gftp_dialog_button_ok,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
577 _protocol_ok_answer, &buf, _protocol_cancel_answer, &buf);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
578
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
579 if (gftp_protocols[request->protonum].use_threads)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
580 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
581 /* 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
582 GDK_THREADS_LEAVE ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
583
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
584 while (*buf == '\0' && *(buf + 1) == ' ')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
585 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
586 sleep (1);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
587 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
588 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
589 else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
590 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
591 while (*buf == '\0' && *(buf + 1) == ' ')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
592 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
593 GDK_THREADS_LEAVE ();
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
594 #if GTK_MAJOR_VERSION == 1
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
595 g_main_iteration (TRUE);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
596 #else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
597 g_main_context_iteration (NULL, TRUE);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
598 #endif
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
599 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
600 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
601
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
602 if (*buf != '\0')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
603 return (g_strdup (buf));
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
604 else
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
605 return (NULL);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
606 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 470
diff changeset
607