SF.net SVN: geany:[5777] branches/0.20.1

colombanw at users.sourceforge.net colombanw at xxxxx
Mon May 9 17:35:37 UTC 2011


Revision: 5777
          http://geany.svn.sourceforge.net/geany/?rev=5777&view=rev
Author:   colombanw
Date:     2011-05-09 17:35:37 +0000 (Mon, 09 May 2011)

Log Message:
-----------
Don't remove and add the symbols tree view if we re-add the same one

Modified Paths:
--------------
    branches/0.20.1/ChangeLog
    branches/0.20.1/src/sidebar.c

Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog	2011-05-09 17:35:09 UTC (rev 5776)
+++ branches/0.20.1/ChangeLog	2011-05-09 17:35:37 UTC (rev 5777)
@@ -1,3 +1,9 @@
+2011-05-09  Colomban Wendling  <colomban(at)geany(dot)org>
+
+ * src/sidebar.c:
+   Don't remove and add the symbols tree view if we re-add the same one.
+
+
 2011-05-08  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * configure.ac, doc/geany.txt, geany.nsi, geany_private.rc,

Modified: branches/0.20.1/src/sidebar.c
===================================================================
--- branches/0.20.1/src/sidebar.c	2011-05-09 17:35:09 UTC (rev 5776)
+++ branches/0.20.1/src/sidebar.c	2011-05-09 17:35:37 UTC (rev 5777)
@@ -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.



More information about the Commits mailing list