[gnome-builder/albfan/grep-filters: 2/2] grep: Use path filters in UI
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/albfan/grep-filters: 2/2] grep: Use path filters in UI
- Date: Wed, 11 Sep 2019 19:47:25 +0000 (UTC)
commit 3b2084be9b176c908d3747e72f254010425002f2
Author: Alberto Fanjul <albertofanjul gmail com>
Date: Wed Sep 11 21:47:03 2019 +0200
grep: Use path filters in UI
src/plugins/grep/gbp-grep-popover.c | 38 ++++++++++++++++++++++++++++++++++++
src/plugins/grep/gbp-grep-popover.ui | 37 ++++++++++++++++++++++++++---------
2 files changed, 66 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/grep/gbp-grep-popover.c b/src/plugins/grep/gbp-grep-popover.c
index af2df8e2a..7c6610ec3 100644
--- a/src/plugins/grep/gbp-grep-popover.c
+++ b/src/plugins/grep/gbp-grep-popover.c
@@ -37,6 +37,10 @@ struct _GbpGrepPopover
GFile *file;
GtkEntry *entry;
+ GtkEntry *file_filter;
+ GtkEntry *ignore_filter;
+ char **file_filters;
+ char **ignore_filters;
GtkButton *button;
GtkCheckButton *regex_button;
GtkCheckButton *whole_button;
@@ -90,6 +94,10 @@ gbp_grep_popover_button_clicked_cb (GbpGrepPopover *self,
gboolean at_word_boundaries;
gboolean case_sensitive;
gboolean recursive;
+ gchar *file_filter;
+ gchar **file_filters;
+ gchar *ignore_filter;
+ gchar **ignore_filters;
g_assert (GBP_IS_GREP_POPOVER (self));
g_assert (GTK_IS_BUTTON (button));
@@ -111,6 +119,34 @@ gbp_grep_popover_button_clicked_cb (GbpGrepPopover *self,
gbp_grep_model_set_case_sensitive (model, case_sensitive);
gbp_grep_model_set_query (model, gtk_entry_get_text (self->entry));
+ file_filter = gtk_entry_get_text (self->file_filter);
+ if (file_filter != NULL)
+ {
+ file_filter = g_strdup (file_filter);
+ if (g_strcmp0 (g_strstrip (file_filter), "") != 0)
+ {
+ file_filters = g_strsplit (g_strstrip (file_filter), ",", 0);
+ for (int i = 0; file_filters[i]; i++) {
+ file_filters[i] = g_strstrip (file_filters[i]);
+ }
+ gbp_grep_model_set_file_filter (model, (const gchar * const *)file_filters);
+ }
+ }
+
+ ignore_filter = gtk_entry_get_text (self->ignore_filter);
+ if (ignore_filter != NULL)
+ {
+ ignore_filter = g_strdup (ignore_filter);
+ if (g_strcmp0 (g_strstrip (ignore_filter), "") != 0)
+ {
+ ignore_filters = g_strsplit (g_strstrip (ignore_filter), ",", 0);
+ for (int i = 0; ignore_filters[i]; i++) {
+ ignore_filters[i] = g_strstrip (ignore_filters[i]);
+ }
+ gbp_grep_model_set_ignore_filter (model, (const gchar * const *)ignore_filters);
+ }
+ }
+
if (gtk_widget_get_visible (GTK_WIDGET (self->recursive_button)))
gbp_grep_model_set_recursive (model, recursive);
else
@@ -218,6 +254,8 @@ gbp_grep_popover_class_init (GbpGrepPopoverClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/plugins/grep/gbp-grep-popover.ui");
gtk_widget_class_bind_template_child (widget_class, GbpGrepPopover, button);
gtk_widget_class_bind_template_child (widget_class, GbpGrepPopover, entry);
+ gtk_widget_class_bind_template_child (widget_class, GbpGrepPopover, file_filter);
+ gtk_widget_class_bind_template_child (widget_class, GbpGrepPopover, ignore_filter);
gtk_widget_class_bind_template_child (widget_class, GbpGrepPopover, regex_button);
gtk_widget_class_bind_template_child (widget_class, GbpGrepPopover, whole_button);
gtk_widget_class_bind_template_child (widget_class, GbpGrepPopover, case_button);
diff --git a/src/plugins/grep/gbp-grep-popover.ui b/src/plugins/grep/gbp-grep-popover.ui
index 2a8baa2c8..80b406183 100644
--- a/src/plugins/grep/gbp-grep-popover.ui
+++ b/src/plugins/grep/gbp-grep-popover.ui
@@ -19,10 +19,9 @@
</child>
<child>
<object class="GtkBox">
- <property name="margin-top">6</property>
- <property name="orientation">horizontal</property>
- <property name="spacing">6</property>
- <property name="visible">true</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkEntry" id="entry">
<property name="placeholder-text" translatable="yes">Search for…</property>
@@ -31,14 +30,34 @@
</object>
</child>
<child>
- <object class="GtkButton" id="button">
+ <object class="GtkEntry" id="file_filter">
+ <property name="placeholder-text" translatable="yes">File filter…</property>
+ <property name="width-chars">24</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkEntry" id="ignore_filter">
+ <property name="placeholder-text" translatable="yes">Dirs to ignore…</property>
+ <property name="width-chars">24</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button">
<property name="hexpand">false</property>
<property name="halign">end</property>
- <property name="label" translatable="yes">Find</property>
+ <property name="label" translatable="yes">Find</property>
<property name="visible">true</property>
- <style>
- <class name="suggested-action"/>
- </style>
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]