Commit 259c95fa authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan

Fixed bug 4717, Nautilus draw desktop icons overlapping.

2000-11-15  Gene Z. Ragan  <gzr@eazel.com>

	Fixed bug 4717, Nautilus draw desktop icons overlapping.

	The problem was caused by the icon container responding to
	an idle function that lays out icons that had been
	newly added.  This is a problem if the callback is called
	form an idle after th eicon container has been created, but
	before a size has been allocated. A nely intialized GtkWidget
	has a default allocation of 0, 0, 1, 1 which is too small
	for the layout algorithm to work properly.  A flag was added
	that is set to TRUE when the size_allocate function is called.

	* src/nautilus-desktop-window.c: (nautilus_desktop_window_new):
	Set has_been_allocated to FALSE initially.

	* libnautilus-extensions/nautilus-icon-container.c:
	(size_allocate), (nautilus_icon_container_initialize),
	(nautilus_icon_container_add):
	Checj status of has_been_allocated flag before adding
	and laying out new icons.

	* libnautilus-extensions/nautilus-icon-private.h:
	Added has_been_allocated flag that is set to TRUE
	when size_allocated is first called.

	Work in progress on allowing desktop links to be renamed.

	* src/file-manager/fm-desktop-icon-view.c:
	(find_and_update_home_link):
	Allow renaming of home links.

	* src/file-manager/fm-icon-view.c:
	(special_link_in_selection):
	Removed home link from special link types.

	* libnautilus-extensions/nautilus-file.c:
	(nautilus_file_can_rename):
	Allow renaming of home link types.
parent 3c7ded1f
2000-11-15 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 4717, Nautilus draw desktop icons overlapping.
The problem was caused by the icon container responding to
an idle function that lays out icons that had been
newly added. This is a problem if the callback is called
form an idle after th eicon container has been created, but
before a size has been allocated. A nely intialized GtkWidget
has a default allocation of 0, 0, 1, 1 which is too small
for the layout algorithm to work properly. A flag was added
that is set to TRUE when the size_allocate function is called.
* src/nautilus-desktop-window.c: (nautilus_desktop_window_new):
Set has_been_allocated to FALSE initially.
* libnautilus-extensions/nautilus-icon-container.c:
(size_allocate), (nautilus_icon_container_initialize),
(nautilus_icon_container_add):
Checj status of has_been_allocated flag before adding
and laying out new icons.
* libnautilus-extensions/nautilus-icon-private.h:
Added has_been_allocated flag that is set to TRUE
when size_allocated is first called.
Work in progress on allowing desktop links to be renamed.
* src/file-manager/fm-desktop-icon-view.c:
(find_and_update_home_link):
Allow renaming of home links.
* src/file-manager/fm-icon-view.c:
(special_link_in_selection):
Removed home link from special link types.
* libnautilus-extensions/nautilus-file.c:
(nautilus_file_can_rename):
Allow renaming of home link types.
2000-11-15 Rebecca Schulman <rebecka@eazel.com>
This change is the first part of the fix for bug 3920.
The fix will allow nautilus to tell a user that the
......
......@@ -701,6 +701,10 @@ nautilus_file_can_rename (NautilusFile *file)
{
NautilusFile *parent;
gboolean result;
const char *path;
char *text_uri, *unescaped_path;
GnomeVFSURI *uri;
gboolean can_rename_link;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
......@@ -716,7 +720,36 @@ nautilus_file_can_rename (NautilusFile *file)
/* Certain types of links can't be renamed */
if (nautilus_file_is_nautilus_link (file)) {
return FALSE;
text_uri = nautilus_file_get_uri (file);
uri = gnome_vfs_uri_new (text_uri);
path = gnome_vfs_uri_get_path (uri);
unescaped_path = gnome_vfs_unescape_string_for_display (path);
switch (nautilus_link_local_get_link_type (unescaped_path)) {
case NAUTILUS_LINK_HOME:
can_rename_link = TRUE;
break;
case NAUTILUS_LINK_TRASH:
case NAUTILUS_LINK_MOUNT:
can_rename_link = FALSE;
break;
case NAUTILUS_LINK_GENERIC:
can_rename_link = FALSE;
break;
default:
can_rename_link = FALSE;
break;
}
g_free (text_uri);
gnome_vfs_uri_unref (uri);
if (!can_rename_link) {
return FALSE;
}
}
/* User must have write permissions for the parent directory. */
......
......@@ -2191,6 +2191,8 @@ static void
size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
NAUTILUS_ICON_CONTAINER (widget)->details->has_been_allocated = TRUE;
if (allocation->x != widget->allocation.x ||
allocation->width != widget->allocation.width ||
allocation->y != widget->allocation.y ||
......@@ -3148,6 +3150,7 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
container->details->rename_widget = NULL;
container->details->original_text = NULL;
container->details->type_select_state = NULL;
container->details->has_been_allocated = FALSE;
}
static gboolean
......@@ -3694,11 +3697,11 @@ nautilus_icon_container_add (NautilusIconContainer *container,
details->new_icons = g_list_prepend (details->new_icons, icon);
/* Run an idle function to add the icons. */
if (container->details->idle_id == 0) {
if (container->details->idle_id == 0 && container->details->has_been_allocated) {
container->details->idle_id = gtk_idle_add
(finish_adding_new_icons_callback, container);
}
return TRUE;
}
......
......@@ -198,6 +198,9 @@ struct NautilusIconContainerDetails {
/* Layout mode */
NautilusIconLayoutMode layout_mode;
/* Set to TRUE after first allocation has been done */
gboolean has_been_allocated;
/* Is the container fixed or resizable */
gboolean is_fixed_size;
......
......@@ -701,6 +701,10 @@ nautilus_file_can_rename (NautilusFile *file)
{
NautilusFile *parent;
gboolean result;
const char *path;
char *text_uri, *unescaped_path;
GnomeVFSURI *uri;
gboolean can_rename_link;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
......@@ -716,7 +720,36 @@ nautilus_file_can_rename (NautilusFile *file)
/* Certain types of links can't be renamed */
if (nautilus_file_is_nautilus_link (file)) {
return FALSE;
text_uri = nautilus_file_get_uri (file);
uri = gnome_vfs_uri_new (text_uri);
path = gnome_vfs_uri_get_path (uri);
unescaped_path = gnome_vfs_unescape_string_for_display (path);
switch (nautilus_link_local_get_link_type (unescaped_path)) {
case NAUTILUS_LINK_HOME:
can_rename_link = TRUE;
break;
case NAUTILUS_LINK_TRASH:
case NAUTILUS_LINK_MOUNT:
can_rename_link = FALSE;
break;
case NAUTILUS_LINK_GENERIC:
can_rename_link = FALSE;
break;
default:
can_rename_link = FALSE;
break;
}
g_free (text_uri);
gnome_vfs_uri_unref (uri);
if (!can_rename_link) {
return FALSE;
}
}
/* User must have write permissions for the parent directory. */
......
......@@ -2191,6 +2191,8 @@ static void
size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
NAUTILUS_ICON_CONTAINER (widget)->details->has_been_allocated = TRUE;
if (allocation->x != widget->allocation.x ||
allocation->width != widget->allocation.width ||
allocation->y != widget->allocation.y ||
......@@ -3148,6 +3150,7 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
container->details->rename_widget = NULL;
container->details->original_text = NULL;
container->details->type_select_state = NULL;
container->details->has_been_allocated = FALSE;
}
static gboolean
......@@ -3694,11 +3697,11 @@ nautilus_icon_container_add (NautilusIconContainer *container,
details->new_icons = g_list_prepend (details->new_icons, icon);
/* Run an idle function to add the icons. */
if (container->details->idle_id == 0) {
if (container->details->idle_id == 0 && container->details->has_been_allocated) {
container->details->idle_id = gtk_idle_add
(finish_adding_new_icons_callback, container);
}
return TRUE;
}
......
......@@ -198,6 +198,9 @@ struct NautilusIconContainerDetails {
/* Layout mode */
NautilusIconLayoutMode layout_mode;
/* Set to TRUE after first allocation has been done */
gboolean has_been_allocated;
/* Is the container fixed or resizable */
gboolean is_fixed_size;
......
......@@ -880,7 +880,7 @@ find_and_update_home_link (void)
/* Ignore directories. The home link is at the top level */
if (!S_ISDIR (status.st_mode)) {
/* Check and see if this is a home link */
link_path = nautilus_make_path (desktop_path, this_entry->d_name);
link_path = nautilus_make_path (desktop_path, this_entry->d_name);
if (nautilus_link_local_is_home_link (link_path)) {
/* Create the home link */
......
......@@ -700,10 +700,6 @@ special_link_in_selection (FMDirectoryView *view)
return TRUE;
}
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_HOME)) {
return TRUE;
}
if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_MOUNT)) {
return TRUE;
}
......
......@@ -126,8 +126,7 @@ nautilus_desktop_window_new (NautilusApplication *application)
/* Point window at the desktop folder.
* Note that nautilus_desktop_window_initialize is too early to do this.
*/
desktop_directory_uri = gnome_vfs_get_uri_from_local_path
(desktop_directory_path);
desktop_directory_uri = gnome_vfs_get_uri_from_local_path (desktop_directory_path);
g_free (desktop_directory_path);
nautilus_window_goto_uri (NAUTILUS_WINDOW (window), desktop_directory_uri);
g_free (desktop_directory_uri);
......
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