Commit ec054c80 authored by John Sullivan's avatar John Sullivan

Fixed the worst part of bug 2068 (dragging icon causes

	immediate update of scroll area). Some related bugs
	remain, which I'll write up separately

	* libnautilus-extensions/nautilus-gnome-extensions.h:
	* libnautilus-extensions/nautilus-gnome-extensions.c:
	(nautilus_gnome_canvas_set_scroll_region_include_visible_area):
	New function, sets scroll region to given parameters,
	also forcing visible area to be included.

	* libnautilus-extensions/nautilus-icon-container.c:
	(update_scroll_region): New function, extracted from
	nautilus_icon_container_update_scroll_region, now takes
	boolean for whether to include the visible area.
	(nautilus_icon_container_update_scroll_region): Now calls
	update_scroll_region.
	(nautilus_icon_container_update_scroll_region_include_visible_area):
	New function, calls update_scroll_region.
	(size_allocate): Do no work if allocation hasn't changed. This
	didn't help with bug 2068 but is a worthwhile optimization.

	* libnautilus-extensions/nautilus-icon-private.h:
	Prototype for nautilus_icon_container_update_scroll_region_
	include_visible_area

	* libnautilus-extensions/nautilus-icon-dnd.c: (handle_local_move):
	call ..._include_visible_area when updating scroll region after
	drag & drop, instead of just ..._update_scroll_region, so no
	origin-shifting occurs.
parent 8edfc9ca
2000-10-02 John Sullivan <sullivan@eazel.com>
Fixed the worst part of bug 2068 (dragging icon causes
immediate update of scroll area). Some related bugs
remain, which I'll write up separately
* libnautilus-extensions/nautilus-gnome-extensions.h:
* libnautilus-extensions/nautilus-gnome-extensions.c:
(nautilus_gnome_canvas_set_scroll_region_include_visible_area):
New function, sets scroll region to given parameters,
also forcing visible area to be included.
* libnautilus-extensions/nautilus-icon-container.c:
(update_scroll_region): New function, extracted from
nautilus_icon_container_update_scroll_region, now takes
boolean for whether to include the visible area.
(nautilus_icon_container_update_scroll_region): Now calls
update_scroll_region.
(nautilus_icon_container_update_scroll_region_include_visible_area):
New function, calls update_scroll_region.
(size_allocate): Do no work if allocation hasn't changed. This
didn't help with bug 2068 but is a worthwhile optimization.
* libnautilus-extensions/nautilus-icon-private.h:
Prototype for nautilus_icon_container_update_scroll_region_
include_visible_area
* libnautilus-extensions/nautilus-icon-dnd.c: (handle_local_move):
call ..._include_visible_area when updating scroll region after
drag & drop, instead of just ..._update_scroll_region, so no
origin-shifting occurs.
2000-10-02 Robey Pointer <robey@eazel.com>
* components/services/install/lib/eazel-install-protocols.c:
......
......@@ -422,6 +422,34 @@ nautilus_gnome_canvas_set_scroll_region_left_justify (GnomeCanvas *canvas,
MAX (x2, x1 + width), MAX (y2, y1 + height));
}
/* Set a new scroll region without eliminating any of the currently-visible area. */
void
nautilus_gnome_canvas_set_scroll_region_include_visible_area (GnomeCanvas *canvas,
double x1, double y1,
double x2, double y2)
{
double old_x1, old_y1, old_x2, old_y2;
double old_scroll_x, old_scroll_y;
double height, width;
gnome_canvas_get_scroll_region (canvas, &old_x1, &old_y1, &old_x2, &old_y2);
/* The -1 here is due to the ill-conceived ++ in scroll_to. */
width = (GTK_WIDGET (canvas)->allocation.width - 1) / canvas->pixels_per_unit;
height = (GTK_WIDGET (canvas)->allocation.height - 1) / canvas->pixels_per_unit;
old_scroll_x = gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))->value;
old_scroll_y = gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))->value;
x1 = MIN (x1, old_x1 + old_scroll_x);
y1 = MIN (y1, old_y1 + old_scroll_y);
x2 = MAX (x2, old_x1 + old_scroll_x + width);
y2 = MAX (y2, old_y1 + old_scroll_y + height);
nautilus_gnome_canvas_set_scroll_region
(canvas, x1, y1, x2, y2);
}
/* Code from GMC, contains all the voodoo needed to start
* a terminal from the file manager nicely
......
......@@ -53,6 +53,13 @@ void nautilus_gnome_canvas_set_scroll_region_left_justify (GnomeCanvas
double x2,
double y2);
/* Set a new scroll region without eliminating any of the currently-visible area. */
void nautilus_gnome_canvas_set_scroll_region_include_visible_area (GnomeCanvas *canvas,
double x1,
double y1,
double x2,
double y2);
/* For cases where you need to get more than one item updated. */
void nautilus_gnome_canvas_request_update_all (GnomeCanvas *canvas);
void nautilus_gnome_canvas_item_request_update_deep (GnomeCanvasItem *item);
......
......@@ -476,8 +476,8 @@ get_all_icon_bounds (NautilusIconContainer *container,
x1, y1, x2, y2);
}
void
nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
static void
update_scroll_region (NautilusIconContainer *container, gboolean include_visible)
{
double x1, y1, x2, y2;
GtkAdjustment *hadj, *vadj;
......@@ -497,12 +497,22 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
}
get_all_icon_bounds (container, &x1, &y1, &x2, &y2);
nautilus_gnome_canvas_set_scroll_region_left_justify
(GNOME_CANVAS (container),
x1 - CONTAINER_PAD_LEFT,
y1 - CONTAINER_PAD_TOP,
x2 + CONTAINER_PAD_RIGHT,
y2 + CONTAINER_PAD_BOTTOM);
if (include_visible) {
nautilus_gnome_canvas_set_scroll_region_include_visible_area
(GNOME_CANVAS (container),
x1 - CONTAINER_PAD_LEFT,
y1 - CONTAINER_PAD_TOP,
x2 + CONTAINER_PAD_RIGHT,
y2 + CONTAINER_PAD_BOTTOM);
} else {
nautilus_gnome_canvas_set_scroll_region_left_justify
(GNOME_CANVAS (container),
x1 - CONTAINER_PAD_LEFT,
y1 - CONTAINER_PAD_TOP,
x2 + CONTAINER_PAD_RIGHT,
y2 + CONTAINER_PAD_BOTTOM);
}
hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container));
vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
......@@ -526,6 +536,18 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
nautilus_gtk_adjustment_clamp_value (vadj);
}
void
nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
{
update_scroll_region (container, FALSE);
}
void
nautilus_icon_container_update_scroll_region_include_visible_area (NautilusIconContainer *container)
{
update_scroll_region (container, TRUE);
}
static NautilusIconContainer *sort_hack_container;
static int
......@@ -2069,9 +2091,15 @@ static void
size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
if (allocation->x != widget->allocation.x ||
allocation->width != widget->allocation.width ||
allocation->y != widget->allocation.y ||
allocation->height != widget->allocation.height) {
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
relayout (NAUTILUS_ICON_CONTAINER (widget));
relayout (NAUTILUS_ICON_CONTAINER (widget));
}
}
static void
......
......@@ -734,8 +734,11 @@ handle_local_move (NautilusIconContainer *container,
}
nautilus_icon_container_select_list_unselect_others
(container, moved_icons);
/* Might have been moved in a way that requires adjusting scroll region */
nautilus_icon_container_update_scroll_region (container);
/* Might have been moved in a way that requires adjusting scroll region.
* Include visible area so coordinate-adjustment "auto-scrolling" doesn't
* occur after the drop. (see bugzilla.eazel.com 2068)
*/
nautilus_icon_container_update_scroll_region_include_visible_area (container);
g_list_free (moved_icons);
}
......
......@@ -219,6 +219,8 @@ void nautilus_icon_container_scroll (NautilusIconC
int delta_x,
int delta_y);
void nautilus_icon_container_update_scroll_region (NautilusIconContainer *container);
void nautilus_icon_container_update_scroll_region_include_visible_area
(NautilusIconContainer *container);
/* label color for items */
guint32 nautilus_icon_container_get_label_color (NautilusIconContainer *container,
......
......@@ -422,6 +422,34 @@ nautilus_gnome_canvas_set_scroll_region_left_justify (GnomeCanvas *canvas,
MAX (x2, x1 + width), MAX (y2, y1 + height));
}
/* Set a new scroll region without eliminating any of the currently-visible area. */
void
nautilus_gnome_canvas_set_scroll_region_include_visible_area (GnomeCanvas *canvas,
double x1, double y1,
double x2, double y2)
{
double old_x1, old_y1, old_x2, old_y2;
double old_scroll_x, old_scroll_y;
double height, width;
gnome_canvas_get_scroll_region (canvas, &old_x1, &old_y1, &old_x2, &old_y2);
/* The -1 here is due to the ill-conceived ++ in scroll_to. */
width = (GTK_WIDGET (canvas)->allocation.width - 1) / canvas->pixels_per_unit;
height = (GTK_WIDGET (canvas)->allocation.height - 1) / canvas->pixels_per_unit;
old_scroll_x = gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))->value;
old_scroll_y = gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))->value;
x1 = MIN (x1, old_x1 + old_scroll_x);
y1 = MIN (y1, old_y1 + old_scroll_y);
x2 = MAX (x2, old_x1 + old_scroll_x + width);
y2 = MAX (y2, old_y1 + old_scroll_y + height);
nautilus_gnome_canvas_set_scroll_region
(canvas, x1, y1, x2, y2);
}
/* Code from GMC, contains all the voodoo needed to start
* a terminal from the file manager nicely
......
......@@ -53,6 +53,13 @@ void nautilus_gnome_canvas_set_scroll_region_left_justify (GnomeCanvas
double x2,
double y2);
/* Set a new scroll region without eliminating any of the currently-visible area. */
void nautilus_gnome_canvas_set_scroll_region_include_visible_area (GnomeCanvas *canvas,
double x1,
double y1,
double x2,
double y2);
/* For cases where you need to get more than one item updated. */
void nautilus_gnome_canvas_request_update_all (GnomeCanvas *canvas);
void nautilus_gnome_canvas_item_request_update_deep (GnomeCanvasItem *item);
......
......@@ -476,8 +476,8 @@ get_all_icon_bounds (NautilusIconContainer *container,
x1, y1, x2, y2);
}
void
nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
static void
update_scroll_region (NautilusIconContainer *container, gboolean include_visible)
{
double x1, y1, x2, y2;
GtkAdjustment *hadj, *vadj;
......@@ -497,12 +497,22 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
}
get_all_icon_bounds (container, &x1, &y1, &x2, &y2);
nautilus_gnome_canvas_set_scroll_region_left_justify
(GNOME_CANVAS (container),
x1 - CONTAINER_PAD_LEFT,
y1 - CONTAINER_PAD_TOP,
x2 + CONTAINER_PAD_RIGHT,
y2 + CONTAINER_PAD_BOTTOM);
if (include_visible) {
nautilus_gnome_canvas_set_scroll_region_include_visible_area
(GNOME_CANVAS (container),
x1 - CONTAINER_PAD_LEFT,
y1 - CONTAINER_PAD_TOP,
x2 + CONTAINER_PAD_RIGHT,
y2 + CONTAINER_PAD_BOTTOM);
} else {
nautilus_gnome_canvas_set_scroll_region_left_justify
(GNOME_CANVAS (container),
x1 - CONTAINER_PAD_LEFT,
y1 - CONTAINER_PAD_TOP,
x2 + CONTAINER_PAD_RIGHT,
y2 + CONTAINER_PAD_BOTTOM);
}
hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container));
vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
......@@ -526,6 +536,18 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
nautilus_gtk_adjustment_clamp_value (vadj);
}
void
nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
{
update_scroll_region (container, FALSE);
}
void
nautilus_icon_container_update_scroll_region_include_visible_area (NautilusIconContainer *container)
{
update_scroll_region (container, TRUE);
}
static NautilusIconContainer *sort_hack_container;
static int
......@@ -2069,9 +2091,15 @@ static void
size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
if (allocation->x != widget->allocation.x ||
allocation->width != widget->allocation.width ||
allocation->y != widget->allocation.y ||
allocation->height != widget->allocation.height) {
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
relayout (NAUTILUS_ICON_CONTAINER (widget));
relayout (NAUTILUS_ICON_CONTAINER (widget));
}
}
static void
......
......@@ -734,8 +734,11 @@ handle_local_move (NautilusIconContainer *container,
}
nautilus_icon_container_select_list_unselect_others
(container, moved_icons);
/* Might have been moved in a way that requires adjusting scroll region */
nautilus_icon_container_update_scroll_region (container);
/* Might have been moved in a way that requires adjusting scroll region.
* Include visible area so coordinate-adjustment "auto-scrolling" doesn't
* occur after the drop. (see bugzilla.eazel.com 2068)
*/
nautilus_icon_container_update_scroll_region_include_visible_area (container);
g_list_free (moved_icons);
}
......
......@@ -219,6 +219,8 @@ void nautilus_icon_container_scroll (NautilusIconC
int delta_x,
int delta_y);
void nautilus_icon_container_update_scroll_region (NautilusIconContainer *container);
void nautilus_icon_container_update_scroll_region_include_visible_area
(NautilusIconContainer *container);
/* label color for items */
guint32 nautilus_icon_container_get_label_color (NautilusIconContainer *container,
......
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