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