[nautilus] canvas-container: cache icon positions for accessibles
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] canvas-container: cache icon positions for accessibles
- Date: Mon, 1 Sep 2014 22:37:06 +0000 (UTC)
commit aa5fb604de6d284af8beb015f912d56f1dac1851
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Sep 1 12:20:00 2014 -0700
canvas-container: cache icon positions for accessibles
Instead of calling g_list_index() every time, cache positions when
resorting.
libnautilus-private/nautilus-canvas-container.c | 22 ++++++++++++++++------
libnautilus-private/nautilus-canvas-private.h | 3 +++
2 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index 098d401..3d0cf7d 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -1102,6 +1102,19 @@ nautilus_canvas_container_update_scroll_region (NautilusCanvasContainer *contain
}
}
+static void
+cache_icon_positions (NautilusCanvasContainer *container)
+{
+ GList *l;
+ gint idx;
+ NautilusCanvasIcon *icon;
+
+ for (l = container->details->icons, idx = 0; l != NULL; l = l ->next) {
+ icon = l->data;
+ icon->position = idx++;
+ }
+}
+
static int
compare_icons_data (gconstpointer a, gconstpointer b, gpointer canvas_container)
{
@@ -1154,6 +1167,7 @@ resort (NautilusCanvasContainer *container)
{
sort_icons (container, &container->details->icons);
sort_selection (container);
+ cache_icon_positions (container);
}
typedef struct {
@@ -7666,17 +7680,15 @@ nautilus_canvas_container_accessible_icon_added_cb (NautilusCanvasContainer *con
NautilusCanvasIcon *icon;
AtkObject *atk_parent;
AtkObject *atk_child;
- int index;
icon = g_hash_table_lookup (container->details->icon_set, icon_data);
if (icon) {
atk_parent = ATK_OBJECT (data);
atk_child = atk_gobject_accessible_for_object
(G_OBJECT (icon->item));
- index = g_list_index (container->details->icons, icon);
g_signal_emit_by_name (atk_parent, "children-changed::add",
- index, atk_child, NULL);
+ icon->position, atk_child, NULL);
}
}
@@ -7688,17 +7700,15 @@ nautilus_canvas_container_accessible_icon_removed_cb (NautilusCanvasContainer *c
NautilusCanvasIcon *icon;
AtkObject *atk_parent;
AtkObject *atk_child;
- int index;
icon = g_hash_table_lookup (container->details->icon_set, icon_data);
if (icon) {
atk_parent = ATK_OBJECT (data);
atk_child = atk_gobject_accessible_for_object
(G_OBJECT (icon->item));
- index = g_list_index (container->details->icons, icon);
g_signal_emit_by_name (atk_parent, "children-changed::remove",
- index, atk_child, NULL);
+ icon->position, atk_child, NULL);
}
}
diff --git a/libnautilus-private/nautilus-canvas-private.h b/libnautilus-private/nautilus-canvas-private.h
index bfccf19..d624556 100644
--- a/libnautilus-private/nautilus-canvas-private.h
+++ b/libnautilus-private/nautilus-canvas-private.h
@@ -52,6 +52,9 @@ typedef struct {
/* Scale factor (stretches icon). */
double scale;
+ /* Position in the view */
+ int position;
+
/* Whether this item is selected. */
eel_boolean_bit is_selected : 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]