[nautilus/merge_replace_dialog: 2/12] Hook the dialog inside the relevant file operations
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: svn-commits-list gnome org
- Subject: [nautilus/merge_replace_dialog: 2/12] Hook the dialog inside the relevant file operations
- Date: Wed, 22 Apr 2009 09:58:35 -0400 (EDT)
commit faa8e16e903a428d28baecb10160158d064eb328
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Apr 2 14:16:03 2008 +0200
Hook the dialog inside the relevant file operations
Load the dialog at the right place when doing a file operation;
Fix a typo in the dialog filenames (confilct->conflict).
---
...ct-dialog.c => nautilus-file-conflict-dialog.c} | 90 ++++++++++++--------
...ct-dialog.h => nautilus-file-conflict-dialog.h} | 7 +-
libnautilus-private/nautilus-file-operations.c | 10 ++-
3 files changed, 66 insertions(+), 41 deletions(-)
diff --git a/libnautilus-private/nautilus-file-confilct-dialog.c b/libnautilus-private/nautilus-file-conflict-dialog.c
similarity index 76%
rename from libnautilus-private/nautilus-file-confilct-dialog.c
rename to libnautilus-private/nautilus-file-conflict-dialog.c
index 70f7f7c..d384dd1 100644
--- a/libnautilus-private/nautilus-file-confilct-dialog.c
+++ b/libnautilus-private/nautilus-file-conflict-dialog.c
@@ -28,7 +28,7 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include <gtk/gtkdialog.h>
+#include <glib/gi18n.h>
#include <gtk/gtkmessagedialog.h>
#include "nautilus-file.h"
#include "nautilus-icon-info.h"
@@ -51,6 +51,7 @@ G_DEFINE_TYPE (NautilusFileConflictDialog,
nautilus_file_conflict_dialog,
GTK_TYPE_MESSAGE_DIALOG);
+#define NAUTILUS_FILE_CONFLICT_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), NAUTILUS_TYPE_FILE_CONFLICT_DIALOG, NautilusFileConflictDialogDetails))
static gboolean
is_dir (GFile *file)
@@ -81,12 +82,14 @@ build_dialog_appearance (NautilusFileConflictDialog *dialog)
char *primary_text, *secondary_text;
char *src_name, *dest_name, *dest_dir_name;
char *label_text;
- char *size, date;
- GdkPixbuf *src_pixbuf, *dest_pixbuf;
- GtkImage *src_image, *dest_image;
+ char *size, *date;
+ //GdkPixbuf *src_pixbuf, *dest_pixbuf;
+ GtkWidget *src_image, *dest_image;
GtkWidget *src_label, *dest_label;
NautilusFile *src, *dest, *dest_dir;
+ g_print ("build dialog appearance \n");
+
mdialog = GTK_MESSAGE_DIALOG (dialog);
details = dialog->details;
source_is_dir = is_dir (details->source);
@@ -129,27 +132,31 @@ build_dialog_appearance (NautilusFileConflictDialog *dialog)
"Do you want to replace it?"),
dest_name);
secondary_text = g_strdup_printf
- (_("The file already exists in \"%F\". "
+ (_("The file already exists in \"%s\". "
"Replacing it will overwrite its content."),
dest_dir_name);
}
- gtk_message_dialog_set_text (mdialog, primary_text);
+ gtk_message_dialog_set_markup (mdialog, primary_text);
gtk_message_dialog_format_secondary_text (mdialog, secondary_text);
g_free (primary_text);
g_free (secondary_text);
-
+
/* Set up file icons */
- src_pixbuf = nautilus_file_get_icon_pixbuf (src,
- NAUTILUS_ICON_SIZE_STANDARD,
- TRUE,
- NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS);
- dest_pixbuf = nautilus_file_get_icon_pixbuf (dest,
- NAUTILUS_ICON_SIZE_STANDARD,
- TRUE,
- NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS);
- src_image = gtk_image_new_from_pixbuf (src_pixbuf);
- dest_image = gtk_image_new_from_pixbuf (dest_pixbuf);
+ //src_pixbuf = nautilus_file_get_icon_pixbuf (src,
+ // NAUTILUS_ICON_SIZE_STANDARD,
+ // FALSE,
+ // 0);
+ //dest_pixbuf = nautilus_file_get_icon_pixbuf (dest,
+ // NAUTILUS_ICON_SIZE_STANDARD,
+ // FALSE,
+ // 0);
+ //src_image = gtk_image_new_from_pixbuf (src_pixbuf);
+ //dest_image = gtk_image_new_from_pixbuf (dest_pixbuf);
+ src_image = gtk_image_new_from_stock (GTK_STOCK_FILE,
+ NAUTILUS_ICON_SIZE_STANDARD);
+ dest_image = gtk_image_new_from_stock (GTK_STOCK_FILE,
+ NAUTILUS_ICON_SIZE_STANDARD);
gtk_box_pack_start (GTK_BOX (details->first_hbox),
src_image, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (details->second_hbox),
@@ -158,32 +165,32 @@ build_dialog_appearance (NautilusFileConflictDialog *dialog)
gtk_widget_show (dest_image);
/* Set up labels */
- src_label = gtk_label_new ();
- date = nautilus_file_get_date_as_string (src,
- NAUTILUS_DATE_TYPE_MODIFIED);
- size = nautilus_file_get_size_as_string (src);
+ src_label = gtk_label_new (NULL);
+ date = nautilus_file_get_string_attribute (src,
+ "date_modified");
+ size = nautilus_file_get_string_attribute (src, "size");
label_text = g_markup_printf_escaped (_("<b>Original file:</b> %s\n"
"<i>Size:</i> %s\n"
- "<i>Last modified:</i> %s",
+ "<i>Last modified:</i> %s"),
src_name,
size,
- date));
+ date);
gtk_label_set_markup (GTK_LABEL (src_label),
label_text);
g_free (size);
g_free (date);
g_free (label_text);
- dest_label = gtk_label_new ();
- date = nautilus_file_get_date_as_string (dest,
- NAUTILUS_DATE_TYPE_MODIFIED);
- size = nautilus_file_get_size_as_string (dest);
+ dest_label = gtk_label_new (NULL);
+ date = nautilus_file_get_string_attribute (dest,
+ "date_modified");
+ size = nautilus_file_get_string_attribute (dest, "size");
label_text = g_markup_printf_escaped (_("<b>Replace with:</b> %s\n"
"<i>Size:</i> %s\n"
- "<i>Last modified:</i> %s",
+ "<i>Last modified:</i> %s"),
dest_name,
size,
- date));
+ date);
gtk_label_set_markup (GTK_LABEL (dest_label),
label_text);
g_free (size);
@@ -226,12 +233,8 @@ nautilus_file_conflict_dialog_init (NautilusFileConflictDialog *dialog)
NautilusFileConflictDialogDetails *details;
GtkMessageDialog *mdialog;
- details = dialog->details;
+ details = dialog->details = NAUTILUS_FILE_CONFLICT_DIALOG_GET_PRIVATE (dialog);
mdialog = GTK_MESSAGE_DIALOG (dialog);
-
- /* Setup the image */
- gtk_message_dialog_set_image (mdialog,
- GTK_STOCK_DIALOG_QUESTION);
/* Setup the hboxes to pack file infos into */
first_hbox = gtk_hbox_new (FALSE, 6);
@@ -239,7 +242,7 @@ nautilus_file_conflict_dialog_init (NautilusFileConflictDialog *dialog)
gtk_box_pack_start (GTK_BOX (mdialog->label->parent),
first_hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (mdialog->label->parent),
- first_hbox, FALSE, FALSE, 0);
+ second_hbox, FALSE, FALSE, 0);
gtk_widget_show (first_hbox);
gtk_widget_show (second_hbox);
details->first_hbox = first_hbox;
@@ -255,10 +258,20 @@ nautilus_file_conflict_dialog_init (NautilusFileConflictDialog *dialog)
gtk_widget_show (expander);
details->expander = expander;
details->entry = entry;
+
+ g_print ("end of init\n");
+}
+
+static void
+nautilus_file_conflict_dialog_class_init (NautilusFileConflictDialogClass *klass)
+{
+ nautilus_file_conflict_dialog_parent_class = g_type_class_peek_parent (klass);
+
+ g_type_class_add_private (klass, sizeof (NautilusFileConflictDialogDetails));
}
GtkWidget *
-nautilus_file_conflict_dialog_new (GtkWidget *parent,
+nautilus_file_conflict_dialog_new (GtkWindow *parent,
GFile *source,
GFile *destination,
GFile *dest_dir)
@@ -267,10 +280,13 @@ nautilus_file_conflict_dialog_new (GtkWidget *parent,
dialog = GTK_WIDGET (g_object_new (NAUTILUS_TYPE_FILE_CONFLICT_DIALOG,
"title", _("File conflict"),
- "parent", parent));
+ "message-type", GTK_MESSAGE_QUESTION,
+ NULL));
set_source_and_destination (dialog,
source,
destination,
dest_dir);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ parent);
return dialog;
}
diff --git a/libnautilus-private/nautilus-file-confilct-dialog.h b/libnautilus-private/nautilus-file-conflict-dialog.h
similarity index 94%
rename from libnautilus-private/nautilus-file-confilct-dialog.h
rename to libnautilus-private/nautilus-file-conflict-dialog.h
index 9a61d09..415c3b2 100644
--- a/libnautilus-private/nautilus-file-confilct-dialog.h
+++ b/libnautilus-private/nautilus-file-conflict-dialog.h
@@ -39,7 +39,7 @@
typedef struct _NautilusFileConflictDialog NautilusFileConflictDialog;
typedef struct _NautilusFileConflictDialogClass NautilusFileConflictDialogClass;
-typedef struct _NautilusFileConflictDialogDetails NautilusFileConfictDialogDetails;
+typedef struct _NautilusFileConflictDialogDetails NautilusFileConflictDialogDetails;
struct _NautilusFileConflictDialog {
GtkMessageDialog parent;
@@ -52,9 +52,10 @@ struct _NautilusFileConflictDialogClass {
GType nautilus_file_conflict_dialog_get_type (void) G_GNUC_CONST;
-GtkWidget* nautilus_file_conflict_dialog_new (GtkWidget *parent,
+GtkWidget* nautilus_file_conflict_dialog_new (GtkWindow *parent,
GFile *source,
- GFile *destination);
+ GFile *destination,
+ GFile *dest_dir);
char* nautilus_file_conflict_dialog_get_new_name (NautilusFileConflictDialog *dialog);
#endif /* NAUTILUS_FILE_CONFLICT_DIALOG_H */
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index d1a92f1..34c361a 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -66,6 +66,7 @@
#include "nautilus-autorun.h"
#include "nautilus-trash-monitor.h"
#include "nautilus-file-utilities.h"
+#include "nautilus-file-conflict-dialog.h"
static gboolean confirm_trash_auto_value;
@@ -3989,6 +3990,7 @@ copy_move_file (CopyMoveJob *copy_job,
if (!overwrite &&
IS_IO_ERROR (error, EXISTS)) {
gboolean is_merge;
+ GtkWidget *dialog;
if (unique_names) {
g_object_unref (dest);
@@ -3996,9 +3998,14 @@ copy_move_file (CopyMoveJob *copy_job,
g_error_free (error);
goto retry;
}
+
+ dialog = nautilus_file_conflict_dialog_new (job->parent_window,
+ src, dest, dest_dir);
+ gtk_widget_show (dialog);
is_merge = FALSE;
- if (is_dir (dest)) {
+#if 0
+ if (is_dir (dest)) {
if (is_dir (src)) {
is_merge = TRUE;
primary = f (_("A folder named \"%B\" already exists. Do you want to merge the source folder?"),
@@ -4073,6 +4080,7 @@ copy_move_file (CopyMoveJob *copy_job,
} else {
g_assert_not_reached ();
}
+#endif
}
else if (overwrite &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]