Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 23 Jan 2022 16:44:14 UTC Commit: 0c311c02fd3f1b527d777ca21a5f83f198d57537 https://github.com/geany/geany/commit/0c311c02fd3f1b527d777ca21a5f83f198d575...
Log Message: ----------- Use per-document filter for symbol tree
Modified Paths: -------------- src/callbacks.c src/document.c src/documentprivate.h src/symbols.c
Modified: src/callbacks.c 16 lines changed, 15 insertions(+), 1 deletions(-) =================================================================== @@ -440,10 +440,15 @@ void on_toolbutton_search_clicked(GtkAction *action, gpointer user_data) void on_entry_tagfilter_changed(GtkAction *action, gpointer user_data) { GeanyDocument *doc = document_get_current(); + GtkEntry *filter_entry;
if (!doc) return;
+ filter_entry = GTK_ENTRY(ui_lookup_widget(main_widgets.window, "entry_tagfilter")); + g_free(doc->priv->tag_filter); + doc->priv->tag_filter = g_strdup(gtk_entry_get_text(filter_entry)); + /* make sure the tree is fully re-created so it appears correctly * after applying filter */ if (doc->priv->tag_store) @@ -524,14 +529,23 @@ static void on_notebook1_switch_page_after(GtkNotebook *notebook, gpointer page,
if (doc != NULL) { + GtkEntry *filter_entry = GTK_ENTRY(ui_lookup_widget(main_widgets.window, "entry_tagfilter")); + const gchar *entry_text = gtk_entry_get_text(filter_entry); + sidebar_select_openfiles_item(doc); ui_save_buttons_toggle(doc->changed); ui_set_window_title(doc); ui_update_statusbar(doc, -1); ui_update_popup_reundo_items(doc); ui_document_show_hide(doc); /* update the document menu */ build_menu_update(doc); - sidebar_update_tag_list(doc, TRUE); + if (g_strcmp0(entry_text, doc->priv->tag_filter) != 0) + { + /* calls sidebar_update_tag_list() in on_entry_tagfilter_changed() */ + gtk_entry_set_text(filter_entry, doc->priv->tag_filter); + } + else + sidebar_update_tag_list(doc, TRUE); document_highlight_tags(doc);
document_check_disk_status(doc, TRUE);
Modified: src/document.c 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -647,6 +647,7 @@ static GeanyDocument *document_create(const gchar *utf8_filename)
/* initialize default document settings */ doc->priv = g_new0(GeanyDocumentPrivate, 1); + doc->priv->tag_filter = g_strdup(""); doc->id = ++doc_id_counter; doc->index = new_idx; doc->file_name = g_strdup(utf8_filename); @@ -734,6 +735,7 @@ static gboolean remove_page(guint page_num) } g_free(doc->encoding); g_free(doc->priv->saved_encoding.encoding); + g_free(doc->priv->tag_filter); g_free(doc->file_name); g_free(doc->real_path); if (doc->tm_file)
Modified: src/documentprivate.h 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -112,6 +112,8 @@ typedef struct GeanyDocumentPrivate GtkWidget *info_bars[NUM_MSG_TYPES]; /* Keyed Data List to attach arbitrary data to the document */ GData *data; + /* Text used for filtering symbol tree. */ + gchar *tag_filter; } GeanyDocumentPrivate;
Modified: src/symbols.c 4 lines changed, 1 insertions(+), 3 deletions(-) =================================================================== @@ -320,16 +320,14 @@ static GList *get_tag_list(GeanyDocument *doc, TMTagType tag_types) { GList *tag_names = NULL; guint i, j; - GtkEntry *tf_entry; gchar **tf_strv;
g_return_val_if_fail(doc, NULL);
if (! doc->tm_file || ! doc->tm_file->tags_array) return NULL;
- tf_entry = GTK_ENTRY(ui_lookup_widget(main_widgets.window, "entry_tagfilter")); - tf_strv = g_strsplit_set(gtk_entry_get_text(tf_entry), " ", -1); + tf_strv = g_strsplit_set(doc->priv->tag_filter, " ", -1);
for (i = 0; i < doc->tm_file->tags_array->len; ++i) {
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).