Remember Find in Files mode at startup.
Add configuration_add_pref_group(), with separate array for GUI prefs. Move search pref group to search.c. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3383 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
9d84753cdf
commit
8de6b131c9
@ -1,3 +1,12 @@
|
|||||||
|
2008-12-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||||
|
|
||||||
|
* src/keyfile.c, src/keyfile.h, src/search.c, src/main.c:
|
||||||
|
Remember Find in Files mode at startup.
|
||||||
|
Add configuration_add_pref_group(), with separate array for GUI
|
||||||
|
prefs.
|
||||||
|
Move search pref group to search.c.
|
||||||
|
|
||||||
|
|
||||||
2008-12-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
2008-12-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||||
|
|
||||||
* src/build.c:
|
* src/build.c:
|
||||||
|
@ -92,15 +92,18 @@ static gint session_notebook_page;
|
|||||||
static gint hpan_position;
|
static gint hpan_position;
|
||||||
static gint vpan_position;
|
static gint vpan_position;
|
||||||
|
|
||||||
|
static GPtrArray *keyfile_groups = NULL;
|
||||||
GPtrArray *pref_groups = NULL;
|
GPtrArray *pref_groups = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void add_pref_group(GeanyPrefGroup *group)
|
/* The group will be free'd on quitting.
|
||||||
|
* @param for_prefs_dialog is whether the group also has Prefs dialog items. */
|
||||||
|
void configuration_add_pref_group(struct GeanyPrefGroup *group, gboolean for_prefs_dialog)
|
||||||
{
|
{
|
||||||
if (pref_groups == NULL)
|
g_ptr_array_add(keyfile_groups, group);
|
||||||
pref_groups = g_ptr_array_new();
|
|
||||||
|
|
||||||
g_ptr_array_add(pref_groups, group);
|
if (for_prefs_dialog)
|
||||||
|
g_ptr_array_add(pref_groups, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +112,7 @@ static void init_pref_groups(void)
|
|||||||
GeanyPrefGroup *group;
|
GeanyPrefGroup *group;
|
||||||
|
|
||||||
group = stash_group_new(PACKAGE);
|
group = stash_group_new(PACKAGE);
|
||||||
add_pref_group(group);
|
configuration_add_pref_group(group, TRUE);
|
||||||
stash_group_add_string(group, &prefs.default_open_path,
|
stash_group_add_string(group, &prefs.default_open_path,
|
||||||
"default_open_path", "");
|
"default_open_path", "");
|
||||||
|
|
||||||
@ -143,14 +146,9 @@ static void init_pref_groups(void)
|
|||||||
stash_group_add_integer(group, (gint*)&editor_prefs.autocompletion_max_entries,
|
stash_group_add_integer(group, (gint*)&editor_prefs.autocompletion_max_entries,
|
||||||
"autocompletion_max_entries", GEANY_MAX_AUTOCOMPLETE_WORDS);
|
"autocompletion_max_entries", GEANY_MAX_AUTOCOMPLETE_WORDS);
|
||||||
|
|
||||||
group = stash_group_new("search");
|
|
||||||
add_pref_group(group);
|
|
||||||
stash_group_add_toggle_button(group, &search_prefs.use_current_file_dir,
|
|
||||||
"pref_search_current_file_dir", TRUE, "check_fif_current_dir");
|
|
||||||
|
|
||||||
/* hidden prefs (don't overwrite them so users can edit them manually) */
|
/* hidden prefs (don't overwrite them so users can edit them manually) */
|
||||||
group = stash_group_new(PACKAGE);
|
group = stash_group_new(PACKAGE);
|
||||||
add_pref_group(group);
|
configuration_add_pref_group(group, FALSE);
|
||||||
stash_group_set_write_once(group, TRUE);
|
stash_group_set_write_once(group, TRUE);
|
||||||
stash_group_add_boolean(group, &editor_prefs.show_scrollbars,
|
stash_group_add_boolean(group, &editor_prefs.show_scrollbars,
|
||||||
"show_editor_scrollbars", TRUE);
|
"show_editor_scrollbars", TRUE);
|
||||||
@ -177,7 +175,7 @@ static void settings_action(GKeyFile *config, SettingAction action)
|
|||||||
gpointer *ptr;
|
gpointer *ptr;
|
||||||
GeanyPrefGroup *group;
|
GeanyPrefGroup *group;
|
||||||
|
|
||||||
foreach_ptr_array(group, ptr, pref_groups)
|
foreach_ptr_array(group, ptr, keyfile_groups)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
@ -1096,6 +1094,8 @@ static void generate_filetype_extensions(const gchar *output_dir)
|
|||||||
|
|
||||||
void configuration_init(void)
|
void configuration_init(void)
|
||||||
{
|
{
|
||||||
|
keyfile_groups = g_ptr_array_new();
|
||||||
|
pref_groups = g_ptr_array_new();
|
||||||
init_pref_groups();
|
init_pref_groups();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,9 +1105,10 @@ void configuration_finalize(void)
|
|||||||
gpointer *ptr;
|
gpointer *ptr;
|
||||||
GeanyPrefGroup *group;
|
GeanyPrefGroup *group;
|
||||||
|
|
||||||
foreach_ptr_array(group, ptr, pref_groups)
|
foreach_ptr_array(group, ptr, keyfile_groups)
|
||||||
stash_group_free(group);
|
stash_group_free(group);
|
||||||
|
|
||||||
|
g_ptr_array_free(keyfile_groups, TRUE);
|
||||||
g_ptr_array_free(pref_groups, TRUE);
|
g_ptr_array_free(pref_groups, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,10 @@ void configuration_init(void);
|
|||||||
|
|
||||||
void configuration_finalize(void);
|
void configuration_finalize(void);
|
||||||
|
|
||||||
|
struct GeanyPrefGroup;
|
||||||
|
|
||||||
|
void configuration_add_pref_group(struct GeanyPrefGroup *group, gboolean for_prefs_dialog);
|
||||||
|
|
||||||
void configuration_save(void);
|
void configuration_save(void);
|
||||||
|
|
||||||
gboolean configuration_load(void);
|
gboolean configuration_load(void);
|
||||||
|
@ -921,11 +921,11 @@ gint main(gint argc, gchar **argv)
|
|||||||
editor_init();
|
editor_init();
|
||||||
|
|
||||||
configuration_init();
|
configuration_init();
|
||||||
|
search_init();
|
||||||
load_settings();
|
load_settings();
|
||||||
|
|
||||||
msgwin_init();
|
msgwin_init();
|
||||||
build_init();
|
build_init();
|
||||||
search_init();
|
|
||||||
ui_create_insert_menu_items();
|
ui_create_insert_menu_items();
|
||||||
ui_create_insert_date_menu_items();
|
ui_create_insert_date_menu_items();
|
||||||
keybindings_init();
|
keybindings_init();
|
||||||
|
56
src/search.c
56
src/search.c
@ -40,6 +40,8 @@
|
|||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "encodings.h"
|
#include "encodings.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
#include "keyfile.h"
|
||||||
|
#include "stash.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -50,7 +52,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
GEANY_RESPONSE_FIND = 1,
|
GEANY_RESPONSE_FIND = 1,
|
||||||
GEANY_RESPONSE_FIND_PREVIOUS,
|
GEANY_RESPONSE_FIND_PREVIOUS,
|
||||||
GEANY_RESPONSE_FIND_IN_FILE,
|
GEANY_RESPONSE_FIND_IN_FILE,
|
||||||
@ -63,12 +66,28 @@ enum {
|
|||||||
GEANY_RESPONSE_REPLACE_IN_SEL
|
GEANY_RESPONSE_REPLACE_IN_SEL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
FIF_FGREP,
|
||||||
|
FIF_GREP,
|
||||||
|
FIF_EGREP
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
GeanySearchData search_data;
|
GeanySearchData search_data;
|
||||||
|
|
||||||
GeanySearchPrefs search_prefs;
|
GeanySearchPrefs search_prefs;
|
||||||
|
|
||||||
|
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
gint fif_mode;
|
||||||
|
}
|
||||||
|
settings;
|
||||||
|
|
||||||
|
GeanyPrefGroup *fif_prefs = NULL;
|
||||||
|
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
GtkWidget *find_dialog;
|
GtkWidget *find_dialog;
|
||||||
@ -121,9 +140,30 @@ search_find_in_files(const gchar *utf8_search_text, const gchar *dir, const gcha
|
|||||||
const gchar *enc);
|
const gchar *enc);
|
||||||
|
|
||||||
|
|
||||||
|
static void init_prefs(void)
|
||||||
|
{
|
||||||
|
GeanyPrefGroup *group;
|
||||||
|
|
||||||
|
group = stash_group_new("search");
|
||||||
|
configuration_add_pref_group(group, TRUE);
|
||||||
|
stash_group_add_toggle_button(group, &search_prefs.use_current_file_dir,
|
||||||
|
"pref_search_current_file_dir", TRUE, "check_fif_current_dir");
|
||||||
|
|
||||||
|
group = stash_group_new("search");
|
||||||
|
fif_prefs = group;
|
||||||
|
configuration_add_pref_group(group, FALSE);
|
||||||
|
stash_group_add_radio_buttons(group, &settings.fif_mode, "fif_mode", FIF_FGREP,
|
||||||
|
"radio_fgrep", FIF_FGREP,
|
||||||
|
"radio_grep", FIF_GREP,
|
||||||
|
"radio_egrep", FIF_EGREP,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void search_init(void)
|
void search_init(void)
|
||||||
{
|
{
|
||||||
search_data.text = NULL;
|
search_data.text = NULL;
|
||||||
|
init_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -654,6 +694,8 @@ static void create_fif_dialog()
|
|||||||
|
|
||||||
rbtn = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(rbtn),
|
rbtn = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(rbtn),
|
||||||
_("_Extended regular expressions"));
|
_("_Extended regular expressions"));
|
||||||
|
g_object_set_data_full(G_OBJECT(widgets.find_in_files_dialog), "radio_egrep",
|
||||||
|
g_object_ref(rbtn), (GDestroyNotify)g_object_unref);
|
||||||
ui_widget_set_tooltip_text(rbtn, _("See grep's manual page for more information."));
|
ui_widget_set_tooltip_text(rbtn, _("See grep's manual page for more information."));
|
||||||
gtk_button_set_focus_on_click(GTK_BUTTON(rbtn), FALSE);
|
gtk_button_set_focus_on_click(GTK_BUTTON(rbtn), FALSE);
|
||||||
gtk_container_add(GTK_CONTAINER(rbox), rbtn);
|
gtk_container_add(GTK_CONTAINER(rbox), rbtn);
|
||||||
@ -744,6 +786,8 @@ void search_show_find_in_files_dialog(const gchar *dir)
|
|||||||
create_fif_dialog();
|
create_fif_dialog();
|
||||||
sel = editor_get_default_selection(editor, search_prefs.use_current_word, NULL);
|
sel = editor_get_default_selection(editor, search_prefs.use_current_word, NULL);
|
||||||
}
|
}
|
||||||
|
stash_group_display(fif_prefs, widgets.find_in_files_dialog);
|
||||||
|
|
||||||
/* only set selection if the dialog is not already visible, or has just been created */
|
/* only set selection if the dialog is not already visible, or has just been created */
|
||||||
if (! sel && ! GTK_WIDGET_VISIBLE(widgets.find_in_files_dialog))
|
if (! sel && ! GTK_WIDGET_VISIBLE(widgets.find_in_files_dialog))
|
||||||
sel = editor_get_default_selection(editor, search_prefs.use_current_word, NULL);
|
sel = editor_get_default_selection(editor, search_prefs.use_current_word, NULL);
|
||||||
@ -1118,10 +1162,6 @@ on_widget_key_pressed_set_focus(GtkWidget *widget, GdkEventKey *event, gpointer
|
|||||||
|
|
||||||
static GString *get_grep_options(void)
|
static GString *get_grep_options(void)
|
||||||
{
|
{
|
||||||
gboolean fgrep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
|
||||||
lookup_widget(widgets.find_in_files_dialog, "radio_fgrep")));
|
|
||||||
gboolean grep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
|
||||||
lookup_widget(widgets.find_in_files_dialog, "radio_grep")));
|
|
||||||
gboolean invert = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
gboolean invert = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
||||||
lookup_widget(widgets.find_in_files_dialog, "check_invert")));
|
lookup_widget(widgets.find_in_files_dialog, "check_invert")));
|
||||||
gboolean case_sens = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
gboolean case_sens = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
||||||
@ -1143,9 +1183,9 @@ static GString *get_grep_options(void)
|
|||||||
if (recursive)
|
if (recursive)
|
||||||
g_string_append_c(gstr, 'r');
|
g_string_append_c(gstr, 'r');
|
||||||
|
|
||||||
if (fgrep)
|
if (settings.fif_mode == FIF_FGREP)
|
||||||
g_string_append_c(gstr, 'F');
|
g_string_append_c(gstr, 'F');
|
||||||
else if (! grep)
|
else if (settings.fif_mode == FIF_EGREP)
|
||||||
g_string_append_c(gstr, 'E');
|
g_string_append_c(gstr, 'E');
|
||||||
|
|
||||||
if (extra)
|
if (extra)
|
||||||
@ -1168,6 +1208,8 @@ static void
|
|||||||
on_find_in_files_dialog_response(GtkDialog *dialog, gint response,
|
on_find_in_files_dialog_response(GtkDialog *dialog, gint response,
|
||||||
G_GNUC_UNUSED gpointer user_data)
|
G_GNUC_UNUSED gpointer user_data)
|
||||||
{
|
{
|
||||||
|
stash_group_update(fif_prefs, widgets.find_in_files_dialog);
|
||||||
|
|
||||||
if (response == GTK_RESPONSE_ACCEPT)
|
if (response == GTK_RESPONSE_ACCEPT)
|
||||||
{
|
{
|
||||||
GtkWidget *search_combo = find_in_files.search_combo;
|
GtkWidget *search_combo = find_in_files.search_combo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user