[brasero: 9/18] Some more fixes and leaks fixed



commit c971073947bbe8b02221f4530dec84bb95ecb1da
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Thu Apr 30 21:09:46 2009 +0200

    Some more fixes and leaks fixed
---
 libbrasero-burn/brasero-data-project.c   |    6 ++-
 libbrasero-burn/brasero-track-data-cfg.c |  105 ++++++++++++++++++++++++++----
 src/brasero-data-disc.c                  |   22 +-----
 src/brasero-filter-option.c              |    1 -
 4 files changed, 102 insertions(+), 32 deletions(-)

diff --git a/libbrasero-burn/brasero-data-project.c b/libbrasero-burn/brasero-data-project.c
index 19d6f8a..1d0871f 100644
--- a/libbrasero-burn/brasero-data-project.c
+++ b/libbrasero-burn/brasero-data-project.c
@@ -2387,7 +2387,11 @@ brasero_data_project_get_contents (BraseroDataProject *self,
 				      &callback_data);
 	}
 
-	if (grafts)
+	if (!grafts) {
+		g_slist_foreach (callback_data.grafts, (GFunc) brasero_graft_point_free, NULL);
+		g_slist_free (callback_data.grafts);
+	}
+	else
 		*grafts = callback_data.grafts;
 
 	if (!unreadable) {
diff --git a/libbrasero-burn/brasero-track-data-cfg.c b/libbrasero-burn/brasero-track-data-cfg.c
index 53f08ae..9cc5aeb 100644
--- a/libbrasero-burn/brasero-track-data-cfg.c
+++ b/libbrasero-burn/brasero-track-data-cfg.c
@@ -349,7 +349,7 @@ brasero_track_data_cfg_iter_next (GtkTreeModel *model,
 
 static void
 brasero_track_data_cfg_node_shown (GtkTreeModel *model,
-				    GtkTreeIter *iter)
+				   GtkTreeIter *iter)
 {
 	BraseroFileNode *node;
 	BraseroTrackDataCfgPrivate *priv;
@@ -377,8 +377,18 @@ brasero_track_data_cfg_node_shown (GtkTreeModel *model,
 		return;
 	}
 
-	if (node->parent && !node->parent->is_root)
-		node->parent->is_expanded = TRUE;
+	if (node->parent && !node->parent->is_root) {
+		if (!node->parent->is_expanded) {
+			GtkTreePath *treepath;
+
+			node->parent->is_expanded = TRUE;
+			treepath = gtk_tree_model_get_path (model, iter);
+			gtk_tree_model_row_changed (model,
+						    treepath,
+						    iter);
+			gtk_tree_path_free (treepath);
+		}
+	}
 
 	if (!node)
 		return;
@@ -432,8 +442,18 @@ brasero_track_data_cfg_node_hidden (GtkTreeModel *model,
 		return;
 	}
 
-	if (node->parent && !node->parent->is_root)
-		node->parent->is_expanded = FALSE;
+	if (node->parent && !node->parent->is_root) {
+		if (node->parent->is_expanded) {
+			GtkTreePath *treepath;
+
+			node->parent->is_expanded = FALSE;
+			treepath = gtk_tree_model_get_path (model, iter);
+			gtk_tree_model_row_changed (model,
+						    treepath,
+						    iter);
+			gtk_tree_path_free (treepath);
+		}
+	}
 
 	if (!node)
 		return;
@@ -512,6 +532,26 @@ brasero_track_data_cfg_get_value (GtkTreeModel *model,
 			g_value_set_string (value, NULL);
 			return;
 
+		case BRASERO_DATA_TREE_MODEL_IS_FILE:
+			g_value_init (value, G_TYPE_BOOLEAN);
+			g_value_set_boolean (value, FALSE);
+			return;
+
+		case BRASERO_DATA_TREE_MODEL_IS_LOADING:
+			g_value_init (value, G_TYPE_BOOLEAN);
+			g_value_set_boolean (value, FALSE);
+			return;
+
+		case BRASERO_DATA_TREE_MODEL_IS_IMPORTED:
+			g_value_init (value, G_TYPE_BOOLEAN);
+			g_value_set_boolean (value, FALSE);
+			return;
+
+		case BRASERO_DATA_TREE_MODEL_URI:
+			g_value_init (value, G_TYPE_STRING);
+			g_value_set_string (value, NULL);
+			return;
+
 		default:
 			return;
 		}
@@ -522,7 +562,7 @@ brasero_track_data_cfg_get_value (GtkTreeModel *model,
 	switch (column) {
 	case BRASERO_DATA_TREE_MODEL_EDITABLE:
 		g_value_init (value, G_TYPE_BOOLEAN);
-		g_value_set_boolean (value, (node->is_imported == FALSE) && node->is_selected);
+		g_value_set_boolean (value, (node->is_imported == FALSE)/* && node->is_selected*/);
 		return;
 
 	case BRASERO_DATA_TREE_MODEL_NAME: {
@@ -1540,16 +1580,37 @@ brasero_track_data_cfg_add_empty_directory (BraseroTrackDataCfg *track,
 {
 	BraseroTrackDataCfgPrivate *priv;
 	BraseroFileNode *parent_node;
+	gchar *default_name = NULL;
 	BraseroFileNode *node;
 
 	g_return_val_if_fail (BRASERO_TRACK_DATA_CFG (track), FALSE);
-	priv = BRASERO_TRACK_DATA_CFG_PRIVATE (track);
 
+	priv = BRASERO_TRACK_DATA_CFG_PRIVATE (track);
 	if (priv->loading)
 		return NULL;
 
 	parent_node = brasero_track_data_cfg_path_to_node (track, parent);
-	node = brasero_data_project_add_empty_directory (BRASERO_DATA_PROJECT (priv->tree), name, parent_node);
+	if (parent_node->is_file)
+		parent_node = parent_node->parent;
+
+	if (!name) {
+		guint nb = 1;
+
+		default_name = g_strdup_printf (_("New folder"));
+		while (brasero_file_node_check_name_existence (parent_node, default_name)) {
+			g_free (default_name);
+			default_name = g_strdup_printf (_("New folder %i"), nb);
+			nb++;
+		}
+
+	}
+
+	node = brasero_data_project_add_empty_directory (BRASERO_DATA_PROJECT (priv->tree),
+							 name? name:default_name,
+							 parent_node);
+	if (default_name)
+		g_free (default_name);
+
 	if (!node)
 		return NULL;
 
@@ -1593,14 +1654,32 @@ gboolean
 brasero_track_data_cfg_reset (BraseroTrackDataCfg *track)
 {
 	BraseroTrackDataCfgPrivate *priv;
+	BraseroFileNode *root;
+	GtkTreePath *treepath;
+	guint num;
+	guint i;
 
 	g_return_val_if_fail (BRASERO_TRACK_DATA_CFG (track), FALSE);
 	priv = BRASERO_TRACK_DATA_CFG_PRIVATE (track);
 	if (priv->loading)
 		return FALSE;
 
-	priv->loading = 0;
+	root = brasero_data_project_get_root (BRASERO_DATA_PROJECT (priv->tree));
+	num = brasero_file_node_get_n_children (root);
+
 	brasero_data_project_reset (BRASERO_DATA_PROJECT (priv->tree));
+
+	treepath = gtk_tree_path_new_first ();
+	for (i = 0; i < num; i++)
+		gtk_tree_model_row_deleted (GTK_TREE_MODEL (track), treepath);
+	gtk_tree_path_free (treepath);
+
+	g_slist_free (priv->shown);
+	priv->shown = NULL;
+
+	priv->G2_files = FALSE;
+	priv->deep_directory = FALSE;
+
 	return TRUE;
 }
 
@@ -1721,6 +1800,7 @@ brasero_track_data_cfg_set_source (BraseroTrackData *track,
 	priv->loading = brasero_data_project_load_contents (BRASERO_DATA_PROJECT (priv->tree),
 							    grafts,
 							    excluded);
+
 	if (!priv->loading)
 		return BRASERO_BURN_OK;
 
@@ -1774,6 +1854,7 @@ brasero_track_data_cfg_get_grafts (BraseroTrackData *track)
 	priv = BRASERO_TRACK_DATA_CFG_PRIVATE (track);
 
 	/* append a slash for mkisofs */
+	fs_type = brasero_track_data_cfg_get_fs (track);
 	brasero_data_project_get_contents (BRASERO_DATA_PROJECT (priv->tree),
 					   &grafts,
 					   NULL,
@@ -1792,6 +1873,7 @@ brasero_track_data_cfg_get_excluded (BraseroTrackData *track)
 	priv = BRASERO_TRACK_DATA_CFG_PRIVATE (track);
 
 	/* append a slash for mkisofs */
+	fs_type = brasero_track_data_cfg_get_fs (track);
 	brasero_data_project_get_contents (BRASERO_DATA_PROJECT (priv->tree),
 					   NULL,
 					   &unreadable,
@@ -1843,7 +1925,7 @@ brasero_track_data_cfg_get_status (BraseroTrack *track,
 	if (priv->loading) {
 		brasero_status_set_not_ready (status,
 					      (gdouble) (priv->loading - priv->loading_remaining) / (gdouble) priv->loading,
-					      g_strdup (_("Analysing files")));
+					      _("Analysing files"));
 		return BRASERO_BURN_NOT_READY;
 	}
 
@@ -1853,7 +1935,7 @@ brasero_track_data_cfg_get_status (BraseroTrack *track,
 		if (status)
 			brasero_status_set_not_ready (status,
 						      -1.0,
-						      g_strdup (_("Analysing files")));
+						      _("Analysing files"));
 
 		return BRASERO_BURN_NOT_READY;
 	}
@@ -2193,7 +2275,6 @@ brasero_track_data_cfg_init (BraseroTrackDataCfg *object)
 	} while (!priv->stamp);
 
 	priv->theme = gtk_icon_theme_get_default ();
-
 	priv->tree = brasero_data_tree_model_new ();
 
 	g_signal_connect (priv->tree,
diff --git a/src/brasero-data-disc.c b/src/brasero-data-disc.c
index 1f85344..5a2f5a1 100644
--- a/src/brasero-data-disc.c
+++ b/src/brasero-data-disc.c
@@ -316,28 +316,13 @@ brasero_data_disc_new_folder_clicked_cb (GtkButton *button,
 	GtkTreeViewColumn *column;
 	GtkTreePath *treepath;
 	GtkTreePath *parent;
-	gchar *name;
-	gint nb;
 
 	priv = BRASERO_DATA_DISC_PRIVATE (disc);
 	if (priv->reject_files)
 		return;
 
 	parent = brasero_data_disc_get_parent (disc);
-	name = g_strdup_printf (_("New folder"));
-	nb = 1;
-
-newname:
-
-	/* just to make sure that tree is not hidden behind info */
-	treepath = brasero_track_data_cfg_add_empty_directory (BRASERO_TRACK_DATA_CFG (priv->project), name, parent);
-	if (!treepath) {
-		g_free (name);
-		name = g_strdup_printf (_("New folder %i"), nb);
-		nb++;
-		goto newname;
-	}
-
+	treepath = brasero_track_data_cfg_add_empty_directory (BRASERO_TRACK_DATA_CFG (priv->project), NULL, parent);
 	gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
 
 	/* grab focus must be called before next function to avoid
@@ -351,7 +336,6 @@ newname:
 				  column,
 				  TRUE);
 	gtk_tree_path_free (treepath);
-	g_free (name);
 }
 
 struct _BraseroClipData {
@@ -1418,6 +1402,8 @@ brasero_data_disc_load_track (BraseroDisc *disc,
 	res = brasero_track_data_set_source (BRASERO_TRACK_DATA (priv->project),
 					     track->contents.data.grafts,
 					     track->contents.data.excluded);
+
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
 	if (res == BRASERO_BURN_OK) {
 		brasero_status_free (status);
 		gtk_widget_set_sensitive (GTK_WIDGET (priv->tree), TRUE);
@@ -1987,7 +1973,7 @@ brasero_data_disc_button_pressed_cb (GtkTreeView *tree,
 			if (!is_imported)
 				priv->selected = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->project), treepath);
 		}
-		else if ((event->state & GDK_SHIFT_MASK) == 0)
+		else if (treepath && (event->state & GDK_SHIFT_MASK) == 0)
 			priv->selected = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->project), treepath);
 		else
 			priv->selected = NULL;
diff --git a/src/brasero-filter-option.c b/src/brasero-filter-option.c
index 9b89e46..4c62a1e 100644
--- a/src/brasero-filter-option.c
+++ b/src/brasero-filter-option.c
@@ -35,7 +35,6 @@
 #include "brasero-misc.h"
 
 #include "brasero-filter-option.h"
-#include "brasero-data-project.h"
 #include "brasero-data-vfs.h"
 
 typedef struct _BraseroFilterOptionPrivate BraseroFilterOptionPrivate;



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