comparison src/gtk/gftp-gtk.c @ 863:9f10d3c835cb

2006-11-30 Brian Masney <masneyb@gftp.org> * lib/options.h src/gtk/gftp-gtk.c - added new option: connect_to_remote_on_startup. If this is enabled, then the application will automatically connect to the remote server when it is started. (closes #330418)
author masneyb
date Sat, 23 Dec 2006 18:16:32 +0000
parents 72400fdbd0ed
children 1fae947d4418
comparison
equal deleted inserted replaced
862:885038cb945b 863:9f10d3c835cb
1070 gftpui_show_or_hide_command (); 1070 gftpui_show_or_hide_command ();
1071 return (mainvbox); 1071 return (mainvbox);
1072 } 1072 }
1073 1073
1074 1074
1075 static void 1075 static int
1076 init_gftp (int argc, char *argv[], GtkWidget * parent) 1076 _get_selected_protocol ()
1077 { 1077 {
1078 if (argc == 2 && strncmp (argv[1], "--", 2) != 0) 1078 GtkWidget * tempwid;
1079 { 1079
1080 if (gftp_parse_url (window2.request, argv[1]) == 0) 1080 tempwid = gtk_menu_get_active (GTK_MENU (protocol_menu));
1081 ftp_connect (&window2, window2.request); 1081 return (GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (tempwid))));
1082 else
1083 gftp_usage ();
1084 }
1085 } 1082 }
1086 1083
1087 1084
1088 void 1085 void
1089 toolbar_hostedit (GtkWidget * widget, gpointer data) 1086 toolbar_hostedit (GtkWidget * widget, gpointer data)
1103 } 1100 }
1104 1101
1105 if (GFTP_IS_CONNECTED (current_wdata->request)) 1102 if (GFTP_IS_CONNECTED (current_wdata->request))
1106 gftp_disconnect (current_wdata->request); 1103 gftp_disconnect (current_wdata->request);
1107 1104
1108 tempwid = gtk_menu_get_active (GTK_MENU (protocol_menu)); 1105 num = _get_selected_protocol ();
1109 num = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (tempwid)));
1110 init = gftp_protocols[num].init; 1106 init = gftp_protocols[num].init;
1111 if (init (current_wdata->request) < 0) 1107 if (init (current_wdata->request) < 0)
1112 return; 1108 return;
1113 1109
1114 txt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); 1110 txt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry));
1299 g_snprintf (buf, buflen, "%x:%x:%x", color->red, color->green, color->blue); 1295 g_snprintf (buf, buflen, "%x:%x:%x", color->red, color->green, color->blue);
1300 return (0); 1296 return (0);
1301 } 1297 }
1302 1298
1303 1299
1300 static void
1301 _setup_window1 ()
1302 {
1303 if (gftp_protocols[GFTP_LOCAL_NUM].init (window1.request) == 0)
1304 {
1305 gftp_setup_startup_directory (window1.request,
1306 "local_startup_directory");
1307 gftp_connect (window1.request);
1308 ftp_list_files (&window1);
1309 }
1310 }
1311
1312
1313 static void
1314 _setup_window2 (int argc, char **argv)
1315 {
1316 intptr_t connect_to_remote_on_startup;
1317
1318 gftp_lookup_request_option (window2.request, "connect_to_remote_on_startup",
1319 &connect_to_remote_on_startup);
1320
1321 if (argc == 2 && strncmp (argv[1], "--", 2) != 0)
1322 {
1323 if (gftp_parse_url (window2.request, argv[1]) == 0)
1324 ftp_connect (&window2, window2.request);
1325 else
1326 gftp_usage ();
1327 }
1328 else if (connect_to_remote_on_startup)
1329 {
1330 if (gftp_protocols[_get_selected_protocol ()].init (current_wdata->request) == 0)
1331 {
1332 gftp_setup_startup_directory (window2.request,
1333 "remote_startup_directory");
1334 gftp_connect (window2.request);
1335 ftp_list_files (&window2);
1336 }
1337 }
1338 else
1339 {
1340 /* On the remote window, even though we aren't connected, draw the sort
1341 icon on that side */
1342 sortrows (GTK_CLIST (window2.listbox), -1, &window2);
1343 }
1344 }
1345
1346
1304 int 1347 int
1305 main (int argc, char **argv) 1348 main (int argc, char **argv)
1306 { 1349 {
1307 GtkWidget *window, *ui; 1350 GtkWidget *window, *ui;
1308 1351
1354 gtk_widget_show (window); 1397 gtk_widget_show (window);
1355 1398
1356 gftpui_common_about (ftp_log, NULL); 1399 gftpui_common_about (ftp_log, NULL);
1357 1400
1358 gtk_timeout_add (1000, update_downloads, NULL); 1401 gtk_timeout_add (1000, update_downloads, NULL);
1359 if (gftp_protocols[GFTP_LOCAL_NUM].init (window1.request) == 0) 1402
1360 { 1403 _setup_window1 ();
1361 gftp_setup_startup_directory (window1.request, 1404 _setup_window2 (argc, argv);
1362 "local_startup_directory");
1363 gftp_connect (window1.request);
1364 ftp_list_files (&window1);
1365 }
1366
1367 /* On the remote window, even though we aren't connected, draw the sort
1368 icon on that side */
1369 sortrows (GTK_CLIST (window2.listbox), -1, &window2);
1370
1371 init_gftp (argc, argv, window);
1372 1405
1373 GDK_THREADS_ENTER (); 1406 GDK_THREADS_ENTER ();
1374 gtk_main (); 1407 gtk_main ();
1375 GDK_THREADS_LEAVE (); 1408 GDK_THREADS_LEAVE ();
1376 1409