1
1

Merges from the FileOpContext-changes branch. Please see

the ChangeLogs for full information. - Federico
Этот коммит содержится в:
Miguel de Icaza 1999-01-14 01:10:32 +00:00
родитель e27c12cfac
Коммит e0faaa671f
38 изменённых файлов: 2662 добавлений и 2258 удалений

Просмотреть файл

@ -1,3 +1,9 @@
1999-01-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gpageprop.c (item_properties): Use file contexts appropriately.
* gdnd.c (perform_action): Use file contexts appropriately.
1999-01-13 Jonathan Blandford <jrb@redhat.com>
* glayout.c (create_container): finished the New->menu. Looks
@ -16,6 +22,18 @@
* gprop.c:
s/gtk_toggle_button_state/gtk_toggle_button_active
1999-01-12 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop.c (desktop_icon_info_delete): Pass the file operation
context to erase_dir() and erase_file().
* gcmd.c (gnome_sort_cmd): Cast the sort functions to avoid
warnings.
* gdialogs.c: Converted to use FileOpContext.
* gmain.h: Added some prototypes needed in the Gnome version.
1999-01-12 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdesktop.c (desktop_drag_data_received): Drops on the desktop by
@ -123,6 +141,17 @@
results so the next time works. Will do this tomorrow.
(gnome_external_panelize): think I finished this now.
1999-01-05 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop-icon.c (desktop_icon_realize): Make icons sticky as
well.
* gpageprop.c (item_properties): Use a file operation context.
* gdnd.c (perform_action): Likewise.
* gdesktop.c (desktop_icon_info_delete): Likewise.
* Makefile.in: Added fileopctx.o.
1999-01-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdesktop.c (desktop_icon_drop_uri_list): Implement
@ -149,6 +178,15 @@
* gcmd.c (gnome_external_panelize): mostly hooked up now.
will finish tomorrow (shouldn't take very long...)
1999-01-04 Federico Mena Quintero <federico@nuclecu.unam.mx>
* Makefile.in (GNOMESRCS): Removed temp-hack.c from the list of
sources.
(GNOMEHDRS): Ditto for gdialogs.h.
* gscreen.c (x_create_panel): Removed periods from the toolbar
button tooltips.
1999-01-04 Jonathan Blandford <jrb@redhat.com>
* glayout.c: menu changes.

Просмотреть файл

@ -36,6 +36,7 @@ GNOMESRCS = \
gcorba.c \
gdesktop-icon.c \
gdesktop.c \
gdialogs.c \
gdnd.c \
ghelp.c \
gicon.c \
@ -50,7 +51,6 @@ GNOMESRCS = \
gpopup.c \
gprefs.c \
gprop.c \
gdialogs.c \
gscreen.c \
gtools.c \
gtkdtree.c \
@ -103,13 +103,14 @@ LOBJS = mad.o
#
# These objects from ../src do depend on HAVE_GNOME
#
OOBJS = dlg.o screen.o widget.o wtools.o info.o boxes.o \
file.o find.o dialog.o key.o chmod.o chown.o view.o \
panelize.o hotlist.o background.o dir.o util.o \
win.o color.o profile.o user.o ext.o setup.o \
subshell.o terms.o achown.o fsusage.o mountlist.o \
@XCURSES@ @REGEX_O@ complete.o command.o \
option.o cmd.o utilunix.o xslint.o gdialogs.o filenot.o treestore.o
OOBJS = dlg.o screen.o widget.o wtools.o info.o boxes.o \
file.o find.o dialog.o key.o chmod.o chown.o view.o \
panelize.o hotlist.o background.o dir.o util.o \
win.o color.o profile.o user.o ext.o setup.o \
subshell.o terms.o achown.o fsusage.o mountlist.o \
@XCURSES@ @REGEX_O@ complete.o command.o \
option.o cmd.o utilunix.o xslint.o gdialogs.o filenot.o \
fileopctx.o treestore.o
CORBAOBJS = \
main-corba.o \

Просмотреть файл

@ -1,8 +1,8 @@
[Desktop Entry]
Name=Gnumeric Spread Sheet
Comment=Create a new Spread Sheet with Gnumeric
TryExec=gnumeric
Exec=gnumeric
Name=Image
Comment=Create a new Image
TryExec=gimp
Exec=gimp
Icon=gnome-gimp.png
Terminal=0
Type=Application

Просмотреть файл

@ -24,14 +24,15 @@
#include "layout.h"
#include "../vfs/vfs.h"
static enum {
enum {
SORT_NAME,
SORT_EXTENSION,
SORT_ACCESS,
SORT_MODIFY,
SORT_CHANGE,
SORT_SIZE
} SortOrderCode;
};
static char *panelize_section = "Panelize";
void
@ -271,22 +272,22 @@ gnome_sort_cmd (GtkWidget *widget, WPanel *panel)
(omenu)->menu_item),
"SORT_ORDER_CODE") ) {
case SORT_NAME:
sfn = sort_name;
sfn = (sortfn *) sort_name;
break;
case SORT_EXTENSION:
sfn = sort_ext;
sfn = (sortfn *) sort_ext;
break;
case SORT_ACCESS:
sfn = sort_atime;
sfn = (sortfn *) sort_atime;
break;
case SORT_MODIFY:
sfn = sort_time;
sfn = (sortfn *) sort_time;
break;
case SORT_CHANGE:
sfn = sort_ctime;
sfn = (sortfn *) sort_ctime;
break;
case SORT_SIZE:
sfn = sort_size;
sfn = (sortfn *) sort_size;
break;
}
/* case sensitive */
@ -548,7 +549,6 @@ gnome_filter_cmd (GtkWidget *widget, WPanel *panel)
GtkWidget *entry;
GtkWidget *label;
gchar *text1, *text2, *text3;
GList *list;
filter_dlg = gnome_dialog_new (_("Set Filter"), GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
@ -619,7 +619,9 @@ void
gnome_open_files (GtkWidget *widget, WPanel *panel)
{
GList *later = NULL;
#if 0
GList *now;
#endif
gint i;
/* FIXME: this is the easy way to do things. We want the

Просмотреть файл

@ -160,11 +160,14 @@ desktop_icon_realize (GtkWidget *widget)
if (gnome_win_hints_wm_exists ()) {
gnome_win_hints_set_layer (widget, WIN_LAYER_DESKTOP);
gnome_win_hints_set_state (widget, WIN_STATE_FIXED_POSITION | WIN_STATE_ARRANGE_IGNORE);
gnome_win_hints_set_state (widget,
WIN_STATE_FIXED_POSITION
| WIN_STATE_ARRANGE_IGNORE
| WIN_STATE_STICKY);
gnome_win_hints_set_hints (widget,
(WIN_HINTS_SKIP_FOCUS
| WIN_HINTS_SKIP_WINLIST
| WIN_HINTS_SKIP_TASKBAR));
WIN_HINTS_SKIP_FOCUS
| WIN_HINTS_SKIP_WINLIST
| WIN_HINTS_SKIP_TASKBAR);
}
/* Set the stipple color now that we have a style */

Просмотреть файл

@ -34,7 +34,9 @@
#include "dialog.h"
#define DIR_H_INCLUDE_HANDLE_DIRENT /* bleah */
#include "dir.h"
#include "ext.h"
#include "file.h"
#include "fileopctx.h"
#include "gconf.h"
#include "gdesktop.h"
#include "gdesktop-icon.h"
@ -735,28 +737,32 @@ desktop_icon_info_delete (DesktopIconInfo *dii)
{
char *full_name;
struct stat s;
FileOpContext *ctx;
long progress_count = 0;
double progress_bytes = 0;
/* 1. Delete the file */
create_op_win (OP_DELETE, 1);
ctx = file_op_context_new ();
file_op_context_create_ui (ctx, OP_DELETE, TRUE);
x_flush_events ();
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
if (lstat (full_name, &s) != -1){
if (lstat (full_name, &s) != -1) {
if (S_ISLNK (s.st_mode))
erase_file (full_name, &progress_count, &progress_bytes, TRUE);
erase_file (ctx, full_name, &progress_count, &progress_bytes, TRUE);
else {
if (S_ISDIR (s.st_mode))
erase_dir (full_name, &progress_count, &progress_bytes);
erase_dir (ctx, full_name, &progress_count, &progress_bytes);
else
erase_file (full_name, &progress_count, &progress_bytes, TRUE);
}
erase_file (ctx, full_name, &progress_count, &progress_bytes, TRUE);
}
gmeta_del_icon_pos (full_name);
}
g_free (full_name);
destroy_op_win ();
file_op_context_destroy (ctx);
/* 2. Destroy the dicon */
desktop_icon_info_destroy (dii);

Просмотреть файл

@ -23,8 +23,6 @@ extern int desktop_use_shaped_icons; /* Whether to use shaped icons or not (for
extern int desktop_auto_placement; /* Whether to auto-place icons or not (user placement) */
extern int desktop_snap_icons; /* Whether to snap icons to the grid or not */
extern int want_transparent_icons;
extern int want_transparent_text;
/* Initializes the desktop -- init DnD, load the default desktop icons, etc. */
void desktop_init (void);

Просмотреть файл

@ -6,33 +6,55 @@
#include <gnome.h>
#include "file.h"
#include "filegui.h"
#include "fileopctx.h"
#include "regex.h"
#include "../vfs/vfs.h"
enum {
REPLACE_PROMPT,
REPLACE_ALWAYS,
REPLACE_UPDATE,
REPLACE_NEVER,
REPLACE_ABORT,
REPLACE_SIZE,
REPLACE_OPTION_MENU
REPLACE_PROMPT,
REPLACE_ALWAYS,
REPLACE_UPDATE,
REPLACE_NEVER,
REPLACE_ABORT,
REPLACE_SIZE,
REPLACE_OPTION_MENU
} FileReplaceCode;
static GtkWidget *op_win = NULL;
static GtkWidget *fmd_win = NULL;
static GtkObject *count_label = NULL;
static GtkObject *byte_prog = NULL;
static GtkWidget *file_label = NULL;
static GtkWidget *op_source_label = NULL;
static GtkWidget *op_target_label = NULL;
static GtkWidget *op_radio = NULL;
int op_preserve = 1;
static gint copy_status;
static gint minor_copy_status;
/* This structure describes the UI and internal data required by a file
* operation context.
*/
typedef struct {
/* The progress window */
GtkWidget *op_win;
/* Set to FALSE in file_op_context_create_ui, set on the cancel_cb if
* user click on Cancel.
*/
gboolean aborting;
/* Source file label */
GtkWidget *op_source_label;
/* Target file label */
GtkWidget *op_target_label;
/* File number label */
GtkObject *count_label;
/* Current file label */
GtkWidget *file_label;
/* Bytes progress bar */
GtkObject *byte_prog;
/* Copy status in query replace dialog */
int copy_status;
int minor_copy_status;
/* Overwrite toggle */
GtkWidget *op_radio;
} FileOpContextUI;
/* Set to FALSE in create_op_win, set on the cancel_cb if user click on Cancel */
gboolean aborting;
#define GDIALOG_TO_STRING "To: "
#define GDIALOG_FROM_STRING "Copying from: "
@ -49,26 +71,26 @@ fmd_check_box_callback (GtkWidget *widget, gpointer data)
}
static gchar *
trim_file_name (gchar *path, gint length, gint cur_length)
trim_file_name (FileOpContextUI *ui, gchar *path, gint length, gint cur_length)
{
static gint dotdotdot = 0;
gchar *path_copy = NULL;
gint len;
if (!dotdotdot)
dotdotdot = gdk_string_width (op_source_label->style->font, "...");
dotdotdot = gdk_string_width (ui->op_source_label->style->font, "...");
/* Cut the font length of path to length. */
length -= dotdotdot;
len = (gint) ((1.0 - (gfloat) length / (gfloat) cur_length) * strlen (path));
/* we guess a starting point */
if (gdk_string_width (op_source_label->style->font, path + len) < length) {
while (gdk_string_width (op_source_label->style->font, path + len) < length)
if (gdk_string_width (ui->op_source_label->style->font, path + len) < length) {
while (gdk_string_width (ui->op_source_label->style->font, path + len) < length)
len --;
len++;
} else {
while (gdk_string_width (op_source_label->style->font, path + len) > length)
while (gdk_string_width (ui->op_source_label->style->font, path + len) > length)
len ++;
}
path_copy = g_malloc (sizeof (gchar [1 + 3 + strlen (path) - len]));
@ -77,33 +99,40 @@ trim_file_name (gchar *path, gint length, gint cur_length)
}
FileProgressStatus
file_progress_show_source (char *path)
file_progress_show_source (FileOpContext *ctx, char *path)
{
static gint from_width = 0;
FileOpContextUI *ui;
gint path_width;
gchar *path_copy = NULL;
g_return_val_if_fail (op_source_label != NULL, FILE_CONT);
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
if (aborting)
ui = ctx->ui;
g_return_val_if_fail (ui->op_source_label != NULL, FILE_CONT);
if (ui->aborting)
return FILE_ABORT;
if (path == NULL){
gtk_label_set (GTK_LABEL (op_source_label), "");
gtk_label_set (GTK_LABEL (ui->op_source_label), "");
return FILE_CONT;
}
if (!from_width){
from_width = gdk_string_width (op_source_label->style->font,
from_width = gdk_string_width (ui->op_source_label->style->font,
_(GDIALOG_FROM_STRING));
}
path_width = gdk_string_width (op_source_label->style->font, path);
path_width = gdk_string_width (ui->op_source_label->style->font, path);
if (from_width + path_width < GDIALOG_PROGRESS_WIDTH)
gtk_label_set (GTK_LABEL (op_source_label), path);
gtk_label_set (GTK_LABEL (ui->op_source_label), path);
else {
path_copy = trim_file_name (path, GDIALOG_PROGRESS_WIDTH - from_width, path_width);
path_copy = trim_file_name (ui, path, GDIALOG_PROGRESS_WIDTH - from_width,
path_width);
gtk_label_set (GTK_LABEL (op_source_label), path_copy);
gtk_label_set (GTK_LABEL (ui->op_source_label), path_copy);
g_free (path_copy);
}
@ -111,31 +140,37 @@ file_progress_show_source (char *path)
}
FileProgressStatus
file_progress_show_target (char *path)
file_progress_show_target (FileOpContext *ctx, char *path)
{
static gint to_width = 0;
FileOpContextUI *ui;
gint path_width;
gchar *path_copy = NULL;
g_return_val_if_fail (op_target_label != NULL, FILE_CONT);
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
if (aborting)
ui = ctx->ui;
g_return_val_if_fail (ui->op_target_label != NULL, FILE_CONT);
if (ui->aborting)
return FILE_ABORT;
if (path == NULL){
gtk_label_set (GTK_LABEL (op_target_label), "");
gtk_label_set (GTK_LABEL (ui->op_target_label), "");
return FILE_CONT;
}
if (!to_width)
to_width = gdk_string_width (op_target_label->style->font,
to_width = gdk_string_width (ui->op_target_label->style->font,
_(GDIALOG_TO_STRING));
path_width = gdk_string_width (op_target_label->style->font, path);
path_width = gdk_string_width (ui->op_target_label->style->font, path);
if (to_width + path_width < GDIALOG_PROGRESS_WIDTH)
gtk_label_set (GTK_LABEL (op_target_label), path);
gtk_label_set (GTK_LABEL (ui->op_target_label), path);
else {
path_copy = trim_file_name (path, GDIALOG_PROGRESS_WIDTH - to_width, path_width);
gtk_label_set (GTK_LABEL (op_target_label), path_copy);
path_copy = trim_file_name (ui, path, GDIALOG_PROGRESS_WIDTH - to_width, path_width);
gtk_label_set (GTK_LABEL (ui->op_target_label), path_copy);
g_free (path_copy);
}
@ -143,81 +178,124 @@ file_progress_show_target (char *path)
}
FileProgressStatus
file_progress_show_deleting (char *path)
file_progress_show_deleting (FileOpContext *ctx, char *path)
{
if (aborting)
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (ui->aborting)
return FILE_ABORT;
g_warning ("memo: file_progress_show_deleting!\npath\t%s\n",path);
/* FIXME */
g_warning ("memo: file_progress_show_deleting!\npath\t%s\n", path);
return FILE_CONT;
}
FileProgressStatus
file_progress_show (long done, long total)
file_progress_show (FileOpContext *ctx, long done, long total)
{
static gchar count[10];
FileOpContextUI *ui;
if (aborting)
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (ui->aborting)
return FILE_ABORT;
snprintf (count, 9, "%d%%", (gint)(100.0 *(gfloat)done/(gfloat)total));
gtk_label_set (GTK_LABEL (file_label), count);
gtk_label_set (GTK_LABEL (ui->file_label), count);
while (gtk_events_pending ())
gtk_main_iteration ();
return FILE_CONT;
}
FileProgressStatus
file_progress_show_count (long done, long total)
file_progress_show_count (FileOpContext *ctx, long done, long total)
{
static gchar count[14]; /* that's a lot of files... */
FileOpContextUI *ui;
if (aborting)
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (ui->aborting)
return FILE_ABORT;
snprintf (count, 13, "%d/%d", done, total);
gtk_label_set (GTK_LABEL (count_label), count);
gtk_label_set (GTK_LABEL (ui->count_label), count);
while (gtk_events_pending ())
gtk_main_iteration ();
return FILE_CONT;
}
FileProgressStatus
file_progress_show_bytes (double done, double total)
file_progress_show_bytes (FileOpContext *ctx, double done, double total)
{
if (aborting)
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (ui->aborting)
return FILE_ABORT;
if (!total)
gtk_progress_bar_update (GTK_PROGRESS_BAR (byte_prog), 0.0);
if (total == 0.0)
gtk_progress_bar_update (GTK_PROGRESS_BAR (ui->byte_prog), 0.0);
else
gtk_progress_bar_update (GTK_PROGRESS_BAR (byte_prog), (gfloat) done/(gfloat) total);
gtk_progress_bar_update (GTK_PROGRESS_BAR (ui->byte_prog),
(gfloat) done/(gfloat) total);
while (gtk_events_pending ())
gtk_main_iteration ();
return FILE_CONT;
}
static void
option_menu_policy_callback (GtkWidget *menu, gpointer data)
option_menu_policy_callback (GtkWidget *item, gpointer data)
{
minor_copy_status = (gint) data;
copy_status = (gint) data;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op_radio), TRUE);
FileOpContextUI *ui;
int status;
ui = data;
status = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (item)));
ui->minor_copy_status = status;
ui->copy_status = status;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->op_radio), TRUE);
}
static void
policy_callback (GtkWidget *button, gpointer data)
{
FileOpContextUI *ui;
int status;
ui = data;
status = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (button)));
if (GTK_TOGGLE_BUTTON (button)->active) {
g_print ("toggle\n");
if ((gint) data == REPLACE_OPTION_MENU) {
copy_status = minor_copy_status;
if (status == REPLACE_OPTION_MENU) {
ui->copy_status = ui->minor_copy_status;
} else
copy_status = (gint) data;
ui->copy_status = status;
}
}
FileProgressStatus
file_progress_query_replace_policy (gboolean dialog_needed)
file_progress_query_replace_policy (FileOpContext *ctx, gboolean dialog_needed)
{
FileOpContextUI *ui;
GtkWidget *qrp_dlg;
GtkWidget *radio;
GtkWidget *vbox;
@ -230,13 +308,18 @@ file_progress_query_replace_policy (gboolean dialog_needed)
GtkWidget *menu;
GtkWidget *menu_item;
if (aborting)
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (ui->aborting)
return FILE_ABORT;
copy_status = REPLACE_PROMPT;
ui->copy_status = REPLACE_PROMPT;
if (dialog_needed == FALSE)
return FILE_CONT;
minor_copy_status = REPLACE_ALWAYS;
ui->minor_copy_status = REPLACE_ALWAYS;
g_print ("in file_progress_query_replace_policy\n");
qrp_dlg = gnome_dialog_new (_("Files Exist"),
GNOME_STOCK_BUTTON_OK,
@ -259,45 +342,57 @@ file_progress_query_replace_policy (gboolean dialog_needed)
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
radio = gtk_radio_button_new_with_label (group, _("Prompt me before overwriting any file."));
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (policy_callback), (gpointer) REPLACE_PROMPT);
gtk_object_set_user_data (GTK_OBJECT (radio), GINT_TO_POINTER (REPLACE_PROMPT));
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), ui);
gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
radio = gtk_radio_button_new_with_label (group, _("Don't overwrite any files."));
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (policy_callback), (gpointer) REPLACE_NEVER);
gtk_object_set_user_data (GTK_OBJECT (radio), GINT_TO_POINTER (REPLACE_NEVER));
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), ui);
gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
op_radio = gtk_radio_button_new (group);
gtk_signal_connect (GTK_OBJECT (op_radio), "toggled", GTK_SIGNAL_FUNC (policy_callback), (gpointer) REPLACE_OPTION_MENU);
ui->op_radio = gtk_radio_button_new (group);
gtk_object_set_user_data (GTK_OBJECT (ui->op_radio), GINT_TO_POINTER (REPLACE_OPTION_MENU));
gtk_signal_connect (GTK_OBJECT (ui->op_radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), ui);
hrbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hrbox), gtk_label_new (_("Overwrite:")), FALSE, FALSE, 0);
/* we set up the option menu. */
omenu = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (hrbox), omenu, FALSE, FALSE, 0);
menu = gtk_menu_new ();
menu_item = gtk_menu_item_new_with_label ( _("Older files."));
gtk_menu_append (GTK_MENU (menu), menu_item);
gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (REPLACE_UPDATE));
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (option_menu_policy_callback), (gpointer) REPLACE_UPDATE);
GTK_SIGNAL_FUNC (option_menu_policy_callback), ui);
menu_item = gtk_menu_item_new_with_label ( _("Files only if size differs."));
gtk_menu_append (GTK_MENU (menu), menu_item);
gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (REPLACE_SIZE));
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (option_menu_policy_callback), (gpointer) REPLACE_SIZE);
GTK_SIGNAL_FUNC (option_menu_policy_callback), ui);
menu_item = gtk_menu_item_new_with_label ( _("All files."));
gtk_menu_append (GTK_MENU (menu), menu_item);
gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (REPLACE_ALWAYS));
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (option_menu_policy_callback), (gpointer) REPLACE_ALWAYS);
GTK_SIGNAL_FUNC (option_menu_policy_callback), ui);
gtk_widget_show_all (menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
gtk_signal_connect (GTK_OBJECT (op_radio), "toggled", GTK_SIGNAL_FUNC (policy_callback), (gpointer) REPLACE_ALWAYS);
gtk_box_pack_start (GTK_BOX (vbox), op_radio, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (op_radio));
gtk_container_add (GTK_CONTAINER (op_radio), hrbox);
gtk_signal_connect (GTK_OBJECT (ui->op_radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), (gpointer) REPLACE_ALWAYS);
gtk_box_pack_start (GTK_BOX (vbox), ui->op_radio, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ui->op_radio));
gtk_container_add (GTK_CONTAINER (ui->op_radio), hrbox);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (qrp_dlg)->vbox),
hbox, FALSE, FALSE, 0);
@ -308,30 +403,36 @@ file_progress_query_replace_policy (gboolean dialog_needed)
break;
case -1:
default:
copy_status = REPLACE_ABORT;
ui->copy_status = REPLACE_ABORT;
return FILE_ABORT;
}
return FILE_CONT;
}
FileProgressStatus
file_progress_real_query_replace (enum OperationMode mode, char *destname, struct stat *_s_stat, struct stat *_d_stat)
file_progress_real_query_replace (FileOpContext *ctx, enum OperationMode mode, char *destname,
struct stat *_s_stat, struct stat *_d_stat)
{
FileOpContextUI *ui;
GtkWidget *qr_dlg;
gchar msg[128];
GtkWidget *label;
if (aborting)
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (ui->aborting)
return FILE_ABORT;
/* so what's the situation? Do we prompt or don't we prompt. */
if (copy_status == REPLACE_PROMPT){
if (ui->copy_status == REPLACE_PROMPT){
qr_dlg = gnome_dialog_new (_("File Exists"),
GNOME_STOCK_BUTTON_YES,
GNOME_STOCK_BUTTON_NO,
GNOME_STOCK_BUTTON_CANCEL, NULL);
snprintf (msg, sizeof (msg)-1, _("The target file already exists: %s"), destname);
label = gtk_label_new (msg);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
@ -355,7 +456,7 @@ file_progress_real_query_replace (enum OperationMode mode, char *destname, struc
}
}
switch (copy_status){
switch (ui->copy_status){
case REPLACE_UPDATE:
if (_s_stat->st_mtime > _d_stat->st_mtime)
return FILE_CONT;
@ -377,15 +478,21 @@ file_progress_real_query_replace (enum OperationMode mode, char *destname, struc
}
void
file_progress_set_stalled_label (char *stalled_msg)
file_progress_set_stalled_label (FileOpContext *ctx, char *stalled_msg)
{
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui != NULL);
if (!stalled_msg || !*stalled_msg)
return;
/* FIXME */
g_warning ("FIXME: file_progress_set_stalled_label!\nmsg\t%s\n",stalled_msg);
}
char *
file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_one, int *do_background)
file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char *def_text,
int only_one, int *do_background)
{
GtkWidget *fmd_win;
GtkWidget *notebook;
GtkWidget *hbox;
GtkWidget *vbox, *label;
@ -398,8 +505,10 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_
const char *error;
struct stat buf;
file_mask_stable_symlinks = 0;
g_return_val_if_fail (ctx != NULL, NULL);
ctx->stable_symlinks = 0;
/* Basic window */
if (operation == OP_COPY)
fmd_win = gnome_dialog_new (_("Copy"), GNOME_STOCK_BUTTON_OK,
@ -441,7 +550,7 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_
gtk_box_pack_end (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (vbox), fentry, FALSE, FALSE, 0);
gnome_file_entry_set_modal(GNOME_FILE_ENTRY (fentry),TRUE);
gtk_box_pack_end (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
/* Advanced Options */
@ -454,37 +563,41 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
cbox = gtk_check_button_new_with_label (_("Preserve symlinks"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), file_mask_stable_symlinks);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled", (GtkSignalFunc) fmd_check_box_callback, &file_mask_stable_symlinks);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->stable_symlinks);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
(GtkSignalFunc) fmd_check_box_callback, &ctx->stable_symlinks);
#if 0
gnome_widget_add_help (cbox, "FIXME: Add something here Miguel");
#endif
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
if (operation == OP_COPY) {
cbox = gtk_check_button_new_with_label (_("Follow links."));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), file_mask_op_follow_links);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled", (GtkSignalFunc) fmd_check_box_callback, &file_mask_op_follow_links);
gnome_widget_add_help (cbox, _("Selecting this will copy the files that symlinks point "
"to instead of just copying the link."));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->follow_links);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
(GtkSignalFunc) fmd_check_box_callback, &ctx->follow_links);
gnome_widget_add_help (cbox,
_("Selecting this will copy the files that symlinks point "
"to instead of just copying the link."));
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
cbox = gtk_check_button_new_with_label (_("Preserve file attributes."));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), op_preserve);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled", (GtkSignalFunc) fmd_check_box_callback, &op_preserve);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->op_preserve);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
(GtkSignalFunc) fmd_check_box_callback, &ctx->op_preserve);
gnome_widget_add_help (cbox, _("Preserves the permissions and the UID/GID if possible"));
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
cbox = gtk_check_button_new_with_label (_("Recursively copy subdirectories."));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), dive_into_subdirs);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled", (GtkSignalFunc) fmd_check_box_callback, &dive_into_subdirs);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->dive_into_subdirs);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
(GtkSignalFunc) fmd_check_box_callback, &ctx->dive_into_subdirs);
gnome_widget_add_help (cbox, _("If set, this will copy the directories recursively"));
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
}
gtk_widget_show_all (GNOME_DIALOG (fmd_win)->vbox);
gtk_window_set_modal (GTK_WINDOW (fmd_win), FALSE);
gnome_dialog_set_close (GNOME_DIALOG (fmd_win), TRUE);
@ -495,28 +608,28 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_
gtk_widget_destroy (fmd_win);
return NULL;
}
dest_dir = gnome_file_entry_get_full_path(GNOME_FILE_ENTRY (fentry), TRUE);
gtk_widget_destroy (fmd_win);
easy_patterns = 1;
if (!dest_dir || !*dest_dir){
if (!dest_dir || !*dest_dir)
return NULL;
}
if (file_mask_op_follow_links && operation != OP_MOVE)
file_mask_xstat = mc_stat;
if (ctx->follow_links && operation != OP_MOVE)
ctx->stat_func = mc_stat;
else
file_mask_xstat = mc_lstat;
if (op_preserve || operation == OP_MOVE){
file_mask_preserve = 1;
file_mask_umask_kill = 0777777;
file_mask_preserve_uidgid = (geteuid () == 0) ? 1 : 0;
}
else {
int i;
file_mask_preserve = file_mask_preserve_uidgid = 0;
i = umask (0);
umask (i);
file_mask_umask_kill = i ^ 0777777;
ctx->stat_func = mc_lstat;
if (ctx->op_preserve || operation == OP_MOVE){
ctx->preserve = 1;
ctx->umask_kill = 0777777;
ctx->preserve_uidgid = (geteuid () == 0) ? 1 : 0;
} else {
int i;
ctx->preserve = ctx->preserve_uidgid = 0;
i = umask (0);
umask (i);
ctx->umask_kill = i ^ 0777777;
}
source_mask = strdup ("*");
orig_mask = source_mask;
@ -526,41 +639,44 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_
return dest_dir;
}
if (!dest_dir){
if (!dest_dir)
return NULL;
}
if (!*dest_dir) {
g_free (dest_dir);
return NULL;
}
if (source_easy_patterns){
if (source_easy_patterns) {
source_easy_patterns = easy_patterns;
easy_patterns = 1;
source_mask = convert_pattern (source_mask, match_file, 1);
easy_patterns = source_easy_patterns;
error = re_compile_pattern (source_mask, strlen (source_mask), &file_mask_rx);
error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx);
free (source_mask);
} else
error = re_compile_pattern (source_mask, strlen (source_mask), &file_mask_rx);
if (error){
error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx);
if (error)
g_warning ("%s\n",error);
}
if (orig_mask)
free (orig_mask);
file_mask_dest_mask = strrchr (dest_dir, PATH_SEP);
if (file_mask_dest_mask == NULL)
file_mask_dest_mask = dest_dir;
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
if (ctx->dest_mask == NULL)
ctx->dest_mask = dest_dir;
else
file_mask_dest_mask++;
orig_mask = file_mask_dest_mask;
if (!*file_mask_dest_mask || (!dive_into_subdirs && !is_wildcarded (file_mask_dest_mask) &&
(!only_one || (!mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))) ||
(dive_into_subdirs && ((!only_one && !is_wildcarded (file_mask_dest_mask)) ||
(only_one && !mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))))
file_mask_dest_mask = strdup ("*");
ctx->dest_mask++;
orig_mask = ctx->dest_mask;
if (!*ctx->dest_mask || (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask) &&
(!only_one || (!mc_stat (dest_dir, &buf)
&& S_ISDIR (buf.st_mode)))) ||
(ctx->dive_into_subdirs && ((!only_one && !is_wildcarded (ctx->dest_mask)) ||
(only_one && !mc_stat (dest_dir, &buf)
&& S_ISDIR (buf.st_mode)))))
ctx->dest_mask = strdup ("*");
else {
file_mask_dest_mask = strdup (file_mask_dest_mask);
ctx->dest_mask = strdup (ctx->dest_mask);
*orig_mask = 0;
}
if (!*dest_dir){
@ -571,97 +687,109 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_
}
static void
cancel_cb (void)
cancel_cb (GtkWidget *widget, gpointer data)
{
aborting = TRUE;
FileOpContextUI *ui;
ui = data;
ui->aborting = TRUE;
}
void
create_op_win (FileOperation op, int with_eta)
file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
{
FileOpContextUI *ui;
GtkWidget *alignment;
GtkWidget *hbox;
aborting = FALSE;
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui == NULL);
ui = g_new0 (FileOpContextUI, 1);
ctx->ui = ui;
switch (op) {
case OP_MOVE:
op_win = gnome_dialog_new ("Move Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
ui->op_win = gnome_dialog_new ("Move Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
break;
case OP_COPY:
op_win = gnome_dialog_new ("Copy Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
ui->op_win = gnome_dialog_new ("Copy Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
break;
case OP_DELETE:
op_win = gnome_dialog_new ("Delete Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_widget_show_all (GNOME_DIALOG (op_win)->vbox);
gtk_widget_show_now (op_win);
ui->op_win = gnome_dialog_new ("Delete Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_widget_show_all (GNOME_DIALOG (ui->op_win)->vbox);
gtk_widget_show_now (ui->op_win);
return;
}
gnome_dialog_button_connect_object (GNOME_DIALOG (op_win), 0,
GTK_SIGNAL_FUNC(cancel_cb), NULL);
gnome_dialog_button_connect (GNOME_DIALOG (ui->op_win), 0,
GTK_SIGNAL_FUNC (cancel_cb), ui);
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (alignment), hbox);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(GDIALOG_FROM_STRING)), FALSE, FALSE, 0);
op_source_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), op_source_label, FALSE, FALSE, 0);
gtk_box_set_spacing (GTK_BOX (GNOME_DIALOG (op_win)->vbox), GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (GNOME_DIALOG (op_win)->vbox), GNOME_PAD);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (op_win)->vbox),
ui->op_source_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), ui->op_source_label, FALSE, FALSE, 0);
gtk_box_set_spacing (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox), GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (GNOME_DIALOG (ui->op_win)->vbox), GNOME_PAD);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox),
alignment, FALSE, FALSE, 0);
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (alignment), hbox);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(GDIALOG_TO_STRING)), FALSE, FALSE, 0);
op_target_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), op_target_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (op_win)->vbox),
ui->op_target_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), ui->op_target_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox),
alignment, FALSE, FALSE, 0);
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("File ")), FALSE, FALSE, 0);
count_label = GTK_OBJECT (gtk_label_new (""));
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (count_label), FALSE, FALSE, 0);
ui->count_label = GTK_OBJECT (gtk_label_new (""));
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (ui->count_label), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(" is ")), FALSE, FALSE, 0);
file_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), file_label, FALSE, FALSE, 0);
ui->file_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), ui->file_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(" Done.")), FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (alignment), hbox);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (op_win)->vbox),
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox),
alignment, FALSE, FALSE, 0);
byte_prog = GTK_OBJECT (gtk_progress_bar_new ());
gtk_widget_set_usize (GTK_WIDGET (byte_prog), GDIALOG_PROGRESS_WIDTH, -1);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (op_win)->vbox),
GTK_WIDGET (byte_prog), FALSE, FALSE, 0);
ui->byte_prog = GTK_OBJECT (gtk_progress_bar_new ());
gtk_widget_set_usize (GTK_WIDGET (ui->byte_prog), GDIALOG_PROGRESS_WIDTH, -1);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox),
GTK_WIDGET (ui->byte_prog), FALSE, FALSE, 0);
/*done with things */
gtk_widget_show_all (GNOME_DIALOG (op_win)->vbox);
gtk_widget_show_now (op_win);
gtk_widget_show_all (GNOME_DIALOG (ui->op_win)->vbox);
gtk_widget_show_now (ui->op_win);
}
void
destroy_op_win (void)
file_op_context_destroy_ui (FileOpContext *ctx)
{
if (op_win){
gtk_widget_destroy (op_win);
op_win = NULL;
op_source_label = NULL;
op_target_label = NULL;
}
FileOpContextUI *ui;
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui != NULL);
ui = ctx->ui;
gtk_widget_destroy (ui->op_win);
g_free (ui);
ctx->ui = NULL;
}
void
fmd_init_i18n()
fmd_init_i18n (int force)
{
/* unneccessary func */
}

Просмотреть файл

@ -10,6 +10,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "file.h"
#include "fileopctx.h"
#include "main.h"
#include "panel.h"
#include "gscreen.h"
@ -121,17 +122,11 @@ perform_action_on_panel (WPanel *source_panel, GdkDragAction action, char *destd
{
switch (action) {
case GDK_ACTION_COPY:
if (ask)
panel_operate (source_panel, OP_COPY, destdir);
else
panel_operate_def (source_panel, OP_COPY, destdir);
panel_operate (source_panel, OP_COPY, destdir, ask);
break;
case GDK_ACTION_MOVE:
if (ask)
panel_operate (source_panel, OP_MOVE, destdir);
else
panel_operate_def (source_panel, OP_MOVE, destdir);
panel_operate (source_panel, OP_MOVE, destdir, ask);
break;
default:
@ -180,22 +175,23 @@ perform_action (GList *names, GdkDragAction action, char *destdir)
char *name;
char *dest_name;
int result;
FileOpContext *ctx;
ctx = file_op_context_new ();
switch (action) {
case GDK_ACTION_COPY:
create_op_win (OP_COPY, FALSE);
file_op_context_create_ui (ctx, OP_COPY, FALSE);
break;
case GDK_ACTION_MOVE:
create_op_win (OP_MOVE, FALSE);
file_op_context_create_ui (ctx, OP_MOVE, FALSE);
break;
default:
g_assert_not_reached ();
}
file_mask_defaults ();
for (; names; names = names->next) {
name = names->data;
if (strncmp (name, "file:", 5) == 0)
@ -216,25 +212,25 @@ perform_action (GList *names, GdkDragAction action, char *destdir)
if (S_ISDIR (s.st_mode)) {
if (action == GDK_ACTION_COPY)
copy_dir_dir (
name, dest_name,
TRUE, FALSE,
FALSE, FALSE,
&count, &bytes);
copy_dir_dir (ctx,
name, dest_name,
TRUE, FALSE,
FALSE, FALSE,
&count, &bytes);
else
move_dir_dir (
name, dest_name,
&count, &bytes);
move_dir_dir (ctx,
name, dest_name,
&count, &bytes);
} else {
if (action == GDK_ACTION_COPY)
copy_file_file (
name, dest_name,
TRUE,
&count, &bytes, 1);
copy_file_file (ctx,
name, dest_name,
TRUE,
&count, &bytes, 1);
else
move_file_file (
name, dest_name,
&count, &bytes);
move_file_file (ctx,
name, dest_name,
&count, &bytes);
}
}
} while (result != 0);
@ -243,7 +239,7 @@ perform_action (GList *names, GdkDragAction action, char *destdir)
break;
}
destroy_op_win ();
file_op_context_destroy (ctx);
}
/**
@ -285,7 +281,8 @@ gdnd_drop_on_directory (GdkDragContext *context, GtkSelectionData *selection_dat
/* Symlinks do not use file.c */
if (source_panel && action != GDK_ACTION_LINK)
perform_action_on_panel (source_panel, action, destdir, context->suggested_action == GDK_ACTION_ASK);
perform_action_on_panel (source_panel, action, destdir,
context->suggested_action == GDK_ACTION_ASK);
else {
names = gnome_uri_list_extract_uris (selection_data->data);

Просмотреть файл

@ -3,6 +3,7 @@
#include "dlg.h"
#include "panel.h"
#include "widget.h"
#include "info.h"
int xtoolkit_init (int *argc, char *argv []);
void xtoolkit_end (void);
@ -34,6 +35,11 @@ void bind_gtk_keys (GtkWidget *w, Dlg_head *h);
WPanel *new_panel_at (char *dir);
WPanel *new_panel_with_geometry_at (char *dir, char *geometry);
void layout_panel_gone (WPanel *panel);
void gtkrundlg_event (Dlg_head *h);
int gmc_open (file_entry *fe);
int gmc_view (char *filename, int start_line);
void x_show_info (WInfo *info, struct my_statfs *s, struct stat *b);
void x_create_info (Dlg_head *h, widget_data parent, WInfo *info);
struct gmc_color_pairs_s {
GdkColor *fore, *back;

Просмотреть файл

@ -20,6 +20,7 @@
#include "util.h"
#include "dialog.h"
#include "file.h"
#include "fileopctx.h"
#include "../vfs/vfs.h"
#include "gdesktop.h"
#include "gdesktop-icon.h"
@ -193,28 +194,29 @@ item_properties (GtkWidget *parent, char *fname, DesktopIconInfo *dii)
if (strchr (new_name, '/'))
message (1, "Error", "The new name includes the `/' character");
else if (strcmp (new_name, base) != 0) {
char *base = x_basename (fname);
char save = *base;
char *full_target;
long count = 0;
double bytes = 0;
char *base = x_basename (fname);
char save = *base;
char *full_target;
long count = 0;
double bytes = 0;
FileOpContext *ctx;
*base = 0;
full_target = concat_dir_and_file (fname, new_name);
*base = save;
ctx = file_op_context_new ();
file_op_context_create_ui (ctx, OP_MOVE, FALSE);
move_file_file (ctx, fname, full_target, &count, &bytes);
file_op_context_destroy (ctx);
*base = 0;
full_target = concat_dir_and_file (fname, new_name);
*base = save;
if (dii) {
free (dii->filename);
dii->filename = full_target;
} else
free (full_target);
create_op_win (OP_MOVE, 0);
file_mask_defaults ();
move_file_file (fname, full_target, &count, &bytes);
destroy_op_win ();
if (dii) {
free (dii->filename);
dii->filename = full_target;
} else
free (full_target);
retval |= GPROP_FILENAME;
retval |= GPROP_FILENAME;
}
/* Check and change title and icon -- change is handled by caller */

Просмотреть файл

@ -2259,26 +2259,26 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
gtk_toolbar_append_space (GTK_TOOLBAR (status_line));
gtk_toolbar_append_widget (GTK_TOOLBAR (status_line),
panel->back_b,
"Go to the previous directory.", NULL);
"Go to the previous directory", NULL);
gtk_toolbar_append_widget (GTK_TOOLBAR (status_line),
panel->up_b,
"Go up a level in the directory heirarchy.", NULL);
"Go up a level in the directory heirarchy", NULL);
gtk_toolbar_append_widget (GTK_TOOLBAR (status_line),
panel->fwd_b,
"Go to the next directory.", NULL);
"Go to the next directory", NULL);
gtk_toolbar_append_space (GTK_TOOLBAR (status_line));
gtk_toolbar_append_widget (GTK_TOOLBAR (status_line),
button_switch_to_icon (panel),
"Icon view.", NULL);
"Icon view", NULL);
gtk_toolbar_append_widget (GTK_TOOLBAR (status_line),
button_switch_to_brief_listing (panel),
"Brief view.", NULL);
"Brief view", NULL);
gtk_toolbar_append_widget (GTK_TOOLBAR (status_line),
button_switch_to_full_listing (panel),
"Detailed view.", NULL);
"Detailed view", NULL);
gtk_toolbar_append_widget (GTK_TOOLBAR (status_line),
button_switch_to_custom_listing (panel),
"Custom view.", NULL);
"Custom view", NULL);
dock = gnome_dock_item_new ("gmc-toolbar", GNOME_DOCK_ITEM_BEH_EXCLUSIVE | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL);
gtk_container_add (GTK_CONTAINER(dock),status_line);
gnome_dock_add_item (GNOME_DOCK(GNOME_APP (panel->xwindow)->dock),

Просмотреть файл

@ -224,7 +224,6 @@ gtk_dtree_do_select_dir (GtkDTree *dtree, char *path)
{
GtkCTreeNode *current_node;
char *s, *current, *npath;
char *request;
g_return_val_if_fail (dtree != NULL, FALSE);
g_return_val_if_fail (GTK_IS_DTREE (dtree), FALSE);
@ -504,8 +503,6 @@ gtk_dtree_dirty_notify (int state)
static void
gtk_dtree_init (GtkDTree *dtree)
{
static int tree_inited;
dtree->current_path = NULL;
dtree->auto_expanded_nodes = NULL;

1303
po/mc.pot

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,3 +1,13 @@
1999-01-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* treestore.c (tree_store_load): Use g_return_val_if_fail(), not
g_return_if_fail().
(tree_store_rescan): Added parentheses to clarify || and &&.
* tree.c (tree_add_entry): Removed unused variable.
* treestore.h: Added prototype for tree_store_start_check_cwd().
1999-01-13 Miguel de Icaza <miguel@nuclecu.unam.mx>
* view.c (search): Missing condition.
@ -5,6 +15,14 @@
* treestore.c (tree_store_opendir): Simplistic fix. This is not
quite correct.
1999-01-12 Federico Mena Quintero <federico@nuclecu.unam.mx>
* panelize.h: Added prototype for do_external_panelize().
* screen.c (move_selection): Unused variable fixes for HAVE_X.
* boxes.c (configure_vfs): Removed an unused variable.
1999-01-12 Jonathan Blandford <jrb@redhat.com>
* cmd.c (mkdir_cmd): now mkdir_cmd will accept relative, and
@ -19,6 +37,21 @@ Tue Jan 12 13:40:46 1999 Timur Bakeyev <mc@bat.ru>
* treestore.c (tree_store_save): Add signature for version 2.0 of
the file format.
1999-01-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
* file.c (do_file_error): Made static.
(query_recursive): Have cases for background/foreground operation.
(do_file_error): Likewise.
* background.c: Removed the bg_ctx global, since now all the
contexts are carried around by the functions that actually need
them.
* fileopctx.h (FileOpContext): Moved the op_preserve field to here.
* filegui.c (file_mask_dialog): Removed the ui assertion, since
now the op_preserve field is kept in the main context structure.
1999-01-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* util.c: Provide workarounds for Linux kernel bug.
@ -57,6 +90,59 @@ Sun Jan 10 02:18:33 1999 Timur Bakeyev <mc@bat.ru>
* file.c (panel_operate_flags): Only show this dialog box if it is
a copy or move operation
1999-01-06 Federico Mena Quintero <federico@nuclecu.unam.mx>
* background.c (do_background): Make it a bit saner. Now we store
a per-child-process FileOpContext structure.
* 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-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* widget.c (listbox_new): Assing l->height.

Просмотреть файл

@ -25,7 +25,7 @@ SRCS = dir.c util.c main.c screen.c dialog.c key.c keyxdef.c menu.c \
complete.c slint.c command.c cmd.c panelize.c learn.c \
listmode.c utilunix.c background.c rxvt.c \
text.c popt.c findme.c poptparse.c poptconfig.c popthelp.c \
filegui.c filenot.c treestore.c
filegui.c filenot.c fileopctx.c treestore.c
HDRS = color.h file.h mouse.h user.h dialog.h find.h main.h \
util.h dir.h global.h menu.h panel.h win.h mem.h \
@ -36,7 +36,7 @@ HDRS = color.h file.h mouse.h user.h dialog.h find.h main.h \
myslang.h command.h cmd.h tty.h fs.h panelize.h achown.h \
learn.h listmode.h features.inc background.h \
x.h textconf.h i18n.h findme.h popt.h filegui.h keys.h xtty.h \
poptint.h treestore.h
poptint.h fileopctx.h treestore.h
OBJS = dir.o util.o screen.o dialog.o key.o keyxdef.o menu.o \
file.o win.o color.o help.o find.o profile.o user.o view.o \
@ -46,7 +46,8 @@ OBJS = dir.o util.o screen.o dialog.o key.o keyxdef.o menu.o \
mountlist.o @XCURSES@ @REGEX_O@ complete.o slint.o command.o \
cmd.o main.o panelize.o learn.o listmode.o utilunix.o \
background.o rxvt.o text.o popt.o findme.o poptparse.o \
poptconfig.o popthelp.o filegui.o filenot.o treestore.o
poptconfig.o popthelp.o filegui.o filenot.o fileopctx.o \
treestore.o
#
# Distribution variables

Просмотреть файл

@ -51,7 +51,7 @@
#endif
#include "util.h"
#include "dialog.h"
#include "background.h"
#include "fileopctx.h"
#include "mad.h"
#include "key.h" /* For add_select_channel(), delete_select_channel() */
#include "regex.h"
@ -61,10 +61,6 @@
/* If true, this is a background process */
int we_are_background = 0;
/* Ugh, ugly hack */
extern int do_append;
extern int recursive_result;
#ifdef WITH_BACKGROUND
/* If set background tasks wait to be attached */
int background_wait = 0;
@ -80,9 +76,11 @@ static int parent_fd;
#define mymsg "Desde el hijo\n\r"
struct TaskList *task_list = NULL;
static int background_attention (int fd, void *closure);
void
register_task_running (pid_t pid, int fd, char *info)
static void
register_task_running (FileOpContext *ctx, pid_t pid, int fd, char *info)
{
TaskList *new;
@ -94,7 +92,7 @@ register_task_running (pid_t pid, int fd, char *info)
new->fd = fd;
task_list = new;
add_select_channel (fd, background_attention, (void *) pid);
add_select_channel (fd, background_attention, ctx);
}
void
@ -128,23 +126,23 @@ unregister_task_running (pid_t pid, int fd)
* -1 on failure
*/
int
do_background (char *info)
do_background (FileOpContext *ctx, char *info)
{
int comm [2]; /* control connection stream */
int pid;
if (socketpair (AF_UNIX, SOCK_STREAM, 0, comm) == -1)
return -1;
if ((pid = fork ()) == -1)
return -1;
if (pid == 0){
int nullfd;
parent_fd = comm [1];
we_are_background = 1;
/* Make stdin/stdout/stderr point somewhere */
close (0);
close (1);
@ -159,7 +157,7 @@ do_background (char *info)
/* To make it obvious if it fails, there is a bug report on this */
write (2, mymsg, sizeof (mymsg));
write (1, mymsg, sizeof (mymsg));
/* Just for debugging the background back end */
if (background_wait){
volatile int i = 1;
@ -170,7 +168,8 @@ do_background (char *info)
return 0;
} else {
close (comm [1]);
register_task_running (pid, comm [0], info);
ctx->pid = pid;
register_task_running (ctx, pid, comm [0], info);
return 1;
}
}
@ -273,36 +272,39 @@ real_message_3s (enum OperationMode mode, int *flags, char *title, char *str1, c
* specified routine
*/
int
background_attention (int fd, void *xpid)
static int
background_attention (int fd, void *closure)
{
FileOpContext *ctx;
int have_ctx;
void *routine;
int argc, i, result, status;
char *data [MAXCALLARGS];
char *resstr;
pid_t pid = (pid_t) xpid;
int bytes;
enum ReturnType type;
char *background_process_error = _(" Background process error ");
ctx = closure;
bytes = read (fd, &routine, sizeof (routine));
if (bytes < (sizeof (routine))){
if (errno == ECHILD)
message (1, background_process_error, _(" Child died unexpectedly "));
else
message (1, background_process_error, _(" Unknown error in child "));
unregister_task_running (pid, fd);
waitpid (pid, &status, 0);
unregister_task_running (ctx->pid, fd);
waitpid (ctx->pid, &status, 0);
return 0;
}
/* If the routine is zero, then the child is telling us that he is dying */
if ((int) routine == MSG_CHILD_EXITING){
unregister_task_running (pid, fd);
waitpid (pid, &status, 0);
unregister_task_running (ctx->pid, fd);
waitpid (ctx->pid, &status, 0);
return 0;
}
read (fd, &argc, sizeof (argc));
if (argc > MAXCALLARGS){
message (1, _(" Background protocol error "),
@ -310,42 +312,64 @@ background_attention (int fd, void *xpid)
" than we can handle. \n"));
}
read (fd, &type, sizeof (type));
read (fd, &have_ctx, sizeof (have_ctx));
if (have_ctx)
read (fd, ctx, sizeof (FileOpContext));
for (i = 0; i < argc; i++){
int size;
read (fd, &size, sizeof (size));
data [i] = xmalloc (size+1, "RPC Arguments");
read (fd, data [i], size);
data [i][size] = 0; /* NULL terminate the blocks (they could be strings) */
}
/* Handle the call */
if (type == Return_Integer){
switch (argc){
case 1:
result = (*(int (*)(int, char *))routine)(Background, data [0]);
break;
case 2:
result = (*(int (*)(int, char *, char *))routine)
(Background, data [0], data [1]);
break;
case 3:
result = (*(int (*)(int, char *, char *, char *))routine)
(Background, data [0], data [1], data [2]);
break;
case 4:
result = (*(int (*)(int, char *, char *, char *, char *))routine)
(Background, data [0], data [1], data [2], data [3]);
break;
}
if (have_ctx)
switch (argc){
case 1:
result = (*(int (*)(int, char *))routine)(Background, data [0]);
break;
case 2:
result = (*(int (*)(int, char *, char *))routine)
(Background, data [0], data [1]);
break;
case 3:
result = (*(int (*)(int, char *, char *, char *))routine)
(Background, data [0], data [1], data [2]);
break;
case 4:
result = (*(int (*)(int, char *, char *, char *, char *))routine)
(Background, data [0], data [1], data [2], data [3]);
break;
}
else
switch (argc){
case 1:
result = (*(int (*)(FileOpContext *, int, char *))routine)
(ctx, Background, data [0]);
break;
case 2:
result = (*(int (*)(FileOpContext *, int, char *, char *))routine)
(ctx, Background, data [0], data [1]);
break;
case 3:
result = (*(int (*)(FileOpContext *, int, char *, char *, char *))routine)
(ctx, Background, data [0], data [1], data [2]);
break;
case 4:
result = (*(int (*)(FileOpContext *, int, char *, char *, char *, char *))routine)
(ctx, Background, data [0], data [1], data [2], data [3]);
break;
}
/* Send the result code and the value for shared variables */
write (fd, &result, sizeof (int));
write (fd, &file_progress_do_append, sizeof (file_progress_do_append));
write (fd, &file_progress_recursive_result, sizeof (file_progress_recursive_result));
write (fd, &result, sizeof (int));
if (have_ctx)
write (fd, ctx, sizeof (FileOpContext));
} else if (type == Return_String) {
int len;
@ -396,23 +420,36 @@ background_attention (int fd, void *xpid)
/* }}} */
/* {{{ client RPC routines */
/* Sends the header for a call to a routine in the parent process. If the file
* operation context is not NULL, then it requests that the first parameter of
* the call be a file operation context.
*/
static void
parent_call_header (void *routine, int argc, enum ReturnType type)
parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext *ctx)
{
int have_ctx;
have_ctx = (ctx != NULL);
write (parent_fd, &routine, sizeof (routine));
write (parent_fd, &argc, sizeof (int));
write (parent_fd, &type, sizeof (type));
write (parent_fd, &have_ctx, sizeof (have_ctx));
if (have_ctx)
write (parent_fd, ctx, sizeof (FileOpContext));
}
int
parent_call (void *routine, int argc, ...)
parent_call (void *routine, FileOpContext *ctx, int argc, ...)
{
va_list ap;
int i;
va_start (ap, argc);
parent_call_header (routine, argc, Return_Integer);
for (i = 0; i < argc; i++){
parent_call_header (routine, argc, Return_Integer, ctx);
for (i = 0; i < argc; i++) {
int len;
void *value;
@ -421,12 +458,10 @@ parent_call (void *routine, int argc, ...)
write (parent_fd, &len, sizeof (int));
write (parent_fd, value, len);
}
/* Besides the regular result, get the value for
* variables that may be modified in the parent that affect our behaviour
*/
read (parent_fd, &i, sizeof (int));
read (parent_fd, &file_progress_do_append, sizeof (file_progress_do_append));
read (parent_fd, &file_progress_recursive_result, sizeof (file_progress_recursive_result));
read (parent_fd, &i, sizeof (int));
if (ctx)
read (parent_fd, ctx, sizeof (FileOpContext));
return i;
}
@ -438,7 +473,7 @@ parent_call_string (void *routine, int argc, ...)
int i;
va_start (ap, argc);
parent_call_header (routine, argc, Return_String);
parent_call_header (routine, argc, Return_String, NULL);
for (i = 0; i < argc; i++){
int len;
void *value;
@ -448,7 +483,7 @@ parent_call_string (void *routine, int argc, ...)
write (parent_fd, &len, sizeof (int));
write (parent_fd, value, len);
}
read (parent_fd, &i, sizeof (int));
read (parent_fd, &i, sizeof (int));
if (!i)
return NULL;
str = xmalloc (i + 1, "parent_return");
@ -463,21 +498,12 @@ tell_parent (int msg)
write (parent_fd, &msg, sizeof (int));
}
int
call_1s (int (*routine)(enum OperationMode, char *), char *str)
{
if (we_are_background)
return parent_call ((void *)routine, 1, strlen (str), str);
else
return (*routine)(Foreground, str);
}
void
message_1s (int flags, char *title, char *str1)
{
if (we_are_background)
parent_call ((void *)real_message_1s, 3, sizeof (flags), &flags,
strlen (title), title, strlen (str1), str1);
parent_call ((void *)real_message_1s, NULL, 3, sizeof (flags), &flags,
strlen (title), title, strlen (str1), str1);
else
real_message_1s (Foreground, &flags, title, str1);
}
@ -486,7 +512,7 @@ void
message_2s (int flags, char *title, char *str1, char *str2)
{
if (we_are_background)
parent_call ((void *)real_message_2s, 4, sizeof (flags), &flags,
parent_call ((void *)real_message_2s, NULL, 4, sizeof (flags), &flags,
strlen (title), title, strlen (str1), str1,
strlen (str2), str2);
else
@ -497,7 +523,7 @@ void
message_3s (int flags, char *title, char *str1, char *str2, const char *str3)
{
if (we_are_background)
parent_call ((void *)real_message_3s, 3, sizeof (flags), &flags,
parent_call ((void *)real_message_3s, NULL, 3, sizeof (flags), &flags,
strlen (title), title, strlen (str1), str1,
strlen (str2), str2, strlen (str3), str3);
else

Просмотреть файл

@ -14,12 +14,6 @@ enum {
MSG_CHILD_EXITING
};
/* First argument passed to real functions */
enum OperationMode {
Foreground,
Background
};
enum ReturnType {
Return_String,
Return_Integer
@ -42,14 +36,11 @@ extern struct TaskList *task_list;
extern int background_wait;
int do_background (char *info);
int background_attention (int fd, void *xpid);
int do_background (FileOpContext *ctx, char *info);
void tell_parent (int msg);
int parent_call (void *routine, int argc, ...);
int call_1s (int (*routine)(enum OperationMode, char *), char *str);
int parent_call (void *routine, FileOpContext *ctx, int argc, ...);
void unregister_task_running (pid_t, int fd);
void register_task_running (pid_t, int, char *);
/* stubs */
void message_1s (int flags, char *title, char *str1);

Просмотреть файл

@ -49,7 +49,8 @@
#include "main.h" /* For the confirm_* variables */
#include "tree.h"
#include "layout.h" /* for get_nth_panel_name proto */
#include "background.h" /* for background definitions */
#include "fileopctx.h"
#include "background.h"
#include "x.h"
static int DISPLAY_X = 45, DISPLAY_Y = 14;
@ -701,8 +702,6 @@ configure_vfs (void)
#endif
if (quick_dialog (&confvfs_dlg) != B_CANCEL) {
char *p;
vfs_timeout = atoi (ret_timeout);
free (ret_timeout);
if (vfs_timeout < 0 || vfs_timeout > 10000)

Просмотреть файл

@ -58,6 +58,7 @@
#include "view.h" /* view() */
#include "dialog.h" /* query_dialog, message */
#include "file.h" /* the file operations */
#include "fileopctx.h"
#include "find.h" /* do_find */
#include "hotlist.h"
#include "tree.h"
@ -359,7 +360,7 @@ void edit_cmd_new (WPanel *panel)
void copy_cmd (void)
{
save_cwds_stat ();
if (panel_operate (cpanel, OP_COPY, NULL)){
if (panel_operate (cpanel, OP_COPY, NULL, TRUE)){
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen ();
}
@ -368,7 +369,7 @@ void copy_cmd (void)
void ren_cmd (void)
{
save_cwds_stat ();
if (panel_operate (cpanel, OP_MOVE, NULL)){
if (panel_operate (cpanel, OP_MOVE, NULL, TRUE)){
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen ();
}
@ -377,7 +378,7 @@ void ren_cmd (void)
void copymove_cmd_with_default (int copy, char *thedefault)
{
save_cwds_stat ();
if (panel_operate (cpanel, copy ? OP_COPY : OP_MOVE, thedefault)){
if (panel_operate (cpanel, copy ? OP_COPY : OP_MOVE, thedefault, TRUE)){
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen ();
}
@ -417,7 +418,7 @@ void delete_cmd (void)
{
save_cwds_stat ();
if (panel_operate (cpanel, OP_DELETE, NULL)){
if (panel_operate (cpanel, OP_DELETE, NULL, TRUE)){
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen ();
}
@ -620,15 +621,16 @@ static int check_for_default(char *default_file, char *file)
struct stat s;
long count = 0;
double bytes = 0;
FileOpContext *ctx;
if (mc_stat (file, &s)){
if (mc_stat (default_file, &s)){
return -1;
}
create_op_win (OP_COPY, 0);
file_mask_defaults ();
copy_file_file (default_file, file, 1, &count, &bytes, 1);
destroy_op_win ();
ctx = file_op_context_new ();
file_op_context_create_ui (ctx, OP_COPY, 0);
copy_file_file (ctx, default_file, file, 1, &count, &bytes, 1);
file_op_context_destroy (ctx);
}
return 0;
}

Просмотреть файл

@ -33,7 +33,7 @@
#include "main.h"
#include "key.h" /* For mi_getch() */
#include "dlg.h" /* draw_box, yes I know, it's silly */
#include "background.h" /* we_are_background definition */
#include "fileopctx.h"
/* "$Id$" */

1633
src/file.c

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,23 +1,9 @@
#ifndef __FILE_H
#define __FILE_H
#include "fileopctx.h"
#include "background.h"
typedef enum {
OP_COPY,
OP_MOVE,
OP_DELETE
} FileOperation;
extern char *op_names [3];
typedef enum {
FILE_CONT,
FILE_RETRY,
FILE_SKIP,
FILE_ABORT
} FileProgressStatus;
enum {
RECURSIVE_YES,
RECURSIVE_NO,
@ -30,66 +16,36 @@ extern int know_not_what_am_i_doing;
struct link;
int copy_file_file (char *s, char *d, int ask_overwrite,
int copy_file_file (FileOpContext *ctx, char *s, char *d, int ask_overwrite,
long *progres_count, double *progress_bytes,
int is_toplevel_file);
int move_file_file (char *s, char *d,
int move_file_file (FileOpContext *ctx, char *s, char *d,
long *progres_count, double *progress_bytes);
int move_dir_dir (char *s, char *d,
int move_dir_dir (FileOpContext *ctx, char *s, char *d,
long *progres_count, double *progress_bytes);
int copy_dir_dir (char *s, char *d, int toplevel, int move_over,
int copy_dir_dir (FileOpContext *ctx, char *s, char *d, int toplevel, int move_over,
int delete, struct link *parent_dirs,
long *progres_count, double *progress_bytes);
int erase_dir (char *s, long *progres_count, double *progress_bytes);
int erase_file (char *s, long *progress_count, double *progress_bytes, int is_toplevel_file);
int erase_dir_iff_empty (char *s);
int erase_dir (FileOpContext *ctx, char *s, long *progres_count, double *progress_bytes);
int erase_file (FileOpContext *ctx, char *s, long *progress_count, double *progress_bytes,
int is_toplevel_file);
int erase_dir_iff_empty (FileOpContext *ctx, char *s);
/*
* Manually creating the copy/move/delte dialogs
*/
void create_op_win (FileOperation op, int with_eta);
void destroy_op_win (void);
void refresh_op_win (void);
int panel_operate (void *source_panel, FileOperation op,
char *thedefault);
int panel_operate_def (void *source_panel, FileOperation op,
char *thedefault);
void file_mask_defaults (void);
char *file_mask_dialog (FileOperation operation, char *text, char *def_text,
char *thedefault, int ask_user);
char *file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char *def_text,
int only_one, int *do_background);
#ifdef WANT_WIDGETS
char *panel_operate_generate_prompt (char* cmd_buf,
WPanel* panel,
int operation, int only_one,
struct stat* src_stat);
#endif
extern int dive_into_subdirs;
extern int file_op_compute_totals;
/* Error reporting routines */
/* Skip/Retry/Abort routine */
int do_file_error (char *error);
/* Report error with one file */
int file_error (char *format, char *file);
/* Report error with two files */
int files_error (char *format, char *file1, char *file2);
/* This one just displays buf */
int do_file_error (char *buf);
/* Query routines */
/* Replace existing file */
int query_replace (char *destname, struct stat *_s_stat, struct stat *_d_stat);
/* Query recursive delete */
int query_recursive (char *s);
/* Callback routine for background activity */
int background_attention (int fd, void *info);
extern int background_wait;

Просмотреть файл

@ -83,6 +83,7 @@
#endif /* SCO_FLAVOR */
#include <time.h>
#include <utime.h>
#include <glib.h>
#include "mad.h"
#include "regex.h"
#include "setup.h"
@ -99,13 +100,13 @@
#include "layout.h"
#include "widget.h"
#include "wtools.h"
#include "background.h"
/* Needed for current_panel, other_panel and WTree */
#include "dir.h"
#include "panel.h"
#include "file.h"
#include "filegui.h"
#include "fileopctx.h"
#include "tree.h"
#include "key.h"
#include "../vfs/vfs.h"
@ -114,36 +115,44 @@
/* }}} */
/* Describe the components in the panel operations window */
static WLabel *FileLabel [2];
static WLabel *FileString [2];
static WLabel *ProgressLabel [3];
static WGauge *ProgressGauge [3];
static WLabel *eta_label;
static WLabel *bps_label;
static WLabel *stalled_label;
/* This structure describes the UI and internal data required by a file
* operation context.
*/
typedef struct {
/* ETA and bps */
/* Replace dialog: color set, descriptor and filename */
static int replace_colors [4];
static Dlg_head *replace_dlg;
int showing_eta;
int showing_bps;
int showing_eta;
int showing_bps;
int eta_extra;
/* With ETA on we have extra screen space */
int eta_extra = 0;
/* Dialog and widgets for the operation progress window */
Dlg_head *op_dlg;
WLabel *file_label[2];
WLabel *file_string[2];
WLabel *progress_label[3];
WGauge *progress_gauge[3];
WLabel *eta_label;
WLabel *bps_label;
WLabel *stalled_label;
/* Query replace dialog */
Dlg_head *replace_dlg;
char *replace_filename;
int replace_result;
struct stat *s_stat, *d_stat;
} FileOpContextUI;
/* Replace dialog: color set */
static int replace_colors [4];
#ifndef HAVE_X
/* Used to save the hint line */
static int last_hint_line;
static int selected_button;
static int last_percentage [3];
/* The value of the "preserve Attributes" checkbox in the copy file dialog.
* We can't use the value of "preserve" because it can change in order to
* preserve file attributs when moving files across filesystem boundaries
* (we want to keep the value of the checkbox between copy operations).
*/
int op_preserve = 1;
#endif
/* File operate window sizes */
#define WX 62
@ -167,23 +176,21 @@ enum {
REPLACE_REGET
} FileReplaceCode;
/* Pointer to the operate dialog */
static Dlg_head *op_dlg;
static struct stat *s_stat, *d_stat;
FileProgressStatus
file_progress_check_buttons (void)
static FileProgressStatus
check_progress_buttons (FileOpContext *ctx)
{
int c;
Gpm_Event event;
FileOpContextUI *ui;
ui = ctx->ui;
x_flush_events ();
c = get_event (&event, 0, 0);
if (c == EV_NONE)
return FILE_CONT;
dlg_process_event (op_dlg, c, &event);
switch (op_dlg->ret_value) {
dlg_process_event (ui->op_dlg, c, &event);
switch (ui->op_dlg->ret_value) {
case FILE_SKIP:
return FILE_SKIP;
break;
@ -214,195 +221,256 @@ op_win_callback (struct Dlg_head *h, int id, int msg)
}
void
create_op_win (FileOperation op, int with_eta)
file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
{
int i, x_size;
int minus = verbose ? 0 : 3;
int eta_offset = with_eta ? (WX_ETA_EXTRA) / 2 : 0;
FileOpContextUI *ui;
int x_size;
int minus;
int eta_offset;
char *sixty;
char *fifteen;
char *sixty = "";
char *fifteen = "";
file_progress_replace_result = 0;
file_progress_recursive_result = 0;
showing_eta = with_eta;
showing_bps = with_eta;
eta_extra = with_eta ? WX_ETA_EXTRA : 0;
x_size = (WX + 4) + eta_extra;
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui == NULL);
op_dlg = create_dlg (0, 0, WY-minus+4, x_size, dialog_colors,
op_win_callback, "", "opwin", DLG_CENTER);
ui = g_new0 (FileOpContextUI, 1);
ctx->ui = ui;
minus = verbose ? 0 : 3;
eta_offset = with_eta ? (WX_ETA_EXTRA) / 2 : 0;
sixty = "";
fifteen = "";
ctx->recursive_result = 0;
ui->replace_result = 0;
ui->showing_eta = with_eta;
ui->showing_bps = with_eta;
ui->eta_extra = with_eta ? WX_ETA_EXTRA : 0;
x_size = (WX + 4) + ui->eta_extra;
ui->op_dlg = create_dlg (0, 0, WY-minus+4, x_size, dialog_colors,
op_win_callback, "", "opwin", DLG_CENTER);
#ifndef HAVE_X
last_hint_line = the_hint->widget.y;
if ((op_dlg->y + op_dlg->lines) > last_hint_line)
the_hint->widget.y = op_dlg->y + op_dlg->lines+1;
if ((ui->op_dlg->y + ui->op_dlg->lines) > last_hint_line)
the_hint->widget.y = ui->op_dlg->y + ui->op_dlg->lines+1;
#endif
x_set_dialog_title (op_dlg, "");
add_widgetl (op_dlg, button_new (BY-minus, WX - 19 + eta_offset, FILE_ABORT,
NORMAL_BUTTON, _("&Abort"), 0, 0, "abort"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, button_new (BY-minus, 14 + eta_offset, FILE_SKIP,
NORMAL_BUTTON, _("&Skip"), 0, 0, "skip"),
XV_WLAY_CENTERROW);
x_set_dialog_title (ui->op_dlg, "");
add_widgetl (op_dlg, ProgressGauge [2] = gauge_new (7, FCOPY_GAUGE_X, 0, 100, 0, "g-1"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, ProgressLabel [2] = label_new (7, FCOPY_LABEL_X, fifteen, "l-1"),
XV_WLAY_NEXTROW);
add_widgetl (op_dlg, bps_label = label_new (7, WX, "", "bps-label"), XV_WLAY_NEXTROW);
add_widgetl (ui->op_dlg, button_new (BY-minus, WX - 19 + eta_offset, FILE_ABORT,
NORMAL_BUTTON, _("&Abort"), 0, 0, "abort"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, button_new (BY-minus, 14 + eta_offset, FILE_SKIP,
NORMAL_BUTTON, _("&Skip"), 0, 0, "skip"),
XV_WLAY_CENTERROW);
add_widgetl (ui->op_dlg, ui->progress_gauge[2] = gauge_new (7, FCOPY_GAUGE_X, 0, 100, 0, "g-1"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, ui->progress_label[2] = label_new (7, FCOPY_LABEL_X, fifteen, "l-1"),
XV_WLAY_NEXTROW);
add_widgetl (ui->op_dlg, ui->bps_label = label_new (7, WX, "", "bps-label"), XV_WLAY_NEXTROW);
add_widgetl (ui->op_dlg, ui->progress_gauge[1] = gauge_new (8, FCOPY_GAUGE_X, 0, 100, 0, "g-2"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, ui->progress_label[1] = label_new (8, FCOPY_LABEL_X, fifteen, "l-2"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, ui->stalled_label = label_new (8, WX, "", "stalled"), XV_WLAY_NEXTROW);
add_widgetl (ui->op_dlg, ui->progress_gauge[0] = gauge_new (6, FCOPY_GAUGE_X, 0, 100, 0, "g-3"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, ui->progress_label[0] = label_new (6, FCOPY_LABEL_X, fifteen, "l-3"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, ui->eta_label = label_new (6, WX, "", "eta_label"), XV_WLAY_NEXTROW);
add_widgetl (ui->op_dlg, ui->file_string[1] = label_new (4, FCOPY_GAUGE_X, sixty, "fs-l-1"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, ui->file_label[1] = label_new (4, FCOPY_LABEL_X, fifteen, "fs-l-2"),
XV_WLAY_NEXTROW);
add_widgetl (ui->op_dlg, ui->file_string[0] = label_new (3, FCOPY_GAUGE_X, sixty, "fs-x-1"),
XV_WLAY_RIGHTOF);
add_widgetl (ui->op_dlg, ui->file_label[0] = label_new (3, FCOPY_LABEL_X, fifteen, "fs-x-2"),
XV_WLAY_NEXTROW);
add_widgetl (op_dlg, ProgressGauge [1] = gauge_new (8, FCOPY_GAUGE_X, 0, 100, 0, "g-2"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, ProgressLabel [1] = label_new (8, FCOPY_LABEL_X, fifteen, "l-2"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, stalled_label = label_new (8, WX, "", "stalled"), XV_WLAY_NEXTROW);
add_widgetl (op_dlg, ProgressGauge [0] = gauge_new (6, FCOPY_GAUGE_X, 0, 100, 0, "g-3"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, ProgressLabel [0] = label_new (6, FCOPY_LABEL_X, fifteen, "l-3"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, eta_label = label_new (6, WX, "", "eta_label"), XV_WLAY_NEXTROW);
add_widgetl (op_dlg, FileString [1] = label_new (4, FCOPY_GAUGE_X, sixty, "fs-l-1"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, FileLabel [1] = label_new (4, FCOPY_LABEL_X, fifteen, "fs-l-2"),
XV_WLAY_NEXTROW);
add_widgetl (op_dlg, FileString [0] = label_new (3, FCOPY_GAUGE_X, sixty, "fs-x-1"),
XV_WLAY_RIGHTOF);
add_widgetl (op_dlg, FileLabel [0] = label_new (3, FCOPY_LABEL_X, fifteen, "fs-x-2"),
XV_WLAY_NEXTROW);
/* We will manage the dialog without any help, that's why
we have to call init_dlg */
init_dlg (op_dlg);
op_dlg->running = 1;
selected_button = FILE_SKIP;
for (i = 0; i < 3; i++)
last_percentage [i] = -99;
init_dlg (ui->op_dlg);
ui->op_dlg->running = 1;
}
void
destroy_op_win (void)
file_op_context_destroy_ui (FileOpContext *ctx)
{
dlg_run_done (op_dlg);
destroy_dlg (op_dlg);
FileOpContextUI *ui;
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui != NULL);
ui = ctx->ui;
dlg_run_done (ui->op_dlg);
destroy_dlg (ui->op_dlg);
#ifndef HAVE_X
the_hint->widget.y = last_hint_line;
#endif
g_free (ui);
ctx->ui = NULL;
}
static FileProgressStatus
show_no_bar (int n)
show_no_bar (FileOpContext *ctx, int n)
{
FileOpContextUI *ui;
ui = ctx->ui;
if (n >= 0) {
label_set_text (ProgressLabel [n], "");
gauge_show (ProgressGauge [n], 0);
label_set_text (ui->progress_label[n], "");
gauge_show (ui->progress_gauge[n], 0);
}
return file_progress_check_buttons ();
return check_progress_buttons (ctx);
}
static FileProgressStatus
show_bar (int n, long done, long total)
show_bar (FileOpContext *ctx, int n, long done, long total)
{
gauge_set_value (ProgressGauge [n], (int) total, (int) done);
gauge_show (ProgressGauge [n], 1);
return file_progress_check_buttons ();
FileOpContextUI *ui;
ui = ctx->ui;
gauge_set_value (ui->progress_gauge[n], (int) total, (int) done);
gauge_show (ui->progress_gauge[n], 1);
return check_progress_buttons (ctx);
}
static void
file_eta_show ()
file_eta_show (FileOpContext *ctx)
{
int eta_hours, eta_mins, eta_s;
char eta_buffer [30];
FileOpContextUI *ui;
if (!showing_eta)
ui = ctx->ui;
if (!ui->showing_eta)
return;
if (file_progress_eta_secs > 0.5) {
eta_hours = file_progress_eta_secs / (60 * 60);
eta_mins = (file_progress_eta_secs - (eta_hours * 60 * 60)) / 60;
eta_s = file_progress_eta_secs - ((eta_hours * 60 * 60) + eta_mins * 60 );
if (ctx->eta_secs > 0.5) {
eta_hours = ctx->eta_secs / (60 * 60);
eta_mins = (ctx->eta_secs - (eta_hours * 60 * 60)) / 60;
eta_s = ctx->eta_secs - (eta_hours * 60 * 60 + eta_mins * 60);
sprintf (eta_buffer, "ETA %d:%02d.%02d", eta_hours, eta_mins, eta_s);
} else
*eta_buffer = 0;
label_set_text (eta_label, eta_buffer);
label_set_text (ui->eta_label, eta_buffer);
}
static void
file_bps_show ()
file_bps_show (FileOpContext *ctx)
{
char bps_buffer [30];
FileOpContextUI *ui;
if (!showing_bps)
ui = ctx->ui;
if (!ui->showing_bps)
return;
if (file_progress_bps > 1024*1024){
sprintf (bps_buffer, "%.2f MB/s", file_progress_bps / (1024*1024.0));
} else if (file_progress_bps > 1024){
sprintf (bps_buffer, "%.2f KB/s", file_progress_bps / 1024.0);
} else if (file_progress_bps > 1){
sprintf (bps_buffer, "%ld B/s", file_progress_bps);
if (ctx->bps > 1024*1024) {
sprintf (bps_buffer, "%.2f MB/s", ctx->bps / (1024*1024.0));
} else if (ctx->bps > 1024){
sprintf (bps_buffer, "%.2f KB/s", ctx->bps / 1024.0);
} else if (ctx->bps > 1){
sprintf (bps_buffer, "%ld B/s", ctx->bps);
} else
*bps_buffer = 0;
label_set_text (bps_label, bps_buffer);
label_set_text (ui->bps_label, bps_buffer);
}
FileProgressStatus
file_progress_show (long done, long total)
file_progress_show (FileOpContext *ctx, long done, long total)
{
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (!verbose)
return file_progress_check_buttons ();
return check_progress_buttons (ctx);
if (total > 0){
label_set_text (ProgressLabel [0], _("File"));
file_eta_show ();
file_bps_show ();
return show_bar (0, done, total);
label_set_text (ui->progress_label[0], _("File"));
file_eta_show (ctx);
file_bps_show (ctx);
return show_bar (ctx, 0, done, total);
} else
return show_no_bar (0);
return show_no_bar (ctx, 0);
}
FileProgressStatus
file_progress_show_count (long done, long total)
file_progress_show_count (FileOpContext *ctx, long done, long total)
{
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (!verbose)
return file_progress_check_buttons ();
return check_progress_buttons (ctx);
if (total > 0){
label_set_text (ProgressLabel [1], _("Count"));
return show_bar (1, done, total);
label_set_text (ui->progress_label[1], _("Count"));
return show_bar (ctx, 1, done, total);
} else
return show_no_bar (1);
return show_no_bar (ctx, 1);
}
FileProgressStatus
file_progress_show_bytes (double done, double total)
file_progress_show_bytes (FileOpContext *ctx, double done, double total)
{
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (!verbose)
return file_progress_check_buttons ();
return check_progress_buttons (ctx);
if (total > 0){
label_set_text (ProgressLabel [2], _("Bytes"));
return show_bar (2, done, total);
label_set_text (ui->progress_label[2], _("Bytes"));
return show_bar (ctx, 2, done, total);
} else
return show_no_bar (2);
return show_no_bar (ctx, 2);
}
/* }}} */
#ifndef HAVE_X
#define truncFileString(s) name_trunc (s, eta_extra + 47)
#define truncFileString(ui, s) name_trunc (s, ui->eta_extra + 47)
#else
#define truncFileString(s) s
#define truncFileString(ui, s) s
#endif
FileProgressStatus
file_progress_show_source (char *s)
file_progress_show_source (FileOpContext *ctx, char *s)
{
if (s != NULL){
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (s != NULL) {
#ifdef WITH_FULL_PATHS
int i = strlen (cpanel->cwd);
@ -413,36 +481,50 @@ file_progress_show_source (char *s)
}
#endif /* WITH_FULL_PATHS */
label_set_text (FileLabel [0], _("Source"));
label_set_text (FileString [0], truncFileString (s));
return file_progress_check_buttons ();
label_set_text (ui->file_label[0], _("Source"));
label_set_text (ui->file_string[0], truncFileString (ui, s));
return check_progress_buttons (ctx);
} else {
label_set_text (FileLabel [0], "");
label_set_text (FileString [0], "");
return file_progress_check_buttons ();
label_set_text (ui->file_label[0], "");
label_set_text (ui->file_string[0], "");
return check_progress_buttons (ctx);
}
}
FileProgressStatus
file_progress_show_target (char *s)
file_progress_show_target (FileOpContext *ctx, char *s)
{
if (s != NULL){
label_set_text (FileLabel [1], _("Target"));
label_set_text (FileString [1], truncFileString (s));
return file_progress_check_buttons ();
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (s != NULL) {
label_set_text (ui->file_label[1], _("Target"));
label_set_text (ui->file_string[1], truncFileString (ui, s));
return check_progress_buttons (ctx);
} else {
label_set_text (FileLabel [1], "");
label_set_text (FileString [1], "");
return file_progress_check_buttons ();
label_set_text (ui->file_label[1], "");
label_set_text (ui->file_string[1], "");
return check_progress_buttons (ctx);
}
}
FileProgressStatus
file_progress_show_deleting (char *s)
file_progress_show_deleting (FileOpContext *ctx, char *s)
{
label_set_text (FileLabel [0], _("Deleting"));
label_set_text (FileString [0], truncFileString (s));
return file_progress_check_buttons ();
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
label_set_text (ui->file_label[0], _("Deleting"));
label_set_text (ui->file_label[0], truncFileString (ui, s));
return check_progress_buttons (ctx);
}
static int
@ -503,133 +585,152 @@ rd_widgets [] =
};
#define ADD_RD_BUTTON(i)\
add_widgetl (replace_dlg,\
add_widgetl (ui->replace_dlg,\
button_new (rd_widgets [i].ypos, rd_widgets [i].xpos, rd_widgets [i].value,\
NORMAL_BUTTON, rd_widgets [i].text, 0, 0, rd_widgets [i].tkname), \
rd_widgets [i].layout)
#define ADD_RD_LABEL(i,p1,p2)\
#define ADD_RD_LABEL(ui,i,p1,p2)\
sprintf (buffer, rd_widgets [i].text, p1, p2);\
add_widgetl (replace_dlg,\
add_widgetl (ui->replace_dlg,\
label_new (rd_widgets [i].ypos, rd_widgets [i].xpos, buffer, rd_widgets [i].tkname),\
rd_widgets [i].layout)
static void
init_replace (enum OperationMode mode)
init_replace (FileOpContext *ctx, enum OperationMode mode)
{
FileOpContextUI *ui;
char buffer [128];
static int rd_xlen = 60, rd_trunc = X_TRUNC;
static int rd_xlen = 60, rd_trunc = X_TRUNC;
#ifdef ENABLE_NLS
static int i18n_flag;
if (!i18n_flag)
{
int l1, l2, l, row;
register int i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
while (i--)
rd_widgets [i].text = _(rd_widgets [i].text);
static int i18n_flag;
if (!i18n_flag) {
int l1, l2, l, row;
register int i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
while (i--)
rd_widgets [i].text = _(rd_widgets [i].text);
/*
*longest of "Overwrite..." labels
* (assume "Target date..." are short enough)
*/
l1 = max (strlen (rd_widgets [6].text), strlen (rd_widgets [11].text));
/*
*longest of "Overwrite..." labels
* (assume "Target date..." are short enough)
*/
l1 = max (strlen (rd_widgets [6].text), strlen (rd_widgets [11].text));
/* longest of button rows */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
for (row = l = l2 = 0; i--;)
{
if (rd_widgets [i].value != 0)
{
if (row != rd_widgets [i].ypos)
{
row = rd_widgets [i].ypos;
l2 = max (l2, l);
l = 0;
}
l += strlen (rd_widgets [i].text) + 4;
}
/* longest of button rows */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
for (row = l = l2 = 0; i--;) {
if (rd_widgets [i].value != 0) {
if (row != rd_widgets [i].ypos) {
row = rd_widgets [i].ypos;
l2 = max (l2, l);
l = 0;
}
l2 = max (l2, l); /* last row */
rd_xlen = max (rd_xlen, l1 + l2 + 8);
rd_trunc = rd_xlen - 6;
/* Now place buttons */
l1 += 5; /* start of first button in the row */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
for (l = l1, row = 0; --i > 1;)
{
if (rd_widgets [i].value != 0)
{
if (row != rd_widgets [i].ypos)
{
row = rd_widgets [i].ypos;
l = l1;
}
rd_widgets [i].xpos = l;
l += strlen (rd_widgets [i].text) + 4;
}
}
/* Abort button is centered */
rd_widgets [1].xpos = (rd_xlen - strlen (rd_widgets [1].text) - 3) / 2;
l += strlen (rd_widgets [i].text) + 4;
}
}
l2 = max (l2, l); /* last row */
rd_xlen = max (rd_xlen, l1 + l2 + 8);
rd_trunc = rd_xlen - 6;
/* Now place buttons */
l1 += 5; /* start of first button in the row */
i = sizeof (rd_widgets) / sizeof (rd_widgets [0]);
for (l = l1, row = 0; --i > 1;) {
if (rd_widgets [i].value != 0) {
if (row != rd_widgets [i].ypos) {
row = rd_widgets [i].ypos;
l = l1;
}
rd_widgets [i].xpos = l;
l += strlen (rd_widgets [i].text) + 4;
}
}
/* Abort button is centered */
rd_widgets [1].xpos = (rd_xlen - strlen (rd_widgets [1].text) - 3) / 2;
}
#endif /* ENABLE_NLS */
ui = ctx->ui;
replace_colors [0] = ERROR_COLOR;
replace_colors [1] = COLOR_NORMAL;
replace_colors [2] = ERROR_COLOR;
replace_colors [3] = COLOR_NORMAL;
replace_dlg = create_dlg (0, 0, 16, rd_xlen, replace_colors, replace_callback,
"[ Replace ]", "replace", DLG_CENTER);
ui->replace_dlg = create_dlg (0, 0, 16, rd_xlen, replace_colors, replace_callback,
"[ Replace ]", "replace", DLG_CENTER);
x_set_dialog_title (replace_dlg,
mode == Foreground ? _(" File exists ") : _(" Background process: File exists "));
x_set_dialog_title (ui->replace_dlg,
(mode == Foreground
? _(" File exists ")
: _(" Background process: File exists ")));
ADD_RD_LABEL(0, name_trunc (file_progress_replace_filename, rd_trunc - strlen (rd_widgets [0].text)), 0 );
ADD_RD_BUTTON(1);
ADD_RD_BUTTON(2);
ADD_RD_BUTTON(3);
ADD_RD_BUTTON(4);
ADD_RD_BUTTON(5);
ADD_RD_LABEL(6,0,0);
ADD_RD_LABEL(ui, 0,
name_trunc (ui->replace_filename, rd_trunc - strlen (rd_widgets [0].text)), 0);
ADD_RD_BUTTON(1);
ADD_RD_BUTTON(2);
ADD_RD_BUTTON(3);
ADD_RD_BUTTON(4);
ADD_RD_BUTTON(5);
ADD_RD_LABEL(ui, 6, 0, 0);
/* "this target..." widgets */
if (!S_ISDIR (d_stat->st_mode)){
if ((d_stat->st_size && s_stat->st_size > d_stat->st_size))
ADD_RD_BUTTON(7);
if (!S_ISDIR (ui->d_stat->st_mode)){
if ((ui->d_stat->st_size && ui->s_stat->st_size > ui->d_stat->st_size))
ADD_RD_BUTTON(7);
ADD_RD_BUTTON(8);
ADD_RD_BUTTON(8);
}
ADD_RD_BUTTON(9);
ADD_RD_BUTTON(10);
ADD_RD_LABEL(11,0,0);
ADD_RD_BUTTON(9);
ADD_RD_BUTTON(10);
ADD_RD_LABEL(ui, 11,0,0);
ADD_RD_LABEL(12, file_date (d_stat->st_mtime), (int) d_stat->st_size);
ADD_RD_LABEL(13, file_date (s_stat->st_mtime), (int) s_stat->st_size);
ADD_RD_LABEL(ui, 12, file_date (ui->d_stat->st_mtime), (int) ui->d_stat->st_size);
ADD_RD_LABEL(ui, 13, file_date (ui->s_stat->st_mtime), (int) ui->s_stat->st_size);
}
void
file_progress_set_stalled_label (FileOpContext *ctx, char *stalled_msg)
{
FileOpContextUI *ui;
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui != NULL);
ui = ctx->ui;
label_set_text (ui->stalled_label, stalled_msg);
}
FileProgressStatus
file_progress_real_query_replace (enum OperationMode mode, char *destname, struct stat *_s_stat,
file_progress_real_query_replace (FileOpContext *ctx, enum OperationMode mode,
char *destname, struct stat *_s_stat,
struct stat *_d_stat)
{
if (file_progress_replace_result < REPLACE_ALWAYS){
file_progress_replace_filename = destname;
s_stat = _s_stat;
d_stat = _d_stat;
init_replace (mode);
run_dlg (replace_dlg);
file_progress_replace_result = replace_dlg->ret_value;
if (file_progress_replace_result == B_CANCEL)
file_progress_replace_result = REPLACE_ABORT;
destroy_dlg (replace_dlg);
FileOpContextUI *ui;
g_return_val_if_fail (ctx != NULL, FILE_CONT);
g_return_val_if_fail (ctx->ui != NULL, FILE_CONT);
ui = ctx->ui;
if (ui->replace_result < REPLACE_ALWAYS){
ui->replace_filename = destname;
ui->s_stat = _s_stat;
ui->d_stat = _d_stat;
init_replace (ctx, mode);
run_dlg (ui->replace_dlg);
ui->replace_result = ui->replace_dlg->ret_value;
if (ui->replace_result == B_CANCEL)
ui->replace_result = REPLACE_ABORT;
destroy_dlg (ui->replace_dlg);
}
switch (file_progress_replace_result){
switch (ui->replace_result){
case REPLACE_UPDATE:
do_refresh ();
if (_s_stat->st_mtime > _d_stat->st_mtime)
@ -646,10 +747,10 @@ file_progress_real_query_replace (enum OperationMode mode, char *destname, struc
case REPLACE_REGET:
/* Carefull: we fall through and set do_append */
file_progress_do_reget = _d_stat->st_size;
ctx->do_reget = _d_stat->st_size;
case REPLACE_APPEND:
file_progress_do_append = 1;
ctx->do_append = 1;
case REPLACE_YES:
case REPLACE_ALWAYS:
@ -665,15 +766,9 @@ file_progress_real_query_replace (enum OperationMode mode, char *destname, struc
}
}
void
file_progress_set_stalled_label (char *stalled_msg)
{
label_set_text (stalled_label, stalled_msg);
}
#define FMDY 13
#define FMD_XLEN 64
extern int fmd_xlen, fmd_i18n_flag;
extern int fmd_xlen;
static QuickWidget fmd_widgets [] = {
#define FMCB0 FMDC
@ -681,19 +776,12 @@ static QuickWidget fmd_widgets [] = {
#define FMCB11 1
/* follow symlinks and preserve Attributes must be the first */
{ quick_checkbox, 3, 64, 8, FMDY, N_("preserve &Attributes"), 9, 0,
&op_preserve, 0, XV_WLAY_BELOWCLOSE, "preserve" },
0 /* &op_preserve */, 0, XV_WLAY_BELOWCLOSE, "preserve" },
{ quick_checkbox, 3, 64, 7, FMDY, N_("follow &Links"), 7, 0,
&file_mask_op_follow_links, 0, XV_WLAY_BELOWCLOSE, "follow" },
#ifdef HAVE_XVIEW
#define FMDI1 5
#define FMDI2 2
#define FMDC 4
{ quick_input, 3, 64, 6, FMDY, "", 58, 0,
0, 0, XV_WLAY_BELOWCLOSE, "input2" },
#endif
0 /* &file_mask_op_follow_links */, 0, XV_WLAY_BELOWCLOSE, "follow" },
{ quick_label, 3, 64, 5, FMDY, N_("to:"), 0, 0, 0, 0, XV_WLAY_BELOWOF,"to"},
{ quick_checkbox, 37, 64, 4, FMDY, N_("&Using shell patterns"), 0, 0,
0/* &source_easy_patterns */, 0, XV_WLAY_BELOWCLOSE, "using-shell" },
0 /* &source_easy_patterns */, 0, XV_WLAY_BELOWCLOSE, "using-shell" },
{ quick_input, 3, 64, 3, FMDY, "", 58,
0, 0, 0, XV_WLAY_BELOWCLOSE, "input-def" },
#define FMDI1 4
@ -723,19 +811,22 @@ static QuickWidget fmd_widgets [] = {
#endif
{ quick_button, 14, 64, 9, FMDY, N_("&Ok"), 0, B_ENTER, 0, 0, XV_WLAY_NEXTROW, "ok" },
{ quick_checkbox, 42, 64, 8, FMDY, N_("&Stable Symlinks"), 0, 0,
&file_mask_stable_symlinks, 0, XV_WLAY_BELOWCLOSE, "stab-sym" },
0 /* &file_mask_stable_symlinks */, 0, XV_WLAY_BELOWCLOSE, "stab-sym" },
{ quick_checkbox, 31, 64, 7, FMDY, N_("&Dive into subdir if exists"), 0, 0,
&dive_into_subdirs, 0, XV_WLAY_BELOWOF, "dive" },
0 /* &dive_into_subdirs */, 0, XV_WLAY_BELOWOF, "dive" },
{ 0 } };
void
fmd_init_i18n()
fmd_init_i18n (int force)
{
#ifdef ENABLE_NLS
static int initialized = FALSE;
register int i;
int len;
if (initialized && !force)
return;
#ifdef ENABLE_NLS
for (i = sizeof (op_names) / sizeof (op_names[0]); i--;)
op_names [i] = _(op_names [i]);
@ -791,11 +882,11 @@ fmd_init_i18n()
#undef chkbox_xpos
#endif /* ENABLE_NLS */
fmd_i18n_flag = 1;
initialized = TRUE;
}
char *
file_mask_dialog (FileOperation operation, char *text, char *def_text,
file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char *def_text,
int only_one, int *do_background)
{
int source_easy_patterns = easy_patterns;
@ -803,13 +894,22 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text,
const char *error;
struct stat buf;
int val;
QuickDialog Quick_input;
if (!fmd_i18n_flag)
fmd_init_i18n();
g_return_val_if_fail (ctx != NULL, NULL);
file_mask_stable_symlinks = 0;
fmd_init_i18n (FALSE);
/* Set up the result pointers */
fmd_widgets[FMCB12].result = &ctx->op_preserve;
fmd_widgets[FMCB11].result = &ctx->follow_links;
fmd_widgets[FMCB22].result = &ctx->stable_symlinks;
fmd_widgets[FMCB21].result = &ctx->dive_into_subdirs;
/* Create the dialog */
ctx->stable_symlinks = 0;
fmd_widgets [FMDC].result = &source_easy_patterns;
fmd_widgets [FMDI1].text = easy_patterns ? "*" : "^\\(.*\\)$";
Quick_input.xlen = fmd_xlen;
@ -818,8 +918,8 @@ file_mask_dialog (FileOperation operation, char *text, char *def_text,
Quick_input.help = "[Mask Copy/Rename]";
Quick_input.ylen = FMDY;
Quick_input.i18n = 1;
if (operation == OP_COPY){
if (operation == OP_COPY) {
Quick_input.class = "quick_file_mask_copy";
Quick_input.widgets = fmd_widgets;
} else { /* operation == OP_MOVE */
@ -837,22 +937,21 @@ ask_file_mask:
if ((val = quick_dialog_skip (&Quick_input, SKIP)) == B_CANCEL)
return 0;
if (file_mask_op_follow_links && operation != OP_MOVE)
file_mask_xstat = mc_stat;
if (ctx->follow_links && operation != OP_MOVE)
ctx->stat_func = mc_stat;
else
file_mask_xstat = mc_lstat;
if (op_preserve || operation == OP_MOVE){
file_mask_preserve = 1;
file_mask_umask_kill = 0777777;
file_mask_preserve_uidgid = (geteuid () == 0) ? 1 : 0;
}
else {
ctx->stat_func = mc_lstat;
if (ctx->op_preserve || operation == OP_MOVE) {
ctx->preserve = 1;
ctx->umask_kill = 0777777;
ctx->preserve_uidgid = (geteuid () == 0) ? 1 : 0;
} else {
int i;
file_mask_preserve = file_mask_preserve_uidgid = 0;
ctx->preserve = ctx->preserve_uidgid = 0;
i = umask (0);
umask (i);
file_mask_umask_kill = i ^ 0777777;
ctx->umask_kill = i ^ 0777777;
}
orig_mask = source_mask;
@ -866,10 +965,10 @@ ask_file_mask:
easy_patterns = 1;
source_mask = convert_pattern (source_mask, match_file, 1);
easy_patterns = source_easy_patterns;
error = re_compile_pattern (source_mask, strlen (source_mask), &file_mask_rx);
error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx);
free (source_mask);
} else
error = re_compile_pattern (source_mask, strlen (source_mask), &file_mask_rx);
error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx);
if (error){
message_3s (1, MSG_ERROR, _("Invalid source pattern `%s' \n %s "),
@ -880,19 +979,20 @@ ask_file_mask:
}
if (orig_mask)
free (orig_mask);
file_mask_dest_mask = strrchr (dest_dir, PATH_SEP);
if (file_mask_dest_mask == NULL)
file_mask_dest_mask = dest_dir;
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
if (ctx->dest_mask == NULL)
ctx->dest_mask = dest_dir;
else
file_mask_dest_mask++;
orig_mask = file_mask_dest_mask;
if (!*file_mask_dest_mask || (!dive_into_subdirs && !is_wildcarded (file_mask_dest_mask) &&
(!only_one || (!mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))) ||
(dive_into_subdirs && ((!only_one && !is_wildcarded (file_mask_dest_mask)) ||
(only_one && !mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))))
file_mask_dest_mask = strdup ("*");
ctx->dest_mask++;
orig_mask = ctx->dest_mask;
if (!*ctx->dest_mask || (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask) &&
(!only_one || (!mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))) ||
(ctx->dive_into_subdirs && ((!only_one && !is_wildcarded (ctx->dest_mask)) ||
(only_one
&& !mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))))
ctx->dest_mask = strdup ("*");
else {
file_mask_dest_mask = strdup (file_mask_dest_mask);
ctx->dest_mask = strdup (ctx->dest_mask);
*orig_mask = 0;
}
if (!*dest_dir){

Просмотреть файл

@ -4,54 +4,8 @@
/*
* GUI callback routines
*/
FileProgressStatus file_progress_check_buttons (void);
FileProgressStatus file_progress_show (long done, long total);
FileProgressStatus file_progress_show_count (long done, long total);
FileProgressStatus file_progress_show_bytes (double done, double total);
FileProgressStatus file_progress_show_source (char *path);
FileProgressStatus file_progress_show_target (char *path);
FileProgressStatus file_progress_show_deleting (char *path);
FileProgressStatus file_progress_real_query_replace (enum OperationMode mode,
char *destname,
struct stat *_s_stat,
struct stat *_d_stat);
void file_progress_set_stalled_label (char *stalled_msg);
void fmd_init_i18n();
/*
* Shared variables used to pass information from the file.c module to
* the GUI modules. Yes, this is hackish.
*
* This will be replaced with a FileOpContext soon (which will be created with
* create_op_win).
*
* Now, the reason this has not happened yet is that it needs to be done in
* sync with the background.c code (status result is passed trough the pipe
* and this needs to be handled properly, probably by creating a temporary
* FileOpContext and using this).
*
*/
extern int file_progress_replace_result;
extern int file_progress_recursive_result;
extern char *file_progress_replace_filename;
extern double file_progress_eta_secs;
extern int file_progress_do_reget;
extern int file_progress_do_append;
extern int file_mask_op_follow_links;
extern int file_mask_stable_symlinks;
extern int file_mask_preserve;
extern int file_mask_preserve_uidgid;
extern int file_mask_umask_kill;
extern char *file_mask_dest_mask;
extern unsigned long file_progress_bps;
extern unsigned long file_progress_bps_time;
int (*file_mask_xstat)(char *, struct stat *);
extern struct re_pattern_buffer file_mask_rx;
void fmd_init_i18n (int force);
#ifdef WANT_WIDGETS
char *panel_get_file (WPanel *panel, struct stat *stat_buf);

Просмотреть файл

@ -29,6 +29,7 @@ file_op_context_new (void)
ctx = g_new0 (FileOpContext, 1);
ctx->eta_secs = 0.0;
ctx->progress_bytes = 0.0;
ctx->op_preserve = TRUE;
ctx->do_reget = TRUE;
ctx->stat_func = mc_lstat;
ctx->preserve = TRUE;

Просмотреть файл

@ -11,7 +11,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "background.h"
#include "regex.h"
@ -35,6 +34,13 @@ typedef struct {
long progress_count;
double progress_bytes;
/* The value of the "preserve Attributes" checkbox in the copy file dialog.
* We can't use the value of "ctx->preserve" because it can change in order
* to preserve file attributs when moving files across filesystem boundaries
* (we want to keep the value of the checkbox between copy operations).
*/
int op_preserve;
/* Result from the recursive query */
int recursive_result;
@ -114,6 +120,12 @@ typedef enum {
FILE_ABORT
} FileProgressStatus;
/* First argument passed to real functions */
enum OperationMode {
Foreground,
Background
};
/* The following functions are implemented separately by each port */
void file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta);

Просмотреть файл

@ -145,7 +145,9 @@ static int
find_parameters (char **start_dir, char **pattern, char **content)
{
int return_value;
#ifndef HAVE_GNOME
char *temp_dir;
#endif
static char *in_contents = NULL;
static char *in_start_dir = NULL;
static char *in_start_name = NULL;
@ -481,7 +483,9 @@ do_search (struct Dlg_head *h)
static DIR *dirp = 0;
static char directory [MC_MAXPATHLEN+2];
struct stat tmp_stat;
#ifndef HAVE_X
static int pos;
#endif
static int subdirs_left = 0;
char *tmp_name; /* For bulding file names */
@ -493,8 +497,9 @@ do_search (struct Dlg_head *h)
dp = 0;
return;
}
#ifndef HAVE_X
do_search_begin:
#endif
while (!dp){
if (dirp){

Просмотреть файл

@ -35,6 +35,7 @@
#include "win.h" /* print_bytesize */
#include "layout.h"
#include "key.h" /* is_idle() */
#include "x.h"
#ifdef HAVE_TK
# include "tkmain.h"

Просмотреть файл

@ -2811,7 +2811,7 @@ compatibility_move_mc_files (void)
#endif
void
mc_tree_store_load ()
mc_tree_store_load (void)
{
char *tree_file;
@ -2822,7 +2822,7 @@ mc_tree_store_load ()
}
void
mc_tree_store_save ()
mc_tree_store_save (void)
{
char *tree_file;

Просмотреть файл

@ -25,6 +25,9 @@ enum {
extern int quote;
extern volatile int quit;
void mc_tree_store_load (void);
void mc_tree_store_save (void);
/* Execute functions: the base and the routines that use it */
void do_execute (const char *shell, const char *command, int internal_command);
#define execute_internal(command,args) do_execute (command, args, 1)

Просмотреть файл

@ -7,4 +7,6 @@ void load_panelize (void);
void save_panelize (void);
void done_panelize (void);
void do_external_panelize (char *command);
#endif

Просмотреть файл

@ -1655,7 +1655,9 @@ static void
move_selection (WPanel *panel, int lines)
{
int new_pos;
#ifndef HAVE_X
int adjust = 0;
#endif
new_pos = panel->selected + lines;
if (new_pos >= panel->count)

Просмотреть файл

@ -34,7 +34,7 @@
#include "key.h" /* define_sequence */
#include "main.h" /* extern: force_colors */
#include "win.h" /* do_exit_ca_mode */
#include "background.h" /* we_are_background definition */
#include "fileopctx.h"
#include "setup.h"
#ifdef HAVE_SLANG

Просмотреть файл

@ -43,6 +43,7 @@
#include "mouse.h"
#include "main.h"
#include "file.h" /* For copy_dir_dir(), move_dir_dir(), erase_dir() */
#include "fileopctx.h"
#include "help.h"
#include "key.h" /* For mi_getch() */
#include "tree.h"
@ -89,7 +90,6 @@ static tree_entry *forw_ptr (tree_entry *ptr, int *count)
/* Add a directory to the list of directories */
tree_entry *tree_add_entry (WTree *tree, char *name)
{
tree_entry entry;
if (!tree)
return 0;
@ -642,6 +642,7 @@ void tree_copy (WTree *tree, char *default_dest)
char *dest;
long count = 0;
double bytes = 0;
FileOpContext *ctx;
if (!tree->selected_ptr)
return;
@ -651,11 +652,12 @@ void tree_copy (WTree *tree, char *default_dest)
if (!dest || !*dest){
return;
}
create_op_win (OP_COPY, 0);
file_mask_defaults ();
copy_dir_dir (tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes);
destroy_op_win ();
ctx = file_op_context_new ();
file_op_context_create_ui (ctx, OP_COPY, FALSE);
copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes);
file_op_context_destroy (ctx);
free (dest);
}
@ -678,7 +680,8 @@ void tree_move (WTree *tree, char *default_dest)
struct stat buf;
double bytes = 0;
long count = 0;
FileOpContext *ctx;
if (!tree->selected_ptr)
return;
sprintf (cmd_buf, _("Move \"%s\" directory to:"),
@ -698,10 +701,12 @@ void tree_move (WTree *tree, char *default_dest)
free (dest);
return;
}
create_op_win (OP_MOVE, 0);
file_mask_defaults ();
move_dir_dir (tree->selected_ptr->name, dest, &count, &bytes);
destroy_op_win ();
ctx = file_op_context_new ();
file_op_context_create_ui (ctx, OP_MOVE, FALSE);
move_dir_dir (ctx, tree->selected_ptr->name, dest, &count, &bytes);
file_op_context_destroy (ctx);
free (dest);
}
@ -737,6 +742,7 @@ tree_rmdir_cmd (WTree *tree)
char old_dir [MC_MAXPATHLEN];
long count = 0;
double bytes = 0;
FileOpContext *ctx;
if (tree->selected_ptr){
if (!mc_get_current_wd (old_dir, MC_MAXPATHLEN))
@ -756,10 +762,12 @@ tree_rmdir_cmd (WTree *tree)
return;
}
}
create_op_win (OP_DELETE, 0);
if (erase_dir (tree->selected_ptr->name, &count, &bytes) == FILE_CONT)
ctx = file_op_context_new ();
file_op_context_create_ui (ctx, OP_DELETE, FALSE);
if (erase_dir (ctx, tree->selected_ptr->name, &count, &bytes) == FILE_CONT)
tree_forget_cmd (tree);
destroy_op_win ();
file_op_context_destroy (ctx);
mc_chdir (old_dir);
return;
} else

Просмотреть файл

@ -205,7 +205,7 @@ tree_store_load (char *name)
int len, common;
int do_load;
g_return_if_fail (name != NULL);
g_return_val_if_fail (name != NULL, FALSE);
if (ts.loaded)
return TRUE;
@ -679,8 +679,8 @@ tree_store_rescan (char *dir)
for (dp = mc_readdir (dirp); dp; dp = mc_readdir (dirp)){
char *full_name;
if (dp->d_name [0] == '.' &&
dp->d_name [1] == 0 || (dp->d_name [1] == '.' && dp->d_name [2] == 0))
if ((dp->d_name [0] == '.' && dp->d_name [1] == 0)
|| (dp->d_name [1] == '.' && dp->d_name [2] == 0))
continue;
full_name = concat_dir_and_file (dir, dp->d_name);

Просмотреть файл

@ -31,17 +31,18 @@ typedef struct {
extern void (*tree_store_dirty_notify)(int state);
TreeStore *tree_store_init (void);
int tree_store_load (char *name);
int tree_store_save (char *name);
tree_entry *tree_store_add_entry (char *name);
void tree_store_remove_entry (char *name);
void tree_store_destroy (void);
tree_entry *tree_store_start_check (char *path);
void tree_store_mark_checked (const char *subname);
void tree_store_end_check (void);
tree_entry *tree_store_whereis (char *name);
tree_entry *tree_store_rescan (char *dir);
TreeStore *tree_store_init (void);
int tree_store_load (char *name);
int tree_store_save (char *name);
tree_entry *tree_store_add_entry (char *name);
void tree_store_remove_entry (char *name);
void tree_store_destroy (void);
tree_entry *tree_store_start_check (char *path);
tree_entry *tree_store_start_check_cwd (void);
void tree_store_mark_checked (const char *subname);
void tree_store_end_check (void);
tree_entry *tree_store_whereis (char *name);
tree_entry *tree_store_rescan (char *dir);
typedef void (*tree_store_remove_fn)(tree_entry *tree, void *data);
void tree_store_add_entry_remove_hook (tree_store_remove_fn callback, void *data);

Просмотреть файл

@ -77,7 +77,9 @@ int quote = 0;
static int
button_callback (Dlg_head *h, WButton *b, int Msg, int Par)
{
#ifndef HAVE_X
char *txt, buf[256];
#endif
int stop = 0;
int off = 0;
@ -285,7 +287,9 @@ static int radio_event (Gpm_Event *event, WRadio *r);
static int
radio_callback (Dlg_head *h, WRadio *r, int Msg, int Par)
{
#ifndef HAVE_X
int i;
#endif
switch (Msg) {
case WIDGET_INIT:
@ -812,8 +816,10 @@ void
update_input (WInput *in, int clear_first)
{
int has_history = 0;
#ifndef HAVE_X
int i, j;
unsigned char c;
#endif
int buf_len = strlen (in->buffer);
if (should_show_history_button (in))