brasero r1491 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1491 - in trunk: . src
- Date: Sat, 8 Nov 2008 13:02:23 +0000 (UTC)
Author: philippr
Date: Sat Nov 8 13:02:22 2008
New Revision: 1491
URL: http://svn.gnome.org/viewvc/brasero?rev=1491&view=rev
Log:
Implement a much better way to strengthen project loading avoiding the
use of a virtual function freeze (reverts a previous patch).
* src/brasero-data-project.c (brasero_data_project_add_node_real),
(brasero_data_project_add_path),
(brasero_data_project_load_contents_notify_directory),
(brasero_data_project_load_contents_notify),
(brasero_data_project_load_contents):
* src/brasero-data-project.h:
* src/brasero-data-tree-model.c
(brasero_data_tree_model_node_added),
(brasero_data_tree_model_node_removed),
(brasero_data_tree_model_node_changed),
(brasero_data_tree_model_node_reordered),
(brasero_data_tree_model_class_init):
Modified:
trunk/ChangeLog
trunk/src/brasero-data-project.c
trunk/src/brasero-data-project.h
trunk/src/brasero-data-tree-model.c
Modified: trunk/src/brasero-data-project.c
==============================================================================
--- trunk/src/brasero-data-project.c (original)
+++ trunk/src/brasero-data-project.c Sat Nov 8 13:02:22 2008
@@ -70,6 +70,8 @@
/* This is a counter for the number of files to be loaded */
guint loading;
+
+ guint is_loading_contents:1;
};
#define BRASERO_DATA_PROJECT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DATA_PROJECT, BraseroDataProjectPrivate))
@@ -1561,6 +1563,9 @@
if (strlen (BRASERO_FILE_NODE_NAME (node)) > 64)
brasero_data_project_joliet_add_node (self, node);
+ if (priv->is_loading_contents)
+ return;
+
/* Signal that something has changed in the tree */
klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
if (klass->node_added)
@@ -2737,9 +2742,8 @@
/* decrement that since we're not going to load anything */
priv->loading -= 2;
- /* Signal that something has changed in the tree */
- if (klass->node_added)
- klass->node_added (self, node, NULL);
+ /* Don't signal the node addition yet we'll do it later
+ * when all the nodes are created */
}
else {
node->is_file = FALSE;
@@ -2750,9 +2754,8 @@
/* No need to increment priv->loading here since that
* was done at the creation of the temporary folder */
- /* Signal that something has changed in the tree */
- if (klass->node_added)
- klass->node_added (self, node, uri);
+ /* Don't signal the node addition yet we'll do it later
+ * when all the nodes are created */
}
}
else if (node) {
@@ -2880,20 +2883,61 @@
return folders;
}
+static void
+brasero_data_project_load_contents_notify_directory (BraseroDataProject *self,
+ BraseroFileNode *parent,
+ BraseroDataNodeAddedFunc func)
+{
+ BraseroFileNode *child;
+
+ child = BRASERO_FILE_NODE_CHILDREN (parent);
+ while (child) {
+ gchar *uri;
+
+ uri = brasero_data_project_node_to_uri (self, child);
+ func (self, child, uri != NEW_FOLDER? uri:NULL);
+ g_free (uri);
+
+ if (!child->is_file)
+ brasero_data_project_load_contents_notify_directory (self,
+ child,
+ func);
+
+ child = child->next;
+ }
+}
+
+static void
+brasero_data_project_load_contents_notify (BraseroDataProject *self)
+{
+ BraseroDataProjectClass *klass;
+ BraseroDataProjectPrivate *priv;
+
+ klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
+ if (!klass->node_added)
+ return;
+
+ priv = BRASERO_DATA_PROJECT_PRIVATE (self);
+
+ /* we'll notify for every single node in the tree starting from the top.
+ * NOTE: at this point there are only grafted nodes (fake or not) in the
+ * tree. */
+ brasero_data_project_load_contents_notify_directory (self,
+ priv->root,
+ klass->node_added);
+}
+
guint
brasero_data_project_load_contents (BraseroDataProject *self,
GSList *grafts,
GSList *excluded)
{
GSList *iter;
- BraseroFileNode *node;
GSList *folders = NULL;
- BraseroDataProjectClass *klass;
BraseroDataProjectPrivate *priv;
- klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
- if (klass->freeze)
- klass->freeze (self, TRUE);
+ priv = BRASERO_DATA_PROJECT_PRIVATE (self);
+ priv->is_loading_contents = 1;
for (iter = grafts; iter; iter = iter->next) {
BraseroGraftPt *graft;
@@ -2915,8 +2959,6 @@
}
/* Now load the temporary folders that were created */
- priv = BRASERO_DATA_PROJECT_PRIVATE (self);
-
for (iter = folders; iter; iter = iter->next) {
BraseroURINode *graft;
BraseroFileNode *tmp;
@@ -2943,9 +2985,8 @@
priv->loading -= 2;
- /* Signal that something has changed in the tree */
- if (klass->node_added)
- klass->node_added (self, tmp, uri);
+ /* Don't signal the node addition yet we'll do it later
+ * when all the nodes are created */
continue;
}
@@ -2953,26 +2994,16 @@
/* graft it ? */
graft = brasero_data_project_uri_ensure_graft (self, uri);
brasero_file_node_graft (tmp, graft);
-
- /* Signal that something has changed in the tree */
- if (klass->node_added)
- klass->node_added (self, tmp, uri);
-
g_free (uri);
+
+ /* Don't signal the node addition yet we'll do it later when
+ * all the nodes are created */
}
g_slist_free (folders);
- if (klass->freeze)
- klass->freeze (self, FALSE);
+ brasero_data_project_load_contents_notify (self);
- /* Now and only now signal to the tree-model that there are new nodes */
- for (node = BRASERO_FILE_NODE_CHILDREN (priv->root); node; node = node->next) {
- gchar *uri;
-
- uri = brasero_data_project_node_to_uri (self, node);
- if (klass->node_added)
- klass->node_added (self, node, uri);
- }
+ priv->is_loading_contents = 0;
return priv->loading;
}
Modified: trunk/src/brasero-data-project.h
==============================================================================
--- trunk/src/brasero-data-project.h (original)
+++ trunk/src/brasero-data-project.h Sat Nov 8 13:02:22 2008
@@ -62,12 +62,6 @@
/* virtual functions */
/**
- * That's to tell the model whether or not to update it
- */
- void (*freeze) (BraseroDataProject *project,
- gboolean freeze);
-
- /**
* num_nodes is the number of nodes that were at the root of the
* project.
*/
Modified: trunk/src/brasero-data-tree-model.c
==============================================================================
--- trunk/src/brasero-data-tree-model.c (original)
+++ trunk/src/brasero-data-tree-model.c Sat Nov 8 13:02:22 2008
@@ -53,8 +53,6 @@
gint sort_column;
GtkSortType sort_type;
-
- guint freeze:1;
};
#define BRASERO_DATA_TREE_MODEL_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DATA_TREE_MODEL, BraseroDataTreeModelPrivate))
@@ -1162,16 +1160,6 @@
BRASERO_DATA_PROJECT_CLASS (brasero_data_tree_model_parent_class)->reset (project, num_nodes);
}
-static void
-brasero_data_tree_model_freeze (BraseroDataProject *project,
- gboolean freeze)
-{
- BraseroDataTreeModelPrivate *priv;
-
- priv = BRASERO_DATA_TREE_MODEL_PRIVATE (project);
- priv->freeze = freeze;
-}
-
static gboolean
brasero_data_tree_model_node_added (BraseroDataProject *project,
BraseroFileNode *node,
@@ -1189,8 +1177,6 @@
goto end;
priv = BRASERO_DATA_TREE_MODEL_PRIVATE (project);
- if (priv->freeze)
- goto end;
iter.stamp = priv->stamp;
iter.user_data = node;
@@ -1281,8 +1267,6 @@
goto end;
priv = BRASERO_DATA_TREE_MODEL_PRIVATE (project);
- if (priv->freeze)
- goto end;
/* remove it from the shown list and all its children as well */
priv->shown = g_slist_remove (priv->shown, node);
@@ -1345,8 +1329,6 @@
goto end;
priv = BRASERO_DATA_TREE_MODEL_PRIVATE (project);
- if (priv->freeze)
- goto end;
/* Get the iter for the node */
iter.stamp = priv->stamp;
@@ -1411,8 +1393,6 @@
goto end;
priv = BRASERO_DATA_TREE_MODEL_PRIVATE (project);
- if (priv->freeze)
- goto end;
treepath = brasero_data_tree_model_node_to_path (BRASERO_DATA_TREE_MODEL (project), parent);
if (parent != brasero_data_project_get_root (project)) {
@@ -1606,7 +1586,6 @@
vfs_class->activity_changed = brasero_data_tree_model_activity_changed;
data_project_class->reset = brasero_data_tree_model_reset;
- data_project_class->freeze = brasero_data_tree_model_freeze;
data_project_class->node_added = brasero_data_tree_model_node_added;
data_project_class->node_removed = brasero_data_tree_model_node_removed;
data_project_class->node_changed = brasero_data_tree_model_node_changed;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]