gedit r6277 - in trunk: . plugins/filebrowser
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6277 - in trunk: . plugins/filebrowser
- Date: Sun, 11 May 2008 12:24:54 +0100 (BST)
Author: jessevdk
Date: Sun May 11 11:24:54 2008
New Revision: 6277
URL: http://svn.gnome.org/viewvc/gedit?rev=6277&view=rev
Log:
* plugins/filebrowser/gedit-file-browser-store.c:
* plugins/filebrowser/gedit-file-browser-view.c:
Fixed problems with changing model when rows are inserted. This made it
possible to change the expand/collapse actions from an idle function to
immediate functions. This results in much faster 'feel' of the file
browser and also makes restoring the expanded state much faster. Also
fixed two memory leaks
Modified:
trunk/ChangeLog
trunk/plugins/filebrowser/gedit-file-browser-store.c
trunk/plugins/filebrowser/gedit-file-browser-view.c
Modified: trunk/plugins/filebrowser/gedit-file-browser-store.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-store.c (original)
+++ trunk/plugins/filebrowser/gedit-file-browser-store.c Sun May 11 11:24:54 2008
@@ -81,6 +81,7 @@
FileBrowserNode *parent;
gint pos;
+ gboolean inserted;
};
struct _FileBrowserNodeDir
@@ -150,6 +151,9 @@
static gboolean gedit_file_browser_store_iter_parent (GtkTreeModel * tree_model,
GtkTreeIter * iter,
GtkTreeIter * child);
+static void gedit_file_browser_store_row_inserted (GtkTreeModel * tree_model,
+ GtkTreePath * path,
+ GtkTreeIter * iter);
static void gedit_file_browser_store_drag_source_init (GtkTreeDragSourceIface * iface);
static gboolean gedit_file_browser_store_row_draggable (GtkTreeDragSource * drag_source,
@@ -414,6 +418,7 @@
iface->iter_n_children = gedit_file_browser_store_iter_n_children;
iface->iter_nth_child = gedit_file_browser_store_iter_nth_child;
iface->iter_parent = gedit_file_browser_store_iter_parent;
+ iface->row_inserted = gedit_file_browser_store_row_inserted;
}
static void
@@ -482,6 +487,13 @@
return !NODE_IS_FILTERED (node);
}
+static gboolean
+model_node_inserted (GeditFileBrowserStore * model,
+ FileBrowserNode * node)
+{
+ return node == model->priv->virtual_root || (model_node_visibility (model, node) && node->inserted);
+}
+
/* Interface implementation */
static GtkTreeModelFlags
@@ -518,10 +530,11 @@
gedit_file_browser_store_get_iter (GtkTreeModel * tree_model,
GtkTreeIter * iter, GtkTreePath * path)
{
- gint *indices, depth, i;
- FileBrowserNode *node;
- GeditFileBrowserStore *model;
- GSList *item;
+ gint * indices, depth, i;
+ FileBrowserNode * node;
+ FileBrowserNode * child;
+ GeditFileBrowserStore * model;
+ GSList * item;
gint num;
g_assert (GEDIT_IS_FILE_BROWSER_STORE (tree_model));
@@ -541,14 +554,12 @@
if (!NODE_IS_DIR (node))
return FALSE;
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next) {
- if (model_node_visibility
- (model, (FileBrowserNode *) (item->data))) {
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next) {
+ child = (FileBrowserNode *) (item->data);
+
+ if (model_node_inserted (model, child)) {
if (num == indices[i]) {
- node =
- (FileBrowserNode *) (item->
- data);
+ node = child;
break;
}
@@ -586,8 +597,7 @@
num = 0;
- for (item = FILE_BROWSER_NODE_DIR (node->parent)->children;
- item; item = item->next) {
+ for (item = FILE_BROWSER_NODE_DIR (node->parent)->children; item; item = item->next) {
check = (FileBrowserNode *) (item->data);
if (model_node_visibility (model, check)) {
@@ -619,21 +629,20 @@
{
FileBrowserNode *node;
- g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
- NULL);
+ g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model), NULL);
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->user_data != NULL, NULL);
node = (FileBrowserNode *) (iter->user_data);
- return
- gedit_file_browser_store_get_path_real
- (GEDIT_FILE_BROWSER_STORE (tree_model), node);
+ return gedit_file_browser_store_get_path_real (GEDIT_FILE_BROWSER_STORE (tree_model),
+ node);
}
static void
gedit_file_browser_store_get_value (GtkTreeModel * tree_model,
- GtkTreeIter * iter, gint column,
+ GtkTreeIter * iter,
+ gint column,
GValue * value)
{
FileBrowserNode *node;
@@ -644,9 +653,7 @@
node = (FileBrowserNode *) (iter->user_data);
- g_value_init (value,
- GEDIT_FILE_BROWSER_STORE (tree_model)->priv->
- column_types[column]);
+ g_value_init (value, GEDIT_FILE_BROWSER_STORE (tree_model)->priv->column_types[column]);
switch (column) {
case GEDIT_FILE_BROWSER_STORE_COLUMN_URI:
@@ -671,9 +678,10 @@
gedit_file_browser_store_iter_next (GtkTreeModel * tree_model,
GtkTreeIter * iter)
{
- GeditFileBrowserStore *model;
- FileBrowserNode *node;
- GSList *item;
+ GeditFileBrowserStore * model;
+ FileBrowserNode * node;
+ GSList * item;
+ GSList * first;
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
FALSE);
@@ -686,12 +694,10 @@
if (node->parent == NULL)
return FALSE;
- for (item =
- g_slist_next (g_slist_find
- (FILE_BROWSER_NODE_DIR (node->parent)->children,
- node)); item; item = item->next) {
- if (model_node_visibility
- (model, (FileBrowserNode *) (item->data))) {
+ first = g_slist_next (g_slist_find (FILE_BROWSER_NODE_DIR (node->parent)->children, node));
+
+ for (item = first; item; item = item->next) {
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data))) {
iter->user_data = item->data;
return TRUE;
}
@@ -705,9 +711,9 @@
GtkTreeIter * iter,
GtkTreeIter * parent)
{
- FileBrowserNode *node;
- GeditFileBrowserStore *model;
- GSList *item;
+ FileBrowserNode * node;
+ GeditFileBrowserStore * model;
+ GSList * item;
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_STORE (tree_model),
FALSE);
@@ -727,10 +733,8 @@
if (!NODE_IS_DIR (node))
return FALSE;
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next) {
- if (model_node_visibility
- (model, (FileBrowserNode *) (item->data))) {
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next) {
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data))) {
iter->user_data = item->data;
return TRUE;
}
@@ -744,15 +748,14 @@
FileBrowserNode * node)
{
GSList *item;
-
+
if (!NODE_IS_DIR (node))
return FALSE;
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next)
- if (model_node_visibility
- (model, (FileBrowserNode *) (item->data)))
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next) {
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data)))
return TRUE;
+ }
return FALSE;
}
@@ -803,10 +806,8 @@
if (!NODE_IS_DIR (node))
return 0;
- for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
- item = item->next)
- if (model_node_visibility
- (model, (FileBrowserNode *) (item->data)))
+ for (item = FILE_BROWSER_NODE_DIR (node)->children; item; item = item->next)
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data)))
++num;
return num;
@@ -839,8 +840,7 @@
for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
item = item->next) {
- if (model_node_visibility
- (model, (FileBrowserNode *) (item->data))) {
+ if (model_node_inserted (model, (FileBrowserNode *) (item->data))) {
if (num == n) {
iter->user_data = item->data;
return TRUE;
@@ -879,6 +879,16 @@
return TRUE;
}
+static void
+gedit_file_browser_store_row_inserted (GtkTreeModel * tree_model,
+ GtkTreePath * path,
+ GtkTreeIter * iter)
+{
+ FileBrowserNode * node = (FileBrowserNode *)(iter->user_data);
+
+ node->inserted = TRUE;
+}
+
static gboolean
gedit_file_browser_store_row_draggable (GtkTreeDragSource * drag_source,
GtkTreePath * path)
@@ -1162,28 +1172,49 @@
static void
row_changed (GeditFileBrowserStore * model,
- const GtkTreePath * path,
+ GtkTreePath ** path,
GtkTreeIter * iter)
{
- GtkTreePath *copy = gtk_tree_path_copy (path);
-
+ GtkTreeRowReference *ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), *path);
+
/* Insert a copy of the actual path here because the row-inserted
signal may alter the path */
- gtk_tree_model_row_changed (GTK_TREE_MODEL(model), copy, iter);
- gtk_tree_path_free (copy);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL(model), *path, iter);
+ gtk_tree_path_free (*path);
+
+ *path = gtk_tree_row_reference_get_path (ref);
+ gtk_tree_row_reference_free (ref);
}
static void
row_inserted (GeditFileBrowserStore * model,
- const GtkTreePath * path,
+ GtkTreePath ** path,
GtkTreeIter * iter)
{
- GtkTreePath *copy = gtk_tree_path_copy (path);
-
- /* Insert a copy of the actual path here because the row-inserted
- signal may alter the path */
+ /* This function creates a row reference for the path because it's
+ uncertain what might change the actual model/view when we insert
+ a node, maybe another directory load is triggered for example.
+ Because functions that use this function rely on the notion that
+ the path remains pointed towards the inserted node, we use the
+ reference to keep track. */
+ GtkTreeRowReference *ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), *path);
+ GtkTreePath * copy = gtk_tree_path_copy (*path);
+
gtk_tree_model_row_inserted (GTK_TREE_MODEL(model), copy, iter);
gtk_tree_path_free (copy);
+
+ if (ref) {
+ gtk_tree_path_free (*path);
+
+ /* To restore the path, we get the path from the reference. But, since
+ we inserted a row, the path will be one index further than the
+ actual path of our node. We therefore call gtk_tree_path_prev */
+ *path = gtk_tree_row_reference_get_path (ref);
+
+ gtk_tree_path_prev (*path);
+ }
+
+ gtk_tree_row_reference_free (ref);
}
static void
@@ -1249,12 +1280,12 @@
new_visible = model_node_visibility (model, node);
if (old_visible != new_visible) {
- iter.user_data = node;
-
if (old_visible) {
+ node->inserted = FALSE;
row_deleted (model, path);
} else {
- row_inserted (model, path, &iter);
+ iter.user_data = node;
+ row_inserted (model, &path, &iter);
gtk_tree_path_next (path);
}
} else if (old_visible) {
@@ -1486,7 +1517,10 @@
/* Only delete if the node is visible in the tree (but only when it's
not the virtual root) */
if (model_node_visibility (model, node) && node != model->priv->virtual_root)
+ {
+ node->inserted = FALSE;
row_deleted (model, path);
+ }
if (free_path)
gtk_tree_path_free (path);
@@ -1544,8 +1578,9 @@
if (NODE_IS_DUMMY (dummy)
&& model_node_visibility (model, dummy)) {
path = gtk_tree_path_new_first ();
- gtk_tree_model_row_deleted (GTK_TREE_MODEL
- (model), path);
+
+ dummy->inserted = FALSE;
+ row_deleted (model, path);
gtk_tree_path_free (path);
}
}
@@ -1723,7 +1758,7 @@
gedit_file_browser_store_get_path_real
(model, dummy);
- row_inserted (model, path, &iter);
+ row_inserted (model, &path, &iter);
gtk_tree_path_free (path);
}
} else {
@@ -1738,9 +1773,9 @@
(model, dummy);
dummy->flags |=
GEDIT_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
-
- gtk_tree_model_row_deleted (GTK_TREE_MODEL
- (model), path);
+
+ dummy->inserted = FALSE;
+ row_deleted (model, path);
gtk_tree_path_free (path);
}
}
@@ -1782,7 +1817,7 @@
gedit_file_browser_store_get_path_real (model, child);
// Emit row inserted
- row_inserted (model, path, &iter);
+ row_inserted (model, &path, &iter);
gtk_tree_path_free (path);
}
@@ -2250,8 +2285,7 @@
/* Insert node */
iter.user_data = node;
- row_inserted(model, path, &iter);
- model_check_dummy (model, node);
+ row_inserted(model, &path, &iter);
}
if (NODE_IS_DIR (node)) {
@@ -2273,6 +2307,8 @@
/* Move back up to node path */
gtk_tree_path_up (path);
}
+
+ model_check_dummy (model, node);
if (free_path)
gtk_tree_path_free (path);
@@ -2660,7 +2696,7 @@
if (model_node_visibility (tree_model, node)) {
path = gedit_file_browser_store_get_path (GTK_TREE_MODEL (tree_model),
iter);
- row_changed (tree_model, path, iter);
+ row_changed (tree_model, &path, iter);
gtk_tree_path_free (path);
}
}
@@ -3090,7 +3126,7 @@
if (model_node_visibility (model, node)) {
path = gedit_file_browser_store_get_path_real (model, node);
- row_changed (model, path, iter);
+ row_changed (model, &path, iter);
gtk_tree_path_free (path);
/* Reorder this item */
Modified: trunk/plugins/filebrowser/gedit-file-browser-view.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-view.c (original)
+++ trunk/plugins/filebrowser/gedit-file-browser-view.c Sun May 11 11:24:54 2008
@@ -88,31 +88,35 @@
GEDIT_PLUGIN_DEFINE_TYPE (GeditFileBrowserView, gedit_file_browser_view,
GTK_TYPE_TREE_VIEW)
-static void on_cell_edited (GtkCellRendererText * cell,
- gchar * path,
- gchar * new_text,
- GeditFileBrowserView * tree_view);
-static void on_begin_loading (GeditFileBrowserStore * model,
- GtkTreeIter * iter,
- GeditFileBrowserView * obj);
-static void on_end_loading (GeditFileBrowserStore * model,
- GtkTreeIter * iter,
- GeditFileBrowserView * obj);
-
-static void on_begin_refresh (GeditFileBrowserStore * model,
- GeditFileBrowserView * view);
-static void on_end_refresh (GeditFileBrowserStore * model,
- GeditFileBrowserView * view);
-
-static void on_unload (GeditFileBrowserStore * model,
- gchar const * uri,
- GeditFileBrowserView * view);
-
-static void on_row_inserted (GeditFileBrowserStore * model,
- GtkTreePath * path,
- GtkTreeIter * iter,
- GeditFileBrowserView * view);
-
+static void on_cell_edited (GtkCellRendererText * cell,
+ gchar * path,
+ gchar * new_text,
+ GeditFileBrowserView * tree_view);
+static void on_begin_loading (GeditFileBrowserStore * model,
+ GtkTreeIter * iter,
+ GeditFileBrowserView * obj);
+static void on_end_loading (GeditFileBrowserStore * model,
+ GtkTreeIter * iter,
+ GeditFileBrowserView * obj);
+
+static void on_begin_refresh (GeditFileBrowserStore * model,
+ GeditFileBrowserView * view);
+static void on_end_refresh (GeditFileBrowserStore * model,
+ GeditFileBrowserView * view);
+
+static void on_unload (GeditFileBrowserStore * model,
+ gchar const * uri,
+ GeditFileBrowserView * view);
+
+static void on_row_inserted (GeditFileBrowserStore * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter,
+ GeditFileBrowserView * view);
+
+static void on_virtual_root_changed (GeditFileBrowserStore * model,
+ GParamSpec * param,
+ GeditFileBrowserView * view);
+
static void
gedit_file_browser_view_finalize (GObject * object)
{
@@ -124,81 +128,40 @@
if (obj->priv->hover_path)
gtk_tree_path_free (obj->priv->hover_path);
+ if (obj->priv->expand_state)
+ g_hash_table_destroy (obj->priv->expand_state);
+
gdk_cursor_unref (obj->priv->busy_cursor);
G_OBJECT_CLASS (gedit_file_browser_view_parent_class)->
finalize (object);
}
-typedef struct _IdleInfo
-{
- GeditFileBrowserView *view;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path;
-} IdleInfo;
-
-static gboolean
-row_expanded_idle (gpointer data)
+static void
+add_expand_state (GeditFileBrowserView * view,
+ gchar const * uri)
{
- IdleInfo *info = (IdleInfo *) data;
- gchar * uri;
GFile * file;
-
- if (info->view->priv->restore_expand_state)
- {
- gtk_tree_model_get (info->model,
- &(info->iter),
- GEDIT_FILE_BROWSER_STORE_COLUMN_URI,
- &uri,
- -1);
-
- if (uri)
- {
- file = g_file_new_for_uri (uri);
- g_hash_table_insert (info->view->priv->expand_state, file, file);
- g_free (uri);
- }
- }
-
- _gedit_file_browser_store_iter_expanded (GEDIT_FILE_BROWSER_STORE
- (info->model),
- &(info->iter));
- g_free (info);
- return FALSE;
+ if (!uri)
+ return;
+
+ file = g_file_new_for_uri (uri);
+ g_hash_table_insert (view->priv->expand_state, file, file);
}
-static gboolean
-row_collapsed_idle (gpointer data)
+static void
+remove_expand_state (GeditFileBrowserView * view,
+ gchar const * uri)
{
- IdleInfo *info = (IdleInfo *) data;
- gchar * uri;
GFile * file;
- if (info->view->priv->restore_expand_state)
- {
- gtk_tree_model_get (info->model,
- &(info->iter),
- GEDIT_FILE_BROWSER_STORE_COLUMN_URI,
- &uri,
- -1);
-
- if (uri)
- {
- file = g_file_new_for_uri (uri);
- g_hash_table_remove (info->view->priv->expand_state, file);
- g_object_unref (file);
- g_free (uri);
- }
- }
-
- _gedit_file_browser_store_iter_collapsed (GEDIT_FILE_BROWSER_STORE
- (info->model),
- &(info->iter));
+ if (!uri)
+ return;
- g_free (info);
- return FALSE;
+ file = g_file_new_for_uri (uri);
+ g_hash_table_remove (view->priv->expand_state, file);
+ g_object_unref (file);
}
static void
@@ -207,20 +170,28 @@
GtkTreePath * path)
{
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (tree_view);
- IdleInfo *info;
+ gchar * uri;
+ if (GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_expanded)
+ GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_expanded (tree_view, iter, path);
- if (GEDIT_IS_FILE_BROWSER_STORE (view->priv->model)) {
- info = g_new (IdleInfo, 1);
- info->model = view->priv->model;
- info->iter = *iter;
- info->view = view;
+ if (!GEDIT_IS_FILE_BROWSER_STORE (view->priv->model))
+ return;
- g_idle_add (row_expanded_idle, info);
+ if (view->priv->restore_expand_state)
+ {
+ gtk_tree_model_get (view->priv->model,
+ iter,
+ GEDIT_FILE_BROWSER_STORE_COLUMN_URI,
+ &uri,
+ -1);
+
+ add_expand_state (view, uri);
+ g_free (uri);
}
- if (GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_expanded)
- GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_expanded (tree_view, iter, path);
+ _gedit_file_browser_store_iter_expanded (GEDIT_FILE_BROWSER_STORE (view->priv->model),
+ iter);
}
static void
@@ -229,19 +200,28 @@
GtkTreePath * path)
{
GeditFileBrowserView *view = GEDIT_FILE_BROWSER_VIEW (tree_view);
- IdleInfo *info;
+ gchar * uri;
- if (GEDIT_IS_FILE_BROWSER_STORE (view->priv->model)) {
- info = g_new (IdleInfo, 1);
- info->model = view->priv->model;
- info->iter = *iter;
- info->view = view;
+ if (GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_collapsed)
+ GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_collapsed (tree_view, iter, path);
- g_idle_add (row_collapsed_idle, info);
+ if (!GEDIT_IS_FILE_BROWSER_STORE (view->priv->model))
+ return;
+
+ if (view->priv->restore_expand_state)
+ {
+ gtk_tree_model_get (view->priv->model,
+ iter,
+ GEDIT_FILE_BROWSER_STORE_COLUMN_URI,
+ &uri,
+ -1);
+
+ remove_expand_state (view, uri);
+ g_free (uri);
}
- if (GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_collapsed)
- GTK_TREE_VIEW_CLASS (gedit_file_browser_view_parent_class)->row_collapsed (tree_view, iter, path);
+ _gedit_file_browser_store_iter_collapsed (GEDIT_FILE_BROWSER_STORE (view->priv->model),
+ iter);
}
static gboolean
@@ -694,7 +674,6 @@
GtkTreePath * path;
GtkTreeIter child;
gchar * uri;
- GFile * file;
if (!gtk_tree_model_iter_has_child (view->priv->model, iter))
return;
@@ -709,8 +688,8 @@
&uri,
-1);
- file = g_file_new_for_uri (uri);
- g_hash_table_insert (view->priv->expand_state, uri, uri);
+ add_expand_state (view, uri);
+ g_free (uri);
}
if (gtk_tree_model_iter_children (view->priv->model, &child, iter))
@@ -742,6 +721,10 @@
g_signal_handlers_disconnect_by_func (model,
on_row_inserted,
tree_view);
+
+ g_signal_handlers_disconnect_by_func (model,
+ on_virtual_root_changed,
+ tree_view);
}
static void
@@ -763,10 +746,15 @@
G_CALLBACK (on_unload),
tree_view);
- g_signal_connect (model,
+ g_signal_connect_after (model,
"row-inserted",
G_CALLBACK (on_row_inserted),
tree_view);
+
+ g_signal_connect (model,
+ "notify::virtual-root",
+ G_CALLBACK (on_virtual_root_changed),
+ tree_view);
}
static void
@@ -792,7 +780,11 @@
if (view->priv->model && GEDIT_IS_FILE_BROWSER_STORE (view->priv->model))
{
fill_expand_state (view, NULL);
+
install_restore_signals (view, view->priv->model);
+ on_virtual_root_changed (GEDIT_FILE_BROWSER_STORE (view->priv->model),
+ NULL,
+ view);
}
}
else if (view->priv->model && GEDIT_IS_FILE_BROWSER_STORE (view->priv->model))
@@ -1217,41 +1209,11 @@
gchar const * uri,
GeditFileBrowserView * view)
{
- GFile * file;
-
/* Don't remove the expand state if we are refreshing */
if (!view->priv->restore_expand_state || view->priv->is_refresh)
return;
- file = g_file_new_for_uri (uri);
- g_hash_table_remove (view->priv->expand_state, file);
- g_object_unref (file);
-}
-
-typedef struct
-{
- GeditFileBrowserView * view;
- GtkTreeRowReference * reference;
-} ExpandRow;
-
-static gboolean
-idle_expand_row (ExpandRow * info)
-{
- GtkTreePath * path = gtk_tree_row_reference_get_path (info->reference);
-
- if (path)
- {
- gtk_tree_view_expand_row (GTK_TREE_VIEW (info->view),
- path,
- FALSE);
-
- gtk_tree_path_free (path);
- }
-
- gtk_tree_row_reference_free (info->reference);
- g_free (info);
-
- return FALSE;
+ remove_expand_state (view, uri);
}
static void
@@ -1261,7 +1223,6 @@
{
gchar * uri;
GFile * file;
- ExpandRow * info;
GtkTreePath * path;
gtk_tree_model_get (GTK_TREE_MODEL (model),
@@ -1278,12 +1239,9 @@
if (g_hash_table_lookup (view->priv->expand_state, file))
{
- info = g_new (ExpandRow, 1);
- info->view = view;
- info->reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (model),
- path);
-
- g_idle_add ((GSourceFunc)idle_expand_row, info);
+ gtk_tree_view_expand_row (GTK_TREE_VIEW (view),
+ path,
+ FALSE);
}
gtk_tree_path_free (path);
@@ -1323,6 +1281,18 @@
copy);
restore_expand_state (view, model, &parent);
+ gtk_tree_path_free (copy);
+}
+
+static void
+on_virtual_root_changed (GeditFileBrowserStore * model,
+ GParamSpec * param,
+ GeditFileBrowserView * view)
+{
+ gchar * uri = gedit_file_browser_store_get_virtual_root (model);
+
+ add_expand_state (view, uri);
+ g_free (uri);
}
// ex:ts=8:noet:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]