Revision: 5561
http://geany.svn.sourceforge.net/geany/?rev=5561&view=rev
Author: colombanw
Date: 2011-03-05 22:51:32 +0000 (Sat, 05 Mar 2011)
Log Message:
-----------
Don't remove and add the symbols tree view if we re-add the same one
Modified Paths:
--------------
trunk/src/sidebar.c
Modified: trunk/src/sidebar.c
===================================================================
--- trunk/src/sidebar.c 2011-03-05 22:50:04 UTC (rev 5560)
+++ trunk/src/sidebar.c 2011-03-05 22:51:32 UTC (rev 5561)
@@ -198,16 +198,26 @@
/* update = rescan the tags for doc->filename */
void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
{
- if (gtk_bin_get_child(GTK_BIN(tag_window)))
- gtk_container_remove(GTK_CONTAINER(tag_window), gtk_bin_get_child(GTK_BIN(tag_window)));
+ GtkWidget *child = gtk_bin_get_child(GTK_BIN(tag_window));
+ /* changes the tree view to the given one, trying not to do useless changes */
+ #define CHANGE_TREE(new_child) \
+ G_STMT_START { \
+ if (child != new_child) \
+ { \
+ if (child) \
+ gtk_container_remove(GTK_CONTAINER(tag_window), child); \
+ gtk_container_add(GTK_CONTAINER(tag_window), new_child); \
+ } \
+ } G_STMT_END
+
if (tv.default_tag_tree == NULL)
create_default_tag_tree();
/* show default empty tag tree if there are no tags */
if (doc == NULL || doc->file_type == NULL || ! filetype_has_tags(doc->file_type))
{
- gtk_container_add(GTK_CONTAINER(tag_window), tv.default_tag_tree);
+ CHANGE_TREE(tv.default_tag_tree);
return;
}
@@ -228,12 +238,14 @@
if (doc->has_tags)
{
- gtk_container_add(GTK_CONTAINER(tag_window), doc->priv->tag_tree);
+ CHANGE_TREE(doc->priv->tag_tree);
}
else
{
- gtk_container_add(GTK_CONTAINER(tag_window), tv.default_tag_tree);
+ CHANGE_TREE(tv.default_tag_tree);
}
+
+ #undef CHANGE_TREE
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5558
http://geany.svn.sourceforge.net/geany/?rev=5558&view=rev
Author: colombanw
Date: 2011-03-05 22:47:13 +0000 (Sat, 05 Mar 2011)
Log Message:
-----------
Improve implementation of hide_empty_rows() to do all in one shot
Modified Paths:
--------------
trunk/src/symbols.c
Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c 2011-03-05 22:46:32 UTC (rev 5557)
+++ trunk/src/symbols.c 2011-03-05 22:47:13 UTC (rev 5558)
@@ -900,30 +900,21 @@
}
-/* the following code surely can be improved, at the moment it collects some iters
- * for removal and after that the actual removal is done. I didn't find a way to find and remove
- * an empty row in one loop (next iter fails then) */
+/* removes toplevel items that have no children */
static void hide_empty_rows(GtkTreeStore *store)
{
- GtkTreeIter iter, *iters[MAX_SYMBOL_TYPES] = { NULL };
- guint i = 0;
+ GtkTreeIter iter;
+ gboolean cont = TRUE;
if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
return; /* stop when first iter is invalid, i.e. no elements */
- do /* first collect the iters we need to delete empty rows */
+ while (cont)
{
if (! gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter))
- iters[i++] = gtk_tree_iter_copy(&iter);
- } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
-
- /* now actually delete the collected iters */
- for (i = 0; i < MAX_SYMBOL_TYPES; i++)
- {
- if (G_UNLIKELY(iters[i] == NULL))
- break;
- gtk_tree_store_remove(store, iters[i]);
- gtk_tree_iter_free(iters[i]);
+ cont = gtk_tree_store_remove(store, &iter);
+ else
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.