SF.net SVN: geany:[3038] branches/symbol-tree
ntrel at users.sourceforge.net
ntrel at xxxxx
Thu Oct 2 15:48:50 UTC 2008
Revision: 3038
http://geany.svn.sourceforge.net/geany/?rev=3038&view=rev
Author: ntrel
Date: 2008-10-02 15:48:50 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
Refactor add_tree_tags() from symbols_recreate_tag_list().
Modified Paths:
--------------
branches/symbol-tree/ChangeLog
branches/symbol-tree/src/symbols.c
Modified: branches/symbol-tree/ChangeLog
===================================================================
--- branches/symbol-tree/ChangeLog 2008-10-02 15:09:33 UTC (rev 3037)
+++ branches/symbol-tree/ChangeLog 2008-10-02 15:48:50 UTC (rev 3038)
@@ -6,6 +6,8 @@
(gnocci-man) to show methods as children of classes in the symbol
list, and for other tag types to group children by their parents
(thanks; 2083110).
+ * src/symbols.c:
+ Refactor add_tree_tags() from symbols_recreate_tag_list().
2008-10-01 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: branches/symbol-tree/src/symbols.c
===================================================================
--- branches/symbol-tree/src/symbols.c 2008-10-02 15:09:33 UTC (rev 3037)
+++ branches/symbol-tree/src/symbols.c 2008-10-02 15:48:50 UTC (rev 3038)
@@ -841,43 +841,18 @@
}
-gboolean symbols_recreate_tag_list(GeanyDocument *doc, gint sort_mode)
+static void add_tree_tags(GtkTreeStore *tree_store, const GList *tags, filetype_id ft_id)
{
GList *tmp, *skipped = NULL;
- const GList *tags;
GtkTreeIter iter;
- static gint prev_sort_mode = SYMBOLS_SORT_BY_NAME;
- filetype_id ft_id;
gint num_parents = 0, do_skipped = FALSE, num_skipped = 0;
GHashTable *parent_hash;
- const gchar *separator;
+ const gchar *separator = symbols_get_context_separator(ft_id);
- g_return_val_if_fail(doc != NULL, FALSE);
-
- ft_id = FILETYPE_ID(doc->file_type);
- separator = symbols_get_context_separator(ft_id);
-
- if (sort_mode == SYMBOLS_SORT_USE_PREVIOUS)
- sort_mode = prev_sort_mode;
- else
- prev_sort_mode = sort_mode;
-
- tags = get_tag_list(doc, tm_tag_max_t, sort_mode);
- if (doc->tm_file == NULL || tags == NULL)
- return FALSE;
-
- /* Make sure the model stays with us after the tree view unrefs it */
- g_object_ref(GTK_TREE_MODEL(doc->priv->tag_store));
- /* Detach model from view */
- gtk_tree_view_set_model(GTK_TREE_VIEW(doc->priv->tag_tree), NULL);
- /* Clear all contents */
- gtk_tree_store_clear(doc->priv->tag_store);
/* Create a hash table to keep track of parents */
parent_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
g_free);
- init_tag_list(doc);
-
for (tmp = (GList*)tags; tmp && num_skipped < 20;)
{
gchar buf[100] = "", buf2[100] = "";
@@ -1003,7 +978,7 @@
if (!parent_icon)
parent_icon = parent;
- gtk_tree_model_get(GTK_TREE_MODEL(doc->priv->tag_store), parent_icon,
+ gtk_tree_model_get(GTK_TREE_MODEL(tree_store), parent_icon,
SYMBOLS_COLUMN_ICON, &icon, -1);
if (add_child)
{
@@ -1043,8 +1018,8 @@
}
g_snprintf(buf, sizeof(buf), "%s [%d]", final_name, symbol->line);
- gtk_tree_store_append(doc->priv->tag_store, child, parent);
- gtk_tree_store_set(doc->priv->tag_store, child,
+ gtk_tree_store_append(tree_store, child, parent);
+ gtk_tree_store_set(tree_store, child,
SYMBOLS_COLUMN_ICON, icon,
SYMBOLS_COLUMN_NAME, buf,
SYMBOLS_COLUMN_LINE, symbol->line, -1);
@@ -1069,9 +1044,39 @@
else
tmp = g_list_next(tmp);
}
+ g_hash_table_destroy(parent_hash);
+}
+
+gboolean symbols_recreate_tag_list(GeanyDocument *doc, gint sort_mode)
+{
+ const GList *tags;
+ static gint prev_sort_mode = SYMBOLS_SORT_BY_NAME;
+
+ g_return_val_if_fail(doc != NULL, FALSE);
+
+ if (sort_mode == SYMBOLS_SORT_USE_PREVIOUS)
+ sort_mode = prev_sort_mode;
+ else
+ prev_sort_mode = sort_mode;
+
+ tags = get_tag_list(doc, tm_tag_max_t, sort_mode);
+ if (doc->tm_file == NULL || tags == NULL)
+ return FALSE;
+
+ /* Make sure the model stays with us after the tree view unrefs it */
+ g_object_ref(GTK_TREE_MODEL(doc->priv->tag_store));
+ /* Detach model from view */
+ gtk_tree_view_set_model(GTK_TREE_VIEW(doc->priv->tag_tree), NULL);
+ /* Clear all contents */
+ gtk_tree_store_clear(doc->priv->tag_store);
+
+ /* add grandparent type iters */
+ init_tag_list(doc);
+
+ add_tree_tags(doc->priv->tag_store, tags, FILETYPE_ID(doc->file_type));
+
hide_empty_rows(doc->priv->tag_store);
- g_hash_table_destroy(parent_hash);
/* Re-attach model to view */
gtk_tree_view_set_model(GTK_TREE_VIEW(doc->priv->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