summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--libnautilus-extensions/nautilus-icon-canvas-item.c19
-rw-r--r--libnautilus-extensions/nautilus-icon-canvas-item.h1
-rw-r--r--libnautilus-extensions/nautilus-icon-container.c17
-rw-r--r--libnautilus-private/nautilus-icon-canvas-item.c19
-rw-r--r--libnautilus-private/nautilus-icon-canvas-item.h1
-rw-r--r--libnautilus-private/nautilus-icon-container.c17
7 files changed, 75 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index ab211b93c..7a2cbf80b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2001-01-11 Andy Hertzfeld <andy@eazel.com>
+
+ fixed bug 5338, switching to and from "tighter layout" messes up
+ icon labels, by adding a call to invalidate an item's cached label
+ size, and making the icon canvas invalidate the items when appropriate.
+ This also fixes a similar problem when the anti-aliased mode changes.
+
+ * libnautilus-extensions/nautilus-icon-canvas-item.c:
+ (nautilus_icon_canvas_item_initialize),
+ (nautilus_icon_canvas_item_invalidate_label_size),
+ (nautilus_icon_canvas_item_set_arg):
+ renamed internal invalidation routine to make it externally accessible
+
+ * libnautilus-extensions/nautilus-icon-canvas-item.h:
+ added nautilus_icon_canvas_item_invalidate_label_size
+
+ * libnautilus-extensions/nautilus-icon-container.c:
+ (invalidate_label_sizes),
+ (nautilus_icon_container_set_anti_aliased_mode),
+ (nautilus_icon_container_set_tighter_layout):
+ added an invalidate_label_sizes routine and called it when
+ tighter layout or the anti-aliased mode changes.
+
2001-01-11 Robin * Slomkowski <rslomkow@eazel.com>
reviewed by: <Josh Barrow <josh@eazel.com>
diff --git a/libnautilus-extensions/nautilus-icon-canvas-item.c b/libnautilus-extensions/nautilus-icon-canvas-item.c
index 20c3ae033..1d7f14c4a 100644
--- a/libnautilus-extensions/nautilus-icon-canvas-item.c
+++ b/libnautilus-extensions/nautilus-icon-canvas-item.c
@@ -283,8 +283,7 @@ nautilus_icon_canvas_item_initialize (NautilusIconCanvasItem *icon_item)
icon_item->details->is_renaming = FALSE;
/* invalidate cached text dimensions initially */
- icon_item->details->text_width = -1;
- icon_item->details->text_height = -1;
+ nautilus_icon_canvas_item_invalidate_label_size (icon_item);
/* set up the default font and size */
icon_item->details->smooth_font_size = 12;
@@ -342,11 +341,9 @@ pixbuf_is_acceptable (GdkPixbuf *pixbuf)
&& gdk_pixbuf_get_bits_per_sample (pixbuf) == 8;
}
-/* utility routine to invalidate the text width and height cached in the
- * item details.
- */
-static void
-invalidate_text_dimensions (NautilusIconCanvasItem *item)
+/* invalidate the text width and height cached in the item details. */
+void
+nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item)
{
item->details->text_width = -1;
item->details->text_height = -1;
@@ -373,7 +370,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
g_free (details->editable_text);
details->editable_text = g_strdup (GTK_VALUE_STRING (*arg));
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_ADDITIONAL_TEXT:
@@ -384,7 +381,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
g_free (details->additional_text);
details->additional_text = g_strdup (GTK_VALUE_STRING (*arg));
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_FONT:
@@ -401,7 +398,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
details->font = font;
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_HIGHLIGHTED_FOR_SELECTION:
@@ -428,7 +425,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_SMOOTH_FONT:
nautilus_icon_canvas_item_set_smooth_font (NAUTILUS_ICON_CANVAS_ITEM (object),
NAUTILUS_SCALABLE_FONT (GTK_VALUE_OBJECT (*arg)));
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_SMOOTH_FONT_SIZE:
diff --git a/libnautilus-extensions/nautilus-icon-canvas-item.h b/libnautilus-extensions/nautilus-icon-canvas-item.h
index 8de5c8f23..5d196e368 100644
--- a/libnautilus-extensions/nautilus-icon-canvas-item.h
+++ b/libnautilus-extensions/nautilus-icon-canvas-item.h
@@ -86,6 +86,7 @@ gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanv
const ArtDRect *world_rectangle);
gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
const ArtPoint *world_point);
+void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
void nautilus_icon_canvas_item_get_icon_rectangle (NautilusIconCanvasItem *item,
ArtDRect *world_rectangle);
void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item);
diff --git a/libnautilus-extensions/nautilus-icon-container.c b/libnautilus-extensions/nautilus-icon-container.c
index e5917df28..de21f75fb 100644
--- a/libnautilus-extensions/nautilus-icon-container.c
+++ b/libnautilus-extensions/nautilus-icon-container.c
@@ -1219,6 +1219,20 @@ button_event_modifies_selection (GdkEventButton *event)
return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
+/* invalidate the cached label sizes for all the icons */
+static void
+invalidate_label_sizes (NautilusIconContainer *container)
+{
+ GList *p;
+ NautilusIcon *icon;
+
+ for (p = container->details->icons; p != NULL; p = p->next) {
+ icon = p->data;
+
+ nautilus_icon_canvas_item_invalidate_label_size (icon->item);
+ }
+}
+
static gboolean
select_one_unselect_others (NautilusIconContainer *container,
NautilusIcon *icon_to_select)
@@ -3992,6 +4006,8 @@ nautilus_icon_container_set_anti_aliased_mode (NautilusIconContainer *container,
canvas = GNOME_CANVAS (container);
if (canvas->aa != anti_aliased_mode) {
canvas->aa = anti_aliased_mode;
+
+ invalidate_label_sizes (container);
nautilus_icon_container_request_update_all (container);
}
}
@@ -4492,6 +4508,7 @@ nautilus_icon_container_set_tighter_layout (NautilusIconContainer *container,
container->details->tighter_layout = tighter_layout;
+ invalidate_label_sizes (container);
redo_layout (container);
gtk_signal_emit (GTK_OBJECT (container), signals[LAYOUT_CHANGED]);
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index 20c3ae033..1d7f14c4a 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -283,8 +283,7 @@ nautilus_icon_canvas_item_initialize (NautilusIconCanvasItem *icon_item)
icon_item->details->is_renaming = FALSE;
/* invalidate cached text dimensions initially */
- icon_item->details->text_width = -1;
- icon_item->details->text_height = -1;
+ nautilus_icon_canvas_item_invalidate_label_size (icon_item);
/* set up the default font and size */
icon_item->details->smooth_font_size = 12;
@@ -342,11 +341,9 @@ pixbuf_is_acceptable (GdkPixbuf *pixbuf)
&& gdk_pixbuf_get_bits_per_sample (pixbuf) == 8;
}
-/* utility routine to invalidate the text width and height cached in the
- * item details.
- */
-static void
-invalidate_text_dimensions (NautilusIconCanvasItem *item)
+/* invalidate the text width and height cached in the item details. */
+void
+nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item)
{
item->details->text_width = -1;
item->details->text_height = -1;
@@ -373,7 +370,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
g_free (details->editable_text);
details->editable_text = g_strdup (GTK_VALUE_STRING (*arg));
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_ADDITIONAL_TEXT:
@@ -384,7 +381,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
g_free (details->additional_text);
details->additional_text = g_strdup (GTK_VALUE_STRING (*arg));
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_FONT:
@@ -401,7 +398,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
details->font = font;
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_HIGHLIGHTED_FOR_SELECTION:
@@ -428,7 +425,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_SMOOTH_FONT:
nautilus_icon_canvas_item_set_smooth_font (NAUTILUS_ICON_CANVAS_ITEM (object),
NAUTILUS_SCALABLE_FONT (GTK_VALUE_OBJECT (*arg)));
- invalidate_text_dimensions (item);
+ nautilus_icon_canvas_item_invalidate_label_size (item);
break;
case ARG_SMOOTH_FONT_SIZE:
diff --git a/libnautilus-private/nautilus-icon-canvas-item.h b/libnautilus-private/nautilus-icon-canvas-item.h
index 8de5c8f23..5d196e368 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.h
+++ b/libnautilus-private/nautilus-icon-canvas-item.h
@@ -86,6 +86,7 @@ gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanv
const ArtDRect *world_rectangle);
gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
const ArtPoint *world_point);
+void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
void nautilus_icon_canvas_item_get_icon_rectangle (NautilusIconCanvasItem *item,
ArtDRect *world_rectangle);
void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item);
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index e5917df28..de21f75fb 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -1219,6 +1219,20 @@ button_event_modifies_selection (GdkEventButton *event)
return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
+/* invalidate the cached label sizes for all the icons */
+static void
+invalidate_label_sizes (NautilusIconContainer *container)
+{
+ GList *p;
+ NautilusIcon *icon;
+
+ for (p = container->details->icons; p != NULL; p = p->next) {
+ icon = p->data;
+
+ nautilus_icon_canvas_item_invalidate_label_size (icon->item);
+ }
+}
+
static gboolean
select_one_unselect_others (NautilusIconContainer *container,
NautilusIcon *icon_to_select)
@@ -3992,6 +4006,8 @@ nautilus_icon_container_set_anti_aliased_mode (NautilusIconContainer *container,
canvas = GNOME_CANVAS (container);
if (canvas->aa != anti_aliased_mode) {
canvas->aa = anti_aliased_mode;
+
+ invalidate_label_sizes (container);
nautilus_icon_container_request_update_all (container);
}
}
@@ -4492,6 +4508,7 @@ nautilus_icon_container_set_tighter_layout (NautilusIconContainer *container,
container->details->tighter_layout = tighter_layout;
+ invalidate_label_sizes (container);
redo_layout (container);
gtk_signal_emit (GTK_OBJECT (container), signals[LAYOUT_CHANGED]);