[gtk+] Emit row-has-child-toggled when a first node becomes visible in a level
- From: Kristian Rietveld <kristian src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Emit row-has-child-toggled when a first node becomes visible in a level
- Date: Sat, 5 Sep 2009 15:27:09 +0000 (UTC)
commit f483c5b7d635e15373c4fe61c96de3410d299a32
Author: Kristian Rietveld <kris gtk org>
Date: Sat Sep 5 16:41:09 2009 +0200
Emit row-has-child-toggled when a first node becomes visible in a level
If we have a level with zero visible nodes and the first node becomes
visible in that level, then parent has just become a "real" parent node.
In such a case we need to emit row-has-child-toggled. This only applies
to non-root levels that have a parent. This problem was also found when
writing the unit test, the respective cases in the unit test have been
corrected.
This fixes bugs:
Bug 372010 - Filtering not working properly
Bug 525965 - Filtered and sorted GtkTreeView is missing rows
gtk/gtktreemodelfilter.c | 15 +++++++++++++++
gtk/tests/filtermodel.c | 7 +++++--
2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c
index 1036636..2dd41ef 100644
--- a/gtk/gtktreemodelfilter.c
+++ b/gtk/gtktreemodelfilter.c
@@ -1336,6 +1336,21 @@ gtk_tree_model_filter_row_changed (GtkTreeModel *c_model,
gtk_tree_model_row_inserted (GTK_TREE_MODEL (filter), path, &iter);
+ if (level->parent_level && level->visible_nodes == 1)
+ {
+ /* We know that this is the first visible node in this level, so
+ * we need to emit row-has-child-toggled on the parent. This
+ * does not apply to the root level.
+ */
+
+ gtk_tree_path_up (path);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path);
+
+ gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (filter),
+ path,
+ &iter);
+ }
+
if (gtk_tree_model_iter_children (c_model, &children, c_iter))
gtk_tree_model_filter_update_children (filter, level, elt);
}
diff --git a/gtk/tests/filtermodel.c b/gtk/tests/filtermodel.c
index 52e0d51..4a31aa3 100644
--- a/gtk/tests/filtermodel.c
+++ b/gtk/tests/filtermodel.c
@@ -856,8 +856,9 @@ filled_hide_child_levels (FilterTest *fixture,
check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
check_level_length (fixture->filter, "0:4", 0);
- /* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
+ /* Once 0:4:0 got inserted, 0:4 became a parent */
+ signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:0");
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:1");
@@ -1048,11 +1049,12 @@ filled_vroot_hide_child_levels (FilterTest *fixture,
check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
check_level_length (fixture->filter, "0:4", 0);
- /* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */
/* FIXME: Inconsistency! For the non-vroot case we also receive two
* row-has-child-toggled signals here.
*/
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
+ /* Once 0:4:0 got inserted, 0:4 became a parent */
+ signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
set_path_visibility (fixture, "2:0:4:2", TRUE);
set_path_visibility (fixture, "2:0:4:4", TRUE);
@@ -1080,6 +1082,7 @@ empty_show_nodes (FilterTest *fixture,
check_level_length (fixture->filter, "0", 0);
signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:0");
+ signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:0");
set_path_visibility (fixture, "3:2", TRUE);
check_filter_model (fixture);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]