brasero r678 - in trunk: . src



Author: philippr
Date: Fri Mar 14 19:13:17 2008
New Revision: 678
URL: http://svn.gnome.org/viewvc/brasero?rev=678&view=rev

Log:
	Fixed a bug where removing an URI didn\'t remove the child URIs in filtered tree

	* src/brasero-data-disc.c: (brasero_data_disc_filtered_uri_cb):
	* src/brasero-data-project.c:
	(brasero_data_project_uri_remove_graft),
	(brasero_data_project_remove_node_children_graft_cb),
	(brasero_data_project_node_removed):
	* src/brasero-data-project.h:
	* src/brasero-data-vfs.c: (brasero_data_vfs_remove_filtered_uris),
	(brasero_data_vfs_uri_removed), (brasero_data_vfs_class_init):
	* src/brasero-data-vfs.h:
	* src/brasero-file-filtered.c: (brasero_file_filtered_remove),
	(brasero_file_filtered_add):
	* src/brasero-file-filtered.h:

Modified:
   trunk/ChangeLog
   trunk/src/brasero-data-disc.c
   trunk/src/brasero-data-project.c
   trunk/src/brasero-data-project.h
   trunk/src/brasero-data-vfs.c
   trunk/src/brasero-data-vfs.h
   trunk/src/brasero-file-filtered.c
   trunk/src/brasero-file-filtered.h

Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c	(original)
+++ trunk/src/brasero-data-disc.c	Fri Mar 14 19:13:17 2008
@@ -772,7 +772,10 @@
 	BraseroDataDiscPrivate *priv;
 
 	priv = BRASERO_DATA_DISC_PRIVATE (self);
-	brasero_file_filtered_add (BRASERO_FILE_FILTERED (priv->filter), uri, status);
+	if (status != BRASERO_FILTER_NONE)
+		brasero_file_filtered_add (BRASERO_FILE_FILTERED (priv->filter), uri, status);
+	else
+		brasero_file_filtered_remove (BRASERO_FILE_FILTERED (priv->filter), uri);
 }
 
 static void

Modified: trunk/src/brasero-data-project.c
==============================================================================
--- trunk/src/brasero-data-project.c	(original)
+++ trunk/src/brasero-data-project.c	Fri Mar 14 19:13:17 2008
@@ -784,6 +784,7 @@
 				       const gchar *uri)
 {
 	BraseroDataProjectPrivate *priv;
+	BraseroDataProjectClass *klass;
 	BraseroURINode *graft = NULL;
 	gchar *key = NULL;
 	GSList *iter;
@@ -808,6 +809,10 @@
 	/* we have to free the key and data ourselves */
 	g_hash_table_remove (priv->grafts, uri);
 
+	klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
+	if (klass->uri_removed)
+		klass->uri_removed (self, uri);
+
 	if (key && key != NEW_FOLDER)
 		brasero_utils_unregister_string (key);
 
@@ -928,6 +933,9 @@
 		iter_node = iter->data;
 		next = iter->next;
 
+		if (data->node == iter_node)
+			continue;
+
 		if (brasero_file_node_is_ancestor (data->node, iter_node))
 			graft->nodes = g_slist_remove (graft->nodes, iter_node);
 	}
@@ -1005,7 +1013,6 @@
 	 * If not, get the URI and all the nodes with the same URI and
 	 * add the list (less this node) to the hash.
 	 * NOTE: imported file case should not be addressed here*/
-
 	if (node->is_grafted) {
 		BraseroGraft *graft;
 		BraseroURINode *uri_node;

Modified: trunk/src/brasero-data-project.h
==============================================================================
--- trunk/src/brasero-data-project.h	(original)
+++ trunk/src/brasero-data-project.h	Fri Mar 14 19:13:17 2008
@@ -82,6 +82,9 @@
 	void		(*node_reordered)	(BraseroDataProject *project,
 						 BraseroFileNode *parent,
 						 gint *new_order);
+
+	void		(*uri_removed)		(BraseroDataProject *project,
+						 const gchar *uri);
 };
 
 struct _BraseroDataProject

Modified: trunk/src/brasero-data-vfs.c
==============================================================================
--- trunk/src/brasero-data-vfs.c	(original)
+++ trunk/src/brasero-data-vfs.c	Fri Mar 14 19:13:17 2008
@@ -1010,6 +1010,50 @@
 				     self);
 }
 
+static gboolean
+brasero_data_vfs_remove_filtered_uris (gpointer key,
+				       gpointer value,
+				       gpointer callback_data)
+{
+	guint len;
+	gchar *key_uri = key;
+	gchar *uri = callback_data;
+
+	/* always keep restored */
+	if (GPOINTER_TO_INT (value) == BRASERO_DATA_VFS_RESTORED)
+		return FALSE;
+
+	len = strlen (uri);
+	if (!strncmp (uri, key, len)
+	&&   key_uri [len] == G_DIR_SEPARATOR) {
+		brasero_utils_unregister_string (key);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static void
+brasero_data_vfs_uri_removed (BraseroDataProject *project,
+			      const gchar *uri)
+{
+	BraseroDataVFSPrivate *priv;
+
+	priv = BRASERO_DATA_VFS_PRIVATE (project);
+
+	/* That happens when a graft is removed from the tree, that is when this
+	 * graft uri doesn't appear anywhere and when it hasn't got any more 
+	 * parent uri grafted. */
+	g_hash_table_foreach_remove (priv->filtered,
+				     brasero_data_vfs_remove_filtered_uris,
+				     (gpointer) uri);
+	g_signal_emit (project,
+		       brasero_data_vfs_signals [FILTERED_SIGNAL],
+		       0,
+		       BRASERO_FILTER_NONE,
+		       uri);
+}
+
 static void
 brasero_data_vfs_reset (BraseroDataProject *project)
 {
@@ -1090,6 +1134,7 @@
 
 	data_project_class->reset = brasero_data_vfs_reset;
 	data_project_class->node_added = brasero_data_vfs_node_added;
+	data_project_class->uri_removed = brasero_data_vfs_uri_removed;
 
 	/* There is no need to implement the other virtual functions.
 	 * For example, even if we were notified of a node removal it 

Modified: trunk/src/brasero-data-vfs.h
==============================================================================
--- trunk/src/brasero-data-vfs.h	(original)
+++ trunk/src/brasero-data-vfs.h	Fri Mar 14 19:13:17 2008
@@ -35,7 +35,9 @@
 #define BRASERO_FILTER_BROKEN_SYM_KEY		"/apps/brasero/filter/broken_sym"
 
 typedef enum {
-	BRASERO_FILTER_HIDDEN = 1,
+	/* Following means it has been removed */
+	BRASERO_FILTER_NONE			= 0,
+	BRASERO_FILTER_HIDDEN			= 1,
 	BRASERO_FILTER_UNREADABLE,
 	BRASERO_FILTER_BROKEN_SYM,
 	BRASERO_FILTER_RECURSIVE_SYM,

Modified: trunk/src/brasero-file-filtered.c
==============================================================================
--- trunk/src/brasero-file-filtered.c	(original)
+++ trunk/src/brasero-file-filtered.c	Fri Mar 14 19:13:17 2008
@@ -26,6 +26,8 @@
 #  include <config.h>
 #endif
 
+#include <string.h>
+
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
@@ -135,6 +137,60 @@
 }
 
 void
+brasero_file_filtered_remove (BraseroFileFiltered *self,
+			      const gchar *uri)
+{
+	BraseroFileFilteredPrivate *priv;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	guint len;
+
+	priv = BRASERO_FILE_FILTERED_PRIVATE (self);
+
+	model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree));
+	if (!gtk_tree_model_get_iter_first (model, &iter))
+		return;
+
+	len = strlen (uri);
+	while (1) {
+		gchar *iter_uri;
+
+		iter_uri = NULL;
+		gtk_tree_model_get (model, &iter,
+				    UNESCAPED_URI_COL, &iter_uri,
+				    -1);
+
+		if (!iter_uri)
+			continue;
+
+		if (!strcmp (uri, iter_uri)) {
+			g_free (iter_uri);
+			priv->num --;
+			if (!gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
+				break;
+
+			continue;
+		}
+
+		if (!strncmp (uri, iter_uri, len)
+		&&   iter_uri [len] == G_DIR_SEPARATOR) {
+			g_free (iter_uri);
+			priv->num --;
+			if (!gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
+				break;
+
+			continue;
+		}
+
+		g_free (iter_uri);
+		if (!gtk_tree_model_iter_next (model, &iter))
+			break;
+	}
+
+	brasero_file_filtered_update (self);
+}
+
+void
 brasero_file_filtered_add (BraseroFileFiltered *self,
 			   const gchar *uri,
 			   BraseroFilterStatus status)
@@ -169,9 +225,8 @@
 			    URI_COL, uri,
 			    TYPE_COL, _(type),
 			    STATUS_COL, status,
-		    ACTIVABLE_COL, (status != BRASERO_FILTER_UNREADABLE && status != BRASERO_FILTER_RECURSIVE_SYM),
+			    ACTIVABLE_COL, (status != BRASERO_FILTER_UNREADABLE && status != BRASERO_FILTER_RECURSIVE_SYM),
 			    -1);
-
 	g_free (unescaped_uri);
 
 	/* update label */

Modified: trunk/src/brasero-file-filtered.h
==============================================================================
--- trunk/src/brasero-file-filtered.h	(original)
+++ trunk/src/brasero-file-filtered.h	Fri Mar 14 19:13:17 2008
@@ -71,6 +71,11 @@
 brasero_file_filtered_add (BraseroFileFiltered *filter,
 			   const gchar *uri,
 			   BraseroFilterStatus status);
+
+void
+brasero_file_filtered_remove (BraseroFileFiltered *filter,
+			      const gchar *uri);
+
 void
 brasero_file_filtered_clear (BraseroFileFiltered *self);
 



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