[geany/geany] d3ded1: Filter symbols in the Symbol List (new feature)
Dmitry
git-noreply at xxxxx
Thu Jan 13 14:48:31 UTC 2022
Branch: refs/heads/master
Author: Dmitry <dmitryunruh at googlemail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Thu, 13 Jan 2022 14:48:31 UTC
Commit: d3ded11ad2c8caeb0dd4aef2fcff517c5672b2e2
https://github.com/geany/geany/commit/d3ded11ad2c8caeb0dd4aef2fcff517c5672b2e2
Log Message:
-----------
Filter symbols in the Symbol List (new feature)
Modified Paths:
--------------
data/geany.glade
src/callbacks.c
src/callbacks.h
src/symbols.c
Modified: data/geany.glade
43 lines changed, 37 insertions(+), 6 deletions(-)
===================================================================
@@ -8245,17 +8245,48 @@
<signal name="switch-page" handler="on_tv_notebook_switch_page" swapped="no"/>
<signal name="switch-page" handler="on_tv_notebook_switch_page_after" after="yes" swapped="no"/>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <object class="GtkVBox" id="vbox46">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkEntry" id="entry_tagfilter">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">Filter the Symbol List</property>
+ <property name="invisible_char">•</property>
+ <property name="secondary_icon_stock">gtk-clear</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">True</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <signal name="changed" handler="on_entry_tagfilter_changed" swapped="no"/>
+ <signal name="icon-press" handler="on_entry_tagfilter_icon_press" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
- <object class="GtkTreeView" id="treeview2">
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="enable_search">False</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="treeview2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="enable_search">False</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
</child>
Modified: src/callbacks.c
16 lines changed, 15 insertions(+), 1 deletions(-)
===================================================================
@@ -437,6 +437,20 @@ 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();
+ sidebar_update_tag_list(doc, TRUE);
+}
+
+
+void on_entry_tagfilter_icon_press(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event, gpointer user_data)
+{
+ if (event->button.button == 1)
+ gtk_entry_set_text(entry, "");
+}
+
+
/* hides toolbar from toolbar popup menu */
static void on_hide_toolbar1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
@@ -498,7 +512,7 @@ static void on_notebook1_switch_page_after(GtkNotebook *notebook, gpointer page,
ui_update_popup_reundo_items(doc);
ui_document_show_hide(doc); /* update the document menu */
build_menu_update(doc);
- sidebar_update_tag_list(doc, FALSE);
+ sidebar_update_tag_list(doc, TRUE);
document_highlight_tags(doc);
document_check_disk_status(doc, TRUE);
Modified: src/callbacks.h
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -72,6 +72,10 @@ void on_toolbar_search_entry_changed(GtkAction *action, const gchar *text, gpoin
void on_toolbar_search_entry_activate(GtkAction *action, const gchar *text, gpointer user_data);
+void on_entry_tagfilter_changed(GtkAction *action, gpointer user_data);
+
+void on_entry_tagfilter_icon_press(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event, gpointer user_data);
+
void on_toggle_case1_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_find_usage1_activate(GtkMenuItem *menuitem, gpointer user_data);
Modified: src/symbols.c
28 lines changed, 26 insertions(+), 2 deletions(-)
===================================================================
@@ -319,13 +319,22 @@ static gint compare_symbol_lines(gconstpointer a, gconstpointer b)
static GList *get_tag_list(GeanyDocument *doc, TMTagType tag_types)
{
GList *tag_names = NULL;
- guint i;
+ guint i, j;
+
+ GtkEntry *tfentry = NULL; // entry_tagfilter
+ gchar **tfarray = NULL; // Array of the Tag Filter
+ guint tfarlen = 0; // Length of the tfarray
+ gboolean tfapres = TRUE; // Result of the Tag Filter Applying
g_return_val_if_fail(doc, NULL);
if (! doc->tm_file || ! doc->tm_file->tags_array)
return NULL;
+ tfentry = GTK_ENTRY(ui_lookup_widget(main_widgets.window, "entry_tagfilter"));
+ tfarray = g_strsplit_set(gtk_entry_get_text(tfentry), " ", -1);
+ tfarlen = g_strv_length(tfarray);
+
for (i = 0; i < doc->tm_file->tags_array->len; ++i)
{
TMTag *tag = TM_TAG(doc->tm_file->tags_array->pdata[i]);
@@ -335,10 +344,25 @@ static GList *get_tag_list(GeanyDocument *doc, TMTagType tag_types)
if (tag->type & tag_types)
{
- tag_names = g_list_prepend(tag_names, tag);
+ tfapres = TRUE;
+ for (j = 0; j < tfarlen; j++)
+ {
+ if (tfarray[j][0] != '\0')
+ {
+ if (g_strrstr(tag->name, tfarray[j]) == NULL)
+ {
+ tfapres = FALSE;
+ break;
+ }
+ }
+ }
+ if (tfapres) tag_names = g_list_prepend(tag_names, tag);
}
}
tag_names = g_list_sort(tag_names, compare_symbol_lines);
+
+ g_strfreev(tfarray);
+
return tag_names;
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list