view src/gtk/rename_dialog.c @ 326:cdabbe5c9a95

2003-12-4 Brian Masney <masneyb@gftp.org> * src/gftp.in - check for the bin_dir for the binary location * lib/cache.c lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c lib/sslcommon.c src/text/gftp-text.c src/gtk/chmod_dialog.c src/gtk/gftp-gtk.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c - when calling gftp_lookup_global_option() or gftp_lookup_request_option(), if the value is an integer, declare the variable type to be intptr_t. This fixes a bug on 64bit platforms (from Gwenole Beauchesne <gbeauchesne@mandrakesoft.com>) * lib/config_file.c (gftp_config_file_read_float) - 64bit fixup * configure.in - increment version to 2.0.17pre0. Undefine _GNU_SOURCE. Check for stdint.h. * lib/gftp.h - include stdint.h if it is found on the system. * src/gtk/gftp-gtk.c (CreateToolbar) - on startup, have the host edit box grab the keyboard focus
author masneyb
date Fri, 05 Dec 2003 00:21:15 +0000
parents 2ad324cf4930
children
line wrap: on
line source

/*****************************************************************************/
/*  rename_dialog.c - rename dialog box and ftp routines                     */
/*  Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org>                  */
/*                                                                           */
/*  This program is free software; you can redistribute it and/or modify     */
/*  it under the terms of the GNU General Public License as published by     */
/*  the Free Software Foundation; either version 2 of the License, or        */
/*  (at your option) any later version.                                      */
/*                                                                           */
/*  This program is distributed in the hope that it will be useful,          */
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of           */
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            */
/*  GNU General Public License for more details.                             */
/*                                                                           */
/*  You should have received a copy of the GNU General Public License        */
/*  along with this program; if not, write to the Free Software              */
/*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA      */
/*****************************************************************************/

#include "gftp-gtk.h"
static const char cvsid[] = "$Id$";

static const char *edttext;
static gftp_file * curfle;


static void *
do_rename_thread (void * data)
{
  int success, sj;
  intptr_t network_timeout;
  gftp_window_data * wdata;

  wdata = data;

  gftp_lookup_request_option (wdata->request, "network_timeout", 
                              &network_timeout);

  if (wdata->request->use_threads)
    { 
      sj = sigsetjmp (jmp_environment, 1);
      use_jmp_environment = 1;
    }
  else
    sj = 0;

  success = 0;
  if (sj == 0)
    {
      if (network_timeout > 0)
        alarm (network_timeout);
      success = gftp_rename_file (wdata->request, curfle->file, edttext) == 0;
      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 void
dorenCB (gftp_window_data * wdata, gftp_dialog_data * ddata)
{
  int ret;

  edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
  if (*edttext == '\0')
    {
      ftp_log (gftp_logging_misc, NULL,
	       _("Rename: Operation canceled...you must enter a string\n"));
      return;
    }

  if (check_reconnect (wdata) < 0) 
    return;

  ret = GPOINTER_TO_INT (generic_thread (do_rename_thread, wdata));
  if (ret)
    refresh ((gpointer) wdata);
}


void
rename_dialog (gpointer data)
{
  GList *templist, *filelist;
  gftp_window_data * wdata;
  char *tempstr;
  int num;

  wdata = data;
  if (!check_status (_("Rename"), wdata, wdata->request->use_threads, 1, 1, 
                     wdata->request->rename != NULL))
    return;

  templist = GTK_CLIST (wdata->listbox)->selection;
  num = 0;
  filelist = wdata->files;
  templist = get_next_selection (templist, &filelist, &num);
  curfle = filelist->data;

  tempstr = g_strdup_printf (_("What would you like to rename %s to?"), 
                             curfle->file);
  MakeEditDialog (_("Rename"), tempstr, curfle->file, 1, NULL,
                  gftp_dialog_button_rename, dorenCB, wdata, NULL, NULL);
  g_free (tempstr);
}