[gtk+] inspector: Implement find_object() without GtkTreeRowReference
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Implement find_object() without GtkTreeRowReference
- Date: Wed, 26 Aug 2015 14:35:39 +0000 (UTC)
commit 1f2bd47965db972c8d9abd5151e6996ed29b50b5
Author: Benjamin Otte <otte redhat com>
Date: Wed Aug 26 15:44:55 2015 +0200
inspector: Implement find_object() without GtkTreeRowReference
Tree row references are slow to update. And we update the widget list
quite a bit, so when it grows it can get REALLY slow.
gtk/inspector/object-tree.c | 52 +++++++++++++++++++++++++++++++++----------
1 files changed, 40 insertions(+), 12 deletions(-)
---
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index 4af3868..a52d7a2 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -517,7 +517,7 @@ find_class_funcs (GObject *object)
return NULL;
}
-static G_GNUC_UNUSED GObject *
+static GObject *
object_get_parent (GObject *object)
{
const ObjectTreeClassFuncs *funcs;
@@ -1171,26 +1171,54 @@ gtk_inspector_object_tree_scan (GtkInspectorObjectTree *wt,
select_object_internal (wt, selected, FALSE);
}
+static gboolean
+gtk_inspector_object_tree_find_object_at_parent_iter (GtkTreeModel *model,
+ GObject *object,
+ GtkTreeIter *parent,
+ GtkTreeIter *iter)
+{
+ if (!gtk_tree_model_iter_children (model, iter, parent))
+ return FALSE;
+
+ do {
+ GObject *lookup;
+
+ gtk_tree_model_get (model, iter, OBJECT, &lookup, -1);
+
+ if (lookup == object)
+ return TRUE;
+
+ } while (gtk_tree_model_iter_next (model, iter));
+
+ return FALSE;
+}
+
gboolean
gtk_inspector_object_tree_find_object (GtkInspectorObjectTree *wt,
GObject *object,
GtkTreeIter *iter)
{
- ObjectData *od;
+ GtkTreeIter parent_iter;
+ GObject *parent;
- od = g_hash_table_lookup (wt->priv->iters, object);
- if (od && gtk_tree_row_reference_valid (od->row))
+ parent = object_get_parent (object);
+ if (parent)
{
- GtkTreePath *path;
-
- path = gtk_tree_row_reference_get_path (od->row);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (wt->priv->model), iter, path);
- gtk_tree_path_free (path);
+ if (!gtk_inspector_object_tree_find_object (wt, parent, &parent_iter))
+ return FALSE;
- return TRUE;
+ return gtk_inspector_object_tree_find_object_at_parent_iter (GTK_TREE_MODEL (wt->priv->model),
+ object,
+ &parent_iter,
+ iter);
+ }
+ else
+ {
+ return gtk_inspector_object_tree_find_object_at_parent_iter (GTK_TREE_MODEL (wt->priv->model),
+ object,
+ NULL,
+ iter);
}
-
- return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]