This patch makes it possible for plugins to fill the values of the "search for" and "extra options" fields of the find in files dialog.
Signed-off-by: Jiří Techet techet@gmail.com --- plugins/geanyfunctions.h | 2 ++ src/plugindata.h | 1 + src/plugins.c | 3 ++- src/search.c | 21 +++++++++++++++++++-- src/search.h | 1 + 5 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/plugins/geanyfunctions.h b/plugins/geanyfunctions.h index 0b0556e..d015ffd 100644 --- a/plugins/geanyfunctions.h +++ b/plugins/geanyfunctions.h @@ -316,6 +316,8 @@ geany_functions->p_tm->tm_workspace_remove_object #define search_show_find_in_files_dialog \ geany_functions->p_search->search_show_find_in_files_dialog +#define search_show_find_in_files_dialog_with_extra_opt \ + geany_functions->p_search->search_show_find_in_files_dialog_with_extra_opt #define highlighting_get_style \ geany_functions->p_highlighting->highlighting_get_style #define highlighting_set_styles \ diff --git a/src/plugindata.h b/src/plugindata.h index 5405639..aff3143 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -544,6 +544,7 @@ FiletypeFuncs; typedef struct SearchFuncs { void (*search_show_find_in_files_dialog) (const gchar *dir); + void (*search_show_find_in_files_dialog_with_extra_opt) (const gchar *dir, const gchar *extra_opt); } SearchFuncs;
diff --git a/src/plugins.c b/src/plugins.c index 8269111..db421b0 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -281,7 +281,8 @@ static TagManagerFuncs tagmanager_funcs = { };
static SearchFuncs search_funcs = { - &search_show_find_in_files_dialog + &search_show_find_in_files_dialog, + &search_show_find_in_files_dialog_with_extra_opt };
static HighlightingFuncs highlighting_funcs = { diff --git a/src/search.c b/src/search.c index 3e60f62..2149629 100644 --- a/src/search.c +++ b/src/search.c @@ -126,9 +126,10 @@ static struct GtkWidget *dir_combo; GtkWidget *search_combo; GtkWidget *encoding_combo; + GtkWidget *extra_opt_entry; gint position[2]; /* x, y */ } -fif_dlg = {NULL, NULL, NULL, NULL, {0, 0}}; +fif_dlg = {NULL, NULL, NULL, NULL, NULL, {0, 0}};
static gboolean search_read_io(GIOChannel *source, GIOCondition condition, gpointer data); @@ -850,6 +851,7 @@ static void create_fif_dialog(void) gtk_widget_set_sensitive(entry_extra, FALSE); ui_widget_set_tooltip_text(entry_extra, _("Other options to pass to Grep")); ui_hookup_widget(fif_dlg.dialog, entry_extra, "entry_extra"); + fif_dlg.extra_opt_entry = entry_extra;
/* enable entry_extra when check_extra is checked */ g_signal_connect(check_extra, "toggled", @@ -871,7 +873,7 @@ static void create_fif_dialog(void)
/* dir is the directory to search in (UTF-8 encoding), maybe NULL to determine it the usual way * by using the current file's path */ -void search_show_find_in_files_dialog(const gchar *dir) +static void search_show_find_in_files_dialog_internal(const gchar *dir, const gchar *extra_opt) { GtkWidget *entry; /* for child GtkEntry of a GtkComboBoxEntry */ GeanyDocument *doc = document_get_current(); @@ -930,6 +932,9 @@ void search_show_find_in_files_dialog(const gchar *dir) g_free(cur_dir); }
+ if (NZV(extra_opt)) + gtk_entry_set_text(GTK_ENTRY(fif_dlg.extra_opt_entry), extra_opt); + /* set the encoding of the current file */ if (doc != NULL) enc_idx = encodings_get_idx_from_charset(doc->encoding); @@ -950,6 +955,18 @@ void search_show_find_in_files_dialog(const gchar *dir) }
+void search_show_find_in_files_dialog(const gchar *dir) +{ + search_show_find_in_files_dialog_internal(dir, NULL); +} + + +void search_show_find_in_files_dialog_with_extra_opt(const gchar *dir, const gchar *extra_opt) +{ + search_show_find_in_files_dialog_internal(dir, extra_opt); +} + + static void on_find_replace_checkbutton_toggled(GtkToggleButton *togglebutton, gpointer user_data) { diff --git a/src/search.h b/src/search.h index 0934990..26389f6 100644 --- a/src/search.h +++ b/src/search.h @@ -67,6 +67,7 @@ void search_show_replace_dialog(void);
void search_show_find_in_files_dialog(const gchar *dir);
+void search_show_find_in_files_dialog_with_extra_opt(const gchar *dir, const gchar *extra_opt);
struct _ScintillaObject; struct Sci_TextToFind;