Behaves mostly like the symbol tree filter.
<img width="352" alt="Screenshot 2025-01-19 at 20 59 42" src="https://github.com/user-attachments/assets/42b7e64f-5b34-4770-9702-f709bd272...; />
Fixes #3078 You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/4210
-- Commit Summary --
* Set GtkTreeModelFilter as a model for document tree * Move code for selecting document in sidebar to sidebar.c * Add code for filtering document tree
-- File Changes --
M data/geany.glade (43) M src/callbacks.c (31) M src/callbacks.h (6) M src/document.c (8) M src/sidebar.c (201) M src/sidebar.h (6)
-- Patch Links --
https://github.com/geany/geany/pull/4210.patch https://github.com/geany/geany/pull/4210.diff
@techee pushed 1 commit.
218031be41e36e92105ecb6df24d37b78e924a12 Add xml element to glade file
@techee pushed 1 commit.
02faea438f07622cfa23a15c78f01ca14501d591 Remove redundant sidebar_openfiles_select()
@techee pushed 1 commit.
24f3d8bc2dbdfa2e0737ce24e3e6ac3200a6c4c9 Document the filtering feature
@eht16 approved this pull request.
Great. Reviewed, tested, works fine!
Only one tiny nitpick, feel free to ignore it.
@@ -475,6 +475,37 @@ void on_entry_tagfilter_activate(GtkEntry *entry, gpointer user_data)
}
+void on_entry_docfilter_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_docfilter")); + sidebar_openfiles_set_filter(gtk_entry_get_text(filter_entry)); +} + + +void on_entry_docfilter_icon_press(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event, gpointer user_data)
We could save this callback if we use `ui_entry_add_clear_icon()` which does the same and is just a convenience way of doing this.
But since it doesn't add any functionality, we can also leave it as is.
@techee commented on this pull request.
@@ -475,6 +475,37 @@ void on_entry_tagfilter_activate(GtkEntry *entry, gpointer user_data)
}
+void on_entry_docfilter_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_docfilter")); + sidebar_openfiles_set_filter(gtk_entry_get_text(filter_entry)); +} + + +void on_entry_docfilter_icon_press(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event, gpointer user_data)
I'll probably leave it as it is for now.
I'm planning to modify the symbol tree filtering feature to also use `GtkTreeModelFilter` (it doesn't work this way now, filtering is done "manually" which doesn't preserve the tree structure) and I could switch to using `ui_entry_add_clear_icon()` for both of them.
Merged #4210 into master.
Thanks! This is a great feature.
@techee Today I noticed a warning I didn't see before: `(geany:2232962): Gtk-CRITICAL **: 23:20:54.076: gtk_tree_model_filter_get_path: assertion 'GTK_TREE_MODEL_FILTER (model)->priv->stamp == iter->stamp' failed `
I'm not totally sure but it might be related to the changes here. It happens on opening **new** documents when **no** filter is set in the Documents sidebar tab.
Today I noticed a warning I didn't see before:
Thanks for reporting, I'll check what's going on.
See https://github.com/geany/geany/pull/4218 for the fix. This warning actually only happens when you use "persistent untitled documents" which is why I didn't notice it before.
github-comments@lists.geany.org