[brasero] Fix GtkTrackDataCfg (when used as a GtkTreeModel) when nodes are removed and there are hidden files



commit 406946e781857370ae292eed4f10d799ca576279
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Wed Jul 15 20:47:39 2009 +0200

    Fix GtkTrackDataCfg (when used as a GtkTreeModel) when nodes are removed and there are hidden files in it

 libbrasero-burn/brasero-track-data-cfg.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/libbrasero-burn/brasero-track-data-cfg.c b/libbrasero-burn/brasero-track-data-cfg.c
index 4550702..a36803c 100644
--- a/libbrasero-burn/brasero-track-data-cfg.c
+++ b/libbrasero-burn/brasero-track-data-cfg.c
@@ -1521,6 +1521,28 @@ brasero_track_data_cfg_node_added (BraseroDataProject *project,
 //		node->is_visible = TRUE;
 }
 
+static guint
+brasero_track_data_cfg_convert_former_position (BraseroFileNode *former_parent,
+                                                guint former_position)
+{
+	BraseroFileNode *child;
+	guint hidden_num = 0;
+	guint current_pos;
+
+	/* We need to convert former_position to the right position in the
+	 * treeview as there could be some hidden node before this position. */
+	child = BRASERO_FILE_NODE_CHILDREN (former_parent);
+
+	for (current_pos = 0; child && current_pos != former_position; current_pos ++) {
+		if (child->is_hidden)
+			hidden_num ++;
+
+		child = child->next;
+	}
+
+	return former_position - hidden_num;
+}
+
 static void
 brasero_track_data_cfg_node_removed (BraseroDataProject *project,
 				     BraseroFileNode *former_parent,
@@ -1589,7 +1611,7 @@ brasero_track_data_cfg_node_removed (BraseroDataProject *project,
 	/* remove the node. Do it after adding a possible BOGUS row.
 	 * NOTE since BOGUS row has been added move row. */
 	path = brasero_track_data_cfg_node_to_path (self, former_parent);
-	gtk_tree_path_append_index (path, former_position);
+	gtk_tree_path_append_index (path, brasero_track_data_cfg_convert_former_position (former_parent, former_position));
 
 	gtk_tree_model_row_deleted (GTK_TREE_MODEL (self), path);
 	gtk_tree_path_free (path);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]