1998-12-02 07:33:26 +03:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
|
|
|
/* New dialogs... */
|
1998-12-05 04:01:13 +03:00
|
|
|
#include <config.h>
|
|
|
|
#include "panel.h"
|
1998-12-02 07:33:26 +03:00
|
|
|
#include <gnome.h>
|
1999-03-26 23:37:48 +03:00
|
|
|
#include "dialog.h"
|
1999-01-27 04:14:57 +03:00
|
|
|
#include "global.h"
|
1998-12-02 07:33:26 +03:00
|
|
|
#include "file.h"
|
1998-12-04 00:11:36 +03:00
|
|
|
#include "filegui.h"
|
1999-01-14 04:10:32 +03:00
|
|
|
#include "fileopctx.h"
|
1999-01-28 02:22:50 +03:00
|
|
|
#include "eregex.h"
|
1999-03-16 23:46:47 +03:00
|
|
|
#include "main.h"
|
1998-12-05 04:01:13 +03:00
|
|
|
#include "../vfs/vfs.h"
|
1998-12-02 07:33:26 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
enum {
|
1999-01-14 04:10:32 +03:00
|
|
|
REPLACE_PROMPT,
|
|
|
|
REPLACE_ALWAYS,
|
|
|
|
REPLACE_UPDATE,
|
|
|
|
REPLACE_NEVER,
|
|
|
|
REPLACE_ABORT,
|
|
|
|
REPLACE_SIZE,
|
|
|
|
REPLACE_OPTION_MENU
|
1998-12-23 02:38:39 +03:00
|
|
|
} FileReplaceCode;
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
/* 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;
|
|
|
|
|
1999-01-23 23:43:36 +03:00
|
|
|
static char *gdialog_to_string = N_("To: ");
|
|
|
|
static char *gdialog_from_string = N_("Copying from: ");
|
|
|
|
static char *gdialog_deleting_string = N_("Deleting file: ");
|
1999-01-06 04:17:49 +03:00
|
|
|
|
1998-12-04 23:21:11 +03:00
|
|
|
#define GDIALOG_PROGRESS_WIDTH 350
|
1998-12-23 02:38:39 +03:00
|
|
|
|
1998-12-04 00:11:36 +03:00
|
|
|
/* Callbacks go here... */
|
1998-12-04 03:13:53 +03:00
|
|
|
static void
|
1998-12-04 00:11:36 +03:00
|
|
|
fmd_check_box_callback (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
if (data)
|
|
|
|
*((gint*)data) = GTK_TOGGLE_BUTTON (widget)->active;
|
|
|
|
}
|
1998-12-04 03:13:53 +03:00
|
|
|
|
1998-12-04 23:21:11 +03:00
|
|
|
static gchar *
|
1999-01-14 04:10:32 +03:00
|
|
|
trim_file_name (FileOpContextUI *ui, gchar *path, gint length, gint cur_length)
|
1998-12-04 23:21:11 +03:00
|
|
|
{
|
|
|
|
static gint dotdotdot = 0;
|
|
|
|
gchar *path_copy = NULL;
|
|
|
|
gint len;
|
|
|
|
|
|
|
|
if (!dotdotdot)
|
1999-01-14 04:10:32 +03:00
|
|
|
dotdotdot = gdk_string_width (ui->op_source_label->style->font, "...");
|
1998-12-04 23:21:11 +03:00
|
|
|
/* Cut the font length of path to length. */
|
|
|
|
|
|
|
|
length -= dotdotdot;
|
|
|
|
len = (gint) ((1.0 - (gfloat) length / (gfloat) cur_length) * strlen (path));
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1998-12-04 23:21:11 +03:00
|
|
|
/* we guess a starting point */
|
1999-01-14 04:10:32 +03:00
|
|
|
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)
|
1999-08-11 01:52:06 +04:00
|
|
|
len--;
|
1998-12-04 23:21:11 +03:00
|
|
|
len++;
|
|
|
|
} else {
|
1999-01-14 04:10:32 +03:00
|
|
|
while (gdk_string_width (ui->op_source_label->style->font, path + len) > length)
|
1999-08-11 01:52:06 +04:00
|
|
|
len++;
|
1998-12-04 23:21:11 +03:00
|
|
|
}
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-27 04:14:57 +03:00
|
|
|
path_copy = g_strdup_printf ("...%s", path + len);
|
1998-12-04 23:21:11 +03:00
|
|
|
return path_copy;
|
|
|
|
}
|
|
|
|
|
1998-12-02 07:33:26 +03:00
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_show_source (FileOpContext *ctx, char *path)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1998-12-04 23:21:11 +03:00
|
|
|
static gint from_width = 0;
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1998-12-04 23:21:11 +03:00
|
|
|
gint path_width;
|
|
|
|
gchar *path_copy = NULL;
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
g_return_val_if_fail (ctx != NULL, FILE_CONT);
|
1999-03-11 05:00:12 +03:00
|
|
|
|
|
|
|
/* ctx->ui might be NULL for background processes */
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return FILE_CONT;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
ui = ctx->ui;
|
1998-12-04 23:21:11 +03:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
g_return_val_if_fail (ui->op_source_label != NULL, FILE_CONT);
|
|
|
|
|
|
|
|
if (ui->aborting)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
if (path == NULL){
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_source_label), "");
|
1998-12-17 11:28:05 +03:00
|
|
|
return FILE_CONT;
|
1998-12-17 07:51:24 +03:00
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
if (!from_width){
|
1999-01-14 04:10:32 +03:00
|
|
|
from_width = gdk_string_width (ui->op_source_label->style->font,
|
1999-01-23 23:43:36 +03:00
|
|
|
_(gdialog_from_string));
|
1998-12-17 07:51:24 +03:00
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
path_width = gdk_string_width (ui->op_source_label->style->font, path);
|
1998-12-04 23:21:11 +03:00
|
|
|
if (from_width + path_width < GDIALOG_PROGRESS_WIDTH)
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_source_label), path);
|
1998-12-04 23:21:11 +03:00
|
|
|
else {
|
1999-01-14 04:10:32 +03:00
|
|
|
path_copy = trim_file_name (ui, path, GDIALOG_PROGRESS_WIDTH - from_width,
|
|
|
|
path_width);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_source_label), path_copy);
|
1998-12-04 23:21:11 +03:00
|
|
|
g_free (path_copy);
|
|
|
|
}
|
|
|
|
|
1998-12-02 07:33:26 +03:00
|
|
|
return FILE_CONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_show_target (FileOpContext *ctx, char *path)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1998-12-04 23:21:11 +03:00
|
|
|
static gint to_width = 0;
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1998-12-04 23:21:11 +03:00
|
|
|
gint path_width;
|
|
|
|
gchar *path_copy = NULL;
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
g_return_val_if_fail (ctx != NULL, FILE_CONT);
|
1999-03-11 05:00:12 +03:00
|
|
|
/* ctx->ui might be NULL for background processes */
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return FILE_CONT;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
ui = ctx->ui;
|
|
|
|
|
|
|
|
g_return_val_if_fail (ui->op_target_label != NULL, FILE_CONT);
|
1998-12-04 23:21:11 +03:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
if (ui->aborting)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
if (path == NULL){
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_target_label), "");
|
1998-12-17 11:28:05 +03:00
|
|
|
return FILE_CONT;
|
1998-12-17 07:51:24 +03:00
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1999-08-11 01:52:06 +04:00
|
|
|
if (!to_width)
|
1999-01-14 04:10:32 +03:00
|
|
|
to_width = gdk_string_width (ui->op_target_label->style->font,
|
1999-01-23 23:43:36 +03:00
|
|
|
_(gdialog_to_string));
|
1999-01-14 04:10:32 +03:00
|
|
|
path_width = gdk_string_width (ui->op_target_label->style->font, path);
|
1998-12-04 23:21:11 +03:00
|
|
|
if (to_width + path_width < GDIALOG_PROGRESS_WIDTH)
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_target_label), path);
|
1998-12-04 23:21:11 +03:00
|
|
|
else {
|
1999-01-14 04:10:32 +03:00
|
|
|
path_copy = trim_file_name (ui, path, GDIALOG_PROGRESS_WIDTH - to_width, path_width);
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_target_label), path_copy);
|
1998-12-04 23:21:11 +03:00
|
|
|
g_free (path_copy);
|
|
|
|
}
|
|
|
|
|
1998-12-02 07:33:26 +03:00
|
|
|
return FILE_CONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_show_deleting (FileOpContext *ctx, char *path)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-01-20 05:16:09 +03:00
|
|
|
static gint deleting_width = 0;
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1999-01-20 05:16:09 +03:00
|
|
|
gint path_width;
|
|
|
|
gchar *path_copy = NULL;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, FILE_CONT);
|
1999-03-11 05:00:12 +03:00
|
|
|
|
|
|
|
/* ctx->ui might be NULL for background processes */
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return FILE_CONT;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
ui = ctx->ui;
|
|
|
|
|
|
|
|
if (ui->aborting)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
if (path == NULL){
|
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_source_label), "");
|
|
|
|
return FILE_CONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!deleting_width){
|
|
|
|
deleting_width = gdk_string_width (ui->op_source_label->style->font,
|
1999-01-23 23:43:36 +03:00
|
|
|
_(gdialog_deleting_string));
|
1999-01-20 05:16:09 +03:00
|
|
|
}
|
|
|
|
path_width = gdk_string_width (ui->op_source_label->style->font, path);
|
|
|
|
if (deleting_width + path_width < GDIALOG_PROGRESS_WIDTH)
|
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_source_label), path);
|
|
|
|
else {
|
|
|
|
path_copy = trim_file_name (ui, path, GDIALOG_PROGRESS_WIDTH - deleting_width,
|
|
|
|
path_width);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->op_source_label), path_copy);
|
|
|
|
g_free (path_copy);
|
|
|
|
}
|
1998-12-17 11:28:05 +03:00
|
|
|
return FILE_CONT;
|
1998-12-02 07:33:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_show (FileOpContext *ctx, long done, long total)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-03-16 03:11:32 +03:00
|
|
|
static gchar count[20];
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1999-03-16 03:11:32 +03:00
|
|
|
double perc;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, FILE_CONT);
|
1999-01-06 04:17:49 +03:00
|
|
|
|
1999-03-11 05:00:12 +03:00
|
|
|
/* ctx->ui might be NULL for background processes */
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return FILE_CONT;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
ui = ctx->ui;
|
|
|
|
|
|
|
|
if (ui->aborting)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-03-16 03:11:32 +03:00
|
|
|
if (total > 0) {
|
|
|
|
perc = (double) done / (double) total;
|
1999-03-19 20:13:33 +03:00
|
|
|
snprintf (count, 9, "%3d%% ", (gint) (100.0 * perc));
|
1999-03-16 03:11:32 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->file_label), count);
|
1999-03-19 20:13:33 +03:00
|
|
|
}
|
1998-12-04 23:21:11 +03:00
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
1998-12-02 07:33:26 +03:00
|
|
|
return FILE_CONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_show_count (FileOpContext *ctx, long done, long total)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-05-03 22:57:48 +04:00
|
|
|
static gchar count[100];
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, FILE_CONT);
|
|
|
|
|
1999-03-11 05:00:12 +03:00
|
|
|
/* ctx->ui might be NULL for background processes */
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return FILE_CONT;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
ui = ctx->ui;
|
1999-01-06 04:17:49 +03:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
if (ui->aborting)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
|
|
|
|
1999-05-03 22:57:48 +04:00
|
|
|
snprintf (count, 100, "%ld/%ld ", done, total);
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (ui->count_label), count);
|
1998-12-04 23:21:11 +03:00
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
1998-12-02 07:33:26 +03:00
|
|
|
return FILE_CONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_show_bytes (FileOpContext *ctx, double done, double total)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1999-03-16 03:11:32 +03:00
|
|
|
double perc;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, FILE_CONT);
|
1999-03-26 23:37:48 +03:00
|
|
|
|
1999-03-11 05:00:12 +03:00
|
|
|
/* ctx->ui might be NULL for background processes */
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return FILE_CONT;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
ui = ctx->ui;
|
|
|
|
|
|
|
|
if (ui->aborting)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
|
|
|
|
1999-03-26 23:37:48 +03:00
|
|
|
if (total == 0.0)
|
|
|
|
perc = 1.0;
|
|
|
|
else
|
|
|
|
perc = done / total;
|
|
|
|
|
1999-03-16 03:11:32 +03:00
|
|
|
gtk_progress_bar_update (GTK_PROGRESS_BAR (ui->byte_prog), CLAMP (perc, 0.0, 1.0));
|
|
|
|
|
1998-12-04 23:21:11 +03:00
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
1998-12-02 07:33:26 +03:00
|
|
|
return FILE_CONT;
|
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
static void
|
1999-01-14 04:10:32 +03:00
|
|
|
option_menu_policy_callback (GtkWidget *item, gpointer data)
|
1998-12-23 02:38:39 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
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);
|
1998-12-23 02:38:39 +03:00
|
|
|
}
|
1998-12-29 07:15:30 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
static void
|
|
|
|
policy_callback (GtkWidget *button, gpointer data)
|
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
ui = data;
|
|
|
|
status = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (button)));
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
if (GTK_TOGGLE_BUTTON (button)->active) {
|
1999-01-14 04:10:32 +03:00
|
|
|
if (status == REPLACE_OPTION_MENU) {
|
|
|
|
ui->copy_status = ui->minor_copy_status;
|
1998-12-23 02:38:39 +03:00
|
|
|
} else
|
1999-01-14 04:10:32 +03:00
|
|
|
ui->copy_status = status;
|
1998-12-23 02:38:39 +03:00
|
|
|
}
|
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_query_replace_policy (FileOpContext *ctx, gboolean dialog_needed)
|
1998-12-23 02:38:39 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1998-12-23 02:38:39 +03:00
|
|
|
GtkWidget *qrp_dlg;
|
|
|
|
GtkWidget *radio;
|
|
|
|
GtkWidget *vbox;
|
1999-03-11 05:40:53 +03:00
|
|
|
GtkWidget *vbox2;
|
1998-12-23 02:38:39 +03:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *icon;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *hrbox;
|
|
|
|
GSList *group = NULL;
|
|
|
|
GtkWidget *omenu;
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
g_return_val_if_fail (ctx != NULL, FILE_CONT);
|
1999-03-11 05:00:12 +03:00
|
|
|
|
|
|
|
/* ctx->ui might be NULL for background processes */
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return FILE_CONT;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
ui = ctx->ui;
|
|
|
|
|
|
|
|
if (ui->aborting)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
ui->copy_status = REPLACE_PROMPT;
|
1998-12-29 07:15:30 +03:00
|
|
|
if (dialog_needed == FALSE)
|
|
|
|
return FILE_CONT;
|
1999-01-14 04:10:32 +03:00
|
|
|
ui->minor_copy_status = REPLACE_ALWAYS;
|
1998-12-23 02:38:39 +03:00
|
|
|
qrp_dlg = gnome_dialog_new (_("Files Exist"),
|
|
|
|
GNOME_STOCK_BUTTON_OK,
|
|
|
|
GNOME_STOCK_BUTTON_CANCEL,
|
|
|
|
NULL);
|
1999-01-23 23:43:36 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (qrp_dlg), GTK_WIN_POS_MOUSE);
|
1999-03-11 05:40:53 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
1999-03-11 05:40:53 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (qrp_dlg)->vbox), hbox, FALSE, FALSE, 0);
|
1998-12-23 02:38:39 +03:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
icon = gnome_stock_pixmap_widget (hbox, GNOME_STOCK_PIXMAP_HELP);
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
|
1999-03-11 05:40:53 +03:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, GNOME_PAD_SMALL);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Some of the files you are trying to copy already "
|
1999-03-11 05:40:53 +03:00
|
|
|
"exist in the destination folder. Please select "
|
|
|
|
"the action to be performed."));
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
vbox2 = gtk_vbox_new (TRUE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
radio = gtk_radio_button_new_with_label (group, _("Prompt me before overwriting any file."));
|
1999-01-14 04:10:32 +03:00
|
|
|
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);
|
1999-03-11 05:40:53 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), radio, FALSE, FALSE, 0);
|
1998-12-23 02:38:39 +03:00
|
|
|
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
|
|
|
|
|
|
|
|
radio = gtk_radio_button_new_with_label (group, _("Don't overwrite any files."));
|
1999-01-14 04:10:32 +03:00
|
|
|
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);
|
1999-03-11 05:40:53 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), radio, FALSE, FALSE, 0);
|
1998-12-23 02:38:39 +03:00
|
|
|
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
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);
|
1999-03-11 05:40:53 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), ui->op_radio, FALSE, FALSE, 0);
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
hrbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
1999-03-11 05:40:53 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (ui->op_radio), hrbox);
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hrbox), gtk_label_new (_("Overwrite:")), FALSE, FALSE, 0);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
/* 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 ();
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("Older files."));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-14 04:10:32 +03:00
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (REPLACE_UPDATE));
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
1999-01-14 04:10:32 +03:00
|
|
|
GTK_SIGNAL_FUNC (option_menu_policy_callback), ui);
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("Files only if size differs."));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-14 04:10:32 +03:00
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (REPLACE_SIZE));
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
1999-01-14 04:10:32 +03:00
|
|
|
GTK_SIGNAL_FUNC (option_menu_policy_callback), ui);
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("All files."));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-14 04:10:32 +03:00
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (REPLACE_ALWAYS));
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
1999-01-14 04:10:32 +03:00
|
|
|
GTK_SIGNAL_FUNC (option_menu_policy_callback), ui);
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_widget_show_all (menu);
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
|
|
|
|
|
|
|
|
gtk_widget_show_all (GTK_WIDGET (GNOME_DIALOG (qrp_dlg)->vbox));
|
|
|
|
switch (gnome_dialog_run_and_close (GNOME_DIALOG (qrp_dlg))) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
default:
|
1999-01-14 04:10:32 +03:00
|
|
|
ui->copy_status = REPLACE_ABORT;
|
1998-12-23 02:38:39 +03:00
|
|
|
return FILE_ABORT;
|
|
|
|
}
|
|
|
|
return FILE_CONT;
|
|
|
|
}
|
1998-12-02 07:33:26 +03:00
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
FileProgressStatus
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_real_query_replace (FileOpContext *ctx, enum OperationMode mode, char *destname,
|
|
|
|
struct stat *_s_stat, struct stat *_d_stat)
|
1998-12-23 02:38:39 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1998-12-23 02:38:39 +03:00
|
|
|
GtkWidget *qr_dlg;
|
|
|
|
gchar msg[128];
|
|
|
|
GtkWidget *label;
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
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)
|
1999-01-06 04:17:49 +03:00
|
|
|
return FILE_ABORT;
|
|
|
|
|
1998-12-23 02:38:39 +03:00
|
|
|
/* so what's the situation? Do we prompt or don't we prompt. */
|
1999-01-14 04:10:32 +03:00
|
|
|
if (ui->copy_status == REPLACE_PROMPT){
|
1999-01-06 05:08:27 +03:00
|
|
|
qr_dlg = gnome_dialog_new (_("File Exists"),
|
|
|
|
GNOME_STOCK_BUTTON_YES,
|
|
|
|
GNOME_STOCK_BUTTON_NO,
|
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1999-01-23 23:43:36 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (qr_dlg), GTK_WIN_POS_MOUSE);
|
1999-01-06 05:08:27 +03:00
|
|
|
snprintf (msg, sizeof (msg)-1, _("The target file already exists: %s"), destname);
|
|
|
|
label = gtk_label_new (msg);
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (qr_dlg)->vbox),
|
|
|
|
label, FALSE, FALSE, 0);
|
1999-01-06 05:08:27 +03:00
|
|
|
label = gtk_label_new (_("Replace it?"));
|
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (qr_dlg)->vbox),
|
|
|
|
label, FALSE, FALSE, 0);
|
1998-12-23 02:38:39 +03:00
|
|
|
gtk_widget_show_all (GNOME_DIALOG (qr_dlg)->vbox);
|
|
|
|
switch (gnome_dialog_run_and_close (GNOME_DIALOG (qr_dlg))) {
|
|
|
|
case 0:
|
|
|
|
return FILE_CONT;
|
|
|
|
case 1:
|
|
|
|
return FILE_SKIP;
|
|
|
|
default:
|
|
|
|
return FILE_ABORT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
switch (ui->copy_status){
|
1998-12-23 02:38:39 +03:00
|
|
|
case REPLACE_UPDATE:
|
|
|
|
if (_s_stat->st_mtime > _d_stat->st_mtime)
|
|
|
|
return FILE_CONT;
|
|
|
|
else
|
|
|
|
return FILE_SKIP;
|
|
|
|
case REPLACE_SIZE:
|
|
|
|
if (_s_stat->st_size == _d_stat->st_size)
|
|
|
|
return FILE_SKIP;
|
|
|
|
else
|
|
|
|
return FILE_CONT;
|
|
|
|
case REPLACE_ALWAYS:
|
|
|
|
return FILE_CONT;
|
|
|
|
case REPLACE_NEVER:
|
|
|
|
return FILE_SKIP;
|
|
|
|
case REPLACE_ABORT:
|
|
|
|
default:
|
|
|
|
return FILE_ABORT;
|
|
|
|
}
|
|
|
|
}
|
1998-12-17 07:51:24 +03:00
|
|
|
|
1998-12-02 07:33:26 +03:00
|
|
|
void
|
1999-01-14 04:10:32 +03:00
|
|
|
file_progress_set_stalled_label (FileOpContext *ctx, char *stalled_msg)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
g_return_if_fail (ctx != NULL);
|
1999-03-11 05:00:12 +03:00
|
|
|
|
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-04 23:21:11 +03:00
|
|
|
if (!stalled_msg || !*stalled_msg)
|
|
|
|
return;
|
1999-01-14 04:10:32 +03:00
|
|
|
/* FIXME */
|
1998-12-23 02:38:39 +03:00
|
|
|
g_warning ("FIXME: file_progress_set_stalled_label!\nmsg\t%s\n",stalled_msg);
|
1998-12-02 07:33:26 +03:00
|
|
|
}
|
1999-03-11 05:00:12 +03:00
|
|
|
|
1998-12-02 07:33:26 +03:00
|
|
|
char *
|
1999-01-14 04:10:32 +03:00
|
|
|
file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char *def_text,
|
|
|
|
int only_one, int *do_background)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
GtkWidget *fmd_win;
|
1998-12-04 00:11:36 +03:00
|
|
|
GtkWidget *notebook;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox, *label;
|
|
|
|
GtkWidget *fentry;
|
|
|
|
GtkWidget *cbox;
|
|
|
|
GtkWidget *icon;
|
1998-12-04 03:13:53 +03:00
|
|
|
int source_easy_patterns = easy_patterns;
|
1998-12-04 00:11:36 +03:00
|
|
|
char *source_mask, *orig_mask, *dest_dir;
|
|
|
|
const char *error;
|
|
|
|
struct stat buf;
|
1999-05-27 06:06:27 +04:00
|
|
|
int run;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
g_return_val_if_fail (ctx != NULL, NULL);
|
|
|
|
|
|
|
|
ctx->stable_symlinks = 0;
|
|
|
|
|
1998-12-04 00:11:36 +03:00
|
|
|
/* Basic window */
|
|
|
|
if (operation == OP_COPY)
|
1999-08-11 01:52:06 +04:00
|
|
|
fmd_win = gnome_dialog_new (_("Copy"), GNOME_STOCK_BUTTON_OK,
|
1998-12-04 00:11:36 +03:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
|
|
|
else if (operation == OP_MOVE)
|
1999-08-11 01:52:06 +04:00
|
|
|
fmd_win = gnome_dialog_new (_("Move"), GNOME_STOCK_BUTTON_OK,
|
1998-12-04 00:11:36 +03:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
|
|
|
|
1999-01-23 23:43:36 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (fmd_win), GTK_WIN_POS_MOUSE);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1998-12-04 00:11:36 +03:00
|
|
|
notebook = gtk_notebook_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (fmd_win)->vbox),
|
|
|
|
notebook, FALSE, FALSE, 0);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD);
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
|
|
|
hbox,
|
|
|
|
gtk_label_new (_("Destination")));
|
|
|
|
|
|
|
|
/* FIXME: I want a bigger, badder, better Icon here... */
|
1998-12-04 00:11:36 +03:00
|
|
|
icon = gnome_stock_pixmap_widget (hbox, GNOME_STOCK_PIXMAP_HELP);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1998-12-04 00:11:36 +03:00
|
|
|
vbox = gtk_vbox_new (FALSE, GNOME_PAD);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1998-12-04 00:11:36 +03:00
|
|
|
label = gtk_label_new (text);
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
1999-01-06 04:17:49 +03:00
|
|
|
fentry = gnome_file_entry_new ("gmc-copy-file", _("Find Destination Folder"));
|
1998-12-04 00:11:36 +03:00
|
|
|
gnome_file_entry_set_directory (GNOME_FILE_ENTRY (fentry), TRUE);
|
1998-12-04 03:13:53 +03:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (fentry))),
|
1998-12-04 00:11:36 +03:00
|
|
|
def_text);
|
|
|
|
gnome_file_entry_set_default_path (GNOME_FILE_ENTRY (fentry), def_text);
|
1999-08-11 01:52:06 +04:00
|
|
|
gnome_file_entry_set_modal (GNOME_FILE_ENTRY (fentry), TRUE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), fentry, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* Background operations are completely hosed, so we olympically disable
|
|
|
|
* them. How's that for foolproof bugfixing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
*do_background = FALSE;
|
|
|
|
#if 0
|
1999-01-06 04:17:49 +03:00
|
|
|
cbox = gtk_check_button_new_with_label (_("Copy as a background process"));
|
1999-01-13 23:37:47 +03:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), *do_background);
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
|
|
|
|
(GtkSignalFunc) fmd_check_box_callback, do_background);
|
1998-12-06 00:54:25 +03:00
|
|
|
#if 0
|
1998-12-04 00:11:36 +03:00
|
|
|
gnome_widget_add_help (cbox, "Selecting this will run the copying in the background. "
|
|
|
|
"This is useful for transfers over networks that might take a long "
|
|
|
|
"time to complete.");
|
1998-12-06 00:54:25 +03:00
|
|
|
#endif
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
|
1999-08-11 01:52:06 +04:00
|
|
|
#endif
|
1998-12-04 00:11:36 +03:00
|
|
|
|
|
|
|
/* Advanced Options */
|
|
|
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
|
|
|
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
1999-08-11 01:52:06 +04:00
|
|
|
hbox,
|
1999-01-06 04:17:49 +03:00
|
|
|
gtk_label_new (_("Advanced Options")));
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
|
|
|
|
1999-01-06 04:17:49 +03:00
|
|
|
cbox = gtk_check_button_new_with_label (_("Preserve symlinks"));
|
1999-01-14 04:10:32 +03:00
|
|
|
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);
|
1998-12-06 00:54:25 +03:00
|
|
|
#if 0
|
1998-12-04 00:11:36 +03:00
|
|
|
gnome_widget_add_help (cbox, "FIXME: Add something here Miguel");
|
1998-12-06 00:54:25 +03:00
|
|
|
#endif
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
if (operation == OP_COPY) {
|
1999-01-06 04:17:49 +03:00
|
|
|
cbox = gtk_check_button_new_with_label (_("Follow links."));
|
1999-01-14 04:10:32 +03:00
|
|
|
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);
|
1999-03-11 05:40:53 +03:00
|
|
|
#if 0
|
1999-01-14 04:10:32 +03:00
|
|
|
gnome_widget_add_help (cbox,
|
|
|
|
_("Selecting this will copy the files that symlinks point "
|
|
|
|
"to instead of just copying the link."));
|
1999-03-11 05:40:53 +03:00
|
|
|
#endif
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
|
|
|
|
|
1999-01-06 04:17:49 +03:00
|
|
|
cbox = gtk_check_button_new_with_label (_("Preserve file attributes."));
|
1999-01-14 04:10:32 +03:00
|
|
|
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);
|
1999-03-11 05:40:53 +03:00
|
|
|
#if 0
|
1999-08-11 01:52:06 +04:00
|
|
|
gnome_widget_add_help (cbox,
|
|
|
|
_("Preserves the permissions and the UID/GID if possible"));
|
1999-03-11 05:40:53 +03:00
|
|
|
#endif
|
1998-12-04 00:11:36 +03:00
|
|
|
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);
|
1999-01-06 04:17:49 +03:00
|
|
|
cbox = gtk_check_button_new_with_label (_("Recursively copy subdirectories."));
|
1999-01-14 04:10:32 +03:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->dive_into_subdirs);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
|
1999-08-11 01:52:06 +04:00
|
|
|
(GtkSignalFunc) fmd_check_box_callback,
|
|
|
|
&ctx->dive_into_subdirs);
|
1999-03-11 05:40:53 +03:00
|
|
|
#if 0
|
1999-08-11 01:52:06 +04:00
|
|
|
gnome_widget_add_help (cbox,
|
|
|
|
_("If set, this will copy the directories recursively"));
|
1999-03-11 05:40:53 +03:00
|
|
|
#endif
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
|
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_widget_show_all (GNOME_DIALOG (fmd_win)->vbox);
|
|
|
|
gnome_dialog_set_close (GNOME_DIALOG (fmd_win), TRUE);
|
|
|
|
gnome_dialog_close_hides (GNOME_DIALOG (fmd_win), TRUE);
|
|
|
|
|
|
|
|
/* Off to the races!!! */
|
1999-05-27 06:06:27 +04:00
|
|
|
run = gnome_dialog_run (GNOME_DIALOG (fmd_win));
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-08-12 23:26:09 +04:00
|
|
|
if (run == 1 || run == -1) {
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_widget_destroy (fmd_win);
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1999-08-11 01:52:06 +04:00
|
|
|
dest_dir = gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (fentry), FALSE);
|
1998-12-04 00:11:36 +03:00
|
|
|
gtk_widget_destroy (fmd_win);
|
1999-08-12 23:26:09 +04:00
|
|
|
|
1998-12-04 03:13:53 +03:00
|
|
|
easy_patterns = 1;
|
1999-01-14 04:10:32 +03:00
|
|
|
if (!dest_dir || !*dest_dir)
|
1998-12-04 00:11:36 +03:00
|
|
|
return NULL;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
if (ctx->follow_links && operation != OP_MOVE)
|
|
|
|
ctx->stat_func = mc_stat;
|
1998-12-04 00:11:36 +03:00
|
|
|
else
|
1999-01-14 04:10:32 +03:00
|
|
|
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;
|
1998-12-04 00:11:36 +03:00
|
|
|
}
|
1999-01-27 04:14:57 +03:00
|
|
|
source_mask = g_strdup ("*");
|
1998-12-04 03:13:53 +03:00
|
|
|
orig_mask = source_mask;
|
|
|
|
if (!dest_dir || !*dest_dir){
|
|
|
|
if (source_mask)
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (source_mask);
|
1998-12-04 03:13:53 +03:00
|
|
|
return dest_dir;
|
|
|
|
}
|
1998-12-04 00:11:36 +03:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
if (!dest_dir)
|
1998-12-04 00:11:36 +03:00
|
|
|
return NULL;
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-04 00:11:36 +03:00
|
|
|
if (!*dest_dir) {
|
|
|
|
g_free (dest_dir);
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
if (source_easy_patterns) {
|
1998-12-04 03:13:53 +03:00
|
|
|
source_easy_patterns = easy_patterns;
|
|
|
|
easy_patterns = 1;
|
|
|
|
source_mask = convert_pattern (source_mask, match_file, 1);
|
|
|
|
easy_patterns = source_easy_patterns;
|
1999-01-14 04:10:32 +03:00
|
|
|
error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx);
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (source_mask);
|
1998-12-04 03:13:53 +03:00
|
|
|
} else
|
1999-01-14 04:10:32 +03:00
|
|
|
error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx);
|
|
|
|
|
|
|
|
if (error)
|
1998-12-04 03:13:53 +03:00
|
|
|
g_warning ("%s\n",error);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-04 03:13:53 +03:00
|
|
|
if (orig_mask)
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (orig_mask);
|
1999-01-14 04:10:32 +03:00
|
|
|
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
|
|
|
|
if (ctx->dest_mask == NULL)
|
|
|
|
ctx->dest_mask = dest_dir;
|
1998-12-04 00:11:36 +03:00
|
|
|
else
|
1999-01-14 04:10:32 +03:00
|
|
|
ctx->dest_mask++;
|
|
|
|
orig_mask = ctx->dest_mask;
|
1999-08-11 01:52:06 +04:00
|
|
|
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)))))
|
1999-01-27 04:14:57 +03:00
|
|
|
ctx->dest_mask = g_strdup ("*");
|
1998-12-04 00:11:36 +03:00
|
|
|
else {
|
1999-01-27 04:14:57 +03:00
|
|
|
ctx->dest_mask = g_strdup (ctx->dest_mask);
|
1998-12-04 00:11:36 +03:00
|
|
|
*orig_mask = 0;
|
|
|
|
}
|
|
|
|
if (!*dest_dir){
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (dest_dir);
|
|
|
|
dest_dir = g_strdup ("./");
|
1998-12-04 00:11:36 +03:00
|
|
|
}
|
|
|
|
return dest_dir;
|
1998-12-02 07:33:26 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
int
|
|
|
|
file_delete_query_recursive (FileOpContext *ctx, enum OperationMode mode, gchar *s)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *togglebutton;
|
|
|
|
gchar *title;
|
|
|
|
gchar *msg;
|
|
|
|
gint button;
|
|
|
|
gboolean rest_same;
|
|
|
|
|
|
|
|
if (ctx->recursive_result < RECURSIVE_ALWAYS) {
|
1999-08-11 01:52:06 +04:00
|
|
|
msg = g_strdup_printf (_("%s\n\nDirectory not empty. Delete it recursively?"),
|
|
|
|
name_trunc (s, 80));
|
1999-02-26 03:27:23 +03:00
|
|
|
dialog = gnome_message_box_new (msg,
|
|
|
|
GNOME_MESSAGE_BOX_QUESTION,
|
|
|
|
GNOME_STOCK_BUTTON_YES,
|
|
|
|
GNOME_STOCK_BUTTON_NO,
|
|
|
|
GNOME_STOCK_BUTTON_CANCEL,
|
|
|
|
NULL);
|
|
|
|
g_free (msg);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
title = g_strconcat (_(" Delete: "), name_trunc (s, 30), " ", NULL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
|
|
|
g_free (title);
|
|
|
|
|
|
|
|
togglebutton = gtk_check_button_new_with_label (_("Do the same for the rest"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
|
|
|
|
togglebutton, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
gnome_dialog_close_hides (GNOME_DIALOG (dialog), TRUE);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
button = gnome_dialog_run (GNOME_DIALOG (dialog));
|
|
|
|
rest_same = GTK_TOGGLE_BUTTON (togglebutton)->active;
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
switch (button) {
|
|
|
|
case 0:
|
|
|
|
ctx->recursive_result = rest_same ? RECURSIVE_ALWAYS : RECURSIVE_YES;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ctx->recursive_result = rest_same ? RECURSIVE_NEVER : RECURSIVE_NO;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ctx->recursive_result = RECURSIVE_ABORT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
if (ctx->recursive_result != RECURSIVE_ABORT)
|
|
|
|
do_refresh ();
|
|
|
|
}
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
switch (ctx->recursive_result){
|
|
|
|
case RECURSIVE_YES:
|
|
|
|
case RECURSIVE_ALWAYS:
|
|
|
|
return FILE_CONT;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
case RECURSIVE_NO:
|
|
|
|
case RECURSIVE_NEVER:
|
|
|
|
return FILE_SKIP;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
case RECURSIVE_ABORT:
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-26 03:27:23 +03:00
|
|
|
default:
|
|
|
|
return FILE_ABORT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-06 04:17:49 +03:00
|
|
|
static void
|
1999-01-14 04:10:32 +03:00
|
|
|
cancel_cb (GtkWidget *widget, gpointer data)
|
1999-01-06 04:17:49 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
|
|
|
|
|
|
|
ui = data;
|
|
|
|
ui->aborting = TRUE;
|
1999-01-06 04:17:49 +03:00
|
|
|
}
|
|
|
|
|
1999-04-20 00:38:53 +04:00
|
|
|
/* Handler for the close signal from the GnomeDialog in the file operation
|
|
|
|
* context UI. We mark the operation as "aborted" and ask GnomeDialog not to
|
|
|
|
* close the window for us.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
close_cb (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
FileOpContextUI *ui;
|
|
|
|
|
|
|
|
ui = data;
|
|
|
|
ui->aborting = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-02 07:33:26 +03:00
|
|
|
void
|
1999-01-14 04:10:32 +03:00
|
|
|
file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
1998-12-04 03:13:53 +03:00
|
|
|
GtkWidget *alignment;
|
|
|
|
GtkWidget *hbox;
|
1998-12-23 02:38:39 +03:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
g_return_if_fail (ctx != NULL);
|
|
|
|
g_return_if_fail (ctx->ui == NULL);
|
|
|
|
|
|
|
|
ui = g_new0 (FileOpContextUI, 1);
|
|
|
|
ctx->ui = ui;
|
|
|
|
|
1998-12-04 03:13:53 +03:00
|
|
|
switch (op) {
|
|
|
|
case OP_MOVE:
|
1999-01-23 23:43:36 +03:00
|
|
|
ui->op_win = gnome_dialog_new (_("Move Progress"), GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1998-12-04 03:13:53 +03:00
|
|
|
break;
|
|
|
|
case OP_COPY:
|
1999-01-23 23:43:36 +03:00
|
|
|
ui->op_win = gnome_dialog_new (_("Copy Progress"), GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1998-12-04 03:13:53 +03:00
|
|
|
break;
|
|
|
|
case OP_DELETE:
|
1999-01-23 23:43:36 +03:00
|
|
|
ui->op_win = gnome_dialog_new (_("Delete Progress"), GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1999-01-20 05:16:09 +03:00
|
|
|
break;
|
1998-12-02 07:33:26 +03:00
|
|
|
}
|
1999-01-23 23:43:36 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (ui->op_win), GTK_WIN_POS_MOUSE);
|
1998-12-04 03:13:53 +03:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
gnome_dialog_button_connect (GNOME_DIALOG (ui->op_win), 0,
|
1999-04-20 00:38:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (cancel_cb),
|
|
|
|
ui);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ui->op_win), "close",
|
|
|
|
GTK_SIGNAL_FUNC (close_cb),
|
|
|
|
ui);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
if (op != OP_DELETE) {
|
|
|
|
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), hbox);
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(gdialog_from_string)),
|
|
|
|
FALSE, FALSE, 0);
|
1999-01-20 05:16:09 +03:00
|
|
|
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);
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (GNOME_DIALOG (ui->op_win)->vbox),
|
|
|
|
GNOME_PAD);
|
1999-01-20 05:16:09 +03:00
|
|
|
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);
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(gdialog_to_string)),
|
|
|
|
FALSE, FALSE, 0);
|
1999-01-20 05:16:09 +03:00
|
|
|
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);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
} else {
|
|
|
|
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), hbox);
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(gdialog_deleting_string)),
|
|
|
|
FALSE, FALSE, 0);
|
1999-01-20 05:16:09 +03:00
|
|
|
ui->op_source_label = gtk_label_new ("");
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
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);
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (GNOME_DIALOG (ui->op_win)->vbox),
|
|
|
|
GNOME_PAD);
|
1999-01-20 05:16:09 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox),
|
|
|
|
alignment, FALSE, FALSE, 0);
|
1999-08-11 01:52:06 +04:00
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
1999-01-06 04:17:49 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("File ")), FALSE, FALSE, 0);
|
1999-01-14 04:10:32 +03:00
|
|
|
ui->count_label = GTK_OBJECT (gtk_label_new (""));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (ui->count_label), FALSE, FALSE, 0);
|
|
|
|
|
1999-03-19 20:13:33 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("is ")), FALSE, FALSE, 0);
|
1999-01-14 04:10:32 +03:00
|
|
|
ui->file_label = gtk_label_new ("");
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), ui->file_label, FALSE, FALSE, 0);
|
1999-03-19 20:13:33 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("done.")), FALSE, FALSE, 0);
|
1998-12-17 07:51:24 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), hbox);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox),
|
1998-12-17 07:51:24 +03:00
|
|
|
alignment, FALSE, FALSE, 0);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
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);
|
1998-12-17 07:51:24 +03:00
|
|
|
|
1999-08-12 23:26:09 +04:00
|
|
|
/* done with things */
|
1999-01-14 04:10:32 +03:00
|
|
|
gtk_widget_show_all (GNOME_DIALOG (ui->op_win)->vbox);
|
1999-08-12 23:26:09 +04:00
|
|
|
gtk_window_set_modal (GTK_WINDOW (ui->op_win), TRUE);
|
1999-01-14 04:10:32 +03:00
|
|
|
gtk_widget_show_now (ui->op_win);
|
1998-12-02 07:33:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-01-14 04:10:32 +03:00
|
|
|
file_op_context_destroy_ui (FileOpContext *ctx)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContextUI *ui;
|
|
|
|
|
|
|
|
g_return_if_fail (ctx != NULL);
|
|
|
|
|
1999-03-11 05:00:12 +03:00
|
|
|
if (ctx->ui == NULL)
|
|
|
|
return;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-14 04:10:32 +03:00
|
|
|
ui = ctx->ui;
|
|
|
|
|
|
|
|
gtk_widget_destroy (ui->op_win);
|
|
|
|
|
|
|
|
g_free (ui);
|
|
|
|
ctx->ui = NULL;
|
1998-12-02 07:33:26 +03:00
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-02 07:33:26 +03:00
|
|
|
void
|
1999-01-14 04:10:32 +03:00
|
|
|
fmd_init_i18n (int force)
|
1998-12-02 07:33:26 +03:00
|
|
|
{
|
|
|
|
/* unneccessary func */
|
|
|
|
}
|
1999-03-16 03:11:32 +03:00
|
|
|
|
|
|
|
/* Callback for the gnome_request_dialog() in the input dialog */
|
|
|
|
static void
|
|
|
|
input_dialog_cb (gchar *string, gpointer data)
|
|
|
|
{
|
|
|
|
char **s;
|
|
|
|
|
|
|
|
s = data;
|
|
|
|
*s = string;
|
|
|
|
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Our implementation of the general-purpose input dialog */
|
|
|
|
char *
|
|
|
|
real_input_dialog_help (char *header, char *text, char *help, char *def_text)
|
|
|
|
{
|
|
|
|
int is_password;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
char *string;
|
|
|
|
|
|
|
|
if (strncmp (text, _("Password:"), strlen (_("Password"))) == 0)
|
|
|
|
is_password = TRUE;
|
|
|
|
else
|
|
|
|
is_password = FALSE;
|
|
|
|
|
|
|
|
dialog = gnome_request_dialog (is_password, text, def_text, 0,
|
|
|
|
input_dialog_cb, &string,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), header);
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
|
|
|
gtk_main ();
|
|
|
|
return string;
|
|
|
|
}
|
1999-03-16 23:08:35 +03:00
|
|
|
|
|
|
|
/* Our implementation of the symlink-to dialog */
|
|
|
|
void
|
|
|
|
symlink_dialog (char *existing, char *new, char **ret_existing, char **ret_new)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *vbox;
|
1999-03-16 23:46:47 +03:00
|
|
|
GtkWidget *w;
|
1999-03-16 23:08:35 +03:00
|
|
|
GtkWidget *entry1, *entry2;
|
1999-03-16 23:46:47 +03:00
|
|
|
WPanel *panel;
|
1999-03-16 23:08:35 +03:00
|
|
|
int ret;
|
|
|
|
|
1999-03-16 23:46:47 +03:00
|
|
|
g_return_if_fail (existing != NULL);
|
|
|
|
g_return_if_fail (new != NULL);
|
|
|
|
g_return_if_fail (ret_existing != NULL);
|
|
|
|
g_return_if_fail (ret_new != NULL);
|
|
|
|
|
|
|
|
/* Create the dialog */
|
|
|
|
|
1999-03-16 23:08:35 +03:00
|
|
|
dialog = gnome_dialog_new (_("Symbolic Link"),
|
|
|
|
GNOME_STOCK_BUTTON_OK,
|
1999-03-16 23:46:47 +03:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL,
|
|
|
|
NULL);
|
1999-03-16 23:08:35 +03:00
|
|
|
gnome_dialog_close_hides (GNOME_DIALOG (dialog), TRUE);
|
1999-03-16 23:46:47 +03:00
|
|
|
gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
|
|
|
|
|
|
|
|
panel = cpanel;
|
|
|
|
if (!is_a_desktop_panel (panel))
|
|
|
|
gnome_dialog_set_parent (GNOME_DIALOG (dialog), panel->xwindow);
|
1999-03-16 23:08:35 +03:00
|
|
|
|
|
|
|
/* File symlink will point to */
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), vbox, FALSE, FALSE, 0);
|
|
|
|
|
1999-03-16 23:46:47 +03:00
|
|
|
w = gtk_label_new (_("Existing filename (filename symlink will point to):"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
|
1999-03-16 23:08:35 +03:00
|
|
|
|
|
|
|
entry1 = gtk_entry_new ();
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry1), existing);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), entry1, FALSE, FALSE, 0);
|
1999-03-16 23:46:47 +03:00
|
|
|
gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE (entry1));
|
1999-03-16 23:08:35 +03:00
|
|
|
|
|
|
|
/* Name of symlink */
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), vbox, FALSE, FALSE, 0);
|
|
|
|
|
1999-03-16 23:46:47 +03:00
|
|
|
w = gtk_label_new (_("Symbolic link filename:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
|
1999-03-16 23:08:35 +03:00
|
|
|
|
|
|
|
entry2 = gtk_entry_new ();
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry2), new);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), entry2, FALSE, FALSE, 0);
|
1999-03-16 23:46:47 +03:00
|
|
|
gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE (entry2));
|
|
|
|
gtk_widget_grab_focus (entry2);
|
1999-03-16 23:08:35 +03:00
|
|
|
|
|
|
|
/* Run */
|
|
|
|
|
1999-03-16 23:46:47 +03:00
|
|
|
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
|
1999-03-16 23:08:35 +03:00
|
|
|
ret = gnome_dialog_run (GNOME_DIALOG (dialog));
|
|
|
|
|
1999-03-16 23:46:47 +03:00
|
|
|
if (ret != 0) {
|
|
|
|
*ret_existing = NULL;
|
|
|
|
*ret_new = NULL;
|
|
|
|
} else {
|
|
|
|
*ret_existing = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry1)));
|
|
|
|
*ret_new = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry2)));
|
|
|
|
}
|
|
|
|
|
1999-05-27 06:06:27 +04:00
|
|
|
if (ret != -1)
|
|
|
|
gtk_widget_destroy (dialog);
|
1999-03-16 23:08:35 +03:00
|
|
|
}
|