Save sorting order of the symbol list when saving a file (#1917262).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2361 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-03-18 16:09:11 +00:00
parent 309f953389
commit 1c04310ac1
4 changed files with 28 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2008-03-18 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/treeviews.c, src/symbols.c, src/symbols.h:
Save sorting order of the symbol list when saving a file (#1917262).
2008-03-17 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* doc/geany.txt, doc/geany.html:

View File

@ -368,11 +368,11 @@ static gint compare_symbol_lines(const GeanySymbol *a, const GeanySymbol *b)
}
static const GList *get_tag_list(gint idx, guint tag_types, gboolean sort_by_name)
static const GList *get_tag_list(gint idx, guint tag_types, gint sort_mode)
{
static GList *tag_names = NULL;
if (idx >= 0 && doc_list[idx].is_valid && doc_list[idx].tm_file &&
if (DOC_IDX_VALID(idx) && doc_list[idx].tm_file &&
doc_list[idx].tm_file->tags_array)
{
TMTag *tag;
@ -432,7 +432,7 @@ static const GList *get_tag_list(gint idx, guint tag_types, gboolean sort_by_nam
if (! doc_is_utf8) g_free(utf8_name);
}
}
if (sort_by_name)
if (sort_mode == SYMBOLS_SORT_BY_NAME)
tag_names = g_list_sort(tag_names, (GCompareFunc) compare_symbol);
else
tag_names = g_list_sort(tag_names, (GCompareFunc) compare_symbol_lines);
@ -797,17 +797,23 @@ static void hide_empty_rows(GtkTreeModel *model, GtkTreeStore *store)
}
gboolean symbols_recreate_tag_list(gint idx, gboolean sort_by_name)
gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
{
GList *tmp;
const GList *tags;
GtkTreeIter iter;
GtkTreeModel *model;
static gint prev_sort_mode = SYMBOLS_SORT_BY_NAME;
filetype_id ft_id = FILETYPE_ID(doc_list[idx].file_type);
g_return_val_if_fail(DOC_IDX_VALID(idx), FALSE);
tags = get_tag_list(idx, tm_tag_max_t, sort_by_name);
if (sort_mode == SYMBOLS_SORT_USE_PREVIOUS)
sort_mode = prev_sort_mode;
else
prev_sort_mode = sort_mode;
tags = get_tag_list(idx, tm_tag_max_t, sort_mode);
if (doc_list[idx].tm_file == NULL || tags == NULL)
return FALSE;

View File

@ -27,6 +27,13 @@
extern const guint TM_GLOBAL_TYPE_MASK;
enum
{
SYMBOLS_SORT_BY_NAME,
SYMBOLS_SORT_BY_APPEARANCE,
SYMBOLS_SORT_USE_PREVIOUS
};
void symbols_global_tags_loaded(gint file_type_idx);
@ -42,7 +49,7 @@ const gchar **symbols_get_html_entities(void);
void symbols_finalize(void);
gboolean symbols_recreate_tag_list(gint idx, gboolean sort_by_name);
gboolean symbols_recreate_tag_list(gint idx, gint sort_mode);
gint symbols_generate_global_tags(gint argc, gchar **argv, gboolean want_preprocess);

View File

@ -189,7 +189,7 @@ void treeviews_update_tag_list(gint idx, gboolean update)
g_object_ref((gpointer)doc_list[idx].tag_tree); /* to hold it after removing */
}
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, TRUE); /* sort by name by default */
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_USE_PREVIOUS);
}
if (doc_list[idx].has_tags)
@ -602,14 +602,14 @@ static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_d
{
gint idx = document_get_cur_idx();
if (DOC_IDX_VALID(idx))
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, TRUE);
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_BY_NAME);
break;
}
case SYMBOL_ACTION_SORT_BY_APPEARANCE:
{
gint idx = document_get_cur_idx();
if (DOC_IDX_VALID(idx))
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, FALSE);
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_BY_APPEARANCE);
break;
}
case SYMBOL_ACTION_HIDE: