Re: align layout patch
- From: Reginald Melchisedek Poyau <melchisedek earthlink net>
- To: Reginald Melchisedek Poyau <melchisedek earthlink net>
- Cc: Alexander Larsson <alexl redhat com>, nautilus-list gnome org
- Subject: Re: align layout patch
- Date: 10 Sep 2002 02:05:23 -0400
On Thu, 2002-08-29 at 19:05, Reginald Melchisedek Poyau wrote:
> On Thu, 2002-08-29 at 05:16, Alexander Larsson wrote:
> > On 28 Aug 2002, Reginald Melchisedek Poyau wrote:
> >
> > > Fixed a jiggling columns effect bug while at least one file caption was
> > > being updated.
> >
> > I'm sorry i haven't looked at this yet. I'm a bit busy right now. Next
> > week or so i'll look at it.
> Ok, I was planning on reworking this patch anyway to handle handle
> nautilus three layout modes correctly (align). I should have that patch
> ready by next week or so.
Here is the updated patch.
> >
> > --
> > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > Alexander Larsson Red Hat, Inc
> > alexl redhat com alla lysator liu se
> > He's a world-famous native American vagrant haunted by an iconic dead American
> > confidante She's a plucky gypsy museum curator from out of town. They fight
> > crime!
> >
> > --
> > nautilus-list mailing list
> > nautilus-list gnome org
> > http://mail.gnome.org/mailman/listinfo/nautilus-list
> --
> "There has grown in the minds of certain groups in this country the
> idea that just because
> a man or corporation has made a profit out of the public for a number of
> years, the
> government and the courts are charged with guaranteeing such profit in
> the future, even in
> the face of changing circumstances and contrary to public interest. This
> strange doctrine
> is supported by neither statue or common law. Neither corporations or
> individuals have the
> right to come into court and ask that the clock of history be stopped,
> or turned back."
>
> -Robert Heinlein, Life Line, 1939
> --
> nautilus-list mailing list
> nautilus-list gnome org
> http://mail.gnome.org/mailman/listinfo/nautilus-list
>
--
"There has grown in the minds of certain groups in this country the
idea that just because
a man or corporation has made a profit out of the public for a number of
years, the
government and the courts are charged with guaranteeing such profit in
the future, even in
the face of changing circumstances and contrary to public interest. This
strange doctrine
is supported by neither statue or common law. Neither corporations or
individuals have the
right to come into court and ask that the clock of history be stopped,
or turned back."
-Robert Heinlein, Life Line, 1939
Index: nautilus/libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.295
diff -u -b -B -p -u -r1.295 nautilus-icon-container.c
--- nautilus/libnautilus-private/nautilus-icon-container.c 2002/09/09 17:21:36 1.295
+++ nautilus/libnautilus-private/nautilus-icon-container.c 2002/09/10 05:45:07
@@ -28,6 +28,7 @@
#include "nautilus-icon-container.h"
#include "nautilus-global-preferences.h"
+#include "nautilus-file-utilities.h"
#include "nautilus-icon-private.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-marshal.h"
@@ -159,7 +160,7 @@ static void setup_label_gcs
static int click_policy_auto_value;
-static gpointer accessible_parent_class;
+gpointer accessible_parent_class;
static GQuark accessible_private_data_quark = 0;
@@ -779,7 +780,7 @@ resort (NautilusIconContainer *container
/* Given an icon's bounds, compute the width of the space it should be
* placed in.
*/
-static int
+static inline int
get_icon_space_width (NautilusIconContainer *container, const ArtDRect *bounds)
{
double world_width;
@@ -795,148 +796,431 @@ get_icon_space_width (NautilusIconContai
return STANDARD_ICON_GRID_WIDTH;
}
+typedef struct {
+ /* {x,y} Cartesian basis */
+ double *x;
+ double *y;
+
+ /* {u, m} IconLayout basis */
+ double u;
+ double m;
+
+ /* 0 or 180 degrees depending on
+ layout mode. Initial value
+ also depends on layout mode */
+ double m_direction;
+} IconLayoutBases;
+
typedef struct {
- double width;
+ double origin;
+ double end;
+} IconLayoutBasisComponent;
+
+typedef struct {
+ IconLayoutBasisComponent *icon_u_component;
+ IconLayoutBasisComponent *icon_m_component;
double x_offset;
double y_offset;
-} IconPositions;
+} IconLayoutIconInfo;
-static void
-lay_down_one_line (NautilusIconContainer *container,
- GList *line_start,
- GList *line_end,
- double y,
- GArray *positions)
-{
- GList *p;
- NautilusIcon *icon;
- double x;
- IconPositions *position;
- int i;
+typedef struct {
+ /* u is the primary vector (L_R or T_B) in which
+ icons are going to layed down depending on
+ layout mode. m vector is orthogonal to u. */
+ GArray *u_components;
+ GHashTable *m_components;
+ unsigned int u_index;
+ unsigned int m_index;
+} IconLayoutGridCells;
- /* FIXME: Should layout differently when in RTL base mode */
+typedef struct {
+ NautilusIconContainer *container;
+ IconLayoutGridCells *cells;
+ IconLayoutBases bases;
+ IconLayoutBasisComponent max_m_component;
+ double line_u_length;
+ double canvas_u_length;
+ double u_adjustment;
+} IconLayoutGrid;
- /* Lay out the icons along the baseline. */
- x = 0;
- i = 0;
- for (p = line_start; p != line_end; p = p->next) {
- icon = p->data;
+static inline IconLayoutIconInfo*
+icon_layout_get_icon_info (NautilusIconContainer *container,
+ NautilusIcon *icon,
+ GHashTable *icons_informations)
+{
+ ArtDRect bounds;
+ ArtDRect icon_bounds;
+ IconLayoutIconInfo *info;
- position = &g_array_index (positions, IconPositions, i++);
+ info = g_hash_table_lookup (icons_informations, icon);
- icon_set_position
- (icon,
- x + position->x_offset,
- y + position->y_offset);
+ if (info == NULL) {
+ /* Assume it's only one level hierarchy to avoid costly affine calculations */
+ gnome_canvas_item_get_bounds (GNOME_CANVAS_ITEM (icon->item),
+ &bounds.x0, &bounds.y0,
+ &bounds.x1, &bounds.y1);
+ icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
- x += position->width;
+ info = g_new0 (IconLayoutIconInfo, 1);
+ info->icon_u_component = g_new0 (IconLayoutBasisComponent, 1);
+ info->icon_m_component = g_new0 (IconLayoutBasisComponent, 1);
+ info->y_offset = icon_bounds.y0 - icon_bounds.y1;
+ info->x_offset = (icon_bounds.x0 - icon_bounds.x1) / 2;
+
+ switch (container->details->layout_mode)
+ {
+ case NAUTILUS_ICON_LAYOUT_L_R_T_B:
+ info->icon_u_component->origin = get_icon_space_width (container, &bounds) / 2;
+ info->icon_u_component->end = info->icon_u_component->origin;
+ info->icon_m_component->origin = ICON_PAD_TOP + icon_bounds.y1 - bounds.y0;
+ info->icon_m_component->end = bounds.y1 - icon_bounds.y1 + ICON_PAD_BOTTOM;
+ break;
+ case NAUTILUS_ICON_LAYOUT_T_B_L_R:
+ case NAUTILUS_ICON_LAYOUT_T_B_R_L:
+ info->icon_u_component->origin = ICON_PAD_TOP + icon_bounds.y1 - bounds.y0;
+ info->icon_u_component->end = bounds.y1 - icon_bounds.y1 + ICON_PAD_BOTTOM;
+ info->icon_m_component->origin = get_icon_space_width (container, &bounds) / 2;
+ info->icon_m_component->end = info->icon_m_component->origin;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ g_hash_table_insert (icons_informations, icon, info);
}
+
+ return info;
}
+static inline void
+icon_layout_grid_reset (IconLayoutGrid *grid)
+{
+ unsigned int i;
+ IconLayoutBasisComponent *cell_u_component;
+
+ for (i = 0; i < grid->cells->u_components->len; i++) {
+ cell_u_component = &g_array_index (grid->cells->u_components,
+ IconLayoutBasisComponent,
+ i);
+ cell_u_component->origin = 0;
+ cell_u_component->end = 0;
+ }
+ grid->line_u_length = 0;
+ grid->max_m_component.origin = 0;
+ grid->max_m_component.end = 0;
+ grid->cells->m_index = 0;
+ grid->cells->u_index = 0;
+}
+
static void
-lay_down_icons_horizontal (NautilusIconContainer *container,
- GList *icons,
- double start_y)
+icon_layout_grid_init (IconLayoutGrid *grid,
+ NautilusIconContainer *container,
+ GList *icon_list,
+ GHashTable *icons_informations)
{
- GList *p, *line_start;
- NautilusIcon *icon;
- double canvas_width, line_width, space_width, y;
- GArray *positions;
- IconPositions *position;
- ArtDRect bounds;
- ArtDRect icon_bounds;
- GnomeCanvasItem *item;
- double max_height_above, max_height_below;
- double height_above, height_below;
- int i;
+ IconLayoutIconInfo *info = NULL;
+ unsigned int i;
+ GList *p;
- g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
+ switch (container->details->layout_mode)
+ {
+ case NAUTILUS_ICON_LAYOUT_L_R_T_B:
+ /* u vector is parallel to x and m vector is
+ parallel y. */
+ grid->canvas_u_length = (GTK_WIDGET (container)->allocation.width
+ - container->details->left_margin
+ - container->details->right_margin)
+ / GNOME_CANVAS (container)->pixels_per_unit;
- positions = g_array_new (FALSE, FALSE, sizeof (IconPositions));
+ /* Change {u, m} basis to {x,y} basis */
+ grid->bases.x = &grid->bases.u;
+ grid->bases.y = &grid->bases.m;
- /* Lay out icons a line at a time. */
- canvas_width = (GTK_WIDGET (container)->allocation.width
+ grid->bases.m_direction = 1;
+ grid->bases.m = 0;
+
+ break;
+ case NAUTILUS_ICON_LAYOUT_T_B_L_R:
+ /* u vector is parallel to y and m vector is
+ parallel to x. */
+ grid->canvas_u_length = (GTK_WIDGET (container)->allocation.height
+ - container->details->top_margin
+ - container->details->bottom_margin)
+ / GNOME_CANVAS (container)->pixels_per_unit;
+
+ /* Change {u, m} basis to {x,y} basis */
+ grid->bases.x = &grid->bases.m;
+ grid->bases.y = &grid->bases.u;
+
+ grid->bases.m_direction = 1;
+ grid->bases.m = 0;
+
+ break;
+ case NAUTILUS_ICON_LAYOUT_T_B_R_L:
+ /* u vector is parallel to y and m vector is
+ parallel to x. */
+ grid->canvas_u_length = (GTK_WIDGET (container)->allocation.height
+ - container->details->top_margin
+ - container->details->bottom_margin)
+ / GNOME_CANVAS (container)->pixels_per_unit;
+
+ /* Change {u, m} basis to {x,y} basis */
+ grid->bases.x = &grid->bases.m;
+ grid->bases.y = &grid->bases.u;
+
+ grid->bases.m_direction = -1;
+ grid->bases.m = (GTK_WIDGET (container)->allocation.width
- container->details->left_margin
- container->details->right_margin)
/ GNOME_CANVAS (container)->pixels_per_unit;
- line_width = 0;
- line_start = icons;
- y = start_y;
- i = 0;
- max_height_above = 0;
- max_height_below = 0;
- for (p = icons; p != NULL; p = p->next) {
- icon = p->data;
- /* Get the width of the icon. */
- item = GNOME_CANVAS_ITEM (icon->item);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
- /* Assume it's only one level hierarchy to avoid costly affine calculations */
- gnome_canvas_item_get_bounds (item,
- &bounds.x0, &bounds.y0,
- &bounds.x1, &bounds.y1);
+ for (p = icon_list, i = 0, grid->line_u_length = 0;
+ p != NULL && grid->line_u_length - ICON_PAD_RIGHT <= grid->canvas_u_length;
+ p = p->next, i++) {
- space_width = get_icon_space_width (container, &bounds);
+ info = icon_layout_get_icon_info (container,
+ p->data,
+ icons_informations);
- icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
+ grid->line_u_length += info->icon_u_component->origin
+ + info->icon_u_component->end;
+ }
+
+ g_array_set_size (grid->cells->u_components, i);
+ icon_layout_grid_reset (grid);
+}
- /* Calculate size above/below baseline */
- height_above = icon_bounds.y1 - bounds.y0;
- height_below = bounds.y1 - icon_bounds.y1;
- /* If this icon doesn't fit, it's time to lay out the line that's queued up. */
+static IconLayoutGrid*
+icon_layout_grid_new ()
+{
+ IconLayoutGrid *grid;
+
+ grid = g_new0 (IconLayoutGrid, 1);
+ grid->cells = g_new0 (IconLayoutGridCells, 1);
+ grid->cells->m_components = g_hash_table_new (NULL, NULL);
+ grid->cells->u_components = g_array_new (FALSE,
+ FALSE,
+ sizeof (IconLayoutBasisComponent));
+
+ return grid;
+}
+
+static void
+icon_layout_grid_free (IconLayoutGrid *grid)
+{
+ g_array_free (grid->cells->u_components, TRUE);
+ g_hash_table_destroy (grid->cells->m_components);
+ g_free (grid->cells);
+ g_free (grid);
+}
+
+static void
+icon_layout_grid_lay_down_icons (IconLayoutGrid *grid,
+ GList *icon_list,
+ GHashTable *icons_informations)
+{
+ GList *p;
+ IconLayoutIconInfo *info;
+ IconLayoutBasisComponent *cell_u_component, *cell_m_component;
+ unsigned int i, j, m_size;
+
+ m_size = g_hash_table_size (grid->cells->m_components);
+ for (i = 0, p = icon_list; i < m_size; i++) {
+ cell_m_component = g_hash_table_lookup (grid->cells->m_components,
+ GUINT_TO_POINTER (i));
+ grid->bases.m += grid->bases.m_direction * cell_m_component->origin;
+
+ for (j = 0, grid->bases.u = 0;
+ j < grid->cells->u_components->len && p != NULL;
+ j++, p = p->next ) {
+
+ info = g_hash_table_lookup (icons_informations, p->data);
+
+ cell_u_component = &g_array_index (grid->cells->u_components,
+ IconLayoutBasisComponent,
+ j);
+
+ grid->bases.u += cell_u_component->origin;
+
+ icon_set_position
+ (p->data,
+ *grid->bases.x + info->x_offset,
+ *grid->bases.y + info->y_offset);
+
+ /* next cell u component */
+ grid->bases.u += cell_u_component->end + grid->u_adjustment;
+
+ g_free(info->icon_u_component);
+ g_free(info->icon_m_component);
+ g_free(info);
+ }
+ grid->bases.m += grid->bases.m_direction * cell_m_component->end;
+ g_free (cell_m_component);
+ }
+}
+
+static inline gboolean
+icon_layout_grid_set_cell_u_component (IconLayoutGrid *grid,
+ IconLayoutBasisComponent *icon_u_component)
+{
+ double *new, *old;
+ unsigned int i;
+
+ /* set cell u component */
+ new = (double*) icon_u_component;
+ old = (double*) &g_array_index (grid->cells->u_components,
+ IconLayoutBasisComponent,
+ grid->cells->u_index);
+ for (i = 0; i < 2; i++) {
+ if(new[i] > old[i]) {
/* FIXME: why don't we want to guarantee a small white space to the right of
* the last column just like we guarantee a small white space to the left of
* the first column?
*/
- if (line_start != p && line_width + space_width - ICON_PAD_RIGHT > canvas_width) {
- /* Advance to the baseline. */
- y += ICON_PAD_TOP + max_height_above;
+ if (grid->cells->u_components->len > 1 &&
+ grid->line_u_length + new[i] - old[i] - ICON_PAD_RIGHT > grid->canvas_u_length) {
+ /* new grid u line length would exceeds canvas u length */
+
+ /* discard grid cells aligned along last grid line
+ * parallel to m layout vector */
+ g_array_set_size (grid->cells->u_components,
+ grid->cells->u_components->len - 1);
- lay_down_one_line (container, line_start, p, y, positions);
+ /* start over */
+ icon_layout_grid_reset (grid);
- /* Advance to next line. */
- y += max_height_below + ICON_PAD_BOTTOM;
-
- line_width = 0;
- line_start = p;
- i = 0;
+ return FALSE;
- max_height_above = height_above;
- max_height_below = height_below;
} else {
- if (height_above > max_height_above) {
- max_height_above = height_above;
+ grid->line_u_length += new[i] - old[i];
+ old[i] = new[i];
+
}
- if (height_below > max_height_below) {
- max_height_below = height_below;
}
}
- g_array_set_size (positions, i + 1);
- position = &g_array_index (positions, IconPositions, i++);
- position->width = space_width;
- position->x_offset = (space_width - (icon_bounds.x1 - icon_bounds.x0)) / 2;
- position->y_offset = icon_bounds.y0 - icon_bounds.y1;
+ return TRUE;
+}
- /* Add this icon. */
- line_width += space_width;
+static inline void
+icon_layout_grid_set_cell_m_component (IconLayoutGrid *grid,
+ IconLayoutBasisComponent *icon_m_component)
+{
+ IconLayoutBasisComponent *cell_m_component;
+
+ /* Finds maximum cells's m size for all cells along
+ one u grid line */
+ if (icon_m_component->origin > grid->max_m_component.origin) {
+ grid->max_m_component.origin = icon_m_component->origin;
+ }
+ if (icon_m_component->end > grid->max_m_component.end) {
+ grid->max_m_component.end = icon_m_component->end;
+ }
+
+ /* check for end of u line */
+ if (grid->cells->u_index == grid->cells->u_components->len - 1) {
+ /* End of u grid line */
+ if ((cell_m_component = g_hash_table_lookup (grid->cells->m_components,
+ GUINT_TO_POINTER (grid->cells->m_index))) == NULL) {
+
+ cell_m_component = g_new0 (IconLayoutBasisComponent, 1);
+ g_hash_table_insert (grid->cells->m_components,
+ GUINT_TO_POINTER (grid->cells->m_index),
+ cell_m_component);
+ }
+
+ /* set cells' m size for cells on current
+ u grid line */
+ cell_m_component->origin = grid->max_m_component.origin;
+ cell_m_component->end = grid->max_m_component.end;
+
+ /* Advance to new u grid line */
+ ++grid->cells->m_index;
+ grid->cells->u_index = 0;
+ grid->max_m_component.origin = 0;
+ grid->max_m_component.end = 0;
+ } else {
+ /* next grid u cell component */
+ grid->cells->u_index++;
}
+}
- /* Lay down that last line of icons. */
- if (line_start != NULL) {
- /* Advance to the baseline. */
- y += ICON_PAD_TOP + max_height_above;
+static void
+icon_layout_grid_finalize (IconLayoutGrid *grid,
+ GHashTable *icons_informations)
+{
+ IconLayoutBasisComponent *cell_m_component;
- lay_down_one_line (container, line_start, NULL, y, positions);
+ /* Check for possible incomplete last u grid line */
+ if (g_hash_table_size (icons_informations) % grid->cells->u_components->len) {
+ cell_m_component = g_new0 (IconLayoutBasisComponent, 1);
+ cell_m_component->origin = grid->max_m_component.origin;
+ cell_m_component->end = grid->max_m_component.end;
+ g_hash_table_insert (grid->cells->m_components,
+ GUINT_TO_POINTER (grid->cells->m_index),
+ cell_m_component);
+ }
- /* Advance to next line. */
- y += max_height_below + ICON_PAD_BOTTOM;
+ grid->u_adjustment = (grid->canvas_u_length - grid->line_u_length)
+ / ((double) grid->cells->u_components->len);
+}
+
+static void
+lay_down_icons_in_auto_layout (NautilusIconContainer *container,
+ GList *icon_list)
+{
+ GList *p;
+ gboolean result;
+ IconLayoutIconInfo *info;
+ IconLayoutGrid *grid;
+ GHashTable *icons_informations;
+
+ g_return_if_fail (icon_list != NULL);
+ g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
+
+ icons_informations = g_hash_table_new (NULL, NULL);
+
+ grid = icon_layout_grid_new ();
+ icon_layout_grid_init (grid,
+ container,
+ icon_list,
+ icons_informations);
+
+ p = icon_list;
+ while (p != NULL) {
+ info = icon_layout_get_icon_info (container,
+ p->data,
+ icons_informations);
+
+ /* set cell size parallel to u grid line */
+ result = icon_layout_grid_set_cell_u_component (grid,
+ info->icon_u_component);
+ if (result == FALSE) {
+ /* start over */
+ p = icon_list;
+ continue;
+ }
+
+ /* set cells m size when the end of the current
+ u grid line is reached */
+ icon_layout_grid_set_cell_m_component (grid, info->icon_m_component);
+
+ /* next icon */
+ p = p->next;
}
+ icon_layout_grid_finalize (grid, icons_informations);
+
+ icon_layout_grid_lay_down_icons (grid, icon_list, icons_informations);
- g_array_free (positions, TRUE);
+ icon_layout_grid_free (grid);
+ g_hash_table_destroy (icons_informations);
}
/* Search for available space at location */
@@ -1072,13 +1356,13 @@ mark_icon_locations_in_grid (GList *icon
}
static void
-lay_down_icons_tblr (NautilusIconContainer *container, GList *icons)
+lay_down_icons_in_non_auto_layout (NautilusIconContainer *container, GList *icons)
{
GList *p, *placed_icons, *unplaced_icons;
- int index, total, new_length, placed;
+ int index;
NautilusIcon *icon;
- int width, height, max_width, icon_width, icon_height;
- int x, y, x1, x2, y1, y2;
+ int width, height;
+ int x, y;
int *grid_memory;
int **icon_grid;
int num_rows, num_columns;
@@ -1098,10 +1382,6 @@ lay_down_icons_tblr (NautilusIconContain
placed_icons = NULL;
unplaced_icons = NULL;
- total = g_list_length (container->details->icons);
- new_length = g_list_length (icons);
- placed = total - new_length;
- if (placed > 0) {
/* Add only placed icons in list */
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
@@ -1158,37 +1438,13 @@ lay_down_icons_tblr (NautilusIconContain
free (grid_memory);
g_list_free (placed_icons);
g_list_free (unplaced_icons);
- } else {
- /* There are no placed icons. Just lay them down using our rules */
- x = DESKTOP_PAD_HORIZONTAL;
- y = DESKTOP_PAD_VERTICAL;
- max_width = 0;
-
- for (p = icons; p != NULL; p = p->next) {
- icon = p->data;
- icon_get_bounding_box (icon, &x1, &y1, &x2, &y2);
-
- icon_width = x2 - x1;
- icon_height = y2 - y1;
-
- /* Check and see if we need to move to a new column */
- if (y > height - icon_height) {
- x += max_width + DESKTOP_PAD_VERTICAL;
- y = DESKTOP_PAD_VERTICAL;
- max_width = 0;
- }
-
- icon_set_position (icon, x, y);
-
- /* Check for increase in column width */
- if (max_width < icon_width) {
- max_width = icon_width;
- }
-
- y += icon_height + DESKTOP_PAD_VERTICAL;
- }
- }
+}
+static void
+lay_down_icons (NautilusIconContainer *container, GList *icons)
+{
+ if(!container->details->auto_layout) {
+ lay_down_icons_in_non_auto_layout (container, icons);
/* These modes are special. We freeze all of our positions
* after we do the layout.
*/
@@ -1197,27 +1453,9 @@ lay_down_icons_tblr (NautilusIconContain
* It should be a separate switch.
*/
nautilus_icon_container_freeze_icon_positions (container);
-}
-
-
-static void
-lay_down_icons (NautilusIconContainer *container, GList *icons, double start_y)
-{
- switch (container->details->layout_mode)
- {
- case NAUTILUS_ICON_LAYOUT_L_R_T_B:
- lay_down_icons_horizontal (container, icons, start_y);
- break;
-
- case NAUTILUS_ICON_LAYOUT_T_B_L_R:
- case NAUTILUS_ICON_LAYOUT_T_B_R_L:
- /* FIXME bugzilla.gnome.org 42479:
- * Need to handle T_B_R_L differently. */
- lay_down_icons_tblr (container, icons);
- break;
+ } else {
- default:
- g_assert_not_reached ();
+ lay_down_icons_in_auto_layout (container, icons);
}
}
@@ -1234,7 +1472,7 @@ redo_layout_internal (NautilusIconContai
if (container->details->auto_layout
&& container->details->drag_state != DRAG_STATE_STRETCH) {
resort (container);
- lay_down_icons (container, container->details->icons, 0);
+ lay_down_icons (container, container->details->icons);
}
nautilus_icon_container_update_scroll_region (container);
@@ -1282,23 +1520,27 @@ redo_layout (NautilusIconContainer *cont
}
static void
-reload_icon_positions (NautilusIconContainer *container)
+reload_icon_positions_only_for_desktop (NautilusIconContainer *container)
{
GList *p, *no_position_icons;
NautilusIcon *icon;
gboolean have_stored_position;
NautilusIconPosition position;
- ArtDRect bounds;
- double bottom;
+ char *desktop_uri;
+ char *container_uri;
+
g_assert (!container->details->auto_layout);
- resort (container);
+ g_signal_emit_by_name (container, "get_container_uri", &container_uri);
+ desktop_uri = nautilus_get_desktop_directory ();
no_position_icons = NULL;
+ /* Reload icon positions only if current directory
+ is the desktop */
+ if (strcmp (desktop_uri, &container_uri[7]) == 0) {
/* Place all the icons with positions. */
- bottom = 0;
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
@@ -1310,13 +1552,10 @@ reload_icon_positions (NautilusIconConta
&have_stored_position);
if (have_stored_position) {
icon_set_position (icon, position.x, position.y);
- bounds = eel_gnome_canvas_item_get_world_bounds
- (GNOME_CANVAS_ITEM (icon->item));
- if (bounds.y1 > bottom) {
- bottom = bounds.y1;
- }
} else {
no_position_icons = g_list_prepend (no_position_icons, icon);
+ icon->x = -1;
+ icon->y = -1;
}
}
no_position_icons = g_list_reverse (no_position_icons);
@@ -1320,9 +1559,12 @@ reload_icon_positions (NautilusIconConta
}
}
no_position_icons = g_list_reverse (no_position_icons);
-
/* Place all the other icons. */
- lay_down_icons (container, no_position_icons, bottom + ICON_PAD_BOTTOM);
+ lay_down_icons_in_non_auto_layout (container, no_position_icons);
+ }
+
+ g_free (desktop_uri);
+ g_free (container_uri);
g_list_free (no_position_icons);
}
@@ -3988,7 +4230,6 @@ finish_adding_new_icons (NautilusIconCon
{
GList *p, *new_icons, *no_position_icons;
NautilusIcon *icon;
- double bottom;
new_icons = container->details->new_icons;
container->details->new_icons = NULL;
@@ -4010,8 +4251,7 @@ finish_adding_new_icons (NautilusIconCon
g_assert (!container->details->auto_layout);
sort_icons (container, &no_position_icons);
- get_all_icon_bounds (container, NULL, NULL, NULL, &bottom);
- lay_down_icons (container, no_position_icons, bottom + ICON_PAD_BOTTOM);
+ lay_down_icons (container, no_position_icons);
g_list_free (no_position_icons);
}
}
@@ -4695,8 +4935,9 @@ nautilus_icon_container_set_auto_layout
reset_scroll_region_if_not_empty (container);
container->details->auto_layout = auto_layout;
+
if (!auto_layout) {
- reload_icon_positions (container);
+ reload_icon_positions_only_for_desktop (container);
nautilus_icon_container_freeze_icon_positions (container);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]