[gtk+] a11y: Add a hash function for cell infos
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] a11y: Add a hash function for cell infos
- Date: Wed, 16 Nov 2011 03:42:40 +0000 (UTC)
commit 85fee3309260ef843f4533325cafa1e024c54631
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 12 05:38:52 2011 +0100
a11y: Add a hash function for cell infos
Note that comparing the tree is not necessary as the nodes are already
unique per row.
gtk/a11y/gtktreeviewaccessible.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index 0680a94..ebab327 100644
--- a/gtk/a11y/gtktreeviewaccessible.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -241,6 +241,28 @@ cell_info_get_path (GtkTreeViewAccessibleCellInfo *cell_info)
cell_info->node);
}
+static guint
+cell_info_hash (gconstpointer info)
+{
+ const GtkTreeViewAccessibleCellInfo *cell_info = info;
+ guint node, col;
+
+ node = GPOINTER_TO_UINT (cell_info->node);
+ col = GPOINTER_TO_UINT (cell_info->cell_col_ref);
+
+ return ((node << sizeof (guint) / 2) | (node >> sizeof (guint) / 2)) ^ col;
+}
+
+static gboolean
+cell_info_equal (gconstpointer a, gconstpointer b)
+{
+ const GtkTreeViewAccessibleCellInfo *cell_info_a = a;
+ const GtkTreeViewAccessibleCellInfo *cell_info_b = b;
+
+ return cell_info_a->node == cell_info_b->node &&
+ cell_info_a->cell_col_ref == cell_info_b->cell_col_ref;
+}
+
static void
gtk_tree_view_accessible_initialize (AtkObject *obj,
gpointer data)
@@ -263,8 +285,8 @@ gtk_tree_view_accessible_initialize (AtkObject *obj,
accessible->idle_expand_path = NULL;
accessible->n_children_deleted = 0;
- accessible->cell_infos = g_hash_table_new_full (g_direct_hash,
- g_direct_equal, NULL, (GDestroyNotify) cell_info_free);
+ accessible->cell_infos = g_hash_table_new_full (cell_info_hash,
+ cell_info_equal, NULL, (GDestroyNotify) cell_info_free);
widget = GTK_WIDGET (data);
tree_view = GTK_TREE_VIEW (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]