mc/src/fileopctx.c

63 lines
1.4 KiB
C
Raw Normal View History

1999-01-06 Federico Mena Quintero <federico@nuclecu.unam.mx> * fileopctx.h: New file with declarations for the file operation context structure. * fileopctx.c (file_op_context_new): New function to create a file operation context with the default file mask values. (file_op_context_destroy): New function to destroy a file operation context and its associated UI, if appropriate. * filegui.h: Use complete prototype for fmd_init_i18n(). * filegui.c (FileOpContextUI): New structure that describes the UI and internal data for file operation contexts in the text mode version. (file_op_context_create_ui): Renamed from create_op_win() and made it use a context instead of global variables. (file_op_context_destroy_ui): Likewise, renamed from destroy_op_win(). (fmd_widgets): Removed an #ifdef HAVE_XVIEW bit and moved the initialization of the result pointers to file_mask_dialog(), as we need to use the pointers to the fields inside the file op context now. Made all the functions use a file operation context. (file_mask_dialog): Always call fmd_init_i18n(); it will take care of idempotence by itself. (fmd_init_i18n): Now the code that makes sure this function is only called once is here. * cmd.c (check_for_default): Make it use a file operation context. * tree.c (tree_copy): Likewise. (tree_move): Likewise. (tree_rmdir_cmd): Likewise. * file.c: Removed file_progress_replace_progress and file_progress_replace_filename -- they are only used in filegui.c as part of the UI for the file operation context. (panel_operate_generate_prompt): Made static. (panel_operate_generate_prompt): Always call fmd_init_i18n(); it will take care of idempotence by itself. (panel_operate): Removed the panel_operate_def() function, and made panel_operate() take an extra "ask_user" argument. (query_recursive): Made static. * background.c (background_attention): Made static. (register_task_running): Made static. (do_background): Now takes a file operation context as an argument. It stores the pid of the child there. * Makefile.in: Added fileopctx.[ch].
1999-01-07 04:14:50 +03:00
/* File operation contexts for the Midnight Commander
*
* Copyright (C) 1998 The Free Software Foundation
*
* Authors: Federico Mena <federico@nuclecu.unam.mx>
* Miguel de Icaza <miguel@nuclecu.unam.mx>
*/
#include <config.h>
#include <unistd.h>
#include <glib.h>
#include "fileopctx.h"
#include "../vfs/vfs.h"
/**
* file_op_context_new:
*
* Creates a new file operation context with the default values. If you later want
* to have a user interface for this, call #file_op_context_create_ui().
*
* Return value: The newly-created context, filled with the default file mask values.
**/
FileOpContext *
file_op_context_new (void)
{
FileOpContext *ctx;
ctx = g_new0 (FileOpContext, 1);
ctx->eta_secs = 0.0;
ctx->progress_bytes = 0.0;
ctx->op_preserve = TRUE;
1999-01-06 Federico Mena Quintero <federico@nuclecu.unam.mx> * fileopctx.h: New file with declarations for the file operation context structure. * fileopctx.c (file_op_context_new): New function to create a file operation context with the default file mask values. (file_op_context_destroy): New function to destroy a file operation context and its associated UI, if appropriate. * filegui.h: Use complete prototype for fmd_init_i18n(). * filegui.c (FileOpContextUI): New structure that describes the UI and internal data for file operation contexts in the text mode version. (file_op_context_create_ui): Renamed from create_op_win() and made it use a context instead of global variables. (file_op_context_destroy_ui): Likewise, renamed from destroy_op_win(). (fmd_widgets): Removed an #ifdef HAVE_XVIEW bit and moved the initialization of the result pointers to file_mask_dialog(), as we need to use the pointers to the fields inside the file op context now. Made all the functions use a file operation context. (file_mask_dialog): Always call fmd_init_i18n(); it will take care of idempotence by itself. (fmd_init_i18n): Now the code that makes sure this function is only called once is here. * cmd.c (check_for_default): Make it use a file operation context. * tree.c (tree_copy): Likewise. (tree_move): Likewise. (tree_rmdir_cmd): Likewise. * file.c: Removed file_progress_replace_progress and file_progress_replace_filename -- they are only used in filegui.c as part of the UI for the file operation context. (panel_operate_generate_prompt): Made static. (panel_operate_generate_prompt): Always call fmd_init_i18n(); it will take care of idempotence by itself. (panel_operate): Removed the panel_operate_def() function, and made panel_operate() take an extra "ask_user" argument. (query_recursive): Made static. * background.c (background_attention): Made static. (register_task_running): Made static. (do_background): Now takes a file operation context as an argument. It stores the pid of the child there. * Makefile.in: Added fileopctx.[ch].
1999-01-07 04:14:50 +03:00
ctx->do_reget = TRUE;
ctx->stat_func = mc_lstat;
ctx->preserve = TRUE;
ctx->preserve_uidgid = (geteuid () == 0) ? TRUE : FALSE;
ctx->umask_kill = 0777777;
ctx->erase_at_end = TRUE;
return ctx;
}
/**
* file_op_context_destroy:
* @ctx: The file operation context to destroy.
*
* Destroys the specified file operation context and its associated UI data, if
* it exists.
**/
void
file_op_context_destroy (FileOpContext *ctx)
{
g_return_if_fail (ctx != NULL);
if (ctx->ui)
file_op_context_destroy_ui (ctx);
/* FIXME: do we need to free ctx->dest_mask? */
g_free (ctx);
}