SF.net SVN: geany:[3173] branches/symbol-tree

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Nov 5 12:50:29 UTC 2008


Revision: 3173
          http://geany.svn.sourceforge.net/geany/?rev=3173&view=rev
Author:   ntrel
Date:     2008-11-05 12:50:29 +0000 (Wed, 05 Nov 2008)

Log Message:
-----------
Replace macro with static function.

Modified Paths:
--------------
    branches/symbol-tree/ChangeLog
    branches/symbol-tree/src/symbols.c

Modified: branches/symbol-tree/ChangeLog
===================================================================
--- branches/symbol-tree/ChangeLog	2008-11-04 18:14:04 UTC (rev 3172)
+++ branches/symbol-tree/ChangeLog	2008-11-05 12:50:29 UTC (rev 3173)
@@ -1,3 +1,9 @@
+2008-11-05  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/symbols.c:
+   Replace macro with static function.
+
+
 2008-11-04  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/symbols.c:

Modified: branches/symbol-tree/src/symbols.c
===================================================================
--- branches/symbol-tree/src/symbols.c	2008-11-04 18:14:04 UTC (rev 3172)
+++ branches/symbol-tree/src/symbols.c	2008-11-05 12:50:29 UTC (rev 3173)
@@ -1061,12 +1061,13 @@
 }
 
 
-/* Whether iters can be sorted based on tag name and line, not scope.
- * If the scope was prepended, e.g. 'ScopeNameWithNoTag::TagName', this returns FALSE */
-#define tag_is_name_sortable(tag, iter) \
-	((tag) && \
-		(!NZV((tag)->atts.entry.scope) || \
-			gtk_tree_store_iter_depth(GTK_TREE_STORE(model), (iter)) > 1))
+static gboolean tag_has_missing_parent(const TMTag *tag, GtkTreeStore *store,
+		GtkTreeIter *iter)
+{
+	/* if the tag has a parent tag, it should be at depth >= 2 */
+	return NZV(tag->atts.entry.scope) &&
+		gtk_tree_store_iter_depth(store, iter) == 1;
+}
 
 
 static gint tree_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
@@ -1078,8 +1079,10 @@
 	gtk_tree_model_get(model, a, SYMBOLS_COLUMN_TAG, &tag_a, -1);
 	gtk_tree_model_get(model, b, SYMBOLS_COLUMN_TAG, &tag_b, -1);
 
-	if (tag_is_name_sortable(tag_a, a) &&
-		tag_is_name_sortable(tag_b, b))
+	/* Check if the iters can be sorted based on tag name and line, not tree item name.
+	 * Sort by tree name if the scope was prepended, e.g. 'ScopeNameWithNoTag::TagName'. */
+	if (tag_a && !tag_has_missing_parent(tag_a, GTK_TREE_STORE(model), a) &&
+		tag_b && !tag_has_missing_parent(tag_b, GTK_TREE_STORE(model), b))
 	{
 		return sort_by_name ? compare_symbol(tag_a, tag_b) :
 			compare_symbol_lines(tag_a, tag_b);
@@ -1103,7 +1106,7 @@
 
 			/* sort duplicate 'ScopeName::OverloadedTagName' items by line as well */
 			if ((!sort_by_name || cmp == 0) && tag_a && tag_b)
-				cmp = tag_a->atts.entry.line - tag_b->atts.entry.line;
+				cmp = compare_symbol_lines(tag_a, tag_b);
 		}
 		g_free(astr);
 		g_free(bstr);


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