aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-05-14 06:03:24 +0800
committerChris Lahey <clahey@src.gnome.org>2002-05-14 06:03:24 +0800
commit3373cf7e047f1f38161cc11670a061d9c1c903e3 (patch)
treec8304863ce55c5d094db479a3148a65a8557b921
parent3da2b4bbbd72826c20c1568a792174cb15f7badb (diff)
downloadgsoc2013-evolution-3373cf7e047f1f38161cc11670a061d9c1c903e3.tar
gsoc2013-evolution-3373cf7e047f1f38161cc11670a061d9c1c903e3.tar.gz
gsoc2013-evolution-3373cf7e047f1f38161cc11670a061d9c1c903e3.tar.bz2
gsoc2013-evolution-3373cf7e047f1f38161cc11670a061d9c1c903e3.tar.lz
gsoc2013-evolution-3373cf7e047f1f38161cc11670a061d9c1c903e3.tar.xz
gsoc2013-evolution-3373cf7e047f1f38161cc11670a061d9c1c903e3.tar.zst
gsoc2013-evolution-3373cf7e047f1f38161cc11670a061d9c1c903e3.zip
Changed a lot of direct uses in this file of node->is_expanded to call the
2002-05-13 Christopher James Lahey <clahey@ximian.com> * e-tree-table-adapter.c: Changed a lot of direct uses in this file of node->is_expanded to call the function e_tree_table_adapter_node_is_expanded instead. (e_tree_table_adapter_node_is_expanded): Improved this function to know if the root node is visible and always return it as being expanded if it's not. It also doesn't bother creating nodes if they don't exist yet, and instead figures out whether they would be expanded if they were to be created and returns that value instead. svn path=/trunk/; revision=16768
-rw-r--r--widgets/table/e-tree-table-adapter.c146
1 files changed, 76 insertions, 70 deletions
diff --git a/widgets/table/e-tree-table-adapter.c b/widgets/table/e-tree-table-adapter.c
index c88557ab86..d828fbb4a8 100644
--- a/widgets/table/e-tree-table-adapter.c
+++ b/widgets/table/e-tree-table-adapter.c
@@ -188,8 +188,7 @@ find_first_child_node_maybe_deleted(ETreeTableAdapter *adapter, int row)
{
if (row != -1) {
ETreePath path = adapter->priv->map_table[row];
- ETreeTableAdapterNode *current = find_node (adapter, path);
- if (current && current->expanded) {
+ if (e_tree_table_adapter_node_is_expanded (adapter, path)) {
row ++;
if (row >= adapter->priv->n_map)
return -1;
@@ -224,8 +223,7 @@ find_first_child_node(ETreeTableAdapter *adapter, int row)
if (row != -1) {
ETreePath path = adapter->priv->map_table[row];
ETreePath first_child = e_tree_model_node_get_first_child(adapter->priv->source, path);
- ETreeTableAdapterNode *current = find_node (adapter, path);
- if (first_child && current && current->expanded) {
+ if (first_child && e_tree_table_adapter_node_is_expanded (adapter, path)) {
row ++;
if (row >= adapter->priv->n_map)
return -1;
@@ -290,12 +288,9 @@ find_row_num(ETreeTableAdapter *etta, ETreePath path)
sequence[0] = path;
for (i = 0; i < depth; i++) {
- ETreeTableAdapterNode *node;
-
sequence[i + 1] = e_tree_model_node_get_parent(etta->priv->source, sequence[i]);
- node = find_node(etta, sequence[i + 1]);
- if (! ((node && node->expanded) || e_tree_model_get_expanded_default(etta->priv->source))) {
+ if (!e_tree_table_adapter_node_is_expanded (etta, sequence[i + 1])) {
g_free(sequence);
return -1;
}
@@ -325,12 +320,7 @@ array_size_from_path(ETreeTableAdapter *etta, ETreePath path)
{
int size = 1;
- ETreeTableAdapterNode *node = NULL;
-
- if (e_tree_model_node_is_expandable(etta->priv->source, path))
- node = find_or_create_node(etta, path);
-
- if (node && node->expanded) {
+ if (e_tree_table_adapter_node_is_expanded (etta, path)) {
ETreePath children;
for (children = e_tree_model_node_get_first_child(etta->priv->source, path);
@@ -353,14 +343,14 @@ fill_array_from_path(ETreeTableAdapter *etta, ETreePath *array, ETreePath path)
index ++;
- if (e_tree_model_node_is_expandable(etta->priv->source, path))
- node = find_or_create_node(etta, path);
- else
- node = find_node(etta, path);
+ node = find_node(etta, path);
- if (node && node->expanded) {
+ if (e_tree_table_adapter_node_is_expanded (etta, path)) {
ETreePath children;
+ if (!node)
+ node = find_or_create_node(etta, path);
+
for (children = e_tree_model_node_get_first_child(etta->priv->source, path);
children;
children = e_tree_model_node_get_next(etta->priv->source, children)) {
@@ -740,6 +730,7 @@ etta_proxy_node_inserted (ETreeModel *etm, ETreePath parent, ETreePath child, ET
if (parent_node->expandable != e_tree_model_node_is_expandable(etta->priv->source, parent)) {
e_table_model_pre_change(E_TABLE_MODEL(etta));
parent_node->expandable = e_tree_model_node_is_expandable(etta->priv->source, parent);
+ parent_node->expandable_set = 1;
if (etta->priv->root_visible)
e_table_model_row_changed(E_TABLE_MODEL(etta), parent_row);
else if (parent_row != 0)
@@ -747,7 +738,8 @@ etta_proxy_node_inserted (ETreeModel *etm, ETreePath parent, ETreePath child, ET
else
e_table_model_no_change(E_TABLE_MODEL(etta));
}
- if (!parent_node->expanded) {
+
+ if (!e_tree_table_adapter_node_is_expanded (etta, parent)) {
e_table_model_no_change(E_TABLE_MODEL(etta));
return;
}
@@ -1020,57 +1012,58 @@ void e_tree_table_adapter_node_set_expanded (ETreeTableAdapter *etta, ET
ETreeTableAdapterNode *node;
int row;
- if (e_tree_model_node_is_root (etta->priv->source, path) && !etta->priv->root_visible)
+ if (!expanded && e_tree_model_node_is_root (etta->priv->source, path) && !etta->priv->root_visible)
return;
node = find_or_create_node(etta, path);
- if (expanded != node->expanded) {
- node->expanded = expanded;
+ if (expanded == node->expanded)
+ return;
+
+ node->expanded = expanded;
- row = find_row_num(etta, path);
- if (row != -1) {
- e_table_model_pre_change (E_TABLE_MODEL(etta));
+ row = find_row_num(etta, path);
+ if (row != -1) {
+ e_table_model_pre_change (E_TABLE_MODEL(etta));
- if (etta->priv->root_visible) {
- e_table_model_pre_change (E_TABLE_MODEL(etta));
- e_table_model_row_changed(E_TABLE_MODEL(etta), row);
- } else if (row != 0) {
- e_table_model_pre_change (E_TABLE_MODEL(etta));
- e_table_model_row_changed(E_TABLE_MODEL(etta), row - 1);
- }
+ if (etta->priv->root_visible) {
+ e_table_model_pre_change (E_TABLE_MODEL(etta));
+ e_table_model_row_changed(E_TABLE_MODEL(etta), row);
+ } else if (row != 0) {
+ e_table_model_pre_change (E_TABLE_MODEL(etta));
+ e_table_model_row_changed(E_TABLE_MODEL(etta), row - 1);
+ }
- if (expanded) {
- int num_children = array_size_from_path(etta, path) - 1;
- etta_expand_to(etta, etta->priv->n_map + num_children);
- memmove(etta->priv->map_table + row + 1 + num_children,
- etta->priv->map_table + row + 1,
- (etta->priv->n_map - row - 1) * sizeof (ETreePath));
- fill_array_from_path(etta, etta->priv->map_table + row, path);
- etta_update_parent_child_counts(etta, path, num_children);
- if (num_children != 0) {
- if (etta->priv->root_visible)
- e_table_model_rows_inserted(E_TABLE_MODEL(etta), row + 1, num_children);
- else
- e_table_model_rows_inserted(E_TABLE_MODEL(etta), row, num_children);
- } else
- e_table_model_no_change(E_TABLE_MODEL(etta));
- } else {
- int num_children = node->num_visible_children;
- g_assert (etta->priv->n_map >= row + 1 + num_children);
- memmove(etta->priv->map_table + row + 1,
- etta->priv->map_table + row + 1 + num_children,
- (etta->priv->n_map - row - 1 - num_children) * sizeof (ETreePath));
- node->num_visible_children = 0;
- etta_update_parent_child_counts(etta, path, - num_children);
- if (num_children != 0) {
- if (etta->priv->root_visible)
- e_table_model_rows_deleted(E_TABLE_MODEL(etta), row + 1, num_children);
- else
- e_table_model_rows_deleted(E_TABLE_MODEL(etta), row, num_children);
- } else
- e_table_model_no_change(E_TABLE_MODEL(etta));
- }
+ if (expanded) {
+ int num_children = array_size_from_path(etta, path) - 1;
+ etta_expand_to(etta, etta->priv->n_map + num_children);
+ memmove(etta->priv->map_table + row + 1 + num_children,
+ etta->priv->map_table + row + 1,
+ (etta->priv->n_map - row - 1) * sizeof (ETreePath));
+ fill_array_from_path(etta, etta->priv->map_table + row, path);
+ etta_update_parent_child_counts(etta, path, num_children);
+ if (num_children != 0) {
+ if (etta->priv->root_visible)
+ e_table_model_rows_inserted(E_TABLE_MODEL(etta), row + 1, num_children);
+ else
+ e_table_model_rows_inserted(E_TABLE_MODEL(etta), row, num_children);
+ } else
+ e_table_model_no_change(E_TABLE_MODEL(etta));
+ } else {
+ int num_children = node->num_visible_children;
+ g_assert (etta->priv->n_map >= row + 1 + num_children);
+ memmove(etta->priv->map_table + row + 1,
+ etta->priv->map_table + row + 1 + num_children,
+ (etta->priv->n_map - row - 1 - num_children) * sizeof (ETreePath));
+ node->num_visible_children = 0;
+ etta_update_parent_child_counts(etta, path, - num_children);
+ if (num_children != 0) {
+ if (etta->priv->root_visible)
+ e_table_model_rows_deleted(E_TABLE_MODEL(etta), row + 1, num_children);
+ else
+ e_table_model_rows_deleted(E_TABLE_MODEL(etta), row, num_children);
+ } else
+ e_table_model_no_change(E_TABLE_MODEL(etta));
}
}
}
@@ -1126,17 +1119,30 @@ void e_tree_table_adapter_show_node (ETreeTableAdapter *etta, ETreePath
parent = e_tree_model_node_get_parent(etta->priv->source, path);
- if (parent) {
+ while (parent) {
e_tree_table_adapter_node_set_expanded(etta, parent, TRUE);
- e_tree_table_adapter_show_node(etta, parent);
+ parent = e_tree_model_node_get_parent(etta->priv->source, parent);
}
}
gboolean e_tree_table_adapter_node_is_expanded (ETreeTableAdapter *etta, ETreePath path)
{
- if (e_tree_model_node_is_expandable(etta->priv->source, path)) {
- ETreeTableAdapterNode *node = find_or_create_node(etta, path);
- return node->expanded;
- } else
+ ETreeTableAdapterNode *node;
+
+ if (!e_tree_model_node_is_expandable (etta->priv->source, path))
return FALSE;
+
+ if (e_tree_model_node_is_root(etta->priv->source, path) &&
+ !etta->priv->root_visible)
+ return TRUE;
+
+ node = find_node (etta, path);
+ if (node)
+ return node->expanded;
+ else {
+ if (e_tree_model_node_is_root(etta->priv->source, path))
+ return TRUE;
+ else
+ return e_tree_model_get_expanded_default(etta->priv->source);
+ }
}