Esempio n. 1
0
GList *
nautilus_directory_match_pattern (NautilusDirectory *directory, const char *pattern)
{
	GList *files, *l, *ret;
	GPatternSpec *spec;


	ret = NULL;
	spec = g_pattern_spec_new (pattern);
	
	files = nautilus_directory_get_file_list (directory);
	for (l = files; l; l = l->next) {
		NautilusFile *file;
		char *name;
	       
	        file = NAUTILUS_FILE (l->data);
		name = nautilus_file_get_display_name (file);

		if (g_pattern_match_string (spec, name)) {
			ret = g_list_prepend(ret, nautilus_file_ref (file));	
		}

		g_free (name);
	}

	g_pattern_spec_free (spec);
	nautilus_file_list_free (files);

	return ret;
}
Esempio n. 2
0
char *
nautilus_compute_title_for_location (GFile *location)
{
    NautilusFile *file;
    char *title;

    /* TODO-gio: This doesn't really work all that great if the
       info about the file isn't known atm... */

    if (nautilus_is_home_directory (location)) {
        return g_strdup (_("Home"));
    }

    title = NULL;
    if (location) {
        file = nautilus_file_get (location);
        title = nautilus_file_get_description (file);
        if (title == NULL) {
            title = nautilus_file_get_display_name (file);
        }
        nautilus_file_unref (file);
    }

    if (title == NULL) {
        title = g_file_get_basename (location);
    }

    return title;
}
void
nautilus_restore_files_from_trash (GList *files,
				   GtkWindow *parent_window)
{
	NautilusFile *file;
	GHashTable *original_dirs_hash;
	GList *unhandled_files, *l;
	char *message, *file_name;

	original_dirs_hash = nautilus_trashed_files_get_original_directories (files, &unhandled_files);

	for (l = unhandled_files; l != NULL; l = l->next) {
		file = NAUTILUS_FILE (l->data);
		file_name = nautilus_file_get_display_name (file);
		message = g_strdup_printf (_("Could not determine original location of “%s” "), file_name);
		g_free (file_name);

		eel_show_warning_dialog (message,
					 _("The item cannot be restored from trash"),
					 parent_window);
		g_free (message);
	}

	if (original_dirs_hash != NULL) {
		restore_files_ensure_parent_directories (original_dirs_hash, parent_window);
		g_hash_table_unref (original_dirs_hash);
	}

	nautilus_file_list_unref (unhandled_files);
}
Esempio n. 4
0
static gboolean
go_to_server_cb (NautilusWindow *window,
		 GFile          *location,
		 GError         *error,
		 gpointer        user_data)
{
	gboolean retval;

	if (error == NULL) {
		GBookmarkFile *bookmarks;
		GError *error = NULL;
		char *datadir;
		char *filename;
		char *uri;
		char *title;
		NautilusFile *file;
		gboolean safe_to_save = TRUE;

		file = nautilus_file_get_existing (location);

		bookmarks = g_bookmark_file_new ();
		datadir = g_build_filename (g_get_user_config_dir (), "nautilus", NULL);
		filename = g_build_filename (datadir, "servers", NULL);
		g_mkdir_with_parents (datadir, 0700);
		g_free (datadir);
		g_bookmark_file_load_from_file (bookmarks,
						filename,
						&error);
		if (error != NULL) {
			if (! g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
				/* only warn if the file exists */
				g_warning ("Unable to open server bookmarks: %s", error->message);
				safe_to_save = FALSE;
			}
			g_error_free (error);
		}

		if (safe_to_save) {
			uri = nautilus_file_get_uri (file);
			title = nautilus_file_get_display_name (file);
			g_bookmark_file_set_title (bookmarks, uri, title);
			g_bookmark_file_set_visited (bookmarks, uri, -1);
			g_bookmark_file_add_application (bookmarks, uri, NULL, NULL);
			g_free (uri);
			g_free (title);

			g_bookmark_file_to_file (bookmarks, filename, NULL);
		}

		g_free (filename);
		g_bookmark_file_free (bookmarks);

		retval = TRUE;
	} else {
		retval = FALSE;
	}

	return retval;
}
void
nautilus_report_error_loading_directory (NautilusFile *file,
                                         GError       *error,
                                         GtkWindow    *parent_window)
{
    char *file_name;
    char *message;

    if (error == NULL ||
        error->message == NULL)
    {
        return;
    }

    if (error->domain == G_IO_ERROR &&
        error->code == G_IO_ERROR_NOT_MOUNTED)
    {
        /* This case is retried automatically */
        return;
    }

    file_name = nautilus_file_get_display_name (file);

    if (error->domain == G_IO_ERROR)
    {
        switch (error->code)
        {
            case G_IO_ERROR_PERMISSION_DENIED:
            {
                message = g_strdup_printf (_("You do not have the permissions necessary to view the contents of “%s”."),
                                           file_name);
            }
            break;

            case G_IO_ERROR_NOT_FOUND:
            {
                message = g_strdup_printf (_("“%s” could not be found. Perhaps it has recently been deleted."),
                                           file_name);
            }
            break;

            default:
                message = g_strdup_printf (_("Sorry, could not display all the contents of “%s”: %s"), file_name,
                                           error->message);
        }
    }
    else
    {
        message = g_strdup (error->message);
    }

    eel_show_error_dialog (_("This location could not be displayed."), message, parent_window);

    g_free (file_name);
    g_free (message);
}
Esempio n. 6
0
static char *
get_truncated_name_for_file (NautilusFile *file)
{
    g_autofree char *file_name = NULL;

    g_assert (NAUTILUS_IS_FILE (file));

    file_name = nautilus_file_get_display_name (file);

    return eel_str_middle_truncate (file_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
}
void
nautilus_report_error_setting_group (NautilusFile *file,
                                     GError       *error,
                                     GtkWindow    *parent_window)
{
    char *file_name;
    char *message;

    if (error == NULL)
    {
        return;
    }

    file_name = nautilus_file_get_display_name (file);

    message = NULL;
    if (error->domain == G_IO_ERROR)
    {
        switch (error->code)
        {
            case G_IO_ERROR_PERMISSION_DENIED:
            {
                message = g_strdup_printf (_("You do not have the permissions necessary to change the group of “%s”."),
                                           file_name);
            }
            break;

            default:
            {
            }
            break;
        }
    }

    if (message == NULL)
    {
        /* We should invent decent error messages for every case we actually experience. */
        g_warning ("Hit unhandled case %s:%d in nautilus_report_error_setting_group",
                   g_quark_to_string (error->domain), error->code);
        /* fall through */
        message = g_strdup_printf (_("Sorry, could not change the group of “%s”: %s"), file_name,
                                   error->message);
    }


    eel_show_error_dialog (_("The group could not be changed."), message, parent_window);

    g_free (file_name);
    g_free (message);
}
Esempio n. 8
0
void
nautilus_restore_files_from_trash (GList *files,
                                   GtkWindow *parent_window)
{
    NautilusFile *file, *original_dir;
    GHashTable *original_dirs_hash;
    GList *original_dirs, *unhandled_files;
    GFile *original_dir_location;
    GList *locations, *l;
    char *message, *file_name;

    original_dirs_hash = nautilus_trashed_files_get_original_directories (files, &unhandled_files);

    for (l = unhandled_files; l != NULL; l = l->next) {
        file = NAUTILUS_FILE (l->data);
        file_name = nautilus_file_get_display_name (file);
        message = g_strdup_printf (_("Could not determine original location of \"%s\" "), file_name);
        g_free (file_name);

        eel_show_warning_dialog (message,
                                 _("The item cannot be restored from trash"),
                                 parent_window);
        g_free (message);
    }

    if (original_dirs_hash != NULL) {
        original_dirs = g_hash_table_get_keys (original_dirs_hash);
        for (l = original_dirs; l != NULL; l = l->next) {
            original_dir = NAUTILUS_FILE (l->data);
            original_dir_location = nautilus_file_get_location (original_dir);

            files = g_hash_table_lookup (original_dirs_hash, original_dir);
            locations = locations_from_file_list (files);

            nautilus_file_operations_move
            (locations, NULL,
             original_dir_location,
             parent_window,
             NULL, NULL);

            g_list_free_full (locations, g_object_unref);
            g_object_unref (original_dir_location);
        }

        g_list_free (original_dirs);
        g_hash_table_destroy (original_dirs_hash);
    }

    nautilus_file_list_unref (unhandled_files);
}
void
fm_rename_file (NautilusFile *file,
		const char *new_name,
		NautilusFileOperationCallback callback,
		gpointer callback_data)
{
	char *old_name, *wait_message;
	FMRenameData *data;
	char *uri;
	GError *error;

	g_return_if_fail (NAUTILUS_IS_FILE (file));
	g_return_if_fail (new_name != NULL);

	/* Stop any earlier rename that's already in progress. */
	error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
	finish_rename (file, TRUE, error);
	g_error_free (error);

	data = g_new0 (FMRenameData, 1);
	data->name = g_strdup (new_name);
	data->callback = callback;
	data->callback_data = callback_data;
	
	/* Attach the new name to the file. */
	g_object_set_data_full (G_OBJECT (file),
				NEW_NAME_TAG,
				data, (GDestroyNotify)fm_rename_data_free);

	/* Start the timed wait to cancel the rename. */
	old_name = nautilus_file_get_display_name (file);
	wait_message = g_strdup_printf (_("Renaming \"%s\" to \"%s\"."),
					old_name,
					new_name);
	g_free (old_name);
	eel_timed_wait_start (cancel_rename_callback, file, wait_message, 
			      NULL); /* FIXME bugzilla.gnome.org 42395: Parent this? */
	g_free (wait_message);

	uri = nautilus_file_get_uri (file);
	nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
			    "rename file old=\"%s\", new=\"%s\"",
			    uri, new_name);
	g_free (uri);

	/* Start the rename. */
	nautilus_file_rename (file, new_name,
			      rename_callback, NULL);
}
static void
nautilus_mime_application_chooser_apply_labels (NautilusMimeApplicationChooser *chooser)
{
	gchar *label, *extension = NULL, *description = NULL;
	gint num_files;
	NautilusFile *file;

	num_files = g_list_length (chooser->details->files);
	file = chooser->details->files->data;

	/* here we assume all files are of the same content type */
	if (g_content_type_is_unknown (chooser->details->content_type)) {
		extension = nautilus_file_get_extension (file);

		/* Translators: the %s here is a file extension */
		description = g_strdup_printf (_("%s document"), extension);
	} else {
		description = g_content_type_get_description (chooser->details->content_type);
	}

	if (num_files > 1) {
		/* Translators; %s here is a mime-type description */
		label = g_strdup_printf (_("Open all files of type “%s” with"),
					 description);
	} else {
		gchar *display_name;
		display_name = nautilus_file_get_display_name (file);

		/* Translators: first %s is filename, second %s is mime-type description */
		label = g_strdup_printf (_("Select an application to open “%s” and other files of type “%s”"),
					 display_name, description);

		g_free (display_name);
	}

	gtk_label_set_markup (GTK_LABEL (chooser->details->label), label);

	g_free (label);
	g_free (extension);
	g_free (description);
}
static void
bookmark_set_name_from_ready_file (NautilusBookmark *self,
				   NautilusFile *file)
{
	gchar *display_name;

	if (self->details->has_custom_name) {
		return;
	}

	display_name = nautilus_file_get_display_name (self->details->file);

	if (nautilus_file_is_home (self->details->file)) {
		nautilus_bookmark_set_name_internal (self, _("Home"));
	} else if (g_strcmp0 (self->details->name, display_name) != 0) {
		nautilus_bookmark_set_name_internal (self, display_name);
		DEBUG ("%s: name changed to %s", nautilus_bookmark_get_name (self), display_name);
	}

	g_free (display_name);
}
void
nautilus_report_error_setting_permissions (NautilusFile *file,
					   GError *error,
					   GtkWindow *parent_window)
{
	char *file_name;
	char *message;

	if (error == NULL) {
		return;
	}

	file_name = nautilus_file_get_display_name (file);

	message = g_strdup_printf (_("Sorry, could not change the permissions of “%s”: %s"), file_name, error->message);

	eel_show_error_dialog (_("The permissions could not be changed."), message, parent_window);

	g_free (file_name);
	g_free (message);
}		
char *
nautilus_compute_title_for_location (GFile *location)
{
	NautilusFile *file;
	char *title;

	/* TODO-gio: This doesn't really work all that great if the
	   info about the file isn't known atm... */
	
	title = NULL;
	if (location) {
		file = nautilus_file_get (location);
		title = nautilus_file_get_display_name (file);
		nautilus_file_unref (file);
	}

	if (title == NULL) {
		title = g_strdup ("");
	}
	
	return title;
}
void
nautilus_report_error_renaming_file (NautilusFile *file,
				     const char *new_name,
				     GError *error,
				     GtkWindow *parent_window)
{
	char *original_name, *original_name_truncated;
	char *new_name_truncated;
	char *message;

	/* Truncate names for display since very long file names with no spaces
	 * in them won't get wrapped, and can create insanely wide dialog boxes.
	 */
	original_name = nautilus_file_get_display_name (file);
	original_name_truncated = eel_str_middle_truncate (original_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
	g_free (original_name);
	
	new_name_truncated = eel_str_middle_truncate (new_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);

	message = NULL;
	if (error->domain == G_IO_ERROR) {
		switch (error->code) {
		case G_IO_ERROR_EXISTS:
			message = g_strdup_printf (_("The name “%s” is already used in this location. "
						     "Please use a different name."), 
						   new_name_truncated);
			break;
		case G_IO_ERROR_NOT_FOUND:
			message = g_strdup_printf (_("There is no “%s” in this location. "
						     "Perhaps it was just moved or deleted?"), 
						   original_name_truncated);
			break;
		case G_IO_ERROR_PERMISSION_DENIED:
			message = g_strdup_printf (_("You do not have the permissions necessary to rename “%s”."),
						   original_name_truncated);
			break;
		case G_IO_ERROR_INVALID_FILENAME:
			if (strchr (new_name, '/') != NULL) {
				message = g_strdup_printf (_("The name “%s” is not valid because it contains the character “/”. "
							     "Please use a different name."),
							   new_name_truncated);
			} else {
				message = g_strdup_printf (_("The name “%s” is not valid. "
							     "Please use a different name."),
							   new_name_truncated);
			}
			break;
                case G_IO_ERROR_FILENAME_TOO_LONG:
                        message = g_strdup_printf (_("The name “%s” is too long. "
                                                     "Please use a different name."),
                                                     new_name_truncated);
                        break;
		default:
			break;
		}
	}
	
	if (message == NULL) {
		/* We should invent decent error messages for every case we actually experience. */
		g_warning ("Hit unhandled case %s:%d in nautilus_report_error_renaming_file", 
			   g_quark_to_string (error->domain), error->code);
		/* fall through */
		message = g_strdup_printf (_("Sorry, could not rename “%s” to “%s”: %s"), 
					   original_name_truncated, new_name_truncated,
					   error->message);
	}
	
	g_free (original_name_truncated);
	g_free (new_name_truncated);

	eel_show_error_dialog (_("The item could not be renamed."), message, parent_window);
	g_free (message);
}
/* This callback returns the text, both the editable part, and the
 * part below that is not editable.
 */
static void
nautilus_canvas_view_container_get_icon_text (NautilusCanvasContainer *container,
					    NautilusCanvasIconData      *data,
					    char                 **editable_text,
					    char                 **additional_text,
					    gboolean               include_invisible)
{
	GQuark *attributes;
	char *text_array[4];
	int i, j, num_attributes;
	NautilusCanvasView *canvas_view;
	NautilusFile *file;
	gboolean use_additional;

	file = NAUTILUS_FILE (data);

	g_assert (NAUTILUS_IS_FILE (file));
	g_assert (editable_text != NULL);
	canvas_view = get_canvas_view (container);
	g_return_if_fail (canvas_view != NULL);

	use_additional = (additional_text != NULL);

	/* In the smallest zoom mode, no text is drawn. */
	if (nautilus_canvas_container_get_zoom_level (container) == NAUTILUS_ZOOM_LEVEL_SMALLEST &&
            !include_invisible) {
		*editable_text = NULL;
	} else {
		/* Strip the suffix for nautilus object xml files. */
		*editable_text = nautilus_file_get_display_name (file);
	}

	if (!use_additional) {
		return;
	}

	if (NAUTILUS_IS_DESKTOP_ICON_FILE (file) ||
	    nautilus_file_is_nautilus_link (file)) {
		/* Don't show the normal extra information for desktop icons,
		 * or desktop files, it doesn't make sense. */
 		*additional_text = NULL;
		return;
	}

	/* Find out what attributes go below each icon. */
	attributes = nautilus_canvas_view_container_get_icon_text_attribute_names (container,
									   &num_attributes);

	/* Get the attributes. */
	j = 0;
	for (i = 0; i < num_attributes; ++i) {
		char *text;
		if (attributes[i] == attribute_none_q) {
			continue;
		}
		text = nautilus_file_get_string_attribute_q (file, attributes[i]);
		if (text == NULL) {
			continue;
		}
		text_array[j++] = text;
	}
	text_array[j] = NULL;

	/* Return them. */
	if (j == 0) {
		*additional_text = NULL;
	} else if (j == 1) {
		/* Only one item, avoid the strdup + free */
		*additional_text = text_array[0];
	} else {
		*additional_text = g_strjoinv ("\n", text_array);
		
		for (i = 0; i < j; i++) {
			g_free (text_array[i]);
		}
	}
}
static void
file_list_ready_cb (GList *files,
                    gpointer user_data)
{
    NautilusFileConflictDialog *fcd = user_data;
    NautilusFile *src, *dest, *dest_dir;
    time_t src_mtime, dest_mtime;
    gboolean source_is_dir,	dest_is_dir, should_show_type;
    NautilusFileConflictDialogDetails *details;
    char *primary_text, *message, *secondary_text;
    const gchar *message_extra;
    char *dest_name, *dest_dir_name, *edit_name;
    char *label_text;
    char *size, *date, *type = NULL;
    GdkPixbuf *pixbuf;
    GtkWidget *label;
    GString *str;
    PangoAttrList *attr_list;

    details = fcd->details;

    details->handle = NULL;

    dest_dir = g_list_nth_data (files, 0);
    dest = g_list_nth_data (files, 1);
    src = g_list_nth_data (files, 2);

    src_mtime = nautilus_file_get_mtime (src);
    dest_mtime = nautilus_file_get_mtime (dest);

    dest_name = nautilus_file_get_display_name (dest);
    dest_dir_name = nautilus_file_get_display_name (dest_dir);

    source_is_dir = nautilus_file_is_directory (src);
    dest_is_dir = nautilus_file_is_directory (dest);

    type = nautilus_file_get_mime_type (dest);
    should_show_type = !nautilus_file_is_mime_type (src, type);

    g_free (type);
    type = NULL;

    /* Set up the right labels */
    if (dest_is_dir) {
        if (source_is_dir) {
            primary_text = g_strdup_printf
                           (_("Merge folder “%s”?"),
                            dest_name);

            message_extra =
                _("Merging will ask for confirmation before replacing any files in "
                  "the folder that conflict with the files being copied.");

            if (src_mtime > dest_mtime) {
                message = g_strdup_printf (
                              _("An older folder with the same name already exists in “%s”."),
                              dest_dir_name);
            } else if (src_mtime < dest_mtime) {
                message = g_strdup_printf (
                              _("A newer folder with the same name already exists in “%s”."),
                              dest_dir_name);
            } else {
                message = g_strdup_printf (
                              _("Another folder with the same name already exists in “%s”."),
                              dest_dir_name);
            }
        } else {
            message_extra =
                _("Replacing it will remove all files in the folder.");
            primary_text = g_strdup_printf
                           (_("Replace folder “%s”?"), dest_name);
            message = g_strdup_printf
                      (_("A folder with the same name already exists in “%s”."),
                       dest_dir_name);
        }
    } else {
        primary_text = g_strdup_printf
                       (_("Replace file “%s”?"), dest_name);

        message_extra = _("Replacing it will overwrite its content.");

        if (src_mtime > dest_mtime) {
            message = g_strdup_printf (
                          _("An older file with the same name already exists in “%s”."),
                          dest_dir_name);
        } else if (src_mtime < dest_mtime) {
            message = g_strdup_printf (
                          _("A newer file with the same name already exists in “%s”."),
                          dest_dir_name);
        } else {
            message = g_strdup_printf (
                          _("Another file with the same name already exists in “%s”."),
                          dest_dir_name);
        }
    }

    secondary_text = g_strdup_printf ("%s\n%s", message, message_extra);
    g_free (message);

    label = gtk_label_new (primary_text);
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD_CHAR);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (details->titles_vbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    attr_list = pango_attr_list_new ();
    pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
    pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_LARGE));
    g_object_set (label,
                  "attributes", attr_list,
                  NULL);

    pango_attr_list_unref (attr_list);

    label = gtk_label_new (secondary_text);
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (details->titles_vbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_show (label);
    g_free (primary_text);
    g_free (secondary_text);

    /* Set up file icons */
    pixbuf = nautilus_file_get_icon_pixbuf (dest,
                                            NAUTILUS_ICON_SIZE_LARGE,
                                            TRUE,
                                            gtk_widget_get_scale_factor (fcd->details->titles_vbox),
                                            NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS);
    details->dest_image = gtk_image_new_from_pixbuf (pixbuf);
    gtk_box_pack_start (GTK_BOX (details->first_hbox),
                        details->dest_image, FALSE, FALSE, 0);
    gtk_widget_show (details->dest_image);
    g_object_unref (pixbuf);

    pixbuf = nautilus_file_get_icon_pixbuf (src,
                                            NAUTILUS_ICON_SIZE_LARGE,
                                            TRUE,
                                            gtk_widget_get_scale_factor (fcd->details->titles_vbox),
                                            NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS);
    details->src_image = gtk_image_new_from_pixbuf (pixbuf);
    gtk_box_pack_start (GTK_BOX (details->second_hbox),
                        details->src_image, FALSE, FALSE, 0);
    gtk_widget_show (details->src_image);
    g_object_unref (pixbuf);

    /* Set up labels */
    label = gtk_label_new (NULL);
    date = nautilus_file_get_string_attribute (dest,
            "date_modified");
    size = nautilus_file_get_string_attribute (dest, "size");

    if (should_show_type) {
        type = nautilus_file_get_string_attribute (dest, "type");
    }

    str = g_string_new (NULL);
    g_string_append_printf (str, "<b>%s</b>\n", _("Original file"));
    g_string_append_printf (str, "%s %s\n", _("Size:"), size);

    if (should_show_type) {
        g_string_append_printf (str, "%s %s\n", _("Type:"), type);
    }

    g_string_append_printf (str, "%s %s", _("Last modified:"), date);

    label_text = str->str;
    gtk_label_set_markup (GTK_LABEL (label),
                          label_text);
    gtk_box_pack_start (GTK_BOX (details->first_hbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    g_free (size);
    g_free (type);
    g_free (date);
    g_string_erase (str, 0, -1);

    /* Second label */
    label = gtk_label_new (NULL);
    date = nautilus_file_get_string_attribute (src,
            "date_modified");
    size = nautilus_file_get_string_attribute (src, "size");

    if (should_show_type) {
        type = nautilus_file_get_string_attribute (src, "type");
    }

    g_string_append_printf (str, "<b>%s</b>\n", _("Replace with"));
    g_string_append_printf (str, "%s %s\n", _("Size:"), size);

    if (should_show_type) {
        g_string_append_printf (str, "%s %s\n", _("Type:"), type);
    }

    g_string_append_printf (str, "%s %s", _("Last modified:"), date);
    label_text = g_string_free (str, FALSE);

    gtk_label_set_markup (GTK_LABEL (label),
                          label_text);
    gtk_box_pack_start (GTK_BOX (details->second_hbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    g_free (size);
    g_free (date);
    g_free (type);
    g_free (label_text);

    /* Populate the entry */
    edit_name = nautilus_file_get_edit_name (dest);
    details->conflict_name = edit_name;

    gtk_entry_set_text (GTK_ENTRY (details->entry), edit_name);

    if (source_is_dir && dest_is_dir) {
        gtk_button_set_label (GTK_BUTTON (details->replace_button),
                              _("Merge"));
    }

    nautilus_file_monitor_add (src, fcd, NAUTILUS_FILE_ATTRIBUTES_FOR_ICON);
    nautilus_file_monitor_add (dest, fcd, NAUTILUS_FILE_ATTRIBUTES_FOR_ICON);

    details->src_handler_id = g_signal_connect (src, "changed",
                              G_CALLBACK (file_icons_changed), fcd);
    details->dest_handler_id = g_signal_connect (dest, "changed",
                               G_CALLBACK (file_icons_changed), fcd);
}
static void
set_copy_move_dialog_text (FileConflictDialogData *data)
{
    g_autofree gchar *primary_text = NULL;
    g_autofree gchar *secondary_text = NULL;
    const gchar *message_extra;
    time_t source_mtime;
    time_t destination_mtime;
    g_autofree gchar *message = NULL;
    g_autofree gchar *destination_name = NULL;
    g_autofree gchar *destination_directory_name = NULL;
    gboolean source_is_directory;
    gboolean destination_is_directory;

    source_mtime = nautilus_file_get_mtime (data->source);
    destination_mtime = nautilus_file_get_mtime (data->destination);

    destination_name = nautilus_file_get_display_name (data->destination);
    destination_directory_name = nautilus_file_get_display_name (data->destination_directory);

    source_is_directory = nautilus_file_is_directory (data->source);
    destination_is_directory = nautilus_file_is_directory (data->destination);

    if (destination_is_directory)
    {
        if (source_is_directory)
        {
            primary_text = g_strdup_printf (_("Merge folder “%s”?"),
                                            destination_name);

            message_extra = _("Merging will ask for confirmation before replacing any files in "
                              "the folder that conflict with the files being copied.");

            if (source_mtime > destination_mtime)
            {
                message = g_strdup_printf (_("An older folder with the same name already exists in “%s”."),
                                           destination_directory_name);
            }
            else if (source_mtime < destination_mtime)
            {
                message = g_strdup_printf (_("A newer folder with the same name already exists in “%s”."),
                                           destination_directory_name);
            }
            else
            {
                message = g_strdup_printf (_("Another folder with the same name already exists in “%s”."),
                                           destination_directory_name);
            }
        }
        else
        {
            primary_text = g_strdup_printf (_("Replace folder “%s”?"),
                                            destination_name);
            message_extra = _("Replacing it will remove all files in the folder.");
            message = g_strdup_printf (_("A folder with the same name already exists in “%s”."),
                                       destination_directory_name);
        }
    }
    else
    {
        primary_text = g_strdup_printf (_("Replace file “%s”?"),
                                        destination_name);

        message_extra = _("Replacing it will overwrite its content.");

        if (source_mtime > destination_mtime)
        {
            message = g_strdup_printf (_("An older file with the same name already exists in “%s”."),
                                       destination_directory_name);
        }
        else if (source_mtime < destination_mtime)
        {
            message = g_strdup_printf (_("A newer file with the same name already exists in “%s”."),
                                       destination_directory_name);
        }
        else
        {
            message = g_strdup_printf (_("Another file with the same name already exists in “%s”."),
                                       destination_directory_name);
        }
    }

    secondary_text = g_strdup_printf ("%s\n%s", message, message_extra);

    nautilus_file_conflict_dialog_set_text (data->dialog,
                                            primary_text,
                                            secondary_text);
}