Commit e7aa2e75 authored by Darin Adler's avatar Darin Adler

Eliminated code that ref's files when they are the target of the

	* libnautilus-extensions/nautilus-directory-async.c:
	(nautilus_directory_call_when_ready_internal),
	(nautilus_directory_cancel_callback_internal),
	(directory_count_callback), (nautilus_async_destroying_file),
	(start_getting_directory_counts), (top_left_read_done),
	(start_getting_top_lefts):
	Eliminated code that ref's files when they are the target of the
	call_when_ready list or the current file being read for top left
	text or the current directory being counted. Instead, cancel the
	I/O when the file is destroyed (we already had the hook).

	* libnautilus-extensions/nautilus-directory-async.c:
	(lacks_top_left),
	* libnautilus-extensions/nautilus-file-private.h:
	* libnautilus-extensions/nautilus-file.c:
	(nautilus_file_contains_text), (nautilus_file_get_top_left_text):
	Change top left text reading to only read text files and other
	regular files with unknown type.

	* libnautilus-extensions/nautilus-gtk-extensions.c:
	(nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER):
	* libnautilus-extensions/nautilus-gtk-extensions.h:
	Needed a new marshal function.

	* libnautilus-extensions/nautilus-icon-container.h:
	* libnautilus-extensions/nautilus-icon-container.c:
	(resort_and_clear), (auto_position_icon), (relayout):
	Changed around to share more code.
	(reload_icon_positions): Call to reload icon positions when you
	switch from auto to manual layout.
	(idle_handler): Get rid of relayout on idle.
	(nautilus_icon_container_move_icon): Renamed icon_changed to
	icon_position_changed.
	(rubberband_select): Fixed bug where rubberband would never deselect.
	(nautilus_icon_container_initialize_class): Add a new signal called
	get_stored_icon_position and also renamed the icon_changed signal to
	icon_position_changed.
	(nautilus_icon_container_update_icon): Changed back the
	get_icon_images interface to return NautilusScaledIcon objects
	instead of actual pixbufs. This is made possible by the change to
	include the embedded text as one of the parameters when creating
	a NautilusScaledIcon.
	(nautilus_icon_container_add): Merged the two flavors of add and
	removed the extra parameters. Now the icon position and scale comes
	from a callback (via signal).
	(nautilus_icon_container_set_selection): Use a hash table (fixes
	Bugzilla bug 613).
	(nautilus_icon_container_select_list_unselect_others): Use a hash
	table.
	(nautilus_icon_container_set_auto_layout): Reload the previous
	icon positions and "freeze" them (store them) when switching from
	automatic layout to manual.
	(nautilus_icon_container_freeze_icon_positions): Public function
	to store all the icon psoitions. For use later with the dialog that
	you get when you drag an icon.
	* src/file-manager/fm-icon-view.c:
	(get_stored_icon_position_callback): Support new interface for
	getting the icon position. Also used setlocale so metadata always
	uses a locale-independent format for floating point numbers.
	(fm_icon_view_add_file), (fm_icon_view_done_adding_files):
	New simplified interface for adding icons.
	(auto_layout_callback), (manual_layout_callback): Fixed a bug where
	we'd always switch to auto layout on startup. It's actually a bug
	in Bonobo where new radio menu items get callbacks right away.
	(icon_position_changed_callback): Used setlocale so metadata always
	uses a locale-independent format for floating point numbers.
	(get_icon_images_callback): Changed for new simpler embedded text
	API. Moved the actual pixbuf stuff back into NautilusIconContainer.
	(create_icon_container): New get_stored_icon_position callback and
	renamed icon_position_changed callback.

	* libnautilus-extensions/nautilus-icon-dnd.c: (handle_local_move),
	(handle_nonlocal_move),
	(nautilus_icon_container_receive_dropped_icons):
	Restructured the drag code a little bit to make it easy to add the
	dialog that you get when you drag an icon within an auto-layed-out
	window (that I will add soon).

	* libnautilus-extensions/nautilus-icon-factory.h:
	* libnautilus-extensions/nautilus-icon-factory.c:
	(nautilus_scalable_icon_get), (nautilus_scalable_icon_unref),
	(nautilus_scalable_icon_hash), (nautilus_scalable_icon_equal),
	(nautilus_icon_factory_get_icon_for_file),
	(nautilus_icon_factory_get_emblem_icon_by_name),
	(nautilus_icon_factory_get_emblem_icons_for_file),
	(get_image_from_cache),
	(nautilus_icon_factory_get_pixbuf_for_icon),
	(nautilus_icon_factory_get_pixbuf_for_file), (embed_text),
	(load_image_with_embedded_text):
	* src/file-manager/fm-list-view.c:
	(fm_list_view_get_emblem_pixbufs_for_file):
	* src/file-manager/fm-properties-window.c:
	(create_image_widget_for_emblem):
	* src/nautilus-index-title.c: (nautilus_index_title_update_info):
	Even though John talked me out of it, I talked myself back into it.
	Redid the embedded text so it's done entirely inside the icon
	factory. This keeps the interface simple.

	* libnautilus-extensions/nautilus-icon-private.h: Add a missing
	newline.
parent 1ff152ca
2000-05-09 Ramiro Estrugo <set EMAIL_ADDRESS environment variable>
2000-05-09 Darin Adler <darin@eazel.com>
* libnautilus-extensions/nautilus-directory-async.c:
(nautilus_directory_call_when_ready_internal),
(nautilus_directory_cancel_callback_internal),
(directory_count_callback), (nautilus_async_destroying_file),
(start_getting_directory_counts), (top_left_read_done),
(start_getting_top_lefts):
Eliminated code that ref's files when they are the target of the
call_when_ready list or the current file being read for top left
text or the current directory being counted. Instead, cancel the
I/O when the file is destroyed (we already had the hook).
* libnautilus-extensions/nautilus-directory-async.c:
(lacks_top_left),
* libnautilus-extensions/nautilus-file-private.h:
* libnautilus-extensions/nautilus-file.c:
(nautilus_file_contains_text), (nautilus_file_get_top_left_text):
Change top left text reading to only read text files and other
regular files with unknown type.
* libnautilus-extensions/nautilus-gtk-extensions.c:
(nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER):
* libnautilus-extensions/nautilus-gtk-extensions.h:
Needed a new marshal function.
* libnautilus-extensions/nautilus-icon-container.h:
* libnautilus-extensions/nautilus-icon-container.c:
(resort_and_clear), (auto_position_icon), (relayout):
Changed around to share more code.
(reload_icon_positions): Call to reload icon positions when you
switch from auto to manual layout.
(idle_handler): Get rid of relayout on idle.
(nautilus_icon_container_move_icon): Renamed icon_changed to
icon_position_changed.
(rubberband_select): Fixed bug where rubberband would never deselect.
(nautilus_icon_container_initialize_class): Add a new signal called
get_stored_icon_position and also renamed the icon_changed signal to
icon_position_changed.
(nautilus_icon_container_update_icon): Changed back the
get_icon_images interface to return NautilusScaledIcon objects
instead of actual pixbufs. This is made possible by the change to
include the embedded text as one of the parameters when creating
a NautilusScaledIcon.
(nautilus_icon_container_add): Merged the two flavors of add and
removed the extra parameters. Now the icon position and scale comes
from a callback (via signal).
(nautilus_icon_container_set_selection): Use a hash table (fixes
Bugzilla bug 613).
(nautilus_icon_container_select_list_unselect_others): Use a hash
table.
(nautilus_icon_container_set_auto_layout): Reload the previous
icon positions and "freeze" them (store them) when switching from
automatic layout to manual.
(nautilus_icon_container_freeze_icon_positions): Public function
to store all the icon psoitions. For use later with the dialog that
you get when you drag an icon.
* src/file-manager/fm-icon-view.c:
(get_stored_icon_position_callback): Support new interface for
getting the icon position. Also used setlocale so metadata always
uses a locale-independent format for floating point numbers.
(fm_icon_view_add_file), (fm_icon_view_done_adding_files):
New simplified interface for adding icons.
(auto_layout_callback), (manual_layout_callback): Fixed a bug where
we'd always switch to auto layout on startup. It's actually a bug
in Bonobo where new radio menu items get callbacks right away.
(icon_position_changed_callback): Used setlocale so metadata always
uses a locale-independent format for floating point numbers.
(get_icon_images_callback): Changed for new simpler embedded text
API. Moved the actual pixbuf stuff back into NautilusIconContainer.
(create_icon_container): New get_stored_icon_position callback and
renamed icon_position_changed callback.
* libnautilus-extensions/nautilus-icon-dnd.c: (handle_local_move),
(handle_nonlocal_move),
(nautilus_icon_container_receive_dropped_icons):
Restructured the drag code a little bit to make it easy to add the
dialog that you get when you drag an icon within an auto-layed-out
window (that I will add soon).
* libnautilus-extensions/nautilus-icon-factory.h:
* libnautilus-extensions/nautilus-icon-factory.c:
(nautilus_scalable_icon_get), (nautilus_scalable_icon_unref),
(nautilus_scalable_icon_hash), (nautilus_scalable_icon_equal),
(nautilus_icon_factory_get_icon_for_file),
(nautilus_icon_factory_get_emblem_icon_by_name),
(nautilus_icon_factory_get_emblem_icons_for_file),
(get_image_from_cache),
(nautilus_icon_factory_get_pixbuf_for_icon),
(nautilus_icon_factory_get_pixbuf_for_file), (embed_text),
(load_image_with_embedded_text):
* src/file-manager/fm-list-view.c:
(fm_list_view_get_emblem_pixbufs_for_file):
* src/file-manager/fm-properties-window.c:
(create_image_widget_for_emblem):
* src/nautilus-index-title.c: (nautilus_index_title_update_info):
Even though John talked me out of it, I talked myself back into it.
Redid the embedded text so it's done entirely inside the icon
factory. This keeps the interface simple.
* libnautilus-extensions/nautilus-icon-private.h: Add a missing
newline.
2000-05-09 Ramiro Estrugo <ramiro@eazel.com>
* components/mozilla/nautilus-mozilla-content-view.c:
(nautilus_mozilla_content_view_load_uri),
......
......@@ -884,7 +884,6 @@ nautilus_directory_call_when_ready_internal (NautilusDirectory *directory,
}
/* Add the new callback to the list. */
nautilus_file_ref (file);
directory->details->call_when_ready_list = g_list_prepend
(directory->details->call_when_ready_list,
g_memdup (&callback,
......@@ -945,7 +944,6 @@ nautilus_directory_cancel_callback_internal (NautilusDirectory *directory,
&callback,
ready_callback_key_compare);
if (p != NULL) {
nautilus_file_unref (file);
remove_callback_link (directory, p);
state_changed (directory);
}
......@@ -959,11 +957,13 @@ directory_count_callback (GnomeVFSAsyncHandle *handle,
gpointer callback_data)
{
NautilusDirectory *directory;
NautilusFile *count_file_copy;
NautilusFile *count_file;
directory = NAUTILUS_DIRECTORY (callback_data);
g_assert (directory->details->count_in_progress == handle);
count_file = directory->details->count_file;
g_assert (NAUTILUS_IS_FILE (count_file));
if (result == GNOME_VFS_OK) {
return;
......@@ -976,19 +976,13 @@ directory_count_callback (GnomeVFSAsyncHandle *handle,
directory->details->count_file->details->directory_count = entries_read;
directory->details->count_file->details->got_directory_count = TRUE;
}
count_file_copy = directory->details->count_file;
directory->details->count_file = NULL;
directory->details->count_in_progress = NULL;
/* Send file-changed even if count failed, so interested parties can
* distinguish between unknowable and not-yet-known cases.
*/
nautilus_file_changed (count_file_copy);
/* Let go of this request. */
nautilus_file_unref (directory->details->count_file);
nautilus_file_changed (count_file);
/* Start up the next one. */
state_changed (directory);
......@@ -1041,41 +1035,58 @@ nautilus_directory_get_info_for_new_files (NautilusDirectory *directory,
void
nautilus_async_destroying_file (NautilusFile *file)
{
NautilusDirectory *directory;
gboolean changed;
GList *p, *next;
ReadyCallback *callback;
Monitor *monitor;
directory = file->details->directory;
changed = FALSE;
/* Check for callbacks. */
for (p = file->details->directory->details->call_when_ready_list; p != NULL; p = next) {
for (p = directory->details->call_when_ready_list; p != NULL; p = next) {
next = p->next;
callback = p->data;
if (callback->file == file) {
/* Client should have cancelled callback. */
g_warning ("destroyed file has call_when_ready pending");
remove_callback_link (file->details->directory, p);
remove_callback_link (directory, p);
changed = TRUE;
}
}
/* Check for monitors. */
for (p = file->details->directory->details->monitor_list; p != NULL; p = next) {
for (p = directory->details->monitor_list; p != NULL; p = next) {
next = p->next;
monitor = p->data;
if (monitor->file == file) {
/* Client should have removed monitor earlier. */
g_warning ("destroyed file still being monitored");
remove_monitor_link (file->details->directory, p);
remove_monitor_link (directory, p);
changed = TRUE;
}
}
/* Check if it's the file that's currently being worked on for
* counts or for get_file_info. If so, make that NULL so it gets
* canceled right away.
*/
if (directory->details->count_file == file) {
directory->details->count_file = NULL;
changed = TRUE;
}
if (directory->details->top_left_read_state != NULL
&& directory->details->top_left_read_state->file == file) {
directory->details->top_left_read_state->file = NULL;
changed = TRUE;
}
/* Let the directory take care of the rest. */
if (changed) {
state_changed (file->details->directory);
state_changed (directory);
}
}
......@@ -1096,7 +1107,7 @@ wants_directory_count (const Request *request)
static gboolean
lacks_top_left (NautilusFile *file)
{
return !nautilus_file_is_directory (file)
return nautilus_file_contains_text (file)
&& !file->details->got_top_left_text;
}
......@@ -1373,16 +1384,17 @@ start_getting_directory_counts (NautilusDirectory *directory)
* it's still wanted.
*/
if (directory->details->count_in_progress != NULL) {
g_assert (NAUTILUS_IS_FILE (directory->details->count_file));
g_assert (directory->details->count_file->details->directory == directory);
if (is_wanted (directory->details->count_file,
wants_directory_count)) {
return;
if (directory->details->count_file != NULL) {
g_assert (NAUTILUS_IS_FILE (directory->details->count_file));
g_assert (directory->details->count_file->details->directory == directory);
if (is_wanted (directory->details->count_file,
wants_directory_count)) {
return;
}
}
/* The count is not wanted, so stop it. */
gnome_vfs_async_cancel (directory->details->count_in_progress);
nautilus_file_unref (directory->details->count_file);
directory->details->count_file = NULL;
directory->details->count_in_progress = NULL;
}
......@@ -1396,7 +1408,6 @@ start_getting_directory_counts (NautilusDirectory *directory)
}
/* Start counting. */
nautilus_file_ref (file);
directory->details->count_file = file;
uri = nautilus_file_get_uri (file);
gnome_vfs_async_load_directory
......@@ -1434,7 +1445,6 @@ top_left_read_done (NautilusDirectory *directory)
g_assert (NAUTILUS_IS_FILE (directory->details->top_left_read_state->file));
directory->details->top_left_read_state->file->details->got_top_left_text = TRUE;
nautilus_file_unref (directory->details->top_left_read_state->file);
g_free (directory->details->top_left_read_state->buffer);
g_free (directory->details->top_left_read_state);
......@@ -1563,18 +1573,19 @@ start_getting_top_lefts (NautilusDirectory *directory)
* it's still wanted.
*/
if (directory->details->top_left_read_state != NULL) {
g_assert (NAUTILUS_IS_FILE (directory->details->top_left_read_state->file));
g_assert (directory->details->top_left_read_state->file->details->directory == directory);
if (is_wanted (directory->details->top_left_read_state->file,
wants_top_left)) {
return;
if (directory->details->top_left_read_state->file != NULL) {
g_assert (NAUTILUS_IS_FILE (directory->details->top_left_read_state->file));
g_assert (directory->details->top_left_read_state->file->details->directory == directory);
if (is_wanted (directory->details->top_left_read_state->file,
wants_top_left)) {
return;
}
}
/* The top left is not wanted, so stop it. */
gnome_vfs_async_cancel (directory->details->top_left_read_state->handle);
top_left_read_close (directory);
g_free (directory->details->top_left_read_state->buffer);
nautilus_file_unref (directory->details->top_left_read_state->file);
g_free (directory->details->top_left_read_state);
directory->details->top_left_read_state = NULL;
}
......@@ -1588,7 +1599,6 @@ start_getting_top_lefts (NautilusDirectory *directory)
}
/* Start reading. */
nautilus_file_ref (file);
uri = nautilus_file_get_uri (file);
directory->details->top_left_read_state = g_new0 (TopLeftTextReadState, 1);
directory->details->top_left_read_state->file = file;
......
......@@ -49,3 +49,4 @@ void nautilus_file_emit_changed (NautilusFile *file);
void nautilus_file_mark_gone (NautilusFile *file);
char * nautilus_extract_top_left_text (const char *text,
int length);
gboolean nautilus_file_contains_text (NautilusFile *file);
......@@ -1752,14 +1752,46 @@ nautilus_file_is_symbolic_link (NautilusFile *file)
gboolean
nautilus_file_is_directory (NautilusFile *file)
{
if (file == NULL)
if (file == NULL) {
return FALSE;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
return nautilus_file_get_file_type (file) == GNOME_VFS_FILE_TYPE_DIRECTORY;
}
/**
* nautilus_file_contains_text
*
* Check if this file contains text.
* This is private and is used to decide whether or not to read the top left text.
* @file: NautilusFile representing the file in question.
*
* Returns: TRUE if @file has a text MIME type or is a regular file with unknown MIME type.
*
**/
gboolean
nautilus_file_contains_text (NautilusFile *file)
{
char *mime_type;
gboolean contains_text;
if (file == NULL) {
return FALSE;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
mime_type = nautilus_file_get_mime_type (file);
contains_text = nautilus_str_has_prefix (mime_type, "text/")
|| (mime_type == NULL && nautilus_file_get_file_type (file)
== GNOME_VFS_FILE_TYPE_REGULAR);
g_free (mime_type);
return contains_text;
}
/**
* nautilus_file_is_executable
*
......@@ -1802,10 +1834,16 @@ nautilus_file_get_top_left_text (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
/* Show "--" in the file until we read the contents in. */
return file->details->got_top_left_text
? g_strdup (file->details->top_left_text)
: g_strdup (_(" --"));
/* Show " --" in the file until we read the contents in. */
if (!file->details->got_top_left_text) {
if (nautilus_file_contains_text (file)) {
return g_strdup (_(" --"));
}
return NULL;
}
/* Show what we read in. */
return g_strdup (file->details->top_left_text);
}
/**
......
......@@ -393,6 +393,24 @@ nautilus_gtk_marshal_POINTER__POINTER_INT_INT_POINTER_POINTER (GtkObject *object
func_data);
}
void
nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args)
{
(* (void (*)(GtkObject *, gpointer, gpointer, gpointer,
gpointer, gpointer, gpointer, gpointer)) func)
(object,
GTK_VALUE_POINTER (args[0]),
GTK_VALUE_POINTER (args[1]),
GTK_VALUE_POINTER (args[2]),
GTK_VALUE_POINTER (args[3]),
GTK_VALUE_POINTER (args[4]),
GTK_VALUE_POINTER (args[5]),
func_data);
}
gboolean
nautilus_point_in_allocation (const GtkAllocation *allocation,
int x, int y)
......
......@@ -79,6 +79,7 @@ void nautilus_gtk_style_set_font_by_name (GtkStyle
#define nautilus_gtk_marshal_NONE__BOXED_BOXED gtk_marshal_NONE__POINTER_POINTER
#define nautilus_gtk_marshal_NONE__POINTER_STRING_STRING nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER
#define nautilus_gtk_marshal_INT__POINTER_STRING nautilus_gtk_marshal_INT__POINTER_POINTER
#define nautilus_gtk_marshal_POINTER__POINTER_STRING_POINTER nautilus_gtk_marshal_POINTER__POINTER_POINTER_POINTER
#define nautilus_gtk_marshal_POINTER__POINTER_INT_INT_STRING_POINTER nautilus_gtk_marshal_POINTER__POINTER_INT_INT_POINTER_POINTER
#define nautilus_gtk_marshal_STRING__NONE nautilus_gtk_marshal_POINTER__NONE
#define nautilus_gtk_marshal_STRING__POINTER nautilus_gtk_marshal_POINTER__POINTER
......@@ -87,53 +88,57 @@ void nautilus_gtk_style_set_font_by_name (GtkStyle
#define nautilus_gtk_marshal_STRING__POINTER_POINTER_POINTER nautilus_gtk_marshal_POINTER__POINTER_POINTER_POINTER
#define nautilus_gtk_marshal_STRING__POINTER_POINTER_STRING nautilus_gtk_marshal_POINTER__POINTER_POINTER_POINTER
void nautilus_gtk_marshal_NONE__DOUBLE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_INT_INT_DOUBLE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_INT_INT_INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_INT_INT_INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_INT_INT_DOUBLE_DOUBLE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_INT__POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__NONE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER_INT_INT_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__DOUBLE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_INT_INT_DOUBLE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_INT_INT_INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_INT_INT_INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_INT_INT_DOUBLE_DOUBLE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_INT__POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__NONE (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER_INT_INT_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
#endif /* NAUTILUS_GTK_EXTENSIONS_H */
......@@ -70,6 +70,10 @@
#define RUBBERBAND_BUTTON 1
#define CONTEXTUAL_MENU_BUTTON 3
/* Maximum size (pixels) allowed for icons. */
#define MAXIMUM_IMAGE_SIZE 1000
#define MAXIMUM_EMBLEM_SIZE 100
static void activate_selected_items (NautilusIconContainer *container);
static void nautilus_icon_container_initialize_class (NautilusIconContainerClass *class);
static void nautilus_icon_container_initialize (NautilusIconContainer *container);
......@@ -100,12 +104,13 @@ enum {
CONTEXT_CLICK_BACKGROUND,
CONTEXT_CLICK_SELECTION,
GET_CONTAINER_URI,
GET_ICON_TEXT,
GET_ICON_IMAGES,
GET_ICON_TEXT,
GET_ICON_URI,
ICON_CHANGED,
ICON_TEXT_EDIT_OCCURRED,
GET_STORED_ICON_POSITION,
ICON_POSITION_CHANGED,
ICON_TEXT_CHANGED,
ICON_TEXT_EDIT_OCCURRED,
MOVE_COPY_ITEMS,
SELECTION_CHANGED,
LAST_SIGNAL
......@@ -533,22 +538,38 @@ compare_icons (gconstpointer a, gconstpointer b)
return result;
}
static void
resort_and_clear (NautilusIconContainer *container)
{
sort_hack_container = container;
container->details->icons = g_list_sort
(container->details->icons, compare_icons);
nautilus_icon_grid_clear (container->details->grid);
}
static void
auto_position_icon (NautilusIconContainer *container,
NautilusIcon *icon)
{
ArtPoint position;
nautilus_icon_grid_get_position (container->details->grid,
icon, &position);
icon_set_position (icon, position.x, position.y);
}
static void
relayout (NautilusIconContainer *container)
{
GList *p;
NautilusIcon *icon;
ArtPoint position;
if (!container->details->auto_layout) {
return;
}
sort_hack_container = container;
container->details->icons = g_list_sort
(container->details->icons, compare_icons);
nautilus_icon_grid_clear (container->details->grid);
resort_and_clear (container);
/* An icon currently being stretched must be left in place.
* That's "drag_icon". This doesn't come up for cases where
......@@ -562,19 +583,65 @@ relayout (NautilusIconContainer *container)
container->details->drag_icon);
}
/* Place all hte other icons. */
/* Place all the other icons. */
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon != container->details->drag_icon) {
nautilus_icon_grid_get_position (container->details->grid,
icon, &position);
icon_set_position (icon, position.x, position.y);
auto_position_icon (container, icon);
nautilus_icon_grid_add (container->details->grid, icon);
}
}
}
static void
reload_icon_positions (NautilusIconContainer *container)
{
GList *p, *no_position_icons;
NautilusIcon *icon;
gboolean have_stored_position;
int x, y;
double scale_x, scale_y;
g_assert (!container->details->auto_layout);
resort_and_clear (container);
no_position_icons = NULL;
/* Place all the icons with positions. */
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
have_stored_position = FALSE;
gtk_signal_emit (GTK_OBJECT (container),
signals[GET_STORED_ICON_POSITION],
icon->data,
&have_stored_position,
&x,
&y,
&scale_x,
&scale_y);
if (have_stored_position) {
icon_set_position (icon, x, y);
nautilus_icon_grid_add (container->details->grid, icon);
} else {
no_position_icons = g_list_prepend (no_position_icons, icon);
}
}
no_position_icons = g_list_reverse (no_position_icons);
/* Place all the other icons. */
for (p = no_position_icons; p != NULL; p = p->next) {
icon = p->data;
auto_position_icon (container, icon);
nautilus_icon_grid_add (container->details->grid, icon);
}
g_list_free (no_position_icons);
}
static gboolean
idle_handler (gpointer data)
{
......@@ -586,7 +653,6 @@ idle_handler (gpointer data)
container = NAUTILUS_ICON_CONTAINER (data);
details = container->details;
relayout (container);