Commit da18a3bb authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan

*libnautilus-extensions/nautilus-icon-canvas-item.c


2000-04-18  Gene Z. Ragan <gzr@eazel.com>

	*libnautilus-extensions/nautilus-icon-canvas-item.c
	*libnautilus-extensions/nautilus-icon-canvas-item.h
	Renamed several public functions to use proper nomenclature.
	An example would be changing nautilus_icon_canvas_get_editable_text_bounds
	to nautilus_icon_canvas_item_get_editable_text_bounds.  A few of
	these misnaming were in my last submission.

	*libnautilus-extensions/nautilus-icon-container.c
	*libnautilus-extensions/nautilus-icon-container.h
	Renamed nautilus_icon_container_show_rename_widget to
	nautilus_icon_container_start_renaming_selected_item

	*libnautilus-extensions/nautilus-icon-text-item.c
	Fixed the following bugs:
	487 Trying to rename an icon to empty string should revert to original
	498 Renaming text field looks silly when empty
	500 text-editng box too narrow when renaming files with short names
	508 Icon text appears and disappears incorrectly when zooming
parent aac409c0
......@@ -628,7 +628,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
(have_editable && have_additional) ? "\n" : "",
have_additional ? details->additional_text : "",
NULL);
width_so_far = 0;
height_so_far = 0;
......@@ -652,7 +652,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
icon_text_info = gnome_icon_layout_text
(details->font, text_piece, " -_,;.?/&", max_text_width, TRUE);
/* Draw text if we are not is user rename mode */
/* Draw text if we are not in user rename mode */
if (drawable != NULL && details->is_renaming == FALSE) {
text_left = icon_left + (icon_width - icon_text_info->width) / 2;
gnome_icon_paint_text (icon_text_info, drawable, gc,
......@@ -1403,9 +1403,10 @@ nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
return hit_test (item, &canvas_rect);
}
/* Return coordinates of icon text location */
/* Return coordinates of icon and text location */
/*
void
nautilus_icon_canvas_get_text_bounds (NautilusIconCanvasItem *icon_item,
nautilus_icon_canvas_item_get_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect)
{
ArtIRect icon_rect;
......@@ -1414,12 +1415,49 @@ nautilus_icon_canvas_get_text_bounds (NautilusIconCanvasItem *icon_item,
g_return_if_fail (text_rect != NULL);
get_icon_canvas_rectangle (icon_item, &icon_rect);
compute_text_rectangle (icon_item, &icon_rect, text_rect);
}
*/
/* Get the rectangle of the canvas item, in world coordinates. */
void
nautilus_icon_canvas_item_get_bounds (NautilusIconCanvasItem *item,
ArtIRect *rect)
{
double i2w[6];
ArtPoint art_point;
g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item));
g_return_if_fail (rect != NULL);
gnome_canvas_item_i2w_affine (GNOME_CANVAS_ITEM (item), i2w);
art_point.x = 0;
art_point.y = 0;
art_affine_point (&art_point, &art_point, i2w);
rect->x0 = art_point.x;
rect->y0 = art_point.y;
}
/* Return coordinates of icon text location */
void
nautilus_icon_canvas_item_get_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect)
{
ArtIRect icon_rect;
g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (icon_item));
g_return_if_fail (icon_item->details->editable_text != NULL);
g_return_if_fail (text_rect != NULL);
get_icon_canvas_rectangle (icon_item, &icon_rect);
compute_text_rectangle (icon_item, &icon_rect, text_rect);
}
/* Return coordinates of icon editable_text location */
void
nautilus_icon_canvas_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
nautilus_icon_canvas_item_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect)
{
ArtIRect icon_rect;
......@@ -1433,7 +1471,7 @@ nautilus_icon_canvas_get_editable_text_bounds (NautilusIconCanvasItem *icon_item
}
const char *
nautilus_icon_canvas_get_editable_text (NautilusIconCanvasItem *icon_item)
nautilus_icon_canvas_item_get_editable_text (NautilusIconCanvasItem *icon_item)
{
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (icon_item), NULL);
......
......@@ -81,11 +81,13 @@ gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanv
void nautilus_icon_canvas_item_get_icon_rectangle (NautilusIconCanvasItem *item,
ArtDRect *world_rectangle);
void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item);
void nautilus_icon_canvas_get_text_bounds (NautilusIconCanvasItem *icon_item,
void nautilus_icon_canvas_item_get_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect);
void nautilus_icon_canvas_item_get_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect);
void nautilus_icon_canvas_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
void nautilus_icon_canvas_item_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect);
const char *nautilus_icon_canvas_get_editable_text (NautilusIconCanvasItem *icon_item);
const char *nautilus_icon_canvas_item_get_editable_text (NautilusIconCanvasItem *icon_item);
void nautilus_icon_canvas_item_set_renaming (NautilusIconCanvasItem *icon_item,
gboolean state);
......
......@@ -100,6 +100,12 @@ static void update_rename_widget_text (NautilusIconConta
char *new_text);
#endif
#if 0
static void update_rename_widget_text (NautilusIconContainer *container,
NautilusIcon *icon, char *new_text);
#endif
static void hide_rename_widget (NautilusIconContainer *container, NautilusIcon *icon);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
......@@ -1754,6 +1760,7 @@ key_press_event (GtkWidget *widget,
keyboard_space (container, event);
break;
case GDK_Return:
case GDK_KP_Enter:
if (container->details->renaming == TRUE){
end_renaming_mode(container, TRUE);
}
......@@ -2990,20 +2997,23 @@ nautilus_self_check_compute_stretch (int icon_x, int icon_y, int icon_size,
}
/**
* nautilus_icon_container_show_rename_widget
* nautilus_icon_container_start_renaming_selected_item
* @container: An icon container widget.
*
* Displays the edit name widget on the first selected icon
**/
void
nautilus_icon_container_show_rename_widget (NautilusIconContainer *container)
nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
ArtIRect text_rect;
ArtIRect text_rect, icon_rect;
GdkFont *font;
const char *editable_text;
int max_text_width;
int cx, cy;
double ppu;
/* Check if it already in renaming mode. */
details = container->details;
......@@ -3018,10 +3028,10 @@ nautilus_icon_container_show_rename_widget (NautilusIconContainer *container)
}
/* Get location of text item */
nautilus_icon_canvas_get_text_bounds(icon->item, &text_rect);
nautilus_icon_canvas_item_get_text_bounds(icon->item, &text_rect);
/* Make a copy of the original editable text for a later compare */
editable_text = nautilus_icon_canvas_get_editable_text(icon->item);
editable_text = nautilus_icon_canvas_item_get_editable_text(icon->item);
details->original_text = g_strdup(editable_text);
/* Create text renaming widget */
......@@ -3030,14 +3040,23 @@ nautilus_icon_container_show_rename_widget (NautilusIconContainer *container)
NULL));
font = details->label_font[details->zoom_level];
/* FIXME: There needs to be a way to get the max width constant from the canvas item */
ppu = GNOME_CANVAS_ITEM (icon->item)->canvas->pixels_per_unit;
max_text_width = floor (80 * ppu);
nautilus_icon_canvas_item_get_bounds(icon->item, &icon_rect);
gnome_canvas_w2c(GNOME_CANVAS(container), icon_rect.x0, icon_rect.y0, &cx, &cy);
/* FIXME: Why aren't the coordinate transforms taking the scroll amount into account? */
cx += GNOME_CANVAS(container)->scroll_x1 * ppu;
cy = text_rect.y0;
nautilus_icon_text_item_configure (details->rename_widget,
text_rect.x0, /* x */
text_rect.y0, /* y */
(text_rect.x1 - text_rect.x0) + 4, /* width */
font,
cx, /* x */
cy, /* y */
max_text_width + 4, /* width */
font, /* font */
editable_text, /* text */
1);
1); /* allocate local copy */
/* Set up the signals */
gtk_signal_connect (GTK_OBJECT (details->rename_widget), "editing_started",
......
......@@ -141,7 +141,7 @@ gboolean nautilus_icon_container_has_stretch_handles (NautilusIconContaine
gboolean nautilus_icon_container_is_stretched (NautilusIconContainer *container);
void nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container);
void nautilus_icon_container_unstretch (NautilusIconContainer *container);
void nautilus_icon_container_show_rename_widget (NautilusIconContainer *container);
void nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container);
/* options */
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
......
......@@ -13,6 +13,7 @@
#include "nautilus-icon-text-item.h"
#include <math.h>
#include <stdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
......@@ -61,6 +62,9 @@ typedef struct {
/* Whether we need to update because the editing/selected state changed */
guint need_state_update : 1;
/* Store min width and height. These are used when the text entry is empty. */
guint min_width;
guint min_height;
} ItiPrivate;
......@@ -118,7 +122,6 @@ layout_text (Iti *iti)
priv = iti->priv;
/* Save old size */
if (iti->ti) {
old_width = iti->ti->width + 2 * MARGIN_X;
old_height = iti->ti->height + 2 * MARGIN_Y;
......@@ -130,7 +133,6 @@ layout_text (Iti *iti)
}
/* Change the text layout */
if (iti->editing)
text = gtk_entry_get_text (priv->entry);
else
......@@ -143,7 +145,6 @@ layout_text (Iti *iti)
TRUE);
/* Check the sizes and see if we need to emit any signals */
width = iti->ti->width + 2 * MARGIN_X;
height = iti->ti->height + 2 * MARGIN_Y;
......@@ -154,6 +155,7 @@ layout_text (Iti *iti)
gtk_signal_emit (GTK_OBJECT (iti), iti_signals[HEIGHT_CHANGED]);
}
/* Accepts the text in the off-screen entry of an icon text item */
static void
iti_edition_accept (Iti *iti)
......@@ -309,21 +311,28 @@ recompute_bounding_box (Iti *iti)
ArtPoint p, q;
int x1, y1, x2, y2;
int width, height;
ItiPrivate *priv;
item = GNOME_CANVAS_ITEM (iti);
/* Compute width, height, position */
priv = iti->priv;
/* Compute width, height, position */
width = iti->ti->width + 2 * MARGIN_X;
height = iti->ti->height + 2 * MARGIN_Y;
/* Verify we are not smaller than default settings */
if (width < priv->min_width)
width = priv->min_width;
if (height < priv->min_height)
height = priv->min_height;
x1 = iti->x + (iti->width - width) / 2;
y1 = iti->y;
x2 = x1 + width;
y2 = y1 + height;
/* Translate to world coordinates */
gnome_canvas_item_i2w_affine (item, affine);
p.x = x1;
......@@ -490,17 +499,25 @@ iti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
GtkStyle *style;
int w, h;
int xofs, yofs;
ItiPrivate *priv;
iti = ITI (item);
priv = iti->priv;
if (iti->ti) {
w = iti->ti->width + 2 * MARGIN_X;
h = iti->ti->height + 2 * MARGIN_Y;
/* Make sure we aren't smaller than default settings */
if (w < priv->min_width)
w = priv->min_width;
if (h < priv->min_height)
h = priv->min_height;
} else {
w = 2 * MARGIN_X;
h = 2 * MARGIN_Y;
}
xofs = item->x1 - x;
yofs = item->y1 - y;
......@@ -716,6 +733,7 @@ iti_event (GnomeCanvasItem *item, GdkEvent *event)
switch(event->key.keyval) {
case GDK_Escape:
case GDK_Return:
case GDK_KP_Enter:
return FALSE;
default:
......@@ -926,10 +944,10 @@ iti_init (NautilusIconTextItem *iti)
void
nautilus_icon_text_item_configure (NautilusIconTextItem *iti, int x, int y,
int width, GdkFont *font,
const char *text,
gboolean is_static)
const char *text, gboolean is_static)
{
ItiPrivate *priv;
GnomeIconTextInfo *min_text_info;
g_return_if_fail (iti != NULL);
g_return_if_fail (IS_ITI (iti));
......@@ -975,8 +993,17 @@ nautilus_icon_text_item_configure (NautilusIconTextItem *iti, int x, int y,
layout_text (iti);
/* Request update */
/* Calculate and store min and max dimensions */
min_text_info = gnome_icon_layout_text (priv->font,
" ",
DEFAULT_SEPARATORS,
iti->width - 2 * MARGIN_X,
TRUE);
priv->min_width = min_text_info->width + 2 * MARGIN_X;
priv->min_height = min_text_info->height + 2 * MARGIN_Y;
gnome_icon_text_info_free(min_text_info);
/* Request update */
priv->need_pos_update = TRUE;
priv->need_font_update = TRUE;
priv->need_text_update = TRUE;
......
......@@ -628,7 +628,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
(have_editable && have_additional) ? "\n" : "",
have_additional ? details->additional_text : "",
NULL);
width_so_far = 0;
height_so_far = 0;
......@@ -652,7 +652,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
icon_text_info = gnome_icon_layout_text
(details->font, text_piece, " -_,;.?/&", max_text_width, TRUE);
/* Draw text if we are not is user rename mode */
/* Draw text if we are not in user rename mode */
if (drawable != NULL && details->is_renaming == FALSE) {
text_left = icon_left + (icon_width - icon_text_info->width) / 2;
gnome_icon_paint_text (icon_text_info, drawable, gc,
......@@ -1403,9 +1403,10 @@ nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
return hit_test (item, &canvas_rect);
}
/* Return coordinates of icon text location */
/* Return coordinates of icon and text location */
/*
void
nautilus_icon_canvas_get_text_bounds (NautilusIconCanvasItem *icon_item,
nautilus_icon_canvas_item_get_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect)
{
ArtIRect icon_rect;
......@@ -1414,12 +1415,49 @@ nautilus_icon_canvas_get_text_bounds (NautilusIconCanvasItem *icon_item,
g_return_if_fail (text_rect != NULL);
get_icon_canvas_rectangle (icon_item, &icon_rect);
compute_text_rectangle (icon_item, &icon_rect, text_rect);
}
*/
/* Get the rectangle of the canvas item, in world coordinates. */
void
nautilus_icon_canvas_item_get_bounds (NautilusIconCanvasItem *item,
ArtIRect *rect)
{
double i2w[6];
ArtPoint art_point;
g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item));
g_return_if_fail (rect != NULL);
gnome_canvas_item_i2w_affine (GNOME_CANVAS_ITEM (item), i2w);
art_point.x = 0;
art_point.y = 0;
art_affine_point (&art_point, &art_point, i2w);
rect->x0 = art_point.x;
rect->y0 = art_point.y;
}
/* Return coordinates of icon text location */
void
nautilus_icon_canvas_item_get_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect)
{
ArtIRect icon_rect;
g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (icon_item));
g_return_if_fail (icon_item->details->editable_text != NULL);
g_return_if_fail (text_rect != NULL);
get_icon_canvas_rectangle (icon_item, &icon_rect);
compute_text_rectangle (icon_item, &icon_rect, text_rect);
}
/* Return coordinates of icon editable_text location */
void
nautilus_icon_canvas_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
nautilus_icon_canvas_item_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect)
{
ArtIRect icon_rect;
......@@ -1433,7 +1471,7 @@ nautilus_icon_canvas_get_editable_text_bounds (NautilusIconCanvasItem *icon_item
}
const char *
nautilus_icon_canvas_get_editable_text (NautilusIconCanvasItem *icon_item)
nautilus_icon_canvas_item_get_editable_text (NautilusIconCanvasItem *icon_item)
{
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (icon_item), NULL);
......
......@@ -81,11 +81,13 @@ gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanv
void nautilus_icon_canvas_item_get_icon_rectangle (NautilusIconCanvasItem *item,
ArtDRect *world_rectangle);
void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item);
void nautilus_icon_canvas_get_text_bounds (NautilusIconCanvasItem *icon_item,
void nautilus_icon_canvas_item_get_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect);
void nautilus_icon_canvas_item_get_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect);
void nautilus_icon_canvas_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
void nautilus_icon_canvas_item_get_editable_text_bounds (NautilusIconCanvasItem *icon_item,
ArtIRect *text_rect);
const char *nautilus_icon_canvas_get_editable_text (NautilusIconCanvasItem *icon_item);
const char *nautilus_icon_canvas_item_get_editable_text (NautilusIconCanvasItem *icon_item);
void nautilus_icon_canvas_item_set_renaming (NautilusIconCanvasItem *icon_item,
gboolean state);
......
......@@ -100,6 +100,12 @@ static void update_rename_widget_text (NautilusIconConta
char *new_text);
#endif
#if 0
static void update_rename_widget_text (NautilusIconContainer *container,
NautilusIcon *icon, char *new_text);
#endif
static void hide_rename_widget (NautilusIconContainer *container, NautilusIcon *icon);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
......@@ -1754,6 +1760,7 @@ key_press_event (GtkWidget *widget,
keyboard_space (container, event);
break;
case GDK_Return:
case GDK_KP_Enter:
if (container->details->renaming == TRUE){
end_renaming_mode(container, TRUE);
}
......@@ -2990,20 +2997,23 @@ nautilus_self_check_compute_stretch (int icon_x, int icon_y, int icon_size,
}
/**
* nautilus_icon_container_show_rename_widget
* nautilus_icon_container_start_renaming_selected_item
* @container: An icon container widget.
*
* Displays the edit name widget on the first selected icon
**/
void
nautilus_icon_container_show_rename_widget (NautilusIconContainer *container)
nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
ArtIRect text_rect;
ArtIRect text_rect, icon_rect;
GdkFont *font;
const char *editable_text;
int max_text_width;
int cx, cy;
double ppu;
/* Check if it already in renaming mode. */
details = container->details;
......@@ -3018,10 +3028,10 @@ nautilus_icon_container_show_rename_widget (NautilusIconContainer *container)
}
/* Get location of text item */
nautilus_icon_canvas_get_text_bounds(icon->item, &text_rect);
nautilus_icon_canvas_item_get_text_bounds(icon->item, &text_rect);
/* Make a copy of the original editable text for a later compare */
editable_text = nautilus_icon_canvas_get_editable_text(icon->item);
editable_text = nautilus_icon_canvas_item_get_editable_text(icon->item);
details->original_text = g_strdup(editable_text);
/* Create text renaming widget */
......@@ -3030,14 +3040,23 @@ nautilus_icon_container_show_rename_widget (NautilusIconContainer *container)
NULL));
font = details->label_font[details->zoom_level];
/* FIXME: There needs to be a way to get the max width constant from the canvas item */
ppu = GNOME_CANVAS_ITEM (icon->item)->canvas->pixels_per_unit;
max_text_width = floor (80 * ppu);
nautilus_icon_canvas_item_get_bounds(icon->item, &icon_rect);
gnome_canvas_w2c(GNOME_CANVAS(container), icon_rect.x0, icon_rect.y0, &cx, &cy);
/* FIXME: Why aren't the coordinate transforms taking the scroll amount into account? */
cx += GNOME_CANVAS(container)->scroll_x1 * ppu;
cy = text_rect.y0;
nautilus_icon_text_item_configure (details->rename_widget,
text_rect.x0, /* x */
text_rect.y0, /* y */
(text_rect.x1 - text_rect.x0) + 4, /* width */
font,
cx, /* x */
cy, /* y */
max_text_width + 4, /* width */
font, /* font */
editable_text, /* text */
1);
1); /* allocate local copy */
/* Set up the signals */
gtk_signal_connect (GTK_OBJECT (details->rename_widget), "editing_started",
......
......@@ -141,7 +141,7 @@ gboolean nautilus_icon_container_has_stretch_handles (NautilusIconContaine
gboolean nautilus_icon_container_is_stretched (NautilusIconContainer *container);
void nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container);
void nautilus_icon_container_unstretch (NautilusIconContainer *container);
void nautilus_icon_container_show_rename_widget (NautilusIconContainer *container);
void nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container);
/* options */
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
......
......@@ -13,6 +13,7 @@
#include "nautilus-icon-text-item.h"
#include <math.h>
#include <stdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
......@@ -61,6 +62,9 @@ typedef struct {
/* Whether we need to update because the editing/selected state changed */
guint need_state_update : 1;
/* Store min width and height. These are used when the text entry is empty. */
guint min_width;
guint min_height;
} ItiPrivate;
......@@ -118,7 +122,6 @@ layout_text (Iti *iti)
priv = iti->priv;
/* Save old size */
if (iti->ti) {
old_width = iti->ti->width + 2 * MARGIN_X;
old_height = iti->ti->height + 2 * MARGIN_Y;
......@@ -130,7 +133,6 @@ layout_text (Iti *iti)
}
/* Change the text layout */
if (iti->editing)
text = gtk_entry_get_text (priv->entry);
else
......@@ -143,7 +145,6 @@ layout_text (Iti *iti)
TRUE);
/* Check the sizes and see if we need to emit any signals */
width = iti->ti->width + 2 * MARGIN_X;
height = iti->ti->height + 2 * MARGIN_Y;
......@@ -154,6 +155,7 @@ layout_text (Iti *iti)
gtk_signal_emit (GTK_OBJECT (iti), iti_signals[HEIGHT_CHANGED]);
}
/* Accepts the text in the off-screen entry of an icon text item */
static void
iti_edition_accept (Iti *iti)
......@@ -309,21 +311,28 @@ recompute_bounding_box (Iti *iti)
ArtPoint p, q;
int x1, y1, x2, y2;
int width, height;
ItiPrivate *priv;
item = GNOME_CANVAS_ITEM (iti);
/* Compute width, height, position */
priv = iti->priv;
/* Compute width, height, position */
width = iti->ti->width + 2 * MARGIN_X;
height = iti->ti->height + 2 * MARGIN_Y;
/* Verify we are not smaller than default settings */
if (width < priv->min_width)
width = priv->min_width;
if (height < priv->min_height)
height = priv->min_height;
x1 = iti->x + (iti->width - width) / 2;
y1 = iti->y;
x2 = x1 + width;
y2 = y1 + height;
/* Translate to world coordinates */