From 5977bdd9fb59c4a5dbdad7b2d4e62fe0383bebae Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 1 Jun 2003 16:04:58 +0000 Subject: [PATCH] r2772: Show files being operated upon in action windows (Stephen Watson). --- ROX-Filer/Help/Changes | 1 + ROX-Filer/src/abox.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ ROX-Filer/src/abox.h | 10 ++++++ ROX-Filer/src/action.c | 36 ++++++++++++++++--- 4 files changed, 138 insertions(+), 5 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 59d46b0e..d568171b 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -5,6 +5,7 @@ 01-Jun-2003 ~~~~~~~~~~~ Fix compiler warning when not using dnotify (reported by Damien Couderc). +Show files being operated upon in action windows (Stephen Watson). 30-May-2003 (Release 2.0.0) ~~~~~~~~~~~ diff --git a/ROX-Filer/src/abox.c b/ROX-Filer/src/abox.c index 39464fd3..8b3ce821 100644 --- a/ROX-Filer/src/abox.c +++ b/ROX-Filer/src/abox.c @@ -36,6 +36,8 @@ #include "filer.h" #include "display.h" #include "support.h" +#include "diritem.h" +#include "pixmaps.h" #define RESPONSE_QUIET 1 @@ -118,6 +120,7 @@ static void abox_init(GTypeInstance *object, gpointer gclass) GtkWidget *frame, *text, *scrollbar, *button; ABox *abox = ABOX(object); GtkDialog *dialog = GTK_DIALOG(object); + int i; gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); @@ -169,6 +172,36 @@ static void abox_init(GTypeInstance *object, gpointer gclass) GTK_STOCK_YES, GTK_RESPONSE_YES, NULL); + abox->cmp_area = gtk_table_new(2, 4, FALSE); + gtk_box_pack_start(GTK_BOX(dialog->vbox), + abox->cmp_area, FALSE, FALSE, 2); + gtk_table_set_row_spacings(GTK_TABLE(abox->cmp_area), 2); + gtk_table_set_col_spacings(GTK_TABLE(abox->cmp_area), 2); + + for (i = 0; i < 2; i++) + { + abox->cmp_icon[i] = gtk_image_new(); + gtk_table_attach(GTK_TABLE(abox->cmp_area), + abox->cmp_icon[i], + 0, 1, i, i + 1, + GTK_SHRINK, GTK_SHRINK, 1, 1); + abox->cmp_name[i] = gtk_label_new(""); + gtk_table_attach(GTK_TABLE(abox->cmp_area), + abox->cmp_name[i], + 1, 2, i, i + 1, + GTK_EXPAND | GTK_FILL, GTK_SHRINK, 1, 1); + abox->cmp_size[i] = gtk_label_new(""); + gtk_table_attach(GTK_TABLE(abox->cmp_area), + abox->cmp_size[i], + 2, 3, i, i + 1, + GTK_SHRINK, GTK_SHRINK, 1, 1); + abox->cmp_date[i] = gtk_label_new(""); + gtk_table_attach(GTK_TABLE(abox->cmp_area), + abox->cmp_date[i], + 3, 4, i, i + 1, + GTK_SHRINK, GTK_SHRINK, 1, 1); + } + abox->flag_box = gtk_hbox_new(FALSE, 16); gtk_box_pack_end(GTK_BOX(dialog->vbox), abox->flag_box, FALSE, TRUE, 2); @@ -179,6 +212,7 @@ static void abox_init(GTypeInstance *object, gpointer gclass) gtk_dialog_set_default_response(dialog, RESPONSE_QUIET); gtk_widget_show_all(dialog->vbox); + gtk_widget_hide(abox->cmp_area); abox->quiet = abox_add_flag(abox, _("Quiet"), _("Don't confirm every operation"), @@ -555,3 +589,65 @@ static gboolean abox_delete(GtkWidget *dialog, GdkEventAny *event) g_signal_emit_by_name(dialog, "abort_operation"); return TRUE; } + +void abox_show_compare(ABox *abox, gboolean show) +{ + if (show) + gtk_widget_show(abox->cmp_area); + else + gtk_widget_hide(abox->cmp_area); +} + +void abox_set_file(ABox *abox, int i, const gchar *path) +{ + DirItem *item; + gchar *base; + + g_return_if_fail(i >= 0 && i < 2); + + if (!path || !path[0]) + { + /*printf("path=%s\n", path? path: "NULL");*/ + gtk_widget_hide(abox->cmp_icon[i]); + gtk_widget_hide(abox->cmp_name[i]); + gtk_widget_hide(abox->cmp_size[i]); + gtk_widget_hide(abox->cmp_date[i]); + return; + } + + base = g_path_get_basename(path); + item = diritem_new(base); + g_free(base); + diritem_restat(path, item, NULL); + + gtk_image_set_from_pixbuf(GTK_IMAGE(abox->cmp_icon[i]), + item->image->pixbuf); + gtk_widget_show(abox->cmp_icon[i]); + + gtk_label_set_text(GTK_LABEL(abox->cmp_name[i]), item->leafname); + gtk_widget_show(abox->cmp_name[i]); + + if (item->lstat_errno) + { + gtk_label_set_text(GTK_LABEL(abox->cmp_size[i]), "Error"); + gtk_label_set_text(GTK_LABEL(abox->cmp_date[i]), + g_strerror(item->lstat_errno)); + } + else + { + gchar *str; + + gtk_label_set_text(GTK_LABEL(abox->cmp_size[i]), + format_size_aligned(item->size)); + + str = pretty_time(&item->mtime); + gtk_label_set_text(GTK_LABEL(abox->cmp_date[i]), str); + g_free(str); + } + + gtk_widget_show(abox->cmp_size[i]); + gtk_widget_show(abox->cmp_date[i]); + + diritem_free(item); +} + diff --git a/ROX-Filer/src/abox.h b/ROX-Filer/src/abox.h index 9ef92a04..07d0b3d2 100644 --- a/ROX-Filer/src/abox.h +++ b/ROX-Filer/src/abox.h @@ -29,6 +29,12 @@ struct _ABox GtkWidget *entry; /* Plain entry, or part of combo */ FilerWindow *preview; + GtkWidget *cmp_area; /* Area where files are compared */ + GtkWidget *cmp_icon[2]; + GtkWidget *cmp_name[2]; + GtkWidget *cmp_size[2]; + GtkWidget *cmp_date[2]; + gchar *next_dir; /* NULL => no timer active */ gint next_timer; @@ -70,4 +76,8 @@ void abox_add_entry (ABox *abox, const gchar *text, GtkWidget *help_button); +void abox_show_compare (ABox *abox, gboolean show); +void abox_set_file (ABox *abox, int file, + const gchar *path); + #endif /* __ABOX_H__ */ diff --git a/ROX-Filer/src/action.c b/ROX-Filer/src/action.c index 3d758e1d..7e9f5d58 100644 --- a/ROX-Filer/src/action.c +++ b/ROX-Filer/src/action.c @@ -313,6 +313,13 @@ static void process_message(GUIside *gui_side, const gchar *buffer) gui_side->errors++; abox_log(abox, buffer + 1, "error"); } + else if (*buffer == '<') + abox_set_file(abox, 0, buffer+1); + else if (*buffer == '>') + { + abox_set_file(abox, 1, buffer+1); + abox_show_compare(abox, TRUE); + } else abox_log(abox, buffer + 1, NULL); } @@ -508,6 +515,7 @@ static void response(GtkDialog *dialog, gint response, GUIside *gui_side) fputc(code, gui_side->to_child); fflush(gui_side->to_child); + abox_show_compare(gui_side->abox, FALSE); } static void flag_toggled(ABox *abox, gint flag, GUIside *gui_side) @@ -854,6 +862,8 @@ static void do_delete(const char *src_path, const char *unused) : access(src_path, W_OK) != 0; if (write_prot || !quiet) { + printf_send("<%s", src_path); + printf_send(">"); if (!printf_reply(from_parent, write_prot && !o_force, _("?Delete %s'%s'?"), write_prot ? _("WRITE-PROTECTED ") : "", @@ -1001,6 +1011,8 @@ static void do_chmod(const char *path, const char *unused) if (!quiet) { + printf_send("<%s", path); + printf_send(">"); if (!printf_reply(from_parent, FALSE, _("?Change permissions of '%s'?"), path)) return; @@ -1112,6 +1124,8 @@ static void do_copy2(const char *path, const char *dest) } else { + printf_send("<%s", path); + printf_send(">%s", dest_path); if (!printf_reply(from_parent, TRUE, _("?'%s' already exists - %s?"), dest_path, @@ -1138,6 +1152,8 @@ static void do_copy2(const char *path, const char *dest) } else if (!quiet) { + printf_send("<%s", path); + printf_send(">"); if (!printf_reply(from_parent, FALSE, _("?Copy %s as %s?"), path, dest_path)) return; @@ -1269,10 +1285,14 @@ static void do_move2(const char *path, const char *dest) { /* Newer; keep going */ } - else if (!printf_reply(from_parent, TRUE, + else { + printf_send("<%s", path); + printf_send(">%s", dest_path); + if (!printf_reply(from_parent, TRUE, _("?'%s' already exists - overwrite?"), dest_path)) - return; + return; + } if (S_ISDIR(info.st_mode)) err = rmdir(dest_path); @@ -1289,6 +1309,8 @@ static void do_move2(const char *path, const char *dest) } else if (!quiet) { + printf_send("<%s", path); + printf_send(">"); if (!printf_reply(from_parent, FALSE, _("?Move %s as %s?"), path, dest_path)) return; @@ -1356,9 +1378,13 @@ static void do_link(const char *path, const char *dest) if (quiet) printf_send(_("'Linking %s as %s\n"), path, dest_path); - else if (!printf_reply(from_parent, FALSE, - _("?Link %s as %s?"), path, dest_path)) - return; + else { + printf_send("<%s", path); + printf_send(">"); + if (!printf_reply(from_parent, FALSE, + _("?Link %s as %s?"), path, dest_path)) + return; + } if (symlink(path, dest_path)) send_error(); -- 2.11.4.GIT