Revision: 3383 http://geany.svn.sourceforge.net/geany/?rev=3383&view=rev Author: ntrel Date: 2008-12-16 13:01:47 +0000 (Tue, 16 Dec 2008)
Log Message: ----------- 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.
Modified Paths: -------------- trunk/ChangeLog trunk/src/keyfile.c trunk/src/keyfile.h trunk/src/main.c trunk/src/search.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-12-15 21:21:19 UTC (rev 3382) +++ trunk/ChangeLog 2008-12-16 13:01:47 UTC (rev 3383) @@ -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>
* src/build.c:
Modified: trunk/src/keyfile.c =================================================================== --- trunk/src/keyfile.c 2008-12-15 21:21:19 UTC (rev 3382) +++ trunk/src/keyfile.c 2008-12-16 13:01:47 UTC (rev 3383) @@ -92,15 +92,18 @@ static gint hpan_position; static gint vpan_position;
+static GPtrArray *keyfile_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) - pref_groups = g_ptr_array_new(); + g_ptr_array_add(keyfile_groups, group);
- g_ptr_array_add(pref_groups, group); + if (for_prefs_dialog) + g_ptr_array_add(pref_groups, group); }
@@ -109,7 +112,7 @@ GeanyPrefGroup *group;
group = stash_group_new(PACKAGE); - add_pref_group(group); + configuration_add_pref_group(group, TRUE); stash_group_add_string(group, &prefs.default_open_path, "default_open_path", "");
@@ -143,14 +146,9 @@ stash_group_add_integer(group, (gint*)&editor_prefs.autocompletion_max_entries, "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) */ group = stash_group_new(PACKAGE); - add_pref_group(group); + configuration_add_pref_group(group, FALSE); stash_group_set_write_once(group, TRUE); stash_group_add_boolean(group, &editor_prefs.show_scrollbars, "show_editor_scrollbars", TRUE); @@ -177,7 +175,7 @@ gpointer *ptr; GeanyPrefGroup *group;
- foreach_ptr_array(group, ptr, pref_groups) + foreach_ptr_array(group, ptr, keyfile_groups) { switch (action) { @@ -1096,6 +1094,8 @@
void configuration_init(void) { + keyfile_groups = g_ptr_array_new(); + pref_groups = g_ptr_array_new(); init_pref_groups(); }
@@ -1105,9 +1105,10 @@ gpointer *ptr; GeanyPrefGroup *group;
- foreach_ptr_array(group, ptr, pref_groups) + foreach_ptr_array(group, ptr, keyfile_groups) stash_group_free(group);
+ g_ptr_array_free(keyfile_groups, TRUE); g_ptr_array_free(pref_groups, TRUE); }
Modified: trunk/src/keyfile.h =================================================================== --- trunk/src/keyfile.h 2008-12-15 21:21:19 UTC (rev 3382) +++ trunk/src/keyfile.h 2008-12-16 13:01:47 UTC (rev 3383) @@ -33,6 +33,10 @@
void configuration_finalize(void);
+struct GeanyPrefGroup; + +void configuration_add_pref_group(struct GeanyPrefGroup *group, gboolean for_prefs_dialog); + void configuration_save(void);
gboolean configuration_load(void);
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2008-12-15 21:21:19 UTC (rev 3382) +++ trunk/src/main.c 2008-12-16 13:01:47 UTC (rev 3383) @@ -921,11 +921,11 @@ editor_init();
configuration_init(); + search_init(); load_settings();
msgwin_init(); build_init(); - search_init(); ui_create_insert_menu_items(); ui_create_insert_date_menu_items(); keybindings_init();
Modified: trunk/src/search.c =================================================================== --- trunk/src/search.c 2008-12-15 21:21:19 UTC (rev 3382) +++ trunk/src/search.c 2008-12-16 13:01:47 UTC (rev 3383) @@ -40,6 +40,8 @@ #include "editor.h" #include "encodings.h" #include "project.h" +#include "keyfile.h" +#include "stash.h"
#include <unistd.h> #include <string.h> @@ -50,7 +52,8 @@ #endif
-enum { +enum +{ GEANY_RESPONSE_FIND = 1, GEANY_RESPONSE_FIND_PREVIOUS, GEANY_RESPONSE_FIND_IN_FILE, @@ -63,7 +66,14 @@ GEANY_RESPONSE_REPLACE_IN_SEL };
+enum +{ + FIF_FGREP, + FIF_GREP, + FIF_EGREP +};
+ GeanySearchData search_data;
GeanySearchPrefs search_prefs; @@ -71,6 +81,15 @@
static struct { + gint fif_mode; +} +settings; + +GeanyPrefGroup *fif_prefs = NULL; + + +static struct +{ GtkWidget *find_dialog; GtkWidget *replace_dialog; GtkWidget *find_in_files_dialog; @@ -121,9 +140,30 @@ 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) { search_data.text = NULL; + init_prefs(); }
@@ -654,6 +694,8 @@
rbtn = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(rbtn), _("_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.")); gtk_button_set_focus_on_click(GTK_BUTTON(rbtn), FALSE); gtk_container_add(GTK_CONTAINER(rbox), rbtn); @@ -744,6 +786,8 @@ create_fif_dialog(); 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 */ if (! sel && ! GTK_WIDGET_VISIBLE(widgets.find_in_files_dialog)) sel = editor_get_default_selection(editor, search_prefs.use_current_word, NULL); @@ -1118,10 +1162,6 @@
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( lookup_widget(widgets.find_in_files_dialog, "check_invert"))); gboolean case_sens = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( @@ -1143,9 +1183,9 @@ if (recursive) g_string_append_c(gstr, 'r');
- if (fgrep) + if (settings.fif_mode == FIF_FGREP) g_string_append_c(gstr, 'F'); - else if (! grep) + else if (settings.fif_mode == FIF_EGREP) g_string_append_c(gstr, 'E');
if (extra) @@ -1168,6 +1208,8 @@ on_find_in_files_dialog_response(GtkDialog *dialog, gint response, G_GNUC_UNUSED gpointer user_data) { + stash_group_update(fif_prefs, widgets.find_in_files_dialog); + if (response == GTK_RESPONSE_ACCEPT) { GtkWidget *search_combo = find_in_files.search_combo;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.