Mercurial > gftp.yaz
annotate src/gtk/gftp-gtk.c @ 788:0e7ab0a51ddd
2006-7-28 Brian Masney <masneyb@gftp.org>
* src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/misc-gtk.c - warning
fixes when creating the system menus. Removed some unused global
variables.
author | masneyb |
---|---|
date | Fri, 28 Jul 2006 11:20:05 +0000 |
parents | 6cfc7104e23b |
children | afe56dd107ca |
rev | line source |
---|---|
1 | 1 /*****************************************************************************/ |
2 /* gftp-gtk.c - GTK+ 1.2 port of gftp */ | |
255 | 3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */ |
1 | 4 /* */ |
5 /* This program is free software; you can redistribute it and/or modify */ | |
6 /* it under the terms of the GNU General Public License as published by */ | |
7 /* the Free Software Foundation; either version 2 of the License, or */ | |
8 /* (at your option) any later version. */ | |
9 /* */ | |
10 /* This program is distributed in the hope that it will be useful, */ | |
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | |
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | |
13 /* GNU General Public License for more details. */ | |
14 /* */ | |
15 /* You should have received a copy of the GNU General Public License */ | |
16 /* along with this program; if not, write to the Free Software */ | |
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */ | |
18 /*****************************************************************************/ | |
19 | |
20 #include "gftp-gtk.h" | |
33 | 21 static const char cvsid[] = "$Id$"; |
1 | 22 |
23 static GtkItemFactory *log_factory, *dl_factory; | |
24 static GtkWidget * local_frame, * remote_frame, * log_table, * transfer_scroll, | |
604 | 25 * gftpui_command_toolbar; |
1 | 26 |
27 gftp_window_data window1, window2, *other_wdata, *current_wdata; | |
28 GtkWidget * stop_btn, * hostedit, * useredit, * passedit, * portedit, * logwdw, | |
587 | 29 * dlwdw, * protocol_menu, * optionmenu, * gftpui_command_widget, |
604 | 30 * download_left_arrow, * upload_right_arrow, * openurl_btn; |
31 GtkTooltips * openurl_tooltip; | |
1 | 32 GtkAdjustment * logwdw_vadj; |
45 | 33 #if GTK_MAJOR_VERSION > 1 |
1 | 34 GtkTextMark * logwdw_textmark; |
35 #endif | |
788 | 36 int local_start, remote_start, trans_start; |
1 | 37 GHashTable * graphic_hash_table = NULL; |
38 GtkItemFactoryEntry * menus = NULL; | |
39 GtkItemFactory * factory = NULL; | |
40 pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; | |
19 | 41 gftp_graphic * gftp_icon; |
56 | 42 pthread_t main_thread_id; |
129 | 43 GList * viewedit_processes = NULL; |
42 | 44 |
48 | 45 static int |
46 get_column (GtkCListColumn * col) | |
1 | 47 { |
48 | 48 if (col->auto_resize) |
49 return (0); | |
50 else if (!col->visible) | |
51 return (-1); | |
52 else | |
53 return (col->width); | |
54 } | |
42 | 55 |
1 | 56 |
48 | 57 static void |
505 | 58 _gftp_exit (GtkWidget * widget, gpointer data) |
48 | 59 { |
616 | 60 const char *tempstr; |
472 | 61 intptr_t ret; |
129 | 62 |
63 ret = GTK_WIDGET (local_frame)->allocation.width; | |
227 | 64 gftp_set_global_option ("listbox_local_width", GINT_TO_POINTER (ret)); |
129 | 65 ret = GTK_WIDGET (remote_frame)->allocation.width; |
227 | 66 gftp_set_global_option ("listbox_remote_width", GINT_TO_POINTER (ret)); |
129 | 67 ret = GTK_WIDGET (remote_frame)->allocation.height; |
227 | 68 gftp_set_global_option ("listbox_file_height", GINT_TO_POINTER (ret)); |
129 | 69 ret = GTK_WIDGET (log_table)->allocation.height; |
227 | 70 gftp_set_global_option ("log_height", GINT_TO_POINTER (ret)); |
129 | 71 ret = GTK_WIDGET (transfer_scroll)->allocation.height; |
227 | 72 gftp_set_global_option ("transfer_height", GINT_TO_POINTER (ret)); |
129 | 73 |
74 ret = get_column (>K_CLIST (dlwdw)->column[0]); | |
227 | 75 gftp_set_global_option ("file_trans_column", GINT_TO_POINTER (ret)); |
1 | 76 |
129 | 77 ret = get_column (>K_CLIST (window1.listbox)->column[1]); |
227 | 78 gftp_set_global_option ("local_file_width", GINT_TO_POINTER (ret)); |
129 | 79 ret = get_column (>K_CLIST (window1.listbox)->column[2]); |
227 | 80 gftp_set_global_option ("local_size_width", GINT_TO_POINTER (ret)); |
129 | 81 ret = get_column (>K_CLIST (window1.listbox)->column[3]); |
227 | 82 gftp_set_global_option ("local_user_width", GINT_TO_POINTER (ret)); |
129 | 83 ret = get_column (>K_CLIST (window1.listbox)->column[4]); |
227 | 84 gftp_set_global_option ("local_group_width", GINT_TO_POINTER (ret)); |
129 | 85 ret = get_column (>K_CLIST (window1.listbox)->column[5]); |
227 | 86 gftp_set_global_option ("local_date_width", GINT_TO_POINTER (ret)); |
129 | 87 ret = get_column (>K_CLIST (window1.listbox)->column[6]); |
227 | 88 gftp_set_global_option ("local_attribs_width", GINT_TO_POINTER (ret)); |
1 | 89 |
129 | 90 ret = get_column (>K_CLIST (window2.listbox)->column[1]); |
227 | 91 gftp_set_global_option ("remote_file_width", GINT_TO_POINTER (ret)); |
129 | 92 ret = get_column (>K_CLIST (window2.listbox)->column[2]); |
227 | 93 gftp_set_global_option ("remote_size_width", GINT_TO_POINTER (ret)); |
129 | 94 ret = get_column (>K_CLIST (window2.listbox)->column[3]); |
227 | 95 gftp_set_global_option ("remote_user_width", GINT_TO_POINTER (ret)); |
129 | 96 ret = get_column (>K_CLIST (window2.listbox)->column[4]); |
227 | 97 gftp_set_global_option ("remote_group_width", GINT_TO_POINTER (ret)); |
129 | 98 ret = get_column (>K_CLIST (window2.listbox)->column[5]); |
227 | 99 gftp_set_global_option ("remote_date_width", GINT_TO_POINTER (ret)); |
129 | 100 ret = get_column (>K_CLIST (window2.listbox)->column[6]); |
227 | 101 gftp_set_global_option ("remote_attribs_width", GINT_TO_POINTER (ret)); |
37 | 102 |
616 | 103 tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); |
104 gftp_set_global_option ("host_value", tempstr); | |
105 | |
106 tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (portedit)->entry)); | |
107 gftp_set_global_option ("port_value", tempstr); | |
108 | |
109 tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry)); | |
110 gftp_set_global_option ("user_value", tempstr); | |
111 | |
201 | 112 gftp_shutdown (); |
48 | 113 exit (0); |
1 | 114 } |
115 | |
116 | |
117 static gint | |
505 | 118 _gftp_try_close (GtkWidget * widget, GdkEvent * event, gpointer data) |
1 | 119 { |
129 | 120 if (gftp_file_transfers == NULL) |
505 | 121 { |
122 _gftp_exit (NULL, NULL); | |
123 return (0); | |
124 } | |
1 | 125 else |
126 { | |
505 | 127 MakeYesNoDialog (_("Exit"), _("There are file transfers in progress.\nAre you sure you want to exit?"), _gftp_exit, NULL, NULL, NULL); |
128 return (1); | |
1 | 129 } |
130 } | |
131 | |
132 | |
133 static void | |
505 | 134 _gftp_force_close (GtkWidget * widget, gpointer data) |
1 | 135 { |
136 exit (0); | |
137 } | |
138 | |
139 | |
48 | 140 static void |
505 | 141 _gftp_menu_exit (GtkWidget * widget, gpointer data) |
1 | 142 { |
505 | 143 if (!_gftp_try_close (widget, NULL, data)) |
144 _gftp_exit (widget, data); | |
48 | 145 } |
1 | 146 |
147 | |
374 | 148 static void |
149 change_setting (gftp_window_data * wdata, int menuitem, GtkWidget * checkmenu) | |
150 { | |
151 switch (menuitem) | |
152 { | |
505 | 153 case GFTP_MENU_ITEM_ASCII: |
374 | 154 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(1)); |
155 break; | |
505 | 156 case GFTP_MENU_ITEM_BINARY: |
374 | 157 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(0)); |
158 break; | |
505 | 159 case GFTP_MENU_ITEM_WIN1: |
374 | 160 current_wdata = &window1; |
161 other_wdata = &window2; | |
505 | 162 if (wdata->request != NULL) |
374 | 163 update_window_info (); |
164 break; | |
505 | 165 case GFTP_MENU_ITEM_WIN2: |
374 | 166 current_wdata = &window2; |
167 other_wdata = &window1; | |
505 | 168 if (wdata->request != NULL) |
374 | 169 update_window_info (); |
170 break; | |
171 } | |
172 } | |
173 | |
174 | |
175 static void | |
176 _gftpui_gtk_do_openurl (gftp_window_data * wdata, gftp_dialog_data * ddata) | |
177 { | |
425 | 178 const char *tempstr; |
179 char *buf; | |
374 | 180 |
425 | 181 tempstr = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); |
182 if (tempstr != NULL && *tempstr != '\0') | |
183 { | |
184 buf = g_strdup (tempstr); | |
185 destroy_dialog (ddata); | |
186 gftpui_common_cmd_open (wdata, wdata->request, NULL, NULL, buf); | |
187 g_free (buf); | |
188 } | |
374 | 189 } |
190 | |
191 | |
192 static void | |
193 openurl_dialog (gpointer data) | |
194 { | |
195 gftp_window_data * wdata; | |
196 | |
197 wdata = data; | |
784 | 198 MakeEditDialog (_("Open Location"), _("Enter a URL to connect to"), |
374 | 199 NULL, 1, NULL, gftp_dialog_button_connect, |
200 _gftpui_gtk_do_openurl, wdata, | |
201 NULL, NULL); | |
202 } | |
203 | |
204 | |
205 static void | |
206 tb_openurl_dialog (gpointer data) | |
207 { | |
208 const char *edttxt; | |
209 | |
210 if (current_wdata->request->stopable) | |
211 { | |
677 | 212 ftp_log (gftp_logging_error, NULL, |
374 | 213 _("%s: Please hit the stop button first to do anything else\n"), |
784 | 214 _("Open Location")); |
374 | 215 return; |
216 } | |
217 | |
218 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); | |
219 | |
220 if (GFTP_IS_CONNECTED (current_wdata->request)) | |
380 | 221 gftpui_disconnect (current_wdata); |
374 | 222 else if (edttxt != NULL && *edttxt != '\0') |
223 toolbar_hostedit (NULL, NULL); | |
224 else | |
225 openurl_dialog (current_wdata); | |
226 } | |
227 | |
228 | |
514 | 229 static void |
230 gftp_gtk_refresh (gftp_window_data * wdata) | |
231 { | |
232 gftpui_refresh (wdata, 1); | |
233 } | |
234 | |
235 | |
1 | 236 static GtkWidget * |
237 CreateMenus (GtkWidget * parent) | |
238 { | |
788 | 239 int local_len, remote_len, len, i, trans_len, log_len, tools_len, log_start; |
1 | 240 GtkAccelGroup *accel_group; |
505 | 241 intptr_t ascii_transfers; |
1 | 242 GtkWidget * tempwid; |
7 | 243 static GtkItemFactoryEntry menu_items[] = { |
12 | 244 {N_("/_FTP"), NULL, 0, 0, MN_("<Branch>")}, |
245 {N_("/FTP/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, | |
771 | 246 {N_("/FTP/Window _1"), NULL, change_setting, GFTP_MENU_ITEM_WIN1, |
505 | 247 MN_("<RadioItem>")}, |
771 | 248 {N_("/FTP/Window _2"), NULL, change_setting, GFTP_MENU_ITEM_WIN2, |
505 | 249 MN_("/FTP/Window 1")}, |
12 | 250 {N_("/FTP/sep"), NULL, 0, 0, MN_("<Separator>")}, |
788 | 251 {N_("/FTP/Ascii"), NULL, change_setting, GFTP_MENU_ITEM_ASCII, |
505 | 252 MN_("<RadioItem>")}, |
788 | 253 {N_("/FTP/Binary"), NULL, change_setting, GFTP_MENU_ITEM_BINARY, |
505 | 254 MN_("/FTP/Ascii")}, |
12 | 255 {N_("/FTP/sep"), NULL, 0, 0, MN_("<Separator>")}, |
771 | 256 {N_("/FTP/_Preferences..."), NULL, options_dialog, 0, |
12 | 257 MS_(GTK_STOCK_PREFERENCES)}, |
258 {N_("/FTP/sep"), NULL, 0, 0, MN_("<Separator>")}, | |
505 | 259 {N_("/FTP/_Quit"), "<control>Q", _gftp_menu_exit, 0, MS_(GTK_STOCK_QUIT)}, |
12 | 260 {N_("/_Local"), NULL, 0, 0, MN_("<Branch>")}, |
261 {N_("/Local/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, | |
784 | 262 {N_("/Local/Open Location..."), "", openurl_dialog, 0, MS_(GTK_STOCK_OPEN)}, |
771 | 263 {N_("/Local/_Disconnect"), "", gftpui_disconnect, 0, MS_(GTK_STOCK_CLOSE)}, |
12 | 264 {N_("/Local/sep"), NULL, 0, 0, MN_("<Separator>")}, |
265 {N_("/Local/Change Filespec..."), NULL, change_filespec, 0, MN_(NULL)}, | |
771 | 266 {N_("/Local/_Show selected"), NULL, show_selected, 0, MN_(NULL)}, |
267 {N_("/Local/Select _All"), NULL, selectall, 0, MN_(NULL)}, | |
12 | 268 {N_("/Local/Select All Files"), NULL, selectallfiles, 0, MN_(NULL)}, |
269 {N_("/Local/Deselect All"), NULL, deselectall, 0, MN_(NULL)}, | |
270 {N_("/Local/sep"), NULL, 0, 0, MN_("<Separator>")}, | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
12
diff
changeset
|
271 {N_("/Local/Save Directory Listing..."), NULL, save_directory_listing, 0, MN_(NULL)}, |
341 | 272 {N_("/Local/Send SITE Command..."), NULL, gftpui_site_dialog, 0, MN_(NULL)}, |
273 {N_("/Local/Change Directory"), NULL, gftpui_chdir_dialog, 0, MN_(NULL)}, | |
771 | 274 {N_("/Local/_Permissions..."), NULL, chmod_dialog, 0, MN_(NULL)}, |
275 {N_("/Local/_New Folder..."), "<control><shift>N", gftpui_mkdir_dialog, 0, MN_(NULL)}, | |
276 {N_("/Local/Re_name..."), "F2", gftpui_rename_dialog, 0, MN_(NULL)}, | |
12 | 277 {N_("/Local/Delete..."), NULL, delete_dialog, 0, MN_(NULL)}, |
771 | 278 {N_("/Local/_Edit..."), NULL, edit_dialog, 0, MN_(NULL)}, |
279 {N_("/Local/_View..."), NULL, view_dialog, 0, MN_(NULL)}, | |
280 {N_("/Local/_Refresh"), NULL, gftp_gtk_refresh, 0, MS_(GTK_STOCK_REFRESH)}, | |
12 | 281 {N_("/_Remote"), NULL, 0, 0, MN_("<Branch>")}, |
282 {N_("/Remote/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, | |
784 | 283 {N_("/Remote/_Open Location..."), "<control>O", openurl_dialog, 0, |
12 | 284 MS_(GTK_STOCK_OPEN)}, |
771 | 285 {N_("/Remote/_Disconnect"), "<control>D", gftpui_disconnect, 0, |
12 | 286 MS_(GTK_STOCK_CLOSE)}, |
287 {N_("/Remote/sep"), NULL, 0, 0, MN_("<Separator>")}, | |
288 {N_("/Remote/Change Filespec..."), NULL, change_filespec, 0, MN_(NULL)}, | |
771 | 289 {N_("/Remote/_Show selected"), NULL, show_selected, 0, MN_(NULL)}, |
290 {N_("/Remote/Select _All"), NULL, selectall, 0, MN_(NULL)}, | |
12 | 291 {N_("/Remote/Select All Files"), NULL, selectallfiles, 0, MN_(NULL)}, |
292 {N_("/Remote/Deselect All"), NULL, deselectall, 0, MN_(NULL)}, | |
293 {N_("/Remote/sep"), NULL, 0, 0, MN_("<Separator>")}, | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
12
diff
changeset
|
294 {N_("/Remote/Save Directory Listing..."), NULL, save_directory_listing, 0, MN_(NULL)}, |
341 | 295 {N_("/Remote/Send SITE Command..."), NULL, gftpui_site_dialog, 0, MN_(NULL)}, |
296 {N_("/Remote/Change Directory"), NULL, gftpui_chdir_dialog, 0, MN_(NULL)}, | |
771 | 297 {N_("/Remote/_Permisssions..."), NULL, chmod_dialog, 0, MN_(NULL)}, |
298 {N_("/Remote/_New Folder..."), NULL, gftpui_mkdir_dialog, 0, MN_(NULL)}, | |
299 {N_("/Remote/Re_name..."), NULL, gftpui_rename_dialog, 0, MN_(NULL)}, | |
12 | 300 {N_("/Remote/Delete..."), NULL, delete_dialog, 0, MN_(NULL)}, |
771 | 301 {N_("/Remote/_Edit..."), NULL, edit_dialog, 0, MN_(NULL)}, |
302 {N_("/Remote/_View..."), NULL, view_dialog, 0, MN_(NULL)}, | |
303 {N_("/Remote/_Refresh"), NULL, gftp_gtk_refresh, 0, MS_(GTK_STOCK_REFRESH)}, | |
12 | 304 {N_("/_Bookmarks"), NULL, 0, 0, MN_("<Branch>")}, |
305 {N_("/Bookmarks/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, | |
771 | 306 {N_("/Bookmarks/Add _Bookmark"), "<control>B", add_bookmark, 0, |
12 | 307 MS_(GTK_STOCK_ADD)}, |
771 | 308 {N_("/Bookmarks/Edit Bookmarks"), NULL, edit_bookmarks, 0, MN_(NULL)}, |
12 | 309 {N_("/Bookmarks/sep"), NULL, 0, 0, MN_("<Separator>")}, |
771 | 310 {N_("/_Transfer"), NULL, 0, 0, MN_("<Branch>")}, |
311 {N_("/Transfer/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, | |
312 {N_("/Transfer/Start"), NULL, start_transfer, 0, MN_(NULL)}, | |
313 {N_("/Transfer/Stop"), NULL, stop_transfer, 0, | |
12 | 314 MS_(GTK_STOCK_STOP)}, |
771 | 315 {N_("/Transfer/sep"), NULL, 0, 0, MN_("<Separator>")}, |
316 {N_("/Transfer/Skip Current File"), NULL, skip_transfer, 0, MN_(NULL)}, | |
317 {N_("/Transfer/Remove File"), NULL, remove_file_transfer, 0, | |
12 | 318 MS_(GTK_STOCK_DELETE)}, |
771 | 319 {N_("/Transfer/Move File Up"), NULL, move_transfer_up, 0, |
12 | 320 MS_(GTK_STOCK_GO_UP)}, |
771 | 321 {N_("/Transfer/Move File Down"), NULL, move_transfer_down, 0, |
12 | 322 MS_(GTK_STOCK_GO_DOWN)}, |
771 | 323 {N_("/Transfer/sep"), NULL, 0, 0, MN_("<Separator>")}, |
324 {N_("/Transfer/Retrieve Files"), "<control>R", get_files, 0, MN_(NULL)}, | |
325 {N_("/Transfer/Put Files"), "<control>P", put_files, 0, MN_(NULL)}, | |
326 {N_("/L_og"), NULL, 0, 0, MN_("<Branch>")}, | |
327 {N_("/Log/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, | |
328 {N_("/Log/_Clear"), NULL, clearlog, 0, MS_(GTK_STOCK_CLEAR)}, | |
329 {N_("/Log/_View"), NULL, viewlog, 0, MN_(NULL)}, | |
330 {N_("/Log/_Save..."), NULL, savelog, 0, MS_(GTK_STOCK_SAVE)}, | |
12 | 331 {N_("/Tool_s"), NULL, 0, 0, MN_("<Branch>")}, |
332 {N_("/Tools/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, | |
771 | 333 {N_("/Tools/C_ompare Windows"), NULL, compare_windows, 0, MN_(NULL)}, |
334 {N_("/Tools/_Clear Cache"), NULL, clear_cache, 0, MS_(GTK_STOCK_CLEAR)}, | |
615 | 335 {N_("/Help"), NULL, 0, 0, MN_("<Branch>")}, |
12 | 336 {N_("/Help/tearoff"), NULL, 0, 0, MN_("<Tearoff>")}, |
771 | 337 {N_("/Help/_About"), NULL, about_dialog, 0, MS_(GTK_STOCK_ABOUT)} |
1 | 338 }; |
339 | |
340 menus = menu_items; | |
341 | |
342 accel_group = gtk_accel_group_new (); | |
7 | 343 factory = item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group, NULL); |
1 | 344 |
345 i = 0; | |
346 len = 11; | |
347 /* FTP Menu */ | |
348 create_item_factory (factory, len, menu_items, &window2); | |
349 | |
350 i += len; | |
351 /* Local Menu */ | |
352 local_start = i; | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
12
diff
changeset
|
353 local_len = 21; |
1 | 354 create_item_factory (factory, local_len, menu_items + i, &window1); |
355 | |
356 i += local_len; | |
357 /* Remote Menu */ | |
358 remote_start = i; | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
12
diff
changeset
|
359 remote_len = 21; |
1 | 360 create_item_factory (factory, remote_len, menu_items + i, &window2); |
361 | |
362 i += remote_len; | |
363 len = 5; | |
364 /* Bookmarks Menu */ | |
365 create_item_factory (factory, len, menu_items + i, &window2); | |
366 | |
367 i += len; | |
771 | 368 /* Transfer Menu */ |
1 | 369 trans_start = i; |
370 trans_len = 12; | |
371 create_item_factory (factory, trans_len, menu_items + i, NULL); | |
372 | |
373 i += trans_len; | |
374 /* Logging Menu */ | |
375 log_start = i; | |
376 log_len = 5; | |
377 create_item_factory (factory, log_len, menu_items + i, NULL); | |
378 | |
379 i += log_len; | |
380 /* Tools Menu */ | |
381 tools_len = 4; | |
382 create_item_factory (factory, tools_len, menu_items + i, NULL); | |
383 | |
384 i += tools_len; | |
385 /* Help Menu */ | |
386 create_item_factory (factory, 3, menu_items + i, NULL); | |
387 | |
388 build_bookmarks_menu (); | |
389 | |
44 | 390 gtk_window_add_accel_group (GTK_WINDOW (parent), accel_group); |
1 | 391 |
245 | 392 gftp_lookup_global_option ("ascii_transfers", &ascii_transfers); |
393 if (ascii_transfers) | |
394 { | |
788 | 395 tempwid = gtk_item_factory_get_widget (factory, "/FTP/Ascii"); |
245 | 396 gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (tempwid), TRUE); |
397 } | |
398 else | |
399 { | |
788 | 400 tempwid = gtk_item_factory_get_widget (factory, "/FTP/Binary"); |
245 | 401 gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (tempwid), TRUE); |
402 } | |
1 | 403 |
788 | 404 tempwid = gtk_item_factory_get_widget (factory, "/FTP/Window 2"); |
1 | 405 gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (tempwid), TRUE); |
406 | |
7 | 407 window1.ifactory = item_factory_new (GTK_TYPE_MENU, "<local>", NULL, "/Local"); |
408 create_item_factory (window1.ifactory, local_len - 2, menu_items + local_start + 2, &window1); | |
409 | |
410 window2.ifactory = item_factory_new (GTK_TYPE_MENU, "<remote>", NULL, "/Remote"); | |
411 create_item_factory (window2.ifactory, remote_len - 2, menu_items + remote_start + 2, &window2); | |
1 | 412 |
7 | 413 log_factory = item_factory_new (GTK_TYPE_MENU, "<log>", NULL, "/Logging"); |
414 create_item_factory (log_factory, log_len - 2, menu_items + log_start + 2, NULL); | |
1 | 415 |
7 | 416 dl_factory = item_factory_new (GTK_TYPE_MENU, "<download>", NULL, "/Transfers"); |
417 create_item_factory (dl_factory, trans_len - 2, menu_items + trans_start + 2, NULL); | |
1 | 418 |
419 return (factory->widget); | |
420 } | |
421 | |
422 | |
423 static GtkWidget * | |
341 | 424 CreateConnectToolbar (GtkWidget * parent) |
1 | 425 { |
426 const GtkTargetEntry possible_types[] = { | |
427 {"STRING", 0, 0}, | |
428 {"text/plain", 0, 0}, | |
429 {"application/x-rootwin-drop", 0, 1} | |
430 }; | |
431 GtkWidget *toolbar, *box, *tempwid; | |
129 | 432 gftp_config_list_vars * tmplistvar; |
616 | 433 char *default_protocol, *tempstr; |
773 | 434 int i, j, num; |
1 | 435 |
436 toolbar = gtk_handle_box_new (); | |
437 | |
438 box = gtk_hbox_new (FALSE, 4); | |
439 gtk_container_add (GTK_CONTAINER (toolbar), box); | |
440 gtk_container_border_width (GTK_CONTAINER (box), 5); | |
441 | |
604 | 442 openurl_tooltip = gtk_tooltips_new (); |
443 | |
1 | 444 tempwid = toolbar_pixmap (parent, "connect.xpm"); |
445 openurl_btn = gtk_button_new (); | |
446 gtk_container_add (GTK_CONTAINER (openurl_btn), tempwid); | |
447 gtk_signal_connect_object (GTK_OBJECT (openurl_btn), "clicked", | |
448 GTK_SIGNAL_FUNC (tb_openurl_dialog), NULL); | |
449 gtk_signal_connect (GTK_OBJECT (openurl_btn), "drag_data_received", | |
450 GTK_SIGNAL_FUNC (openurl_get_drag_data), NULL); | |
451 gtk_drag_dest_set (openurl_btn, GTK_DEST_DEFAULT_ALL, possible_types, 2, | |
452 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
453 gtk_container_border_width (GTK_CONTAINER (openurl_btn), 1); | |
454 gtk_box_pack_start (GTK_BOX (box), openurl_btn, FALSE, FALSE, 0); | |
455 | |
615 | 456 #if GTK_MAJOR_VERSION == 1 |
1 | 457 tempwid = gtk_label_new (_("Host: ")); |
615 | 458 #else |
459 tempwid = gtk_label_new_with_mnemonic (_("_Host: ")); | |
460 #endif | |
461 | |
1 | 462 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); |
463 | |
464 hostedit = gtk_combo_new (); | |
465 gtk_combo_set_case_sensitive (GTK_COMBO (hostedit), 1); | |
466 gtk_widget_set_size_request (hostedit, 130, -1); | |
467 | |
468 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (hostedit)->entry), "activate", | |
469 GTK_SIGNAL_FUNC (toolbar_hostedit), NULL); | |
129 | 470 |
471 gftp_lookup_global_option ("hosthistory", &tmplistvar); | |
472 if (tmplistvar->list) | |
473 gtk_combo_set_popdown_strings (GTK_COMBO (hostedit), tmplistvar->list); | |
474 | |
1 | 475 gtk_combo_disable_activate (GTK_COMBO (hostedit)); |
616 | 476 |
477 gftp_lookup_global_option ("host_value", &tempstr); | |
478 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry), tempstr); | |
615 | 479 #if GTK_MAJOR_VERSION > 1 |
480 gtk_label_set_mnemonic_widget (GTK_LABEL (tempwid), | |
481 GTK_COMBO (hostedit)->entry); | |
482 #endif | |
1 | 483 gtk_box_pack_start (GTK_BOX (box), hostedit, TRUE, TRUE, 0); |
484 | |
485 tempwid = gtk_label_new (_("Port: ")); | |
486 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
487 | |
488 portedit = gtk_combo_new (); | |
489 gtk_combo_set_case_sensitive (GTK_COMBO (portedit), 1); | |
542 | 490 gtk_widget_set_size_request (portedit, 50, -1); |
1 | 491 |
492 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (portedit)->entry), "activate", | |
493 GTK_SIGNAL_FUNC (toolbar_hostedit), NULL); | |
129 | 494 |
495 gftp_lookup_global_option ("porthistory", &tmplistvar); | |
496 if (tmplistvar->list) | |
497 gtk_combo_set_popdown_strings (GTK_COMBO (portedit), tmplistvar->list); | |
498 | |
1 | 499 gtk_combo_disable_activate (GTK_COMBO (portedit)); |
616 | 500 |
501 gftp_lookup_global_option ("port_value", &tempstr); | |
502 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (portedit)->entry), tempstr); | |
1 | 503 gtk_box_pack_start (GTK_BOX (box), portedit, FALSE, FALSE, 0); |
504 | |
615 | 505 #if GTK_MAJOR_VERSION == 1 |
1 | 506 tempwid = gtk_label_new (_("User: ")); |
615 | 507 #else |
508 tempwid = gtk_label_new_with_mnemonic (_("_User: ")); | |
509 #endif | |
1 | 510 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); |
511 | |
512 useredit = gtk_combo_new (); | |
513 gtk_combo_set_case_sensitive (GTK_COMBO (useredit), 1); | |
514 gtk_widget_set_size_request (useredit, 75, -1); | |
515 | |
516 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (useredit)->entry), "activate", | |
517 GTK_SIGNAL_FUNC (toolbar_hostedit), NULL); | |
129 | 518 |
519 gftp_lookup_global_option ("userhistory", &tmplistvar); | |
520 if (tmplistvar->list) | |
521 gtk_combo_set_popdown_strings (GTK_COMBO (useredit), tmplistvar->list); | |
522 | |
1 | 523 gtk_combo_disable_activate (GTK_COMBO (useredit)); |
616 | 524 |
525 gftp_lookup_global_option ("user_value", &tempstr); | |
526 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (useredit)->entry), tempstr); | |
615 | 527 #if GTK_MAJOR_VERSION > 1 |
528 gtk_label_set_mnemonic_widget (GTK_LABEL (tempwid), | |
529 GTK_COMBO (useredit)->entry); | |
530 #endif | |
1 | 531 gtk_box_pack_start (GTK_BOX (box), useredit, TRUE, TRUE, 0); |
532 | |
533 tempwid = gtk_label_new (_("Pass: ")); | |
534 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
535 | |
536 passedit = gtk_entry_new (); | |
537 gtk_widget_set_size_request (passedit, 55, -1); | |
538 | |
539 gtk_entry_set_visibility (GTK_ENTRY (passedit), FALSE); | |
540 gtk_signal_connect (GTK_OBJECT (passedit), "activate", | |
541 GTK_SIGNAL_FUNC (toolbar_hostedit), NULL); | |
542 gtk_box_pack_start (GTK_BOX (box), passedit, FALSE, FALSE, 0); | |
543 | |
544 tempwid = gtk_vbox_new (FALSE, 0); | |
545 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
546 | |
547 optionmenu = gtk_option_menu_new (); | |
548 gtk_box_pack_start (GTK_BOX (tempwid), optionmenu, TRUE, FALSE, 0); | |
549 | |
550 num = 0; | |
129 | 551 gftp_lookup_global_option ("default_protocol", &default_protocol); |
1 | 552 protocol_menu = gtk_menu_new (); |
773 | 553 for (i = 0, j = 0; gftp_protocols[i].name; i++) |
1 | 554 { |
555 if (!gftp_protocols[i].shown) | |
556 continue; | |
557 | |
129 | 558 if (default_protocol != NULL && |
559 strcmp (gftp_protocols[i].name, default_protocol) == 0) | |
773 | 560 num = j; |
561 | |
562 j++; | |
1 | 563 |
564 tempwid = gtk_menu_item_new_with_label (gftp_protocols[i].name); | |
129 | 565 gtk_object_set_user_data (GTK_OBJECT (tempwid), GINT_TO_POINTER(i)); |
1 | 566 gtk_menu_append (GTK_MENU (protocol_menu), tempwid); |
567 gtk_widget_show (tempwid); | |
568 } | |
569 gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), protocol_menu); | |
570 gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), num); | |
571 | |
45 | 572 #if GTK_MAJOR_VERSION == 1 |
21 | 573 tempwid = toolbar_pixmap (parent, "stop.xpm"); |
19 | 574 #else |
575 tempwid = gtk_image_new_from_stock (GTK_STOCK_STOP, | |
576 GTK_ICON_SIZE_LARGE_TOOLBAR); | |
577 #endif | |
578 | |
1 | 579 stop_btn = gtk_button_new (); |
604 | 580 |
1 | 581 gtk_container_add (GTK_CONTAINER (stop_btn), tempwid); |
582 gtk_widget_set_sensitive (stop_btn, 0); | |
583 gtk_signal_connect_object (GTK_OBJECT (stop_btn), "clicked", | |
584 GTK_SIGNAL_FUNC (stop_button), NULL); | |
585 gtk_container_border_width (GTK_CONTAINER (stop_btn), 1); | |
586 gtk_box_pack_start (GTK_BOX (box), stop_btn, FALSE, FALSE, 0); | |
587 | |
326 | 588 gtk_widget_grab_focus (GTK_COMBO (hostedit)->entry); |
341 | 589 |
1 | 590 return (toolbar); |
591 } | |
592 | |
593 | |
341 | 594 static GtkWidget * |
595 CreateCommandToolbar (void) | |
596 { | |
597 GtkWidget * box, * tempwid; | |
598 | |
599 gftpui_command_toolbar = gtk_handle_box_new (); | |
600 | |
601 box = gtk_hbox_new (FALSE, 4); | |
602 gtk_container_add (GTK_CONTAINER (gftpui_command_toolbar), box); | |
603 gtk_container_border_width (GTK_CONTAINER (box), 5); | |
604 | |
605 tempwid = gtk_label_new (_("Command: ")); | |
606 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
607 | |
608 gftpui_command_widget = gtk_entry_new (); | |
609 gtk_box_pack_start (GTK_BOX (box), gftpui_command_widget, TRUE, TRUE, 0); | |
610 gtk_signal_connect (GTK_OBJECT (gftpui_command_widget), "activate", | |
611 GTK_SIGNAL_FUNC (gftpui_run_command), NULL); | |
612 | |
613 return (gftpui_command_toolbar); | |
614 } | |
615 | |
616 | |
1 | 617 static void |
48 | 618 setup_column (GtkWidget * listbox, int column, int width) |
1 | 619 { |
48 | 620 if (width == 0) |
621 gtk_clist_set_column_auto_resize (GTK_CLIST (listbox), column, TRUE); | |
622 else if (width == -1) | |
623 gtk_clist_set_column_visibility (GTK_CLIST (listbox), column, FALSE); | |
624 else | |
625 gtk_clist_set_column_width (GTK_CLIST (listbox), column, width); | |
1 | 626 } |
627 | |
628 | |
48 | 629 static void |
630 list_doaction (gftp_window_data * wdata) | |
1 | 631 { |
326 | 632 intptr_t list_dblclk_action; |
48 | 633 GList *templist, *filelist; |
634 gftp_file *tempfle; | |
499 | 635 int num, success; |
341 | 636 char *directory; |
48 | 637 |
129 | 638 gftp_lookup_request_option (wdata->request, "list_dblclk_action", |
639 &list_dblclk_action); | |
640 | |
48 | 641 filelist = wdata->files; |
525 | 642 templist = gftp_gtk_get_list_selection (wdata); |
48 | 643 num = 0; |
644 templist = get_next_selection (templist, &filelist, &num); | |
645 tempfle = (gftp_file *) filelist->data; | |
646 | |
337 | 647 if (check_reconnect (wdata) < 0) |
648 return; | |
649 | |
499 | 650 if (S_ISLNK (tempfle->st_mode) || S_ISDIR (tempfle->st_mode)) |
341 | 651 { |
555 | 652 directory = gftp_build_path (wdata->request, wdata->request->directory, |
653 tempfle->file, NULL); | |
341 | 654 success = gftpui_run_chdir (wdata, directory); |
655 g_free (directory); | |
656 } | |
657 else | |
658 success = 0; | |
1 | 659 |
499 | 660 if (!S_ISDIR (tempfle->st_mode) && !success) |
1 | 661 { |
129 | 662 switch (list_dblclk_action) |
48 | 663 { |
664 case 0: | |
665 view_dialog (wdata); | |
666 break; | |
667 case 1: | |
668 edit_dialog (wdata); | |
669 break; | |
670 case 2: | |
671 if (wdata == &window2) | |
672 get_files (wdata); | |
673 else | |
674 put_files (wdata); | |
675 break; | |
676 } | |
1 | 677 } |
678 } | |
679 | |
680 | |
48 | 681 static gint |
682 list_enter (GtkWidget * widget, GdkEventKey * event, gpointer data) | |
683 { | |
684 gftp_window_data * wdata; | |
685 | |
686 wdata = data; | |
687 if (!GFTP_IS_CONNECTED (wdata->request)) | |
688 return (TRUE); | |
689 | |
690 if (event->type == GDK_KEY_PRESS && | |
691 (event->keyval == GDK_KP_Delete || event->keyval == GDK_Delete)) | |
692 { | |
693 delete_dialog (wdata); | |
694 return (FALSE); | |
695 } | |
696 else if (IS_ONE_SELECTED (wdata) && event->type == GDK_KEY_PRESS && | |
697 event->keyval == GDK_Return) | |
698 { | |
699 list_doaction (wdata); | |
700 return (FALSE); | |
701 } | |
702 return (TRUE); | |
703 } | |
704 | |
705 | |
706 static gint | |
707 list_dblclick (GtkWidget * widget, GdkEventButton * event, gpointer data) | |
1 | 708 { |
48 | 709 gftp_window_data * wdata; |
710 | |
711 wdata = data; | |
51 | 712 |
48 | 713 if (event->button == 3) |
714 gtk_item_factory_popup (wdata->ifactory, (guint) event->x_root, | |
715 (guint) event->y_root, 3, event->time); | |
51 | 716 return (FALSE); |
717 } | |
718 | |
48 | 719 |
518 | 720 static void |
51 | 721 select_row_callback (GtkWidget *widget, gint row, gint column, |
722 GdkEventButton *event, gpointer data) | |
723 { | |
724 gftp_window_data * wdata; | |
50 | 725 |
51 | 726 wdata = data; |
50 | 727 |
51 | 728 if (event != NULL && event->type == GDK_2BUTTON_PRESS && event->button == 1 && |
729 GFTP_IS_CONNECTED (wdata->request) && IS_ONE_SELECTED (wdata)) | |
730 list_doaction (wdata); | |
1 | 731 } |
732 | |
733 | |
734 static GtkWidget * | |
129 | 735 CreateFTPWindow (gftp_window_data * wdata) |
1 | 736 { |
737 const GtkTargetEntry possible_types[] = { | |
738 {"STRING", 0, 0}, | |
739 {"text/plain", 0, 0}, | |
740 {"application/x-rootwin-drop", 0, 1} | |
741 }; | |
742 GtkWidget *box, *scroll_list, *parent; | |
326 | 743 intptr_t listbox_file_height, colwidth; |
129 | 744 char *titles[7], tempstr[50]; |
1 | 745 |
746 titles[0] = ""; | |
747 titles[1] = _("Filename"); | |
748 titles[2] = _("Size"); | |
749 titles[3] = _("User"); | |
750 titles[4] = _("Group"); | |
751 titles[5] = _("Date"); | |
752 titles[6] = _("Attribs"); | |
753 | |
754 wdata->request = gftp_request_new (); | |
755 wdata->request->logging_function = ftp_log; | |
756 wdata->filespec = g_malloc0 (2); | |
757 *wdata->filespec = '*'; | |
758 | |
759 parent = gtk_frame_new (NULL); | |
129 | 760 |
761 gftp_lookup_global_option ("listbox_file_height", &listbox_file_height); | |
762 g_snprintf (tempstr, sizeof (tempstr), "listbox_%s_width", wdata->prefix_col_str); | |
763 gftp_lookup_global_option (tempstr, &colwidth); | |
764 gtk_widget_set_size_request (parent, colwidth, listbox_file_height); | |
1 | 765 |
766 gtk_container_border_width (GTK_CONTAINER (parent), 5); | |
767 | |
768 box = gtk_vbox_new (FALSE, 0); | |
769 gtk_container_border_width (GTK_CONTAINER (box), 5); | |
770 gtk_container_add (GTK_CONTAINER (parent), box); | |
771 | |
772 wdata->combo = gtk_combo_new (); | |
773 gtk_combo_set_case_sensitive (GTK_COMBO (wdata->combo), 1); | |
774 gtk_box_pack_start (GTK_BOX (box), wdata->combo, FALSE, FALSE, 0); | |
775 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (wdata->combo)->entry), | |
776 "activate", GTK_SIGNAL_FUNC (chdir_edit), | |
777 (gpointer) wdata); | |
778 if (*wdata->history) | |
779 gtk_combo_set_popdown_strings (GTK_COMBO (wdata->combo), *wdata->history); | |
780 gtk_combo_disable_activate (GTK_COMBO (wdata->combo)); | |
781 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry), ""); | |
782 | |
783 wdata->hoststxt = gtk_label_new (NULL); | |
784 gtk_misc_set_alignment (GTK_MISC (wdata->hoststxt), 0, 0); | |
785 gtk_box_pack_start (GTK_BOX (box), wdata->hoststxt, FALSE, FALSE, 0); | |
786 | |
787 scroll_list = gtk_scrolled_window_new (NULL, NULL); | |
788 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_list), | |
789 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
790 wdata->listbox = gtk_clist_new_with_titles (7, titles); | |
791 gtk_container_add (GTK_CONTAINER (scroll_list), wdata->listbox); | |
792 gtk_drag_source_set (wdata->listbox, GDK_BUTTON1_MASK, possible_types, 3, | |
793 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
794 gtk_drag_dest_set (wdata->listbox, GTK_DEST_DEFAULT_ALL, possible_types, 2, | |
795 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
796 | |
797 gtk_clist_set_selection_mode (GTK_CLIST (wdata->listbox), | |
798 GTK_SELECTION_EXTENDED); | |
799 | |
800 gtk_clist_set_column_width (GTK_CLIST (wdata->listbox), 0, 16); | |
801 gtk_clist_set_column_justification (GTK_CLIST (wdata->listbox), 0, | |
802 GTK_JUSTIFY_CENTER); | |
129 | 803 |
804 g_snprintf (tempstr, sizeof (tempstr), "%s_file_width", wdata->prefix_col_str); | |
805 gftp_lookup_global_option (tempstr, &colwidth); | |
806 setup_column (wdata->listbox, 1, colwidth); | |
807 | |
1 | 808 gtk_clist_set_column_justification (GTK_CLIST (wdata->listbox), 2, |
809 GTK_JUSTIFY_RIGHT); | |
129 | 810 |
811 g_snprintf (tempstr, sizeof (tempstr), "%s_size_width", wdata->prefix_col_str); | |
812 gftp_lookup_global_option (tempstr, &colwidth); | |
813 setup_column (wdata->listbox, 2, colwidth); | |
814 | |
815 g_snprintf (tempstr, sizeof (tempstr), "%s_user_width", wdata->prefix_col_str); | |
816 gftp_lookup_global_option (tempstr, &colwidth); | |
817 setup_column (wdata->listbox, 3, colwidth); | |
818 | |
819 g_snprintf (tempstr, sizeof (tempstr), "%s_group_width", wdata->prefix_col_str); | |
820 gftp_lookup_global_option (tempstr, &colwidth); | |
821 setup_column (wdata->listbox, 4, colwidth); | |
822 | |
823 g_snprintf (tempstr, sizeof (tempstr), "%s_date_width", wdata->prefix_col_str); | |
824 gftp_lookup_global_option (tempstr, &colwidth); | |
825 setup_column (wdata->listbox, 5, colwidth); | |
826 | |
827 g_snprintf (tempstr, sizeof (tempstr), "%s_attribs_width", wdata->prefix_col_str); | |
828 gftp_lookup_global_option (tempstr, &colwidth); | |
829 setup_column (wdata->listbox, 6, colwidth); | |
830 | |
1 | 831 gtk_box_pack_start (GTK_BOX (box), scroll_list, TRUE, TRUE, 0); |
832 gtk_signal_connect (GTK_OBJECT (wdata->listbox), "click_column", | |
833 GTK_SIGNAL_FUNC (sortrows), (gpointer) wdata); | |
834 gtk_signal_connect (GTK_OBJECT (wdata->listbox), "drag_data_get", | |
835 GTK_SIGNAL_FUNC (listbox_drag), (gpointer) wdata); | |
836 gtk_signal_connect (GTK_OBJECT (wdata->listbox), "drag_data_received", | |
837 GTK_SIGNAL_FUNC (listbox_get_drag_data), | |
838 (gpointer) wdata); | |
839 gtk_signal_connect_after (GTK_OBJECT (wdata->listbox), "key_press_event", | |
840 GTK_SIGNAL_FUNC (list_enter), (gpointer) wdata); | |
51 | 841 gtk_signal_connect (GTK_OBJECT (wdata->listbox), "select_row", |
842 GTK_SIGNAL_FUNC(select_row_callback), | |
843 (gpointer) wdata); | |
1 | 844 gtk_signal_connect_after (GTK_OBJECT (wdata->listbox), "button_press_event", |
845 GTK_SIGNAL_FUNC (list_dblclick), (gpointer) wdata); | |
846 return (parent); | |
847 } | |
848 | |
849 | |
850 static gint | |
851 menu_mouse_click (GtkWidget * widget, GdkEventButton * event, gpointer data) | |
852 { | |
518 | 853 GtkItemFactory *mfactory; |
1 | 854 |
518 | 855 mfactory = (GtkItemFactory *) data; |
1 | 856 if (event->button == 3) |
518 | 857 gtk_item_factory_popup (mfactory, (guint) event->x_root, |
1 | 858 (guint) event->y_root, 3, event->time); |
859 return (FALSE); | |
860 } | |
861 | |
862 | |
48 | 863 static GtkWidget * |
864 CreateFTPWindows (GtkWidget * ui) | |
1 | 865 { |
587 | 866 GtkWidget *box, *dlbox, *winpane, *dlpane, *logpane, *mainvbox, *tempwid; |
129 | 867 gftp_config_list_vars * tmplistvar; |
48 | 868 char *dltitles[2]; |
326 | 869 intptr_t tmplookup; |
48 | 870 #if GTK_MAJOR_VERSION > 1 |
871 GtkTextBuffer * textbuf; | |
872 GtkTextIter iter; | |
873 GtkTextTag *tag; | |
129 | 874 GdkColor * fore; |
48 | 875 #endif |
876 | |
877 memset (&window1, 0, sizeof (window1)); | |
878 memset (&window2, 0, sizeof (window2)); | |
129 | 879 |
880 gftp_lookup_global_option ("localhistory", &tmplistvar); | |
881 window1.history = &tmplistvar->list; | |
882 window1.histlen = &tmplistvar->num_items; | |
883 | |
884 gftp_lookup_global_option ("remotehistory", &tmplistvar); | |
885 window2.history = &tmplistvar->list; | |
886 window2.histlen = &tmplistvar->num_items; | |
48 | 887 |
888 mainvbox = gtk_vbox_new (FALSE, 0); | |
889 | |
890 tempwid = CreateMenus (ui); | |
891 gtk_box_pack_start (GTK_BOX (mainvbox), tempwid, FALSE, FALSE, 0); | |
1 | 892 |
341 | 893 tempwid = CreateConnectToolbar (ui); |
894 gtk_box_pack_start (GTK_BOX (mainvbox), tempwid, FALSE, FALSE, 0); | |
895 | |
896 tempwid = CreateCommandToolbar (); | |
48 | 897 gtk_box_pack_start (GTK_BOX (mainvbox), tempwid, FALSE, FALSE, 0); |
898 | |
899 winpane = gtk_hpaned_new (); | |
900 | |
901 box = gtk_hbox_new (FALSE, 0); | |
902 | |
129 | 903 window1.prefix_col_str = "local"; |
904 local_frame = CreateFTPWindow (&window1); | |
48 | 905 gtk_box_pack_start (GTK_BOX (box), local_frame, TRUE, TRUE, 0); |
906 | |
907 dlbox = gtk_vbox_new (FALSE, 0); | |
908 gtk_container_border_width (GTK_CONTAINER (dlbox), 5); | |
909 gtk_box_pack_start (GTK_BOX (box), dlbox, FALSE, FALSE, 0); | |
910 | |
911 #if GTK_MAJOR_VERSION == 1 | |
912 tempwid = toolbar_pixmap (ui, "right.xpm"); | |
913 #else | |
914 tempwid = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, | |
915 GTK_ICON_SIZE_SMALL_TOOLBAR); | |
916 #endif | |
917 | |
587 | 918 upload_right_arrow = gtk_button_new (); |
919 gtk_box_pack_start (GTK_BOX (dlbox), upload_right_arrow, TRUE, FALSE, 0); | |
920 gtk_signal_connect_object (GTK_OBJECT (upload_right_arrow), "clicked", | |
48 | 921 GTK_SIGNAL_FUNC (put_files), NULL); |
587 | 922 gtk_container_add (GTK_CONTAINER (upload_right_arrow), tempwid); |
1 | 923 |
45 | 924 #if GTK_MAJOR_VERSION == 1 |
48 | 925 tempwid = toolbar_pixmap (ui, "left.xpm"); |
1 | 926 #else |
48 | 927 tempwid = gtk_image_new_from_stock (GTK_STOCK_GO_BACK, |
928 GTK_ICON_SIZE_SMALL_TOOLBAR); | |
1 | 929 #endif |
48 | 930 |
587 | 931 download_left_arrow = gtk_button_new (); |
932 gtk_box_pack_start (GTK_BOX (dlbox), download_left_arrow, TRUE, FALSE, 0); | |
933 gtk_signal_connect_object (GTK_OBJECT (download_left_arrow), "clicked", | |
48 | 934 GTK_SIGNAL_FUNC (get_files), NULL); |
587 | 935 gtk_container_add (GTK_CONTAINER (download_left_arrow), tempwid); |
48 | 936 |
937 gtk_paned_pack1 (GTK_PANED (winpane), box, 1, 1); | |
938 | |
129 | 939 window2.prefix_col_str = "remote"; |
940 remote_frame = CreateFTPWindow (&window2); | |
941 | |
48 | 942 gtk_paned_pack2 (GTK_PANED (winpane), remote_frame, 1, 1); |
943 | |
944 dlpane = gtk_vpaned_new (); | |
945 gtk_paned_pack1 (GTK_PANED (dlpane), winpane, 1, 1); | |
946 | |
947 transfer_scroll = gtk_scrolled_window_new (NULL, NULL); | |
129 | 948 gftp_lookup_global_option ("transfer_height", &tmplookup); |
949 gtk_widget_set_size_request (transfer_scroll, -1, tmplookup); | |
48 | 950 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (transfer_scroll), |
951 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
952 | |
953 dltitles[0] = _("Filename"); | |
954 dltitles[1] = _("Progress"); | |
955 dlwdw = gtk_ctree_new_with_titles (2, 0, dltitles); | |
956 gtk_clist_set_selection_mode (GTK_CLIST (dlwdw), GTK_SELECTION_SINGLE); | |
957 gtk_clist_set_reorderable (GTK_CLIST (dlwdw), 0); | |
958 | |
129 | 959 gftp_lookup_global_option ("file_trans_column", &tmplookup); |
960 if (tmplookup == 0) | |
48 | 961 gtk_clist_set_column_auto_resize (GTK_CLIST (dlwdw), 0, TRUE); |
962 else | |
129 | 963 gtk_clist_set_column_width (GTK_CLIST (dlwdw), 0, tmplookup); |
48 | 964 |
115 | 965 gtk_container_add (GTK_CONTAINER (transfer_scroll), dlwdw); |
48 | 966 gtk_signal_connect (GTK_OBJECT (dlwdw), "button_press_event", |
967 GTK_SIGNAL_FUNC (menu_mouse_click), (gpointer) dl_factory); | |
968 gtk_paned_pack2 (GTK_PANED (dlpane), transfer_scroll, 1, 1); | |
969 | |
970 logpane = gtk_vpaned_new (); | |
971 gtk_paned_pack1 (GTK_PANED (logpane), dlpane, 1, 1); | |
972 | |
973 log_table = gtk_table_new (1, 2, FALSE); | |
129 | 974 gftp_lookup_global_option ("log_height", &tmplookup); |
975 gtk_widget_set_size_request (log_table, -1, tmplookup); | |
48 | 976 |
977 #if GTK_MAJOR_VERSION == 1 | |
978 logwdw = gtk_text_new (NULL, NULL); | |
979 | |
980 gtk_text_set_editable (GTK_TEXT (logwdw), FALSE); | |
981 gtk_text_set_word_wrap (GTK_TEXT (logwdw), TRUE); | |
982 | |
983 gtk_table_attach (GTK_TABLE (log_table), logwdw, 0, 1, 0, 1, | |
984 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
985 0, 0); | |
986 gtk_signal_connect (GTK_OBJECT (logwdw), "button_press_event", | |
987 GTK_SIGNAL_FUNC (menu_mouse_click), | |
988 (gpointer) log_factory); | |
989 | |
990 tempwid = gtk_vscrollbar_new (GTK_TEXT (logwdw)->vadj); | |
991 gtk_table_attach (GTK_TABLE (log_table), tempwid, 1, 2, 0, 1, | |
992 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); | |
993 logwdw_vadj = GTK_TEXT (logwdw)->vadj; | |
994 #else | |
995 logwdw = gtk_text_view_new (); | |
996 gtk_text_view_set_editable (GTK_TEXT_VIEW (logwdw), FALSE); | |
997 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (logwdw), FALSE); | |
998 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (logwdw), GTK_WRAP_WORD); | |
999 | |
1000 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
1001 | |
1002 tag = gtk_text_buffer_create_tag (textbuf, "send", NULL); | |
129 | 1003 gftp_lookup_global_option ("send_color", &fore); |
1004 g_object_set (G_OBJECT (tag), "foreground_gdk", fore, NULL); | |
48 | 1005 |
1006 tag = gtk_text_buffer_create_tag (textbuf, "recv", NULL); | |
129 | 1007 gftp_lookup_global_option ("recv_color", &fore); |
1008 g_object_set (G_OBJECT (tag), "foreground_gdk", fore, NULL); | |
48 | 1009 |
1010 tag = gtk_text_buffer_create_tag (textbuf, "error", NULL); | |
129 | 1011 gftp_lookup_global_option ("error_color", &fore); |
1012 g_object_set (G_OBJECT (tag), "foreground_gdk", fore, NULL); | |
48 | 1013 |
1014 tag = gtk_text_buffer_create_tag (textbuf, "misc", NULL); | |
129 | 1015 gftp_lookup_global_option ("misc_color", &fore); |
48 | 1016 g_object_set (G_OBJECT (tag), "foreground_gdk", &fore, NULL); |
1017 | |
1018 tempwid = gtk_scrolled_window_new (NULL, NULL); | |
1019 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tempwid), | |
1020 GTK_POLICY_AUTOMATIC, | |
1021 GTK_POLICY_AUTOMATIC); | |
1022 gtk_container_add (GTK_CONTAINER (tempwid), logwdw); | |
1023 gtk_table_attach (GTK_TABLE (log_table), tempwid, 0, 1, 0, 1, | |
1024 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
1025 0, 0); | |
1026 logwdw_vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tempwid)); | |
1027 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
1028 logwdw_textmark = gtk_text_buffer_create_mark (textbuf, "end", &iter, 1); | |
1029 #endif | |
1030 gtk_paned_pack2 (GTK_PANED (logpane), log_table, 1, 1); | |
1031 gtk_box_pack_start (GTK_BOX (mainvbox), logpane, TRUE, TRUE, 0); | |
1032 | |
1033 gtk_widget_show_all (mainvbox); | |
341 | 1034 gftpui_show_or_hide_command (); |
48 | 1035 return (mainvbox); |
1 | 1036 } |
1037 | |
1038 | |
518 | 1039 static void |
48 | 1040 init_gftp (int argc, char *argv[], GtkWidget * parent) |
1 | 1041 { |
48 | 1042 if (argc == 2 && strncmp (argv[1], "--", 2) != 0) |
1 | 1043 { |
48 | 1044 if (gftp_parse_url (window2.request, argv[1]) == 0) |
767 | 1045 ftp_connect (&window2, window2.request); |
48 | 1046 else |
1047 gftp_usage (); | |
1 | 1048 } |
1049 } | |
1050 | |
1051 | |
1052 void | |
1053 toolbar_hostedit (GtkWidget * widget, gpointer data) | |
1054 { | |
173 | 1055 int (*init) (gftp_request * request); |
129 | 1056 gftp_config_list_vars * tmplistvar; |
1 | 1057 GtkWidget *tempwid; |
1058 const char *txt; | |
1059 int num; | |
1060 | |
1061 if (current_wdata->request->stopable) | |
1062 { | |
677 | 1063 ftp_log (gftp_logging_error, NULL, |
1 | 1064 _("%s: Please hit the stop button first to do anything else\n"), |
1065 _("Connect")); | |
1066 return; | |
1067 } | |
1068 | |
1069 if (GFTP_IS_CONNECTED (current_wdata->request)) | |
640 | 1070 gftp_disconnect (current_wdata->request); |
1 | 1071 |
1072 tempwid = gtk_menu_get_active (GTK_MENU (protocol_menu)); | |
195 | 1073 num = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (tempwid))); |
1 | 1074 init = gftp_protocols[num].init; |
173 | 1075 if (init (current_wdata->request) < 0) |
1076 return; | |
1 | 1077 |
395 | 1078 txt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); |
1079 if (strchr (txt, '/') != NULL) | |
1080 { | |
1081 /* The user entered a URL in the host box... */ | |
1082 gftpui_common_cmd_open (current_wdata, current_wdata->request, NULL, NULL, txt); | |
1083 return; | |
1084 } | |
1085 | |
1086 gftp_set_hostname (current_wdata->request, txt); | |
218 | 1087 if (current_wdata->request->hostname == NULL) |
1088 return; | |
1 | 1089 alltrim (current_wdata->request->hostname); |
1090 | |
1091 if (current_wdata->request->need_hostport && | |
1092 *current_wdata->request->hostname == '\0') | |
1093 { | |
1094 ftp_log (gftp_logging_error, NULL, | |
1095 _("Error: You must type in a host to connect to\n")); | |
1096 return; | |
1097 } | |
1098 | |
129 | 1099 gftp_lookup_global_option ("hosthistory", &tmplistvar); |
1100 add_history (hostedit, &tmplistvar->list, &tmplistvar->num_items, | |
1 | 1101 current_wdata->request->hostname); |
1102 | |
1103 if (strchr (current_wdata->request->hostname, '/') != NULL && | |
1104 gftp_parse_url (current_wdata->request, | |
1105 current_wdata->request->hostname) == 0) | |
1106 { | |
767 | 1107 ftp_connect (current_wdata, current_wdata->request); |
1 | 1108 return; |
1109 } | |
1110 | |
1111 txt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (portedit)->entry)); | |
1112 gftp_set_port (current_wdata->request, strtol (txt, NULL, 10)); | |
129 | 1113 |
1114 gftp_lookup_global_option ("porthistory", &tmplistvar); | |
1115 add_history (portedit, &tmplistvar->list, &tmplistvar->num_items, txt); | |
1 | 1116 |
1117 gftp_set_username (current_wdata->request, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry))); | |
218 | 1118 if (current_wdata->request->username != NULL) |
1119 alltrim (current_wdata->request->username); | |
1120 | |
1 | 1121 |
129 | 1122 gftp_lookup_global_option ("userhistory", &tmplistvar); |
1123 add_history (useredit, &tmplistvar->list, &tmplistvar->num_items, | |
1 | 1124 current_wdata->request->username); |
1125 | |
1126 gftp_set_password (current_wdata->request, | |
1127 gtk_entry_get_text (GTK_ENTRY (passedit))); | |
1128 | |
1129 gftp_set_directory (current_wdata->request, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry))); | |
218 | 1130 if (current_wdata->request->directory != NULL) |
1131 alltrim (current_wdata->request->directory); | |
1 | 1132 |
1133 add_history (current_wdata->combo, current_wdata->history, | |
1134 current_wdata->histlen, current_wdata->request->directory); | |
1135 | |
767 | 1136 ftp_connect (current_wdata, current_wdata->request); |
1 | 1137 } |
1138 | |
1139 | |
1140 void | |
1141 sortrows (GtkCList * clist, gint column, gpointer data) | |
1142 { | |
129 | 1143 char sortcol_name[25], sortasds_name[25]; |
326 | 1144 intptr_t sortcol, sortasds; |
1 | 1145 gftp_window_data * wdata; |
16 | 1146 GtkWidget * sort_wid; |
1147 GList * templist; | |
472 | 1148 int swap_col; |
1 | 1149 |
1150 wdata = data; | |
505 | 1151 g_snprintf (sortcol_name, sizeof (sortcol_name), "%s_sortcol", |
1152 wdata->prefix_col_str); | |
129 | 1153 gftp_lookup_global_option (sortcol_name, &sortcol); |
505 | 1154 g_snprintf (sortasds_name, sizeof (sortasds_name), "%s_sortasds", |
1155 wdata->prefix_col_str); | |
129 | 1156 gftp_lookup_global_option (sortasds_name, &sortasds); |
1157 | |
1158 if (column == -1) | |
1159 column = sortcol; | |
1160 | |
1161 if (column == 0 || (column == sortcol && wdata->sorted)) | |
1 | 1162 { |
129 | 1163 sortasds = !sortasds; |
227 | 1164 gftp_set_global_option (sortasds_name, GINT_TO_POINTER (sortasds)); |
19 | 1165 swap_col = 1; |
1166 } | |
1167 else | |
1168 swap_col = 0; | |
1169 | |
1170 if (swap_col || !wdata->sorted) | |
1171 { | |
1 | 1172 sort_wid = gtk_clist_get_column_widget (clist, 0); |
1173 gtk_widget_destroy (sort_wid); | |
45 | 1174 #if GTK_MAJOR_VERSION == 1 |
129 | 1175 if (sortasds) |
1 | 1176 sort_wid = toolbar_pixmap (wdata->listbox, "down.xpm"); |
1177 else | |
1178 sort_wid = toolbar_pixmap (wdata->listbox, "up.xpm"); | |
19 | 1179 #else |
129 | 1180 if (sortasds) |
19 | 1181 sort_wid = gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, |
1182 GTK_ICON_SIZE_SMALL_TOOLBAR); | |
1183 else | |
1184 sort_wid = gtk_image_new_from_stock (GTK_STOCK_SORT_DESCENDING, | |
1185 GTK_ICON_SIZE_SMALL_TOOLBAR); | |
1186 #endif | |
1187 | |
1 | 1188 gtk_clist_set_column_widget (clist, 0, sort_wid); |
1189 } | |
1190 else | |
129 | 1191 { |
1192 sortcol = column; | |
227 | 1193 gftp_set_global_option (sortcol_name, GINT_TO_POINTER (sortcol)); |
129 | 1194 } |
37 | 1195 |
1196 if (!GFTP_IS_CONNECTED (wdata->request)) | |
1197 return; | |
1 | 1198 |
1199 gtk_clist_freeze (clist); | |
1200 gtk_clist_clear (clist); | |
1201 | |
129 | 1202 wdata->files = gftp_sort_filelist (wdata->files, sortcol, sortasds); |
1 | 1203 |
16 | 1204 templist = wdata->files; |
1205 while (templist != NULL) | |
1 | 1206 { |
16 | 1207 add_file_listbox (wdata, templist->data); |
1208 templist = templist->next; | |
1 | 1209 } |
1210 | |
1211 wdata->sorted = 1; | |
1212 gtk_clist_thaw (clist); | |
1213 update_window_info (); | |
1214 } | |
1215 | |
1216 | |
1217 void | |
1218 stop_button (GtkWidget * widget, gpointer data) | |
1219 { | |
1220 pthread_t comptid; | |
1221 | |
1222 memset (&comptid, 0, sizeof (comptid)); | |
1223 if (!pthread_equal (comptid, window1.tid)) | |
1224 pthread_kill (window1.tid, SIGINT); | |
1225 else if (!pthread_equal (comptid, window2.tid)) | |
1226 pthread_kill (window2.tid, SIGINT); | |
1227 } | |
1228 | |
48 | 1229 |
198 | 1230 static int |
1231 gftp_gtk_config_file_read_color (char *str, gftp_config_vars * cv, int line) | |
1232 { | |
1233 char *red, *green, *blue; | |
1234 GdkColor * color; | |
1235 | |
1236 if (cv->flags & GFTP_CVARS_FLAGS_DYNMEM && cv->value != NULL) | |
1237 g_free (cv->value); | |
1238 | |
1239 gftp_config_parse_args (str, 3, line, &red, &green, &blue); | |
1240 | |
1241 color = g_malloc (sizeof (*color)); | |
1242 color->red = strtol (red, NULL, 16); | |
1243 color->green = strtol (green, NULL, 16); | |
1244 color->blue = strtol (blue, NULL, 16); | |
447 | 1245 |
198 | 1246 g_free (red); |
1247 g_free (green); | |
1248 g_free (blue); | |
1249 | |
1250 cv->value = color; | |
1251 cv->flags |= GFTP_CVARS_FLAGS_DYNMEM; | |
1252 | |
1253 return (0); | |
1254 } | |
1255 | |
1256 | |
1257 static int | |
387 | 1258 gftp_gtk_config_file_write_color (gftp_config_vars * cv, char *buf, |
1259 size_t buflen, int to_config_file) | |
198 | 1260 { |
1261 GdkColor * color; | |
1262 | |
1263 color = cv->value; | |
387 | 1264 g_snprintf (buf, buflen, "%x:%x:%x", color->red, color->green, color->blue); |
198 | 1265 return (0); |
1266 } | |
1267 | |
1268 | |
48 | 1269 int |
1270 main (int argc, char **argv) | |
1271 { | |
1272 GtkWidget *window, *ui; | |
1273 | |
447 | 1274 /* We override the read color functions because we are using a GdkColor |
1275 structures to store the color. If I put this in lib/config_file.c, then | |
1276 the core library would be dependant on Gtk+ being present */ | |
1277 gftp_option_types[gftp_option_type_color].read_function = gftp_gtk_config_file_read_color; | |
1278 gftp_option_types[gftp_option_type_color].write_function = gftp_gtk_config_file_write_color; | |
1279 | |
374 | 1280 gftpui_common_init (&argc, &argv, ftp_log); |
498 | 1281 gftpui_common_child_process_done = 0; |
374 | 1282 |
48 | 1283 g_thread_init (NULL); |
496 | 1284 |
1285 #if GTK_MAJOR_VERSION > 1 | |
460 | 1286 gdk_threads_init(); |
496 | 1287 #endif |
460 | 1288 |
56 | 1289 main_thread_id = pthread_self (); |
48 | 1290 gtk_set_locale (); |
1291 gtk_init (&argc, &argv); | |
1292 | |
374 | 1293 graphic_hash_table = g_hash_table_new (string_hash_function, |
1294 string_hash_compare); | |
198 | 1295 |
48 | 1296 window = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
1297 gtk_signal_connect (GTK_OBJECT (window), "delete_event", | |
505 | 1298 GTK_SIGNAL_FUNC (_gftp_try_close), NULL); |
48 | 1299 gtk_signal_connect (GTK_OBJECT (window), "destroy", |
505 | 1300 GTK_SIGNAL_FUNC (_gftp_force_close), NULL); |
129 | 1301 gtk_window_set_title (GTK_WINDOW (window), gftp_version); |
48 | 1302 gtk_window_set_wmclass (GTK_WINDOW(window), "main", "gFTP"); |
129 | 1303 gtk_widget_set_name (window, gftp_version); |
48 | 1304 gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE); |
1305 gtk_widget_realize (window); | |
1306 | |
1307 gftp_icon = open_xpm (window, "gftp.xpm"); | |
1308 if (gftp_icon != NULL) | |
1309 { | |
1310 gdk_window_set_icon (window->window, NULL, gftp_icon->pixmap, | |
1311 gftp_icon->bitmap); | |
168 | 1312 gdk_window_set_icon_name (window->window, gftp_version); |
48 | 1313 } |
1314 | |
1315 other_wdata = &window1; | |
1316 current_wdata = &window2; | |
1317 ui = CreateFTPWindows (window); | |
1318 gtk_container_add (GTK_CONTAINER (window), ui); | |
1319 gtk_widget_show (window); | |
1320 | |
341 | 1321 gftpui_common_about (ftp_log, NULL); |
48 | 1322 |
1323 gtk_timeout_add (1000, update_downloads, NULL); | |
173 | 1324 if (gftp_protocols[GFTP_LOCAL_NUM].init (window1.request) == 0) |
1325 { | |
422 | 1326 gftp_setup_startup_directory (window1.request); |
173 | 1327 gftp_connect (window1.request); |
496 | 1328 ftp_list_files (&window1); |
173 | 1329 } |
48 | 1330 |
1331 /* On the remote window, even though we aren't connected, draw the sort | |
1332 icon on that side */ | |
129 | 1333 sortrows (GTK_CLIST (window2.listbox), -1, &window2); |
48 | 1334 |
1335 init_gftp (argc, argv, window); | |
1336 | |
1337 GDK_THREADS_ENTER (); | |
1338 gtk_main (); | |
1339 GDK_THREADS_LEAVE (); | |
374 | 1340 |
48 | 1341 return (0); |
1342 } | |
1343 | |
374 | 1344 |
341 | 1345 void |
1346 gftpui_show_or_hide_command (void) | |
1347 { | |
1348 intptr_t cmd_in_gui; | |
48 | 1349 |
341 | 1350 gftp_lookup_global_option ("cmd_in_gui", &cmd_in_gui); |
1351 if (cmd_in_gui) | |
1352 gtk_widget_show (gftpui_command_toolbar); | |
1353 else | |
1354 gtk_widget_hide (gftpui_command_toolbar); | |
1355 } | |
1356 |