brasero r788 - in trunk: . src



Author: philippr
Date: Sat May  3 18:08:31 2008
New Revision: 788
URL: http://svn.gnome.org/viewvc/brasero?rev=788&view=rev

Log:
	Fix for #439916 â Popups are user-unfriendly
	Fixes for data project:
	- fix some problems at load time where GtkTreePaths weren\'t right if a created node had not been added
	- use registered URI in callbacks for g_hash_lookup instead of returned ones (they may be different)

	Fixes for Gio:
	- handle relative paths with symlinks

	* src/brasero-data-disc.c (brasero_data_disc_project_loaded_cb),
	(brasero_data_disc_init):
	* src/brasero-data-project.c (brasero_data_project_node_loaded),
	(brasero_data_project_directory_node_loaded),
	(brasero_data_project_add_path),
	(brasero_data_project_load_contents):
	* src/brasero-data-tree-model.c
	(brasero_data_tree_model_node_index),
	(brasero_data_tree_model_node_to_path),
	(brasero_data_tree_model_get_path),
	(brasero_data_tree_model_node_added),
	(brasero_data_tree_model_node_reordered):
	* src/brasero-data-vfs.c (brasero_data_vfs_load_directory),
	(brasero_data_vfs_loading_node_result),
	(brasero_data_vfs_node_added):
	* src/brasero-disc-message.c (brasero_disc_message_set_context),
	(brasero_disc_message_get_context):
	* src/brasero-disc-message.h:
	* src/brasero-io.c (brasero_io_check_for_parent_symlink),
	(brasero_io_get_file_info_thread):
	* src/brasero-project.c (brasero_project_init),
	(brasero_project_message_remove_all),
	(brasero_project_message_remove), (brasero_project_message),
	(brasero_project_error_size_dialog), (brasero_project_check_size),
	(brasero_project_switch):


Modified:
   trunk/ChangeLog
   trunk/src/brasero-data-disc.c
   trunk/src/brasero-data-project.c
   trunk/src/brasero-data-tree-model.c
   trunk/src/brasero-data-vfs.c
   trunk/src/brasero-disc-message.c
   trunk/src/brasero-disc-message.h
   trunk/src/brasero-io.c
   trunk/src/brasero-project.c

Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c	(original)
+++ trunk/src/brasero-data-disc.c	Sat May  3 18:08:31 2008
@@ -703,7 +703,7 @@
 						   (gdouble) (priv->loading - loading) / (gdouble) priv->loading);
 		return;
 	}
-g_warning ("REACHED\n");
+
 	priv->loading = 0;
 	if (priv->load_errors) {
 		brasero_disc_message_remove_buttons (BRASERO_DISC_MESSAGE (priv->message));
@@ -2038,7 +2038,7 @@
 
 	priv = BRASERO_DATA_DISC_PRIVATE (object);
 
-	gtk_box_set_spacing (GTK_BOX (object), 12);
+	gtk_box_set_spacing (GTK_BOX (object), 0);
 
 	/* message area */
 	priv->message = brasero_disc_message_new ();

Modified: trunk/src/brasero-data-project.c
==============================================================================
--- trunk/src/brasero-data-project.c	(original)
+++ trunk/src/brasero-data-project.c	Sat May  3 18:08:31 2008
@@ -1676,8 +1676,8 @@
 
 			/* exclude the URI we're replacing */
 			brasero_data_project_exclude_uri (self, uri);
-
 			brasero_file_node_ungraft (node);
+
 			graft = brasero_data_project_uri_ensure_graft (self, NEW_FOLDER);
 			brasero_file_node_graft (node, graft);
 			brasero_data_project_node_changed (self, node);
@@ -1737,6 +1737,7 @@
 
 		/* first we exclude the symlink, then we graft its target. */
 		uri = brasero_data_project_node_to_uri (self, node);
+		brasero_file_node_ungraft (node);
 		brasero_data_project_exclude_uri (self, uri);
 		g_free (uri);
 
@@ -1821,6 +1822,7 @@
 			       brasero_data_project_signals [SIZE_CHANGED_SIGNAL],
 			       0);
 }
+
 BraseroFileNode *
 brasero_data_project_add_loading_node (BraseroDataProject *self,
 				       const gchar *uri,
@@ -1882,7 +1884,7 @@
 	BraseroDataProjectPrivate *priv;
 
 	priv = BRASERO_DATA_PROJECT_PRIVATE (self);
-g_warning ("DIRECTORY %s\n", BRASERO_FILE_NODE_NAME (parent));
+
 	/* Mostly useful at project load time. */
 	if (priv->loading) {
 		if (parent->is_grafted || parent->is_tmp_parent) {
@@ -2475,9 +2477,9 @@
 
 	/* create the missing parents if needed */
 	parent = brasero_data_project_create_path (self,
-						    parent,
-						    &path,
-						    &folders);
+						   parent,
+						   &path,
+						   &folders);
 
 	/* Now that we ensured that the parent path exists add the final node */
 
@@ -2494,7 +2496,6 @@
 		 * There is already a graft since it is a fake so remove it from
 		 * previous graft and add the new one (it needs to be grafted). */
 		node->is_tmp_parent = FALSE;
-
 		brasero_file_node_graft (node, graft);
 		folders = g_slist_remove (folders, node);
 
@@ -2528,6 +2529,7 @@
 		}
 	}
 	else if (node) {
+		g_warning ("Already existing node");
 		/* error: the path exists twice. That shouldn't happen */
 		return folders;
 	}
@@ -2551,6 +2553,7 @@
 						    graft,
 						    uri);
 	}
+
 	return folders;
 }
 
@@ -2679,7 +2682,6 @@
 								 folders);
 	}
 
-
 	/* Now load the temporary folders that were created */
 	klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
 	priv = BRASERO_DATA_PROJECT_PRIVATE (self);

Modified: trunk/src/brasero-data-tree-model.c
==============================================================================
--- trunk/src/brasero-data-tree-model.c	(original)
+++ trunk/src/brasero-data-tree-model.c	Sat May  3 18:08:31 2008
@@ -629,6 +629,30 @@
 	return;
 }
 
+/**
+ * This is a function mainly used at project load time. In this context there
+ * can be nodes that have been added to the data project tree but not added 
+ * through the model. Don't count those nodes.
+ */
+static guint
+brasero_data_tree_model_node_index (BraseroFileNode *node)
+{
+	BraseroFileNode *parent;
+	BraseroFileNode *peers;
+	guint pos = 0;
+
+	parent = node->parent;
+	for (peers = BRASERO_FILE_NODE_CHILDREN (parent); peers; peers = peers->next) {
+		if (peers == node)
+			break;
+		if (!peers->is_visible)
+			continue;
+		pos ++;
+	}
+
+	return pos;
+}
+
 GtkTreePath *
 brasero_data_tree_model_node_to_path (BraseroDataTreeModel *self,
 				      BraseroFileNode *node)
@@ -642,7 +666,7 @@
 	for (; node->parent && !node->is_root; node = node->parent) {
 		guint nth;
 
-		nth = brasero_file_node_get_pos_as_child (node);
+		nth = brasero_data_tree_model_node_index (node);
 		gtk_tree_path_prepend_index (path, nth);
 	}
 
@@ -670,7 +694,7 @@
 	for (; node->parent && BRASERO_FILE_NODE_NAME (node); node = node->parent) {
 		guint nth;
 
-		nth = brasero_file_node_get_pos_as_child (node);
+		nth = brasero_data_tree_model_node_index (node);
 		gtk_tree_path_prepend_index (path, nth);
 	}
 
@@ -1160,7 +1184,7 @@
 	if (BRASERO_DATA_PROJECT_CLASS (brasero_data_tree_model_parent_class)->reset)
 		BRASERO_DATA_PROJECT_CLASS (brasero_data_tree_model_parent_class)->reset (project, num_nodes);
 }
-
+guint tintin = 1;
 static gboolean
 brasero_data_tree_model_node_added (BraseroDataProject *project,
 				    BraseroFileNode *node,
@@ -1195,6 +1219,7 @@
 	}
 
 	/* Add the row itself */
+	
 	gtk_tree_model_row_inserted (GTK_TREE_MODEL (project),
 				     path,
 				     &iter);
@@ -1407,6 +1432,7 @@
 					       treepath,
 					       NULL,
 					       new_order);
+
 	gtk_tree_path_free (treepath);
 
 end:

Modified: trunk/src/brasero-data-vfs.c
==============================================================================
--- trunk/src/brasero-data-vfs.c	(original)
+++ trunk/src/brasero-data-vfs.c	Sat May  3 18:08:31 2008
@@ -529,7 +529,7 @@
 	GSList *nodes;
 
 	priv = BRASERO_DATA_VFS_PRIVATE (self);
-g_warning ("REA %s\n", uri);
+
 	/* Start exploration of directory*/
 	reference = brasero_data_project_reference_new (BRASERO_DATA_PROJECT (self), node);
 
@@ -604,15 +604,15 @@
 				      GError *error,
 				      const gchar *uri,
 				      GFileInfo *info,
-				      gpointer NULL_data)
+				      gpointer callback_data)
 {
 	GSList *iter;
 	GSList *nodes;
+	gchar *registered = callback_data;
 	BraseroDataVFS *self = BRASERO_DATA_VFS (owner);
 	BraseroDataVFSPrivate *priv = BRASERO_DATA_VFS_PRIVATE (self);
 
-	nodes = g_hash_table_lookup (priv->loading, uri);
-
+	nodes = g_hash_table_lookup (priv->loading, registered);
 	/* check the status of the operation */
 	if (!brasero_data_vfs_check_uri_result (self, uri, error, info)) {
 		/* we need to remove the loading node that is waiting */
@@ -628,9 +628,9 @@
 		return;
 	}
 
-	/* NOTE: we don't check for a broken symlink here since the
-	 * user chose to add it. So even if it were we would have to 
-	 * add it. The same for hidden files. */
+	/* NOTE: we don't check for a broken symlink here since the  user chose
+	 * to add it. So even if it were we would have to add it. The same for
+	 * hidden files. */
 	for (iter = nodes; iter; iter = iter->next) {
 		guint reference;
 		BraseroFileNode *node;
@@ -640,6 +640,7 @@
 		/* check if the node still exists */
 		node = brasero_data_project_reference_get (BRASERO_DATA_PROJECT (self), reference);
 		brasero_data_project_reference_free (BRASERO_DATA_PROJECT (self), reference);
+
 		if (!node)
 			continue;
 
@@ -653,6 +654,7 @@
 		/* NOTE: check is loading here on purpose. Otherwise directories
 		 * that replace a temp parent wouldn't load since they are also
 		 * reloading. */
+
 		if (!node->is_loading) {
 			brasero_data_project_node_reloaded (BRASERO_DATA_PROJECT (self), node, uri, info);
 			continue;
@@ -932,7 +934,7 @@
 		if (brasero_data_vfs_loading_node (self, node, uri))
 			goto chain;
 
-		return FALSE;
+		goto chain;
 	}
 
 	/* NOTE: a symlink pointing to a directory will return TRUE. */

Modified: trunk/src/brasero-disc-message.c
==============================================================================
--- trunk/src/brasero-disc-message.c	(original)
+++ trunk/src/brasero-disc-message.c	Sat May  3 18:08:31 2008
@@ -73,6 +73,8 @@
 	GtkWidget *button_box;
 	GtkWidget *text_box;
 
+	guint context;
+
 	guint id;
 
 	guint changing_style:1;
@@ -99,6 +101,26 @@
 	NUM_COL
 };
 
+
+void
+brasero_disc_message_set_context (BraseroDiscMessage *self,
+				  guint context_id)
+{
+	BraseroDiscMessagePrivate *priv;
+
+	priv = BRASERO_DISC_MESSAGE_PRIVATE (self);
+	priv->context = context_id;
+}
+
+guint
+brasero_disc_message_get_context (BraseroDiscMessage *self)
+{
+	BraseroDiscMessagePrivate *priv;
+
+	priv = BRASERO_DISC_MESSAGE_PRIVATE (self);
+	return priv->context;
+}
+
 static void
 brasero_disc_message_expander_activated_cb (GtkExpander *expander,
 					    BraseroDiscMessage *self)

Modified: trunk/src/brasero-disc-message.h
==============================================================================
--- trunk/src/brasero-disc-message.h	(original)
+++ trunk/src/brasero-disc-message.h	Sat May  3 18:08:31 2008
@@ -90,6 +90,13 @@
 void
 brasero_disc_message_remove_errors (BraseroDiscMessage *message);
 
+void
+brasero_disc_message_set_context (BraseroDiscMessage *message,
+				  guint context_id);
+
+guint
+brasero_disc_message_get_context (BraseroDiscMessage *message);
+
 G_END_DECLS
 
 #endif /* _BRASERO_DISC_MESSAGE_H_ */

Modified: trunk/src/brasero-io.c
==============================================================================
--- trunk/src/brasero-io.c	(original)
+++ trunk/src/brasero-io.c	Sat May  3 18:08:31 2008
@@ -476,7 +476,20 @@
 
 		    	parent_uri = g_file_get_uri (parent);
 			target_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET);
-			new_root = g_filename_to_uri (target_path, NULL, NULL);
+
+			/* check if this is not a relative path */
+			 if (!g_path_is_absolute (target_path)) {
+				gchar *tmp;
+
+				tmp = g_path_get_dirname (parent_uri);
+				new_root = g_build_path (G_DIR_SEPARATOR_S,
+							 tmp,
+							 target_path,
+							 NULL);
+				g_free (tmp);
+			}
+			else
+				new_root = g_filename_to_uri (target_path, NULL, NULL);
 
 			newuri = g_strconcat (new_root,
 					      uri + strlen (parent_uri),
@@ -730,7 +743,6 @@
 				  G_FILE_QUERY_INFO_NONE,	/* follow symlinks */
 				  cancel,
 				  &error);
-
 	if (error) {
 		brasero_io_return_result (BRASERO_IO (manager),
 					  job->base,

Modified: trunk/src/brasero-project.c
==============================================================================
--- trunk/src/brasero-project.c	(original)
+++ trunk/src/brasero-project.c	Sat May  3 18:08:31 2008
@@ -76,6 +76,7 @@
 #include "brasero-utils.h"
 #include "brasero-uri-container.h"
 #include "brasero-layout-object.h"
+#include "brasero-disc-message.h"
 
 static void brasero_project_class_init (BraseroProjectClass *klass);
 static void brasero_project_init (BraseroProject *sp);
@@ -155,6 +156,8 @@
 	GtkWidget *audio;
 	GtkWidget *data;
 
+	GtkWidget *message;
+
 	GtkUIManager *manager;
 
 	/* header */
@@ -253,6 +256,13 @@
 
 #define BRASERO_PROJECT_VERSION "0.2"
 
+typedef enum {
+	BRASERO_PROJECT_MESSAGE_NONE 		= 0,
+	BRASERO_PROJECT_MESSAGE_SIZE 		= 1,
+	BRASERO_PROJECT_MESSAGE_PROJECT		= 2,
+	BRASERO_PROJECT_MESSAGE_STATUS		= 3
+} BraseroProjectMessageType;
+
 GType
 brasero_project_get_type ()
 {
@@ -387,6 +397,10 @@
 			  G_CALLBACK (brasero_project_focus_changed_cb),
 			  NULL);
 
+	obj->priv->message = gtk_vbox_new (FALSE, 12);
+	gtk_box_pack_start (GTK_BOX (obj), obj->priv->message, FALSE, TRUE, 0);
+	gtk_widget_show (obj->priv->message);
+
 	/* bottom */
 	box = gtk_hbox_new (FALSE, 6);
 	gtk_widget_show (box);
@@ -509,26 +523,69 @@
 
 /********************************** size ***************************************/
 static void
-brasero_project_error_size_dialog (BraseroProject *project)
+brasero_project_message_remove_all (BraseroProject *project)
 {
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
+	GList *children;
+	GList *iter;
 
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT |
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("Please, delete some files from the project."));
+	children = gtk_container_get_children (GTK_CONTAINER (project->priv->message));
+	for (iter = children; iter; iter = iter->next) {
+		GtkWidget *widget;
 
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Project size"));
+		widget = iter->data;
+		gtk_widget_destroy (widget);
+	}
+	g_list_free (children);
+}
 
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("The size of the project is too large for the disc even with the overburn option."));
+static void
+brasero_project_message_remove (BraseroProject *project,
+				guint context_id)
+{
+	GList *children;
+	GList *iter;
 
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
+	children = gtk_container_get_children (GTK_CONTAINER (project->priv->message));
+	for (iter = children; iter; iter = iter->next) {
+		GtkWidget *widget;
+
+		widget = iter->data;
+		if (brasero_disc_message_get_context (BRASERO_DISC_MESSAGE (widget)) == context_id) {
+			gtk_widget_destroy (widget);
+			break;
+		}
+	}
+	g_list_free (children);
+}
+
+static GtkWidget *
+brasero_project_message (BraseroProject *project,
+			 const gchar *primary,
+			 const gchar *secondary,
+			 guint context_id)
+{
+	GtkWidget *message;
+
+	brasero_project_message_remove (project, context_id);
+
+	message = brasero_disc_message_new ();
+	brasero_disc_message_set_context (BRASERO_DISC_MESSAGE (message), context_id);
+	brasero_disc_message_set_primary (BRASERO_DISC_MESSAGE (message), primary);
+	brasero_disc_message_set_secondary (BRASERO_DISC_MESSAGE (message), secondary);
+	gtk_widget_show (message);
+	gtk_box_pack_start (GTK_BOX (project->priv->message), message, FALSE, TRUE, 0);
+
+	return message;
+}
+
+
+static void
+brasero_project_error_size_dialog (BraseroProject *project)
+{
+	brasero_project_message (project,
+				 _("Please, delete some files from the project."),
+				 _("The size of the project is too large for the disc even with the overburn option."),
+				 BRASERO_PROJECT_MESSAGE_SIZE);
 }
 
 static gboolean
@@ -580,6 +637,7 @@
 						    &overburn);
 
 	if (result) {
+		brasero_project_message_remove (project, BRASERO_PROJECT_MESSAGE_SIZE);
 		project->priv->oversized = 0;
 		goto end;
 	}
@@ -594,6 +652,7 @@
 	}
 
 	if (overburn) {
+		brasero_project_message_remove (project, BRASERO_PROJECT_MESSAGE_SIZE);
 		project->priv->oversized = 0;
 		goto end;
 	}
@@ -1115,6 +1174,8 @@
 		brasero_project_size_set_context (BRASERO_PROJECT_SIZE (project->priv->size_display), FALSE);
 	}
 
+	brasero_project_message_remove_all (project);
+
 	/* update the menus */
 	action = gtk_action_group_get_action (project->priv->project_group, "Add");
 	gtk_action_set_visible (action, TRUE);



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