diff src/gtk/menu-items.c @ 341:eedc2c5727fa

2003-12-28 Brian Masney <masneyb@gftp.org> **** NOTE: this commit breaks a lot of functionality in gftp. I **** **** still have more work to do on this. Please don't email me **** **** saying that the CVS code is broken. **** * lib/bookmark.c lib/gftp.h lib/local.c lib/options.h lib/rfc2068.c lib/rfc959.c lib/sshv2.c - moved the use_threads option from the request structure over to the protocol declaration in options.h. * lib/options.h src/gtk/gftp-gtk.c - added cmd_in_gui option. When this option is enabled, a new toolbar will be shown in the GTK+ port that will allow you to control the GUI by entering manual commands. * src/Makefile.am - added uicommon directory * src/gtk/Makefile.am src/text/Makefile.am - link in the uicommon library. * src/uicommon/* src/text/gftp-text.c - moved most of the functionality of the text port over to the uicommon directory. Made this code a little more generic so that the GTK+ port can have a text interface associated with it. * src/gtk/gtkui.c src/gtk/gftp-gtk.c src/gtk/mkdir_dialog.c src/gtk/rename_dialog.c src/gtk/menu-items.c src/gtk/misc-gtk.c - started to clean up the callback functions and make them more tightly integrated with the uicommon code. * src/gtk/bookmarks.c src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/gftp-gtk.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/transfer.c - s/refresh/gftpui_refresh/g s/jmp_environment/gftpui_common_jmp_environment/g s/request->use_threads/gftpui_common_use_threads (request)/g * src/gtk/options_dialog.c (apply_changes) - whenever the options are saved, check to see if the command entry needs to be shown or hidden.
author masneyb
date Sun, 28 Dec 2003 16:02:07 +0000
parents 5f9d5aee0c1c
children d207b8241e96
line wrap: on
line diff
--- a/src/gtk/menu-items.c	Sat Dec 20 22:00:04 2003 +0000
+++ b/src/gtk/menu-items.c	Sun Dec 28 16:02:07 2003 +0000
@@ -354,122 +354,6 @@
 }
 
 
-static void
-dosite (gftp_window_data * wdata, gftp_dialog_data * ddata)
-{
-  const char *edttext;
-
-  edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
-  if (*edttext == '\0')
-    {
-      ftp_log (gftp_logging_misc, NULL,
-               _("SITE: Operation canceled...you must enter a string\n"));
-      return;
-    }
-
-  if (check_reconnect (wdata) < 0)
-    return;
-  gftp_site_cmd (wdata->request, edttext);
-
-  if (!GFTP_IS_CONNECTED (wdata->request))
-    disconnect (wdata);
-}
-
-
-void
-site_dialog (gpointer data)
-{
-  gftp_window_data * wdata;
-
-  wdata = data;
-  if (!check_status (_("Site"), wdata, 0, 0, 0, wdata->request->site != NULL))
-    return;
-
-  MakeEditDialog (_("Site"), _("Enter site-specific command"), NULL, 1,
-                  NULL, gftp_dialog_button_ok, dosite, wdata, NULL, NULL);
-}
-
-
-static void *
-do_change_dir_thread (void * data)
-{
-  int success, sj;
-  intptr_t network_timeout;
-  gftp_window_data * wdata;
-
-  wdata = data;
-
-  if (wdata->request->use_threads)
-    {
-      sj = sigsetjmp (jmp_environment, 1);
-      use_jmp_environment = 1;
-    }
-  else
-    sj = 0;
-
-  gftp_lookup_request_option (wdata->request, "network_timeout", 
-                              &network_timeout);
-
-  success = 0;
-  if (sj == 0) 
-    {
-      if (network_timeout > 0)
-        alarm (network_timeout);
-      success = gftp_set_directory (wdata->request, wdata->request->directory);
-      alarm (0);
-    }
-  else
-    {
-      gftp_disconnect (wdata->request);
-      wdata->request->logging_function (gftp_logging_error,
-                                        wdata->request,
-                                        _("Operation canceled\n"));
-    }
-
-  if (wdata->request->use_threads)
-    use_jmp_environment = 0;
-
-  wdata->request->stopable = 0;
-  return (GINT_TO_POINTER (success));
-}
-
-
-static int
-do_change_dir (gftp_window_data * wdata, char *directory)
-{
-  char *olddir;
-  int ret;
-
-  if (directory != wdata->request->directory)
-    {
-      olddir = wdata->request->directory;
-      wdata->request->directory = g_strdup (directory);
-    }
-  else
-    olddir = NULL;
-
-  ret = GPOINTER_TO_INT (generic_thread (do_change_dir_thread, wdata));
-
-  if (!GFTP_IS_CONNECTED (wdata->request))
-    {
-      disconnect (wdata);
-      if (olddir != NULL)
-        g_free (olddir);
-      return (-2);
-    }
-
-  if (ret != 0)
-    {
-      g_free (wdata->request->directory);
-      wdata->request->directory = olddir;
-    }
-  else
-    g_free (olddir);
-
-  return (ret);
-}
-
-
 int
 chdir_edit (GtkWidget * widget, gpointer data)
 {
@@ -478,85 +362,29 @@
   char *tempstr;
 
   wdata = data;
-  edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry));
+  if (!check_status (_("Chdir"), wdata, gftpui_common_use_threads (wdata->request), 1, 0,
+                     wdata->request->chdir != NULL))
+    return (0);
 
   if (check_reconnect (wdata) < 0)
     return (0);
 
+  edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry));
+
   if (!GFTP_IS_CONNECTED (wdata->request) && *edttxt != '\0')
     {
       toolbar_hostedit (NULL, NULL);
       return (0);
     }
 
-  if (!check_status (_("Chdir"), wdata, wdata->request->use_threads, 0, 0, 
-                     wdata->request->chdir != NULL))
-    return (FALSE);
-
   if ((tempstr = expand_path (edttxt)) == NULL)
     return (FALSE);
 
-  if (check_reconnect (wdata) < 0)
-    return (FALSE);
-
-  if (do_change_dir (wdata, tempstr) == 0)
-    {
-      gtk_clist_freeze (GTK_CLIST (wdata->listbox));
-      remove_files_window (wdata);
-      ftp_list_files (wdata, 1);
-      gtk_clist_thaw (GTK_CLIST (wdata->listbox));
-      add_history (wdata->combo, wdata->history, wdata->histlen, tempstr);
-    }
+  if (gftpui_run_chdir (wdata, tempstr))
+    add_history (wdata->combo, wdata->history, wdata->histlen, edttxt);
 
   g_free (tempstr);
-  return (FALSE);
-}
-
-
-int
-chdir_dialog (gpointer data)
-{
-  GList * templist, * filelist;
-  gftp_window_data * wdata;
-  char *newdir, *tempstr;
-  gftp_file *tempfle;
-  int num, ret;
-
-  wdata = data;
-  if (!check_status (_("Chdir"), wdata, wdata->request->use_threads, 1, 0, 
-                     wdata->request->chdir != NULL))
-    return (0);
-
-  filelist = wdata->files;
-  templist = GTK_CLIST (wdata->listbox)->selection;
-  num = 0;
-  templist = get_next_selection (templist, &filelist, &num);
-  tempfle = filelist->data;
-
-  newdir = gftp_build_path (wdata->request->directory, tempfle->file, NULL);
-
-  if ((tempstr = expand_path (newdir)) == NULL)
-    {
-      g_free (newdir);
-      return (0);
-    }
-
-  g_free (newdir);
-
-  if (check_reconnect (wdata) < 0)
-    return (0);
-
-  ret = 0; 
-  if (do_change_dir (wdata, tempstr) == 0)
-    {
-      gtk_clist_freeze (GTK_CLIST (wdata->listbox));
-      remove_files_window (wdata);
-      ftp_list_files (wdata, 1);
-      gtk_clist_thaw (GTK_CLIST (wdata->listbox));
-      ret = 1;
-    }
-  g_free (tempstr);
-  return (ret);
+  return (0);
 }