Commit 58b235f0 authored by Darin Adler's avatar Darin Adler

Need to unencode the name here because it's used to compare with file

	* libnautilus-extensions/nautilus-directory.c: (uri_get_basename):
	Need to unencode the name here because it's used to compare with
	file names that come from get_file_info.

	* src/file-manager/dfos-xfer.c: (get_parent_make_name_list):
	Unescape the result of get_basename to convert it to a plain old
	file name, since that's why gnome_vfs_xfer wants in its file name
	lists (for now, see bug 1107).

	* libnautilus-extensions/Makefile.am:
	* libnautilus-extensions/nautilus-file-changes-queue-private.h:
	Removed the private header since it's so private it can be in the
	.c file :-)

	* libnautilus-extensions/nautilus-file-changes-queue.h:
	* libnautilus-extensions/nautilus-file-changes-queue.c:
	(nautilus_file_changes_queue_new),
	(nautilus_file_changes_queue_get), (nautilus_file_change_free),
	(nautilus_file_changes_queue_free),
	(nautilus_file_changes_queue_add_common),
	(nautilus_file_changes_queue_get_change):
	A little simplification and reformatting. Got rid of the details
	indirection since the entire data structure is private.
parent c846f982
2000-06-02 Darin Adler <darin@eazel.com>
* libnautilus-extensions/nautilus-directory.c: (uri_get_basename):
Need to unencode the name here because it's used to compare with
file names that come from get_file_info.
* src/file-manager/dfos-xfer.c: (get_parent_make_name_list):
Unescape the result of get_basename to convert it to a plain old
file name, since that's why gnome_vfs_xfer wants in its file name
lists (for now, see bug 1107).
* libnautilus-extensions/Makefile.am:
* libnautilus-extensions/nautilus-file-changes-queue-private.h:
Removed the private header since it's so private it can be in the
.c file :-)
* libnautilus-extensions/nautilus-file-changes-queue.h:
* libnautilus-extensions/nautilus-file-changes-queue.c:
(nautilus_file_changes_queue_new),
(nautilus_file_changes_queue_get), (nautilus_file_change_free),
(nautilus_file_changes_queue_free),
(nautilus_file_changes_queue_add_common),
(nautilus_file_changes_queue_get_change):
A little simplification and reformatting. Got rid of the details
indirection since the entire data structure is private.
2000-06-02 John Sullivan <sullivan@eazel.com>
* libnautilus-extensions/nautilus-mime-actions.h,
......@@ -29,6 +55,7 @@
* libnautilus-extensions/nautilus-icon-container.c (realize):
Reduce flicker by setting the back pixmap to NULL on realize.
2000-06-02 John Sullivan <sullivan@eazel.com>
Finished task 968 (Add one-time viewer choice to "View as"
......
......@@ -75,7 +75,6 @@ libnautilus_extensionsinclude_HEADERS= \
$(NULL)
libnautilus_extensions_la_SOURCES = \
nautilus-file-changes-queue-private.h \
nautilus-icon-private.h \
nautilus-file-private.h \
nautilus-directory-private.h \
......
......@@ -507,7 +507,7 @@ static char *
uri_get_basename (const char *uri)
{
GnomeVFSURI *vfs_uri;
char *name;
char *escaped_name, *name;
/* Make VFS version of URI. */
vfs_uri = gnome_vfs_uri_new (uri);
......@@ -516,8 +516,10 @@ uri_get_basename (const char *uri)
}
/* Extract name part. */
name = gnome_vfs_uri_extract_short_name (vfs_uri);
escaped_name = gnome_vfs_uri_extract_short_path_name (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
name = gnome_vfs_unescape_string (escaped_name, NULL);
g_free (escaped_name);
return name;
}
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-directory.h: Nautilus directory model.
Copyright (C) 1999, 2000 Eazel, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glib.h>
#include "nautilus-file-changes-queue.h"
typedef struct NautilusFileChange NautilusFileChange;
enum {
CHANGE_FILE_INITIAL,
CHANGE_FILE_ADDED,
CHANGE_FILE_REMOVED,
CHANGE_FILE_MOVED
};
struct NautilusFileChange {
int kind;
char *from_uri;
char *to_uri;
};
struct NautilusFileChangesQueueDetails {
GList *head;
GList *tail;
#ifdef G_THREADS_ENABLED
GMutex *mutex;
#endif
};
......@@ -22,7 +22,7 @@
*/
#include <config.h>
#include "nautilus-file-changes-queue-private.h"
#include "nautilus-file-changes-queue.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-directory-private.h"
......@@ -35,21 +35,36 @@
#define MUTEX_UNLOCK(a)
#endif
static void
nautilus_file_change_free (NautilusFileChange *change)
{
g_free (change->from_uri);
g_free (change->to_uri);
}
typedef enum {
CHANGE_FILE_INITIAL,
CHANGE_FILE_ADDED,
CHANGE_FILE_REMOVED,
CHANGE_FILE_MOVED
} NautilusFileChangeKind;
typedef struct {
NautilusFileChangeKind kind;
char *from_uri;
char *to_uri;
} NautilusFileChange;
typedef struct {
GList *head;
GList *tail;
#ifdef G_THREADS_ENABLED
GMutex *mutex;
#endif
} NautilusFileChangesQueue;
static NautilusFileChangesQueue *
nautilus_file_changes_queue_new (void)
{
NautilusFileChangesQueue *result = g_new (NautilusFileChangesQueue, 1);
result->details = g_new0 (NautilusFileChangesQueueDetails, 1);
NautilusFileChangesQueue *result;
result = g_new0 (NautilusFileChangesQueue, 1);
#ifdef G_THREADS_ENABLED
result->details->mutex = g_mutex_new ();
result->mutex = g_mutex_new ();
#endif
return result;
}
......@@ -59,12 +74,23 @@ nautilus_file_changes_queue_get (void)
{
static NautilusFileChangesQueue *file_changes_queue;
if (file_changes_queue == NULL)
file_changes_queue = nautilus_file_changes_queue_new();
if (file_changes_queue == NULL) {
file_changes_queue = nautilus_file_changes_queue_new ();
}
return file_changes_queue;
}
#if 0 /* no public free call yet */
static void
nautilus_file_change_free (NautilusFileChange *change)
{
g_free (change->from_uri);
g_free (change->to_uri);
}
void
nautilus_file_changes_queue_free (NautilusFileChangesQueue *queue)
{
......@@ -79,30 +105,31 @@ nautilus_file_changes_queue_free (NautilusFileChangesQueue *queue)
*/
#endif
for (p = queue->details->head; p != NULL; p = p->next) {
for (p = queue->head; p != NULL; p = p->next) {
nautilus_file_change_free (p->data);
}
g_list_free (queue->details->head);
g_list_free (queue->head);
#ifdef G_THREADS_ENABLED
g_mutex_free (queue->details->mutex);
g_mutex_free (queue->mutex);
#endif
g_free (queue->details);
g_free (queue);
}
#endif /* no public free call yet */
static void
nautilus_file_changes_queue_add_common (NautilusFileChangesQueue *queue,
NautilusFileChange *new_item)
{
/* enqueue the new queue item while locking down the list */
MUTEX_LOCK (queue->details->mutex);
MUTEX_LOCK (queue->mutex);
queue->details->head = g_list_prepend (queue->details->head, new_item);
if (queue->details->tail == NULL)
queue->details->tail = queue->details->head;
queue->head = g_list_prepend (queue->head, new_item);
if (queue->tail == NULL)
queue->tail = queue->head;
MUTEX_UNLOCK (queue->details->mutex);
MUTEX_UNLOCK (queue->mutex);
}
void
......@@ -112,7 +139,6 @@ nautilus_file_changes_queue_file_added (const char *uri)
NautilusFileChangesQueue *queue;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
new_item = g_new0 (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_ADDED;
......@@ -127,7 +153,6 @@ nautilus_file_changes_queue_file_removed (const char *uri)
NautilusFileChangesQueue *queue;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
new_item = g_new0 (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_REMOVED;
......@@ -141,8 +166,7 @@ nautilus_file_changes_queue_file_moved (const char *from, const char *to)
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_MOVED;
......@@ -157,22 +181,22 @@ nautilus_file_changes_queue_get_change (NautilusFileChangesQueue *queue)
GList *new_tail;
NautilusFileChange *result;
g_assert(queue);
g_assert (queue != NULL);
/* dequeue the tail item while locking down the list */
MUTEX_LOCK (queue->details->mutex);
MUTEX_LOCK (queue->mutex);
if (queue->details->tail == NULL) {
if (queue->tail == NULL) {
result = NULL;
} else {
new_tail = queue->details->tail->prev;
result = queue->details->tail->data;
queue->details->head = g_list_remove_link (queue->details->head,
queue->details->tail);
queue->details->tail = new_tail;
new_tail = queue->tail->prev;
result = queue->tail->data;
queue->head = g_list_remove_link (queue->head,
queue->tail);
queue->tail = new_tail;
}
MUTEX_UNLOCK (queue->details->mutex);
MUTEX_UNLOCK (queue->mutex);
return result;
}
......@@ -222,7 +246,6 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
kind = CHANGE_FILE_INITIAL;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
/* Consume changes from the queue, stuffing them into one of three lists,
* keep doing it while the changes are of the same kind, then send them off.
......
......@@ -24,20 +24,13 @@
#ifndef NAUTILUS_FILE_CHANGES_QUEUE_H
#define NAUTILUS_FILE_CHANGES_QUEUE_H
typedef struct NautilusFileChangesQueue NautilusFileChangesQueue;
typedef struct NautilusFileChangesQueueDetails NautilusFileChangesQueueDetails;
#include <glib.h>
void nautilus_file_changes_queue_free (NautilusFileChangesQueue *queue);
void nautilus_file_changes_queue_file_added (const char *uri);
void nautilus_file_changes_queue_file_removed (const char *uri);
void nautilus_file_changes_queue_file_moved (const char *from_uri,
const char *to_uri);
void nautilus_file_changes_queue_file_added (const char *uri);
void nautilus_file_changes_queue_file_removed (const char *uri);
void nautilus_file_changes_queue_file_moved (const char *from_uri,
const char *to_uri);
void nautilus_file_changes_consume_changes (gboolean consume_all);
void nautilus_file_changes_consume_changes (gboolean consume_all);
struct NautilusFileChangesQueue {
NautilusFileChangesQueueDetails *details;
};
#endif
#endif /* NAUTILUS_FILE_CHANGES_QUEUE_H */
......@@ -411,16 +411,24 @@ get_parent_make_name_list (const GList *item_uris, GnomeVFSURI **source_dir_uri,
GList **item_names)
{
const GList *p;
GnomeVFSURI *item_uri;
const gchar *item_name;
char *unescaped_item_name;
/* convert URI list to a source parent URI and a list of names */
for (p = item_uris; p != NULL; p = p->next) {
GnomeVFSURI *item_uri;
const gchar *item_name;
item_uri = gnome_vfs_uri_new (p->data);
item_name = gnome_vfs_uri_get_basename (item_uri);
*item_names = g_list_prepend (*item_names, g_strdup (item_name));
if (*source_dir_uri == NULL)
unescaped_item_name = gnome_vfs_unescape_string (item_name, NULL);
/* FIXME bugzilla.eazel.com 1107: If a file had %00 in
* its name, then this assert would fail. Also, people
* could pass us bad URIs and it would fail.
*/
g_assert (unescaped_item_name != NULL);
*item_names = g_list_prepend (*item_names, unescaped_item_name);
if (*source_dir_uri == NULL) {
*source_dir_uri = gnome_vfs_uri_get_parent (item_uri);
}
gnome_vfs_uri_unref (item_uri);
}
......
......@@ -75,7 +75,6 @@ libnautilus_extensionsinclude_HEADERS= \
$(NULL)
libnautilus_extensions_la_SOURCES = \
nautilus-file-changes-queue-private.h \
nautilus-icon-private.h \
nautilus-file-private.h \
nautilus-directory-private.h \
......
......@@ -507,7 +507,7 @@ static char *
uri_get_basename (const char *uri)
{
GnomeVFSURI *vfs_uri;
char *name;
char *escaped_name, *name;
/* Make VFS version of URI. */
vfs_uri = gnome_vfs_uri_new (uri);
......@@ -516,8 +516,10 @@ uri_get_basename (const char *uri)
}
/* Extract name part. */
name = gnome_vfs_uri_extract_short_name (vfs_uri);
escaped_name = gnome_vfs_uri_extract_short_path_name (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
name = gnome_vfs_unescape_string (escaped_name, NULL);
g_free (escaped_name);
return name;
}
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-directory.h: Nautilus directory model.
Copyright (C) 1999, 2000 Eazel, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glib.h>
#include "nautilus-file-changes-queue.h"
typedef struct NautilusFileChange NautilusFileChange;
enum {
CHANGE_FILE_INITIAL,
CHANGE_FILE_ADDED,
CHANGE_FILE_REMOVED,
CHANGE_FILE_MOVED
};
struct NautilusFileChange {
int kind;
char *from_uri;
char *to_uri;
};
struct NautilusFileChangesQueueDetails {
GList *head;
GList *tail;
#ifdef G_THREADS_ENABLED
GMutex *mutex;
#endif
};
......@@ -22,7 +22,7 @@
*/
#include <config.h>
#include "nautilus-file-changes-queue-private.h"
#include "nautilus-file-changes-queue.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-directory-private.h"
......@@ -35,21 +35,36 @@
#define MUTEX_UNLOCK(a)
#endif
static void
nautilus_file_change_free (NautilusFileChange *change)
{
g_free (change->from_uri);
g_free (change->to_uri);
}
typedef enum {
CHANGE_FILE_INITIAL,
CHANGE_FILE_ADDED,
CHANGE_FILE_REMOVED,
CHANGE_FILE_MOVED
} NautilusFileChangeKind;
typedef struct {
NautilusFileChangeKind kind;
char *from_uri;
char *to_uri;
} NautilusFileChange;
typedef struct {
GList *head;
GList *tail;
#ifdef G_THREADS_ENABLED
GMutex *mutex;
#endif
} NautilusFileChangesQueue;
static NautilusFileChangesQueue *
nautilus_file_changes_queue_new (void)
{
NautilusFileChangesQueue *result = g_new (NautilusFileChangesQueue, 1);
result->details = g_new0 (NautilusFileChangesQueueDetails, 1);
NautilusFileChangesQueue *result;
result = g_new0 (NautilusFileChangesQueue, 1);
#ifdef G_THREADS_ENABLED
result->details->mutex = g_mutex_new ();
result->mutex = g_mutex_new ();
#endif
return result;
}
......@@ -59,12 +74,23 @@ nautilus_file_changes_queue_get (void)
{
static NautilusFileChangesQueue *file_changes_queue;
if (file_changes_queue == NULL)
file_changes_queue = nautilus_file_changes_queue_new();
if (file_changes_queue == NULL) {
file_changes_queue = nautilus_file_changes_queue_new ();
}
return file_changes_queue;
}
#if 0 /* no public free call yet */
static void
nautilus_file_change_free (NautilusFileChange *change)
{
g_free (change->from_uri);
g_free (change->to_uri);
}
void
nautilus_file_changes_queue_free (NautilusFileChangesQueue *queue)
{
......@@ -79,30 +105,31 @@ nautilus_file_changes_queue_free (NautilusFileChangesQueue *queue)
*/
#endif
for (p = queue->details->head; p != NULL; p = p->next) {
for (p = queue->head; p != NULL; p = p->next) {
nautilus_file_change_free (p->data);
}
g_list_free (queue->details->head);
g_list_free (queue->head);
#ifdef G_THREADS_ENABLED
g_mutex_free (queue->details->mutex);
g_mutex_free (queue->mutex);
#endif
g_free (queue->details);
g_free (queue);
}
#endif /* no public free call yet */
static void
nautilus_file_changes_queue_add_common (NautilusFileChangesQueue *queue,
NautilusFileChange *new_item)
{
/* enqueue the new queue item while locking down the list */
MUTEX_LOCK (queue->details->mutex);
MUTEX_LOCK (queue->mutex);
queue->details->head = g_list_prepend (queue->details->head, new_item);
if (queue->details->tail == NULL)
queue->details->tail = queue->details->head;
queue->head = g_list_prepend (queue->head, new_item);
if (queue->tail == NULL)
queue->tail = queue->head;
MUTEX_UNLOCK (queue->details->mutex);
MUTEX_UNLOCK (queue->mutex);
}
void
......@@ -112,7 +139,6 @@ nautilus_file_changes_queue_file_added (const char *uri)
NautilusFileChangesQueue *queue;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
new_item = g_new0 (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_ADDED;
......@@ -127,7 +153,6 @@ nautilus_file_changes_queue_file_removed (const char *uri)
NautilusFileChangesQueue *queue;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
new_item = g_new0 (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_REMOVED;
......@@ -141,8 +166,7 @@ nautilus_file_changes_queue_file_moved (const char *from, const char *to)
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_MOVED;
......@@ -157,22 +181,22 @@ nautilus_file_changes_queue_get_change (NautilusFileChangesQueue *queue)
GList *new_tail;
NautilusFileChange *result;
g_assert(queue);
g_assert (queue != NULL);
/* dequeue the tail item while locking down the list */
MUTEX_LOCK (queue->details->mutex);
MUTEX_LOCK (queue->mutex);
if (queue->details->tail == NULL) {
if (queue->tail == NULL) {
result = NULL;
} else {
new_tail = queue->details->tail->prev;
result = queue->details->tail->data;
queue->details->head = g_list_remove_link (queue->details->head,
queue->details->tail);
queue->details->tail = new_tail;
new_tail = queue->tail->prev;
result = queue->tail->data;
queue->head = g_list_remove_link (queue->head,
queue->tail);
queue->tail = new_tail;
}
MUTEX_UNLOCK (queue->details->mutex);
MUTEX_UNLOCK (queue->mutex);
return result;
}
......@@ -222,7 +246,6 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
kind = CHANGE_FILE_INITIAL;
queue = nautilus_file_changes_queue_get();
g_assert (queue);
/* Consume changes from the queue, stuffing them into one of three lists,
* keep doing it while the changes are of the same kind, then send them off.
......
......@@ -24,20 +24,13 @@
#ifndef NAUTILUS_FILE_CHANGES_QUEUE_H
#define NAUTILUS_FILE_CHANGES_QUEUE_H
typedef struct NautilusFileChangesQueue NautilusFileChangesQueue;
typedef struct NautilusFileChangesQueueDetails NautilusFileChangesQueueDetails;
#include <glib.h>
void nautilus_file_changes_queue_free (NautilusFileChangesQueue *queue);
void nautilus_file_changes_queue_file_added (const char *uri);
void nautilus_file_changes_queue_file_removed (const char *uri);
void nautilus_file_changes_queue_file_moved (const char *from_uri,
const char *to_uri);
void nautilus_file_changes_queue_file_added (const char *uri);
void nautilus_file_changes_queue_file_removed (const char *uri);
void nautilus_file_changes_queue_file_moved (const char *from_uri,
const char *to_uri);
void nautilus_file_changes_consume_changes (gboolean consume_all);
void nautilus_file_changes_consume_changes (gboolean consume_all);
struct NautilusFileChangesQueue {
NautilusFileChangesQueueDetails *details;
};
#endif
#endif /* NAUTILUS_FILE_CHANGES_QUEUE_H */
......@@ -411,16 +411,24 @@ get_parent_make_name_list (const GList *item_uris, GnomeVFSURI **source_dir_uri,
GList **item_names)
{
const GList *p;
GnomeVFSURI *item_uri;
const gchar *item_name;
char *unescaped_item_name;
/* convert URI list to a source parent URI and a list of names */
for (p = item_uris; p != NULL; p = p->next) {
GnomeVFSURI *item_uri;
const gchar *item_name;
item_uri = gnome_vfs_uri_new (p->data);
item_name = gnome_vfs_uri_get_basename (item_uri);
*item_names = g_list_prepend (*item_names, g_strdup (item_name));
if (*source_dir_uri == NULL)
unescaped_item_name = gnome_vfs_unescape_string (item_name, NULL);
/* FIXME bugzilla.eazel.com 1107: If a file had %00 in
* its name, then this assert would fail. Also, people
* could pass us bad URIs and it would fail.
*/
g_assert (unescaped_item_name != NULL);
*item_names = g_list_prepend (*item_names, unescaped_item_name);
if (*source_dir_uri == NULL) {