Commit 74748cdc authored by Darin Adler's avatar Darin Adler

Fixed a bug my changes to GNOME VFS exposed. The callback couldn't handle

	* components/html/ntl-web-browser.c: (browser_vfs_read_callback):
	Fixed a bug my changes to GNOME VFS exposed. The callback couldn't
	handle a "bytes_read" of 0.

	* libnautilus/nautilus-directory-private.h:
	* libnautilus/nautilus-directory.c:
	* libnautilus/nautilus-directory.h:
	* src/file-manager/fm-directory-view.c:
	Added a new interface for monitoring files and directories.
	Also fixed the self-check code that was failing since the
	async. changes.

	* libnautilus/nautilus-file.h:
	Added the interface for monitoring single files, but it isn't
	implemented yet.

	* libnautilus/nautilus-icon-canvas-item.c:
	* libnautilus/nautilus-icon-canvas-item.h:
	* libnautilus/nautilus-icon-container.c:
	* libnautilus/nautilus-icon-container.h:
	* libnautilus/nautilus-icon-dnd.c:
	* libnautilus/nautilus-icon-dnd.h:
	* libnautilus/nautilus-icon-private.h:
	Restructured Andy's modifier changes so the canvas item doesn't
	have to know about modifiers. This makes the canvas item private
	again. Users of NautilusIconContainer shouldn't have to know
	about the canvas item.

	* src/file-manager/fm-icon-view.c:
	Reformatting.
parent 779efc10
2000-04-13 Andy Hertzfeld <andy@eazel.com>
2000-04-13 Darin Adler <darin@eazel.com>
* components/html/ntl-web-browser.c: (browser_vfs_read_callback):
Fixed a bug my changes to GNOME VFS exposed. The callback couldn't
handle a "bytes_read" of 0.
* libnautilus/nautilus-directory-private.h:
* libnautilus/nautilus-directory.c:
* libnautilus/nautilus-directory.h:
* src/file-manager/fm-directory-view.c:
Added a new interface for monitoring files and directories.
Also fixed the self-check code that was failing since the
async. changes.
* libnautilus/nautilus-file.h:
Added the interface for monitoring single files, but it isn't
implemented yet.
* libnautilus/nautilus-icon-canvas-item.c:
* libnautilus/nautilus-icon-canvas-item.h:
* libnautilus/nautilus-icon-container.c:
* libnautilus/nautilus-icon-container.h:
* libnautilus/nautilus-icon-dnd.c:
* libnautilus/nautilus-icon-dnd.h:
* libnautilus/nautilus-icon-private.h:
Restructured Andy's modifier changes so the canvas item doesn't
have to know about modifiers. This makes the canvas item private
again. Users of NautilusIconContainer shouldn't have to know
about the canvas item.
* src/file-manager/fm-icon-view.c:
Reformatting.
2000-04-13 Andy Hertzfeld <andy@eazel.com>
* components/services/startup/nautilus-service-startup-view.c:
made configuration upload work again by adding a "Content-Type"
header, which is now required by Jonathan's script
2000-04-13 Andy Hertzfeld <andy@eazel.com>
2000-04-13 Andy Hertzfeld <andy@eazel.com>
* components/services/startup/nautilus-service-startup-view.c:
fixed problems with the url escaping by unescaping the token
return by the service before re-escaping it
* components/services/startup/eazel-register.c:
added periodic call to gtk_main_iteration during configuration gather
to get feedback displayed
added periodic call to gtk_main_iteration during configuration
gather to get feedback displayed
2000-04-13 Andy Hertzfeld <andy@eazel.com>
......
......@@ -327,21 +327,25 @@ browser_do_post(HTRequest *request, HTStream *stream)
static char vfs_read_buf[40960];
static void
browser_vfs_read_callback(GnomeVFSAsyncHandle *h, GnomeVFSResult res, gpointer buffer,
GnomeVFSFileSize bytes_requested,
GnomeVFSFileSize bytes_read,
gpointer data)
browser_vfs_read_callback (GnomeVFSAsyncHandle *h, GnomeVFSResult res, gpointer buffer,
GnomeVFSFileSize bytes_requested,
GnomeVFSFileSize bytes_read,
gpointer data)
{
VFSHandle *vfsh = data;
g_message("browser_vfs_read_callback: %ld/%ld bytes", (long) bytes_read, (long) bytes_requested);
gtk_html_write(GTK_HTML(vfsh->bi->htmlw), vfsh->sh, buffer, bytes_read);
if(bytes_read != 0)
{
gtk_html_write(GTK_HTML(vfsh->bi->htmlw), vfsh->sh, buffer, bytes_read);
}
if(res != GNOME_VFS_OK)
if(bytes_read == 0 || res != GNOME_VFS_OK)
{
gtk_html_end(GTK_HTML(vfsh->bi->htmlw), vfsh->sh, GTK_HTML_STREAM_OK);
gnome_vfs_async_close(h, (GnomeVFSAsyncCloseCallback)gtk_true, NULL);
g_free(vfsh);
return;
}
gnome_vfs_async_read(h, vfs_read_buf, sizeof(vfs_read_buf), browser_vfs_read_callback, data);
......
......@@ -44,8 +44,6 @@ struct NautilusDirectoryDetails
GnomeVFSURI *metafile_uri;
GnomeVFSURI *alternate_metafile_uri;
guint monitor_files_ref_count;
GList *files;
xmlDoc *metafile;
......@@ -57,11 +55,12 @@ struct NautilusDirectoryDetails
guint write_metafile_idle_id;
MetafileWriteState *write_state;
/* This list is going to be pretty short.
* If we thought it was going to get big, we could
* use a hash table instead.
/* These list are going to be pretty short. If we think they
* are going to get big, we can use hash tables instead.
*/
GList *metafile_callbacks;
GList *monitors;
GList *file_monitors;
gboolean directory_loaded;
GnomeVFSAsyncHandle *directory_load_in_progress;
......@@ -102,4 +101,4 @@ void nautilus_directory_call_when_ready_internal (NautilusDirectory
const QueuedCallback *callback);
/* debugging functions */
int nautilus_directory_number_outstanding (void);
int nautilus_directory_number_outstanding (void);
......@@ -145,6 +145,7 @@ static GnomeVFSDirectoryListPosition nautilus_gnome_vfs_directory_list_get_next_
static void nautilus_gnome_vfs_file_info_list_free (GList *list);
static void nautilus_gnome_vfs_file_info_list_unref (GList *list);
static void schedule_dequeue_pending (NautilusDirectory *directory);
static void stop_monitoring_files (NautilusDirectory *directory);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusDirectory, nautilus_directory, GTK_TYPE_OBJECT)
......@@ -241,10 +242,10 @@ nautilus_directory_destroy (GtkObject *object)
g_assert (directory->details->write_state == NULL);
metafile_read_cancel (directory);
if (directory->details->monitor_files_ref_count != 0) {
if (directory->details->file_monitors != NULL) {
g_warning ("destroying a NautilusDirectory while it's being monitored");
directory->details->monitor_files_ref_count = 1;
nautilus_directory_monitor_files_unref (directory);
stop_monitoring_files (directory);
g_list_free (directory->details->file_monitors);
}
g_hash_table_remove (directory_objects, directory->details->uri_text);
......@@ -876,13 +877,22 @@ nautilus_directory_new (const char* uri)
}
void
nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback callback,
gpointer callback_data)
nautilus_directory_file_monitor_add (NautilusDirectory *directory,
gpointer client,
GList *attributes,
GList *metadata_keys,
NautilusFileListCallback callback,
gpointer callback_data)
{
gboolean first_file_monitor;
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (callback != NULL);
first_file_monitor = directory->details->file_monitors == NULL;
directory->details->file_monitors =
g_list_prepend (directory->details->file_monitors, client);
nautilus_file_list_ref (directory->details->files);
if (directory->details->files != NULL) {
......@@ -891,8 +901,7 @@ nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
callback_data);
}
g_assert (directory->details->monitor_files_ref_count != UINT_MAX);
if (directory->details->monitor_files_ref_count++ != 0) {
if (!first_file_monitor) {
nautilus_file_list_unref (directory->details->files);
return;
}
......@@ -946,7 +955,7 @@ dequeue_pending_idle_callback (gpointer callback_data)
}
/* If we stopped monitoring, then throw away these. */
if (directory->details->monitor_files_ref_count == 0) {
if (directory->details->file_monitors == NULL) {
nautilus_gnome_vfs_file_info_list_free (pending_file_info);
return FALSE;
}
......@@ -1054,16 +1063,9 @@ nautilus_directory_load_callback (GnomeVFSAsyncHandle *handle,
}
}
void
nautilus_directory_monitor_files_unref (NautilusDirectory *directory)
static void
stop_monitoring_files (NautilusDirectory *directory)
{
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (directory->details->monitor_files_ref_count != 0);
if (--directory->details->monitor_files_ref_count != 0) {
return;
}
if (directory->details->directory_load_in_progress != NULL) {
gnome_vfs_async_cancel (directory->details->directory_load_in_progress);
directory->details->directory_load_in_progress = NULL;
......@@ -1072,6 +1074,20 @@ nautilus_directory_monitor_files_unref (NautilusDirectory *directory)
nautilus_file_list_unref (directory->details->files);
}
void
nautilus_directory_file_monitor_remove (NautilusDirectory *directory,
gpointer client)
{
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (g_list_find (directory->details->file_monitors, client) != NULL);
directory->details->file_monitors =
g_list_remove (directory->details->file_monitors, client);
if (directory->details->file_monitors == NULL) {
stop_monitoring_files (directory);
}
}
gboolean
nautilus_directory_are_all_files_seen (NautilusDirectory *directory)
{
......@@ -1553,17 +1569,27 @@ nautilus_directory_files_changed (NautilusDirectory *directory,
static int data_dummy;
static guint file_count;
static gboolean got_metadata_flag;
static void
get_files_callback (NautilusDirectory *directory, GList *files, gpointer data)
get_files_callback (NautilusDirectory *directory, GList *files, gpointer callback_data)
{
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (files);
g_assert (data == &data_dummy);
g_assert (files != NULL);
g_assert (callback_data == &data_dummy);
file_count += g_list_length (files);
}
static void
got_metadata_callback (NautilusDirectory *directory, gpointer callback_data)
{
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (callback_data == &data_dummy);
got_metadata_flag = TRUE;
}
/* Return the number of extant NautilusDirectories */
int
nautilus_directory_number_outstanding (void)
......@@ -1575,13 +1601,26 @@ void
nautilus_self_check_directory (void)
{
NautilusDirectory *directory;
GList *list;
list = g_list_prepend (NULL, "TEST");
directory = nautilus_directory_get ("file:///etc");
NAUTILUS_CHECK_INTEGER_RESULT (g_hash_table_size (directory_objects), 1);
file_count = 0;
nautilus_directory_monitor_files_ref (directory, get_files_callback, &data_dummy);
nautilus_directory_file_monitor_add (directory, &file_count,
NULL, NULL,
get_files_callback, &data_dummy);
got_metadata_flag = FALSE;
nautilus_directory_call_when_ready (directory, list, NULL,
got_metadata_callback, &data_dummy);
while (!got_metadata_flag) {
gtk_main_iteration ();
}
nautilus_directory_set_metadata (directory, "TEST", "default", "value");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_get_metadata (directory, "TEST", "default"), "value");
......@@ -1610,12 +1649,11 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_directory_get ("file:///etc////") == directory, TRUE);
nautilus_directory_unref (directory);
nautilus_directory_monitor_files_unref (directory);
nautilus_directory_file_monitor_remove (directory, &file_count);
nautilus_directory_unref (directory);
/* let the idle function run */
while (gtk_events_pending ()) {
while (g_hash_table_size (directory_objects) != 0) {
gtk_main_iteration ();
}
......@@ -1623,12 +1661,22 @@ nautilus_self_check_directory (void)
directory = nautilus_directory_get ("file:///etc");
got_metadata_flag = FALSE;
nautilus_directory_call_when_ready (directory, list, NULL,
got_metadata_callback, &data_dummy);
while (!got_metadata_flag) {
gtk_main_iteration ();
}
NAUTILUS_CHECK_BOOLEAN_RESULT (directory->details->metafile != NULL, TRUE);
NAUTILUS_CHECK_INTEGER_RESULT (g_hash_table_size (directory_objects), 1);
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_get_metadata (directory, "TEST", "default"), "value");
nautilus_directory_unref (directory);
/* escape_slashes */
NAUTILUS_CHECK_STRING_RESULT (escape_slashes (""), "");
NAUTILUS_CHECK_STRING_RESULT (escape_slashes ("a"), "a");
......@@ -1639,7 +1687,7 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (escape_slashes ("%25"), "%2525");
NAUTILUS_CHECK_STRING_RESULT (escape_slashes ("%2F"), "%252F");
nautilus_directory_unref (directory);
g_list_free (list);
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
......@@ -117,10 +117,14 @@ void nautilus_directory_set_integer_metadata (NautilusDirectory
int metadata);
/* Monitor the files in a directory. */
void nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
void nautilus_directory_file_monitor_add (NautilusDirectory *directory,
gpointer client,
GList *attributes,
GList *metadata_keys,
NautilusFileListCallback initial_files_callback,
gpointer callback_data);
void nautilus_directory_monitor_files_unref (NautilusDirectory *directory);
void nautilus_directory_file_monitor_remove (NautilusDirectory *directory,
gpointer client);
/* Return true if the directory has information about all the files.
* This will be false until the directory has been read at least once.
......
......@@ -70,6 +70,14 @@ void nautilus_file_ref (NautilusFile *
void nautilus_file_unref (NautilusFile *file);
void nautilus_file_delete (NautilusFile *file);
/* Monitor the file. */
void nautilus_file_monitor_add (NautilusFile *file,
gpointer client,
GList *attributes,
GList *metadata_keys);
void nautilus_file_monitor_remove (NautilusFile *file,
gpointer client);
/* Waiting for data that's read asynchronously.
* This interface currently works only for metadata, but could be expanded
* to other attributes as well.
......@@ -124,7 +132,7 @@ char * nautilus_file_get_string_attribute (NautilusFile *
/* Matching with another URI*/
gboolean nautilus_file_matches_uri (NautilusFile *file,
const char *uri);
const char *uri);
/* Comparing two file objects for sorting */
int nautilus_file_compare_for_sort (NautilusFile *file_1,
......
......@@ -54,7 +54,6 @@ struct NautilusIconCanvasItemDetails {
GdkFont *font;
ArtIRect embedded_text_rect;
char *embedded_text_file_URI;
char *modifier;
/* Size of the text at current font. */
int text_width;
......@@ -106,65 +105,63 @@ static GdkFont *embedded_text_font;
/* GtkObject */
static void nautilus_icon_canvas_item_initialize_class (NautilusIconCanvasItemClass *class);
static void nautilus_icon_canvas_item_initialize (NautilusIconCanvasItem *item);
static void nautilus_icon_canvas_item_destroy (GtkObject *object);
static int nautilus_icon_canvas_item_event (GnomeCanvasItem *item,
GdkEvent *event);
static void nautilus_icon_canvas_item_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void nautilus_icon_canvas_item_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void nautilus_icon_canvas_item_destroy (GtkObject *object);
static int nautilus_icon_canvas_item_event (GnomeCanvasItem *item,
GdkEvent *event);
static void nautilus_icon_canvas_item_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void nautilus_icon_canvas_item_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
/* GnomeCanvasItem */
static void nautilus_icon_canvas_item_update (GnomeCanvasItem *item,
double *affine,
ArtSVP *clip_path,
int flags);
static void nautilus_icon_canvas_item_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
int x,
int y,
int width,
int height);
static double nautilus_icon_canvas_item_point (GnomeCanvasItem *item,
double x,
double y,
int cx,
int cy,
GnomeCanvasItem **actual_item);
static void nautilus_icon_canvas_item_bounds (GnomeCanvasItem *item,
double *x1,
double *y1,
double *x2,
double *y2);
static void nautilus_icon_canvas_item_set_modifier (NautilusIconCanvasItem *item,
const char* modifier);
static void nautilus_icon_canvas_item_update (GnomeCanvasItem *item,
double *affine,
ArtSVP *clip_path,
int flags);
static void nautilus_icon_canvas_item_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
int x,
int y,
int width,
int height);
static double nautilus_icon_canvas_item_point (GnomeCanvasItem *item,
double x,
double y,
int cx,
int cy,
GnomeCanvasItem **actual_item);
static void nautilus_icon_canvas_item_bounds (GnomeCanvasItem *item,
double *x1,
double *y1,
double *x2,
double *y2);
/* private */
static void draw_or_measure_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void draw_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void measure_label_text (NautilusIconCanvasItem *item);
static void get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
ArtIRect *rect);
static void emblem_layout_reset (EmblemLayout *layout,
NautilusIconCanvasItem *icon_item,
const ArtIRect *icon_rect);
static gboolean emblem_layout_next (EmblemLayout *layout,
GdkPixbuf **emblem_pixbuf,
ArtIRect *emblem_rect);
static void draw_pixbuf (GdkPixbuf *pixbuf,
GdkDrawable *drawable,
int x,
int y);
static gboolean hit_test_stretch_handle (NautilusIconCanvasItem *item,
const ArtIRect *canvas_rect);
static void draw_or_measure_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void draw_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void measure_label_text (NautilusIconCanvasItem *item);
static void get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
ArtIRect *rect);
static void emblem_layout_reset (EmblemLayout *layout,
NautilusIconCanvasItem *icon_item,
const ArtIRect *icon_rect);
static gboolean emblem_layout_next (EmblemLayout *layout,
GdkPixbuf **emblem_pixbuf,
ArtIRect *emblem_rect);
static void draw_pixbuf (GdkPixbuf *pixbuf,
GdkDrawable *drawable,
int x,
int y);
static gboolean hit_test_stretch_handle (NautilusIconCanvasItem *item,
const ArtIRect *canvas_rect);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconCanvasItem, nautilus_icon_canvas_item, GNOME_TYPE_CANVAS_ITEM)
......@@ -190,8 +187,6 @@ nautilus_icon_canvas_item_initialize_class (NautilusIconCanvasItemClass *class)
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_DROP);
gtk_object_add_arg_type ("NautilusIconCanvasItem::text_source",
GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT_SOURCE);
gtk_object_add_arg_type ("NautilusIconCanvasItem::modifier",
GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_MODIFIER);
object_class->destroy = nautilus_icon_canvas_item_destroy;
object_class->set_arg = nautilus_icon_canvas_item_set_arg;
......@@ -255,11 +250,7 @@ nautilus_icon_canvas_item_destroy (GtkObject *object)
gdk_font_unref (details->font);
}
if (details->embedded_text_file_URI)
g_free(details->embedded_text_file_URI);
if (details->modifier)
g_free(details->modifier);
g_free (details->embedded_text_file_URI);
g_free (details);
......@@ -335,8 +326,6 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
return;
}
details->is_highlighted_for_drop = GTK_VALUE_BOOL (*arg);
nautilus_icon_canvas_item_set_modifier(NAUTILUS_ICON_CANVAS_ITEM (object),
details->is_highlighted_for_drop ? "accept" : "");
break;
case ARG_TEXT_SOURCE:
......@@ -348,14 +337,6 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
details->embedded_text_file_URI = g_strdup (GTK_VALUE_STRING (*arg));
break;
case ARG_MODIFIER:
if (nautilus_strcmp (details->modifier, GTK_VALUE_STRING (*arg)) == 0) {
return;
}
nautilus_icon_canvas_item_set_modifier(NAUTILUS_ICON_CANVAS_ITEM (object), GTK_VALUE_STRING (*arg));
break;
default:
g_warning ("nautilus_icons_view_item_item_set_arg on unknown argument");
return;
......@@ -398,10 +379,6 @@ nautilus_icon_canvas_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_STRING (*arg) = g_strdup (details->embedded_text_file_URI);
break;
case ARG_MODIFIER:
GTK_VALUE_STRING (*arg) = g_strdup (details->modifier);
break;
default:
arg->type = GTK_TYPE_INVALID;
break;
......@@ -424,37 +401,10 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
return details->pixbuf;
}
const char*
nautilus_icon_canvas_item_get_modifier(NautilusIconCanvasItem *item)
{
return item->details->modifier;
}
void
nautilus_icon_canvas_item_set_modifier(NautilusIconCanvasItem *item, const char* modifier)
{
GnomeCanvasItem *canvas_item;
/* if they're the same, there's nothing to do */
if (!modifier && !item->details->modifier)
return;
if (modifier && item->details->modifier && !strcmp(modifier, item->details->modifier))
return;
if (item->details->modifier != NULL)
g_free(item->details->modifier);
item->details->modifier = strdup(modifier);
/* we must update the image, since the modifier has changed */
canvas_item = GNOME_CANVAS_ITEM(item);
nautilus_icon_container_request_update_by_item(NAUTILUS_ICON_CONTAINER(canvas_item->canvas), item);
}
void
nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item,
GdkPixbuf *image,
const ArtIRect *embedded_text_rect)
GdkPixbuf *image,
const ArtIRect *embedded_text_rect)
{
NautilusIconCanvasItemDetails *details;
ArtIRect empty_rect;
......
......@@ -73,8 +73,6 @@ void nautilus_icon_canvas_item_set_emblems (NautilusIconCanva
void nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem *item,
gboolean show_stretch_handles);
const char *nautilus_icon_canvas_item_get_modifier (NautilusIconCanvasItem *item);
/* geometry and hit testing */
gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
const ArtDRect *world_rectangle);
......
......@@ -70,23 +70,18 @@
*/
#define MAXIMUM_INITIAL_ICON_SIZE 2
static void activate_selected_items (NautilusIconContainer *container);
static void nautilus_icon_container_initialize_class (NautilusIconContainerClass *class);
static void nautilus_icon_container_initialize (NautilusIconContainer *container);
static void update_icon (NautilusIconContainer *container,
NautilusIcon *icon);
static void compute_stretch (StretchState *start,
StretchState *current);
static NautilusIcon *get_first_selected_icon (NautilusIconContainer *container);
static NautilusIcon *get_nth_selected_icon (NautilusIconContainer *container,
int index);
#if 0
static gboolean has_selection (NautilusIconContainer *container);
#endif
static gboolean has_multiple_selection (NautilusIconContainer *container);
static void icon_destroy (NautilusIconContainer *container,
NautilusIcon *icon);
static guint icon_get_actual_size (NautilusIcon *icon);
static void activate_selected_items (NautilusIconContainer *container);
static void nautilus_icon_container_initialize_class (NautilusIconContainerClass *class);
static void nautilus_icon_container_initialize (NautilusIconContainer *container);
static void compute_stretch (StretchState *start,
StretchState *current);
static NautilusIcon *get_first_selected_icon (NautilusIconContainer *container);
static NautilusIcon *get_nth_selected_icon (NautilusIconContainer *container,
int index);
static gboolean has_multiple_selection (NautilusIconContainer *container);
static void icon_destroy (NautilusIconContainer *container,
NautilusIcon *icon);
static guint icon_get_actual_size (NautilusIcon *icon);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
......@@ -148,7 +143,7 @@ icon_new (NautilusIconContainer *container,
NULL));
icon->item->user_data = icon;
update_icon (container, icon);
nautilus_icon_container_update_icon (container, icon);
/* Enforce a maximum size for new icons by reducing the scale factor as necessary.
* FIXME: This needs to be done again later when the image changes, so it's not
......@@ -163,7 +158,7 @@ icon_new (NautilusIconContainer *container,
if (actual_size > max_size) {
icon->scale_x = max_size / (double) actual_size;
icon->scale_y = icon->scale_x;
update_icon (container, icon);
nautilus_icon_container_update_icon (container, icon);
}
return icon;
......@@ -629,7 +624,7 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container,
if (scale_x != icon->scale_x || scale_y != icon->scale_y) {
icon->scale_x = scale_x;
icon->scale_y = scale_y;
update_icon (container, icon);
nautilus_icon_container_update_icon (container, icon);
emit_signal = TRUE;
}
......@@ -2142,6 +2137,9 @@ icon_destroy (NautilusIconContainer *container,
if (details->keyboard_icon_to_reveal == icon) {
unschedule_keyboard_icon_reveal (container);
}
if (details->drop_target == icon) {
details->drop_target = NULL;
}
nautilus_icon_grid_remove (details->grid, icon);
......@@ -2211,8 +2209,9 @@ set_up_icon_in_container (NautilusIconContainer *container,
GTK_SIGNAL_FUNC (bounds_changed_callback), container);
}
static void
update_icon (NautilusIconContainer *container, NautilusIcon *icon)
void
nautilus_icon_container_update_icon (NautilusIconContainer *container,
NautilusIcon *icon)
{
NautilusIconContainerDetails *details;
NautilusScalableIcon *scalable_icon;
......@@ -2224,6 +2223,10 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon)
char *contents_as_text;
GdkFont *font;
if (icon == NULL) {
return;
}
details = container->details;
/* Get the icons. */
......@@ -2232,7 +2235,7 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon)
signals[GET_ICON_IMAGES],
icon->data,
&emblem_icons,
nautilus_icon_canvas_item_get_modifier(icon->item),
(icon == details->drop_target) ? "accept" : "",
&scalable_icon);
g_assert (scalable_icon != NULL);