Kaydet (Commit) 4f74783f authored tarafından Enrico Tröger's avatar Enrico Tröger

Add menu items for different sorting of the symbol list to the symbol list popup menu.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1802 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 8525cc95
2007-08-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/symbols.c, src/symbols.h, src/treeviews.c:
Add menu items for different sorting of the symbol list to the symbol
list popup menu.
2007-08-15 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2007-08-15 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/plugindata.h, src/plugins.c: * src/plugindata.h, src/plugins.c:
......
...@@ -320,8 +320,7 @@ static gint compare_symbol(const GeanySymbol *a, const GeanySymbol *b) ...@@ -320,8 +320,7 @@ static gint compare_symbol(const GeanySymbol *a, const GeanySymbol *b)
} }
static const GList * static const GList *get_tag_list(gint idx, guint tag_types, gboolean sort_by_name)
get_tag_list(gint idx, guint tag_types)
{ {
static GList *tag_names = NULL; static GList *tag_names = NULL;
...@@ -385,7 +384,9 @@ get_tag_list(gint idx, guint tag_types) ...@@ -385,7 +384,9 @@ get_tag_list(gint idx, guint tag_types)
if (! doc_is_utf8) g_free(utf8_name); if (! doc_is_utf8) g_free(utf8_name);
} }
} }
tag_names = g_list_sort(tag_names, (GCompareFunc) compare_symbol); if (sort_by_name)
tag_names = g_list_sort(tag_names, (GCompareFunc) compare_symbol);
return tag_names; return tag_names;
} }
else else
...@@ -688,7 +689,7 @@ static void hide_empty_rows(GtkTreeModel *model, GtkTreeStore *store) ...@@ -688,7 +689,7 @@ static void hide_empty_rows(GtkTreeModel *model, GtkTreeStore *store)
} }
gboolean symbols_recreate_tag_list(gint idx) gboolean symbols_recreate_tag_list(gint idx, gboolean sort_by_name)
{ {
GList *tmp; GList *tmp;
const GList *tags; const GList *tags;
...@@ -697,8 +698,9 @@ gboolean symbols_recreate_tag_list(gint idx) ...@@ -697,8 +698,9 @@ gboolean symbols_recreate_tag_list(gint idx)
g_return_val_if_fail(DOC_IDX_VALID(idx), FALSE); g_return_val_if_fail(DOC_IDX_VALID(idx), FALSE);
tags = get_tag_list(idx, tm_tag_max_t); tags = get_tag_list(idx, tm_tag_max_t, sort_by_name);
if (doc_list[idx].tm_file == NULL || tags == NULL) return FALSE; if (doc_list[idx].tm_file == NULL || tags == NULL)
return FALSE;
gtk_tree_store_clear(doc_list[idx].tag_store); gtk_tree_store_clear(doc_list[idx].tag_store);
// unref the store to speed up the filling(from TreeView Tutorial) // unref the store to speed up the filling(from TreeView Tutorial)
......
...@@ -44,9 +44,9 @@ const gchar **symbols_get_html_entities(); ...@@ -44,9 +44,9 @@ const gchar **symbols_get_html_entities();
void symbols_finalize(); void symbols_finalize();
gboolean symbols_recreate_tag_list(gint idx); gboolean symbols_recreate_tag_list(gint idx, gboolean sort_by_name);
int symbols_generate_global_tags(int argc, char **argv); gint symbols_generate_global_tags(gint argc, gchar **argv);
void symbols_show_load_tags_dialog(); void symbols_show_load_tags_dialog();
......
...@@ -52,6 +52,8 @@ enum ...@@ -52,6 +52,8 @@ enum
OPENFILES_ACTION_RELOAD, OPENFILES_ACTION_RELOAD,
OPENFILES_ACTION_HIDE, OPENFILES_ACTION_HIDE,
OPENFILES_ACTION_HIDE_ALL, OPENFILES_ACTION_HIDE_ALL,
SYMBOL_ACTION_SORT_BY_NAME,
SYMBOL_ACTION_SORT_BY_APPEARANCE,
SYMBOL_ACTION_HIDE, SYMBOL_ACTION_HIDE,
SYMBOL_ACTION_HIDE_ALL SYMBOL_ACTION_HIDE_ALL
}; };
...@@ -164,7 +166,7 @@ void treeviews_update_tag_list(gint idx, gboolean update) ...@@ -164,7 +166,7 @@ void treeviews_update_tag_list(gint idx, gboolean update)
g_object_ref((gpointer)doc_list[idx].tag_tree); // to hold it after removing g_object_ref((gpointer)doc_list[idx].tag_tree); // to hold it after removing
} }
doc_list[idx].has_tags = symbols_recreate_tag_list(idx); doc_list[idx].has_tags = symbols_recreate_tag_list(idx, TRUE); // sort by name by default
} }
if (doc_list[idx].has_tags) if (doc_list[idx].has_tags)
...@@ -291,6 +293,24 @@ void treeviews_create_taglist_popup_menu() ...@@ -291,6 +293,24 @@ void treeviews_create_taglist_popup_menu()
tv.popup_taglist = gtk_menu_new(); tv.popup_taglist = gtk_menu_new();
item = gtk_menu_item_new_with_label(_("Sort by name"));
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item);
g_signal_connect((gpointer) item, "activate",
G_CALLBACK(on_taglist_tree_popup_clicked),
GINT_TO_POINTER(SYMBOL_ACTION_SORT_BY_NAME));
item = gtk_menu_item_new_with_label(_("Sort by appearance"));
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item);
g_signal_connect((gpointer) item, "activate",
G_CALLBACK(on_taglist_tree_popup_clicked),
GINT_TO_POINTER(SYMBOL_ACTION_SORT_BY_APPEARANCE));
item = gtk_separator_menu_item_new();
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item);
item = gtk_image_menu_item_new_with_label(_("Hide")); item = gtk_image_menu_item_new_with_label(_("Hide"));
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU)); gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
...@@ -465,6 +485,20 @@ static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_d ...@@ -465,6 +485,20 @@ static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_d
{ {
switch (GPOINTER_TO_INT(user_data)) switch (GPOINTER_TO_INT(user_data))
{ {
case SYMBOL_ACTION_SORT_BY_NAME:
{
gint idx = document_get_cur_idx();
if (DOC_IDX_VALID(idx))
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, TRUE);
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);
break;
}
case SYMBOL_ACTION_HIDE: case SYMBOL_ACTION_HIDE:
{ {
app->sidebar_symbol_visible = FALSE; app->sidebar_symbol_visible = FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment