Commit 6b8d9022 authored by Darin Adler's avatar Darin Adler

Reworked the canvas item class used by the icon

	container. Straightened out the use of various coordinate systems
	and bounds calculations and removed much unused code inherited
	from the GdkPixbuf canvas item class that Andy cloned our code
	from. Changed the class so it doesn't scale icons any more -- we
	leave that to the icon factory so the scaled icons can be cached.

	* libnautilus/gnome-icon-container-dnd.c:
	* libnautilus/gnome-icon-container-private.h:
	* libnautilus/gnome-icon-container.c:
	* libnautilus/nautilus-icons-view-icon-item.c:
	* libnautilus/nautilus-icons-view-icon-item.h:
	Made extensive changes to the icon item class, including getting
	rid of the "x", "y", "width", and "height" attributes, adding a
	new "font" attribute, changing the "label" attribute name to "text"
	to be more consistent with other canvas items, simplifying the
	update logic for now (we can recomplicate it later if need be),
	changing the pixbuf to have a fixed size in pixels instead of being
	scaled with the pixels_per_unit and changing the pixbuf when we change
	zoom levels, and other misc. cleanup.
	(nautilus_icons_view_icon_item_get_arg):
	Fixed bug for "label" which would return a non-strdup'd	piece of text.
	(draw_or_measure_text_box):
	Fixed bug where width of the selection box would be based on the
	length of the last line of text, not the widest, and extra GCs would
	be created for each line of text.

	* libnautilus/nautilus-icons-controller.h:
	* libnautilus/nautilus-icons-controller.c:
	(nautilus_icons_controller_get_icon_image):
	* src/file-manager/fm-icons-controller.c:
	(fm_icons_controller_get_icon_image):
	Changed the interface so that the icons controller specifies the icon
	as a NautilusScalableIcon instead of a GdkPixbuf. This lets the icon
	container get the appropriate icon for size as it zooms.

	* libnautilus/gdk-extensions.h:
	* libnautilus/gdk-extensions.c:
	(nautilus_gdk_font_equal):
	Added a version of gdk_font_equal that works with NULL for the font.
	Maybe we need a naming scheme for these NULL-tolerant variations on
	basic calls.

	* src/ntl-uri-map.c: (nautilus_navinfo_free):
	* src/ntl-window-msgs.c: (nautilus_window_change_location_2):
	Fixed a NULL dereference that would happen when @navi was NULL.

	* libnautilus/nautilus-directory.c:
	(nautilus_directory_try_to_read_metafile):
	Fixed error handling for case when gnome_vfs_read fails.  Fixed
	error handling for case where metafile_info.size won't fit into a
	size_t.  Switched back to g_malloc instead of g_alloca, since the
	size of a file might be too big for the stack. In the long run, we
	will feed the file data directly to the XML code, so this is a bit
	temporary.  Removed the assert that Elliot added to help track
	down the giant files sizes coming from gnome-vfs; the failure in
	g_malloc will be easy to debug, unlike the failure in
	g_alloca. (The assert was added without a ChangeLog entry.)
parent ba73217b
This diff is collapsed.
......@@ -273,8 +273,10 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GnomeVFSResult result;
GnomeVFSFileInfo metafile_info;
GnomeVFSHandle *metafile_handle;
GnomeVFSFileSize size, actual_size;
size_t size; /* not GnomeVFSFileSize, since it's passed to g_malloc */
GnomeVFSFileSize actual_size;
char *buffer;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
g_return_val_if_fail (directory->details->metafile_tree == NULL, GNOME_VFS_ERROR_GENERIC);
......@@ -290,21 +292,22 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GNOME_VFS_OPEN_READ);
if (result == GNOME_VFS_OK) {
/* Check for a size that won't fit into a size_t. */
size = metafile_info.size;
if (size != metafile_info.size)
result = GNOME_VFS_ERROR_TOOBIG;
}
buffer = NULL;
if (result == GNOME_VFS_OK) {
char *buffer;
g_assert(size < 20480);
buffer = g_alloca(size);
buffer = g_malloc (size);
result = gnome_vfs_read (metafile_handle, buffer, size, &actual_size);
buffer[size] = '\0';
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
}
if (result == GNOME_VFS_OK)
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
g_free (buffer);
if (metafile_handle != NULL)
gnome_vfs_close (metafile_handle);
......
......@@ -273,8 +273,10 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GnomeVFSResult result;
GnomeVFSFileInfo metafile_info;
GnomeVFSHandle *metafile_handle;
GnomeVFSFileSize size, actual_size;
size_t size; /* not GnomeVFSFileSize, since it's passed to g_malloc */
GnomeVFSFileSize actual_size;
char *buffer;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
g_return_val_if_fail (directory->details->metafile_tree == NULL, GNOME_VFS_ERROR_GENERIC);
......@@ -290,21 +292,22 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GNOME_VFS_OPEN_READ);
if (result == GNOME_VFS_OK) {
/* Check for a size that won't fit into a size_t. */
size = metafile_info.size;
if (size != metafile_info.size)
result = GNOME_VFS_ERROR_TOOBIG;
}
buffer = NULL;
if (result == GNOME_VFS_OK) {
char *buffer;
g_assert(size < 20480);
buffer = g_alloca(size);
buffer = g_malloc (size);
result = gnome_vfs_read (metafile_handle, buffer, size, &actual_size);
buffer[size] = '\0';
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
}
if (result == GNOME_VFS_OK)
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
g_free (buffer);
if (metafile_handle != NULL)
gnome_vfs_close (metafile_handle);
......
......@@ -273,8 +273,10 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GnomeVFSResult result;
GnomeVFSFileInfo metafile_info;
GnomeVFSHandle *metafile_handle;
GnomeVFSFileSize size, actual_size;
size_t size; /* not GnomeVFSFileSize, since it's passed to g_malloc */
GnomeVFSFileSize actual_size;
char *buffer;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
g_return_val_if_fail (directory->details->metafile_tree == NULL, GNOME_VFS_ERROR_GENERIC);
......@@ -290,21 +292,22 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GNOME_VFS_OPEN_READ);
if (result == GNOME_VFS_OK) {
/* Check for a size that won't fit into a size_t. */
size = metafile_info.size;
if (size != metafile_info.size)
result = GNOME_VFS_ERROR_TOOBIG;
}
buffer = NULL;
if (result == GNOME_VFS_OK) {
char *buffer;
g_assert(size < 20480);
buffer = g_alloca(size);
buffer = g_malloc (size);
result = gnome_vfs_read (metafile_handle, buffer, size, &actual_size);
buffer[size] = '\0';
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
}
if (result == GNOME_VFS_OK)
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
g_free (buffer);
if (metafile_handle != NULL)
gnome_vfs_close (metafile_handle);
......
......@@ -198,6 +198,8 @@ nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
void
nautilus_navinfo_free(NautilusNavigationInfo *navinfo)
{
g_return_if_fail(navinfo != NULL);
if(navinfo->ah)
gnome_vfs_async_cancel(navinfo->ah);
......
......@@ -198,6 +198,8 @@ nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
void
nautilus_navinfo_free(NautilusNavigationInfo *navinfo)
{
g_return_if_fail(navinfo != NULL);
if(navinfo->ah)
gnome_vfs_async_cancel(navinfo->ah);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment