SF.net SVN: geany: [1756] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Jul 28 14:10:49 UTC 2007


Revision: 1756
          http://geany.svn.sourceforge.net/geany/?rev=1756&view=rev
Author:   eht16
Date:     2007-07-28 07:10:49 -0700 (Sat, 28 Jul 2007)

Log Message:
-----------
Hide empty symbol types in the symbol list.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/symbols.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-07-28 11:47:56 UTC (rev 1755)
+++ trunk/ChangeLog	2007-07-28 14:10:49 UTC (rev 1756)
@@ -10,6 +10,7 @@
    if there are any plugins.
    Use PACKAGE_LIB_DIR.
    Load plugins in ~/.geany/plugins/ prior to the default location.
+ * src/symbols.c: Hide empty symbol types in the symbol list.
 
 
 2007-07-27  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c	2007-07-28 11:47:56 UTC (rev 1755)
+++ trunk/src/symbols.c	2007-07-28 14:10:49 UTC (rev 1756)
@@ -43,6 +43,9 @@
 #include "msgwindow.h"
 #include "treeviews.h"
 
+
+#define MAX_SYMBOL_TYPES 8 // amount of types in the symbol list (currently max. 8 are used)
+
 const guint TM_GLOBAL_TYPE_MASK =
 	tm_tag_class_t | tm_tag_enum_t | tm_tag_interface_t |
 	tm_tag_struct_t | tm_tag_typedef_t | tm_tag_union_t;
@@ -640,6 +643,34 @@
 }
 
 
+/* 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) */
+static void hide_empty_rows(GtkTreeModel *model, GtkTreeStore *store)
+{
+	GtkTreeIter iter, *iters[MAX_SYMBOL_TYPES] = { NULL };
+	gint i = 0;
+
+	if (! gtk_tree_model_get_iter_first(model, &iter))
+		return; // stop when first iter is invalid, i.e. no elements
+
+	do // first collect the iters we need to delete empty rows
+	{
+		if (! gtk_tree_model_iter_has_child(model, &iter))
+			iters[i++] = gtk_tree_iter_copy(&iter);
+	} while (gtk_tree_model_iter_next(model, &iter));
+
+	// now actually delete the collected iters
+	for (i = 0; i < MAX_SYMBOL_TYPES; i++)
+	{
+		if (iters[i] == NULL)
+			break;
+		gtk_tree_store_remove(store, iters[i]);
+		gtk_tree_iter_free(iters[i]);
+	}
+}
+
+
 gboolean symbols_recreate_tag_list(gint idx)
 {
 	GList *tmp;
@@ -742,6 +773,7 @@
 				g_object_unref(icon);
 		}
 	}
+	hide_empty_rows(model, doc_list[idx].tag_store);
 	gtk_tree_view_set_model(GTK_TREE_VIEW(doc_list[idx].tag_tree), model); // Re-attach model to view
 	g_object_unref(model);
 	gtk_tree_view_expand_all(GTK_TREE_VIEW(doc_list[idx].tag_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