>From 15fa8c054cb8f620d9b28a348d01649cd7c37f1e Mon Sep 17 00:00:00 2001
From: Dimitar Zhekov <dimitar.zhekov@gmail.com>
Date: Mon, 5 Dec 2011 21:24:33 +0200
Subject: [PATCH] split "always wrap search and hide find dialog" pref into
 "always wrap search" and "hide find dialog"

---
 geany.glade     |   26 +++++++++++++++++++++++---
 src/document.c  |    2 +-
 src/interface.c |   19 +++++++++++++------
 src/keyfile.c   |   14 ++++++++++++--
 src/search.c    |    8 +++++---
 src/search.h    |    3 ++-
 6 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/geany.glade b/geany.glade
index ba18b6f..4037970 100644
--- a/geany.glade
+++ b/geany.glade
@@ -3841,11 +3841,31 @@
 			      <property name="spacing">0</property>
 
 			      <child>
-				<widget class="GtkCheckButton" id="check_ask_suppress_search_dialogs">
+				<widget class="GtkCheckButton" id="check_always_wrap_search">
 				  <property name="visible">True</property>
-				  <property name="tooltip" translatable="yes">Always wrap search around the document and hide the Find dialog after clicking Find Next/Previous</property>
+				  <property name="tooltip" translatable="yes">Always wrap search around the document</property>
 				  <property name="can_focus">True</property>
-				  <property name="label" translatable="yes">Always wrap search and hide the Find dialog</property>
+				  <property name="label" translatable="yes">Always wrap search</property>
+				  <property name="use_underline">True</property>
+				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
+				  <property name="active">False</property>
+				  <property name="inconsistent">False</property>
+				  <property name="draw_indicator">True</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkCheckButton" id="check_hide_find_dialog">
+				  <property name="visible">True</property>
+				  <property name="tooltip" translatable="yes">Hide the Find dialog after clicking Find Next/Previous</property>
+				  <property name="can_focus">True</property>
+				  <property name="label" translatable="yes">Hide the Find dialog</property>
 				  <property name="use_underline">True</property>
 				  <property name="relief">GTK_RELIEF_NORMAL</property>
 				  <property name="focus_on_click">True</property>
diff --git a/src/document.c b/src/document.c
index dbc1e39..ad437da 100644
--- a/src/document.c
+++ b/src/document.c
@@ -1939,7 +1939,7 @@ gint document_find_text(GeanyDocument *doc, const gchar *text, const gchar *orig
 		}
 
 		/* we searched only part of the document, so ask whether to wraparound. */
-		if (search_prefs.suppress_dialogs ||
+		if (search_prefs.always_wrap ||
 			dialogs_show_question_full(parent, GTK_STOCK_FIND, GTK_STOCK_CANCEL,
 				_("Wrap search and find again?"), _("\"%s\" was not found."), original_text))
 		{
diff --git a/src/interface.c b/src/interface.c
index ce9fbff..126e794 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -2574,7 +2574,8 @@ create_prefs_dialog (void)
   GtkWidget *frame36;
   GtkWidget *alignment39;
   GtkWidget *vbox36;
-  GtkWidget *check_ask_suppress_search_dialogs;
+  GtkWidget *check_always_wrap_search;
+  GtkWidget *check_hide_find_dialog;
   GtkWidget *check_search_use_current_word;
   GtkWidget *check_fif_current_dir;
   GtkWidget *label215;
@@ -3195,10 +3196,15 @@ create_prefs_dialog (void)
   gtk_widget_show (vbox36);
   gtk_container_add (GTK_CONTAINER (alignment39), vbox36);
 
-  check_ask_suppress_search_dialogs = gtk_check_button_new_with_mnemonic (_("Always wrap search and hide the Find dialog"));
-  gtk_widget_show (check_ask_suppress_search_dialogs);
-  gtk_box_pack_start (GTK_BOX (vbox36), check_ask_suppress_search_dialogs, FALSE, FALSE, 0);
-  gtk_tooltips_set_tip (tooltips, check_ask_suppress_search_dialogs, _("Always wrap search around the document and hide the Find dialog after clicking Find Next/Previous"), NULL);
+  check_always_wrap_search = gtk_check_button_new_with_mnemonic (_("Always wrap search"));
+  gtk_widget_show (check_always_wrap_search);
+  gtk_box_pack_start (GTK_BOX (vbox36), check_always_wrap_search, FALSE, FALSE, 0);
+  gtk_tooltips_set_tip (tooltips, check_always_wrap_search, _("Always wrap search around the document"), NULL);
+
+  check_hide_find_dialog = gtk_check_button_new_with_mnemonic (_("Hide the Find dialog"));
+  gtk_widget_show (check_hide_find_dialog);
+  gtk_box_pack_start (GTK_BOX (vbox36), check_hide_find_dialog, FALSE, FALSE, 0);
+  gtk_tooltips_set_tip (tooltips, check_hide_find_dialog, _("Hide the Find dialog after clicking Find Next/Previous"), NULL);
 
   check_search_use_current_word = gtk_check_button_new_with_mnemonic (_("Use the current word under the cursor for Find dialogs"));
   gtk_widget_show (check_search_use_current_word);
@@ -5185,7 +5191,8 @@ create_prefs_dialog (void)
   GLADE_HOOKUP_OBJECT (prefs_dialog, frame36, "frame36");
   GLADE_HOOKUP_OBJECT (prefs_dialog, alignment39, "alignment39");
   GLADE_HOOKUP_OBJECT (prefs_dialog, vbox36, "vbox36");
-  GLADE_HOOKUP_OBJECT (prefs_dialog, check_ask_suppress_search_dialogs, "check_ask_suppress_search_dialogs");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, check_always_wrap_search, "check_always_wrap_search");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, check_hide_find_dialog, "check_hide_find_dialog");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_search_use_current_word, "check_search_use_current_word");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_fif_current_dir, "check_fif_current_dir");
   GLADE_HOOKUP_OBJECT (prefs_dialog, label215, "label215");
diff --git a/src/keyfile.c b/src/keyfile.c
index 356de05..19b4c2a 100644
--- a/src/keyfile.c
+++ b/src/keyfile.c
@@ -150,8 +150,6 @@ static void init_pref_groups(void)
 	stash_group_add_toggle_button(group, &interface_prefs.highlighting_invert_all,
 		"highlighting_invert_all", FALSE, "check_highlighting_invert");
 
-	stash_group_add_toggle_button(group, &search_prefs.suppress_dialogs,
-		"pref_main_suppress_search_dialogs", FALSE, "check_ask_suppress_search_dialogs");
 	stash_group_add_toggle_button(group, &search_prefs.use_current_word,
 		"pref_main_search_use_current_word", TRUE, "check_search_use_current_word");
 
@@ -693,6 +691,18 @@ static void load_dialog_prefs(GKeyFile *config)
 			utils_get_setting_boolean(config, PACKAGE, "use_safe_file_saving", FALSE));
 	}
 
+	/* compatibility with Geany 0.21 */
+	{
+		gboolean suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE);
+		const gchar GROUP[] = "search";
+
+		if (!g_key_file_has_key(config, GROUP, "pref_search_always_wrap", NULL))
+			g_key_file_set_boolean(config, GROUP, "pref_search_always_wrap", suppress_search_dialogs);
+
+		if (!g_key_file_has_key(config, GROUP, "pref_search_hide_find_dialog", NULL))
+			g_key_file_set_boolean(config, GROUP, "pref_search_hide_find_dialog", suppress_search_dialogs);
+	}
+
 	/* read stash prefs */
 	settings_action(config, SETTING_READ);
 
diff --git a/src/search.c b/src/search.c
index cd95a45..e066d94 100644
--- a/src/search.c
+++ b/src/search.c
@@ -189,6 +189,10 @@ static void init_prefs(void)
 
 	group = stash_group_new("search");
 	configuration_add_pref_group(group, TRUE);
+	stash_group_add_toggle_button(group, &search_prefs.always_wrap,
+		"pref_search_hide_find_dialog", FALSE, "check_always_wrap_search");
+	stash_group_add_toggle_button(group, &search_prefs.hide_find_dialog,
+		"pref_search_always_wrap", FALSE, "check_hide_find_dialog");
 	stash_group_add_toggle_button(group, &search_prefs.use_current_file_dir,
 		"pref_search_current_file_dir", TRUE, "check_fif_current_dir");
 	stash_group_add_boolean(group, &find_dlg.all_expanded, "find_all_expanded", FALSE);
@@ -1253,9 +1257,7 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
 				gint result = document_find_text(doc, search_data.text, search_data.original_text, search_data.flags,
 					(response == GEANY_RESPONSE_FIND_PREVIOUS), TRUE, GTK_WIDGET(find_dlg.dialog));
 				ui_set_search_entry_background(find_dlg.entry, (result > -1));
-				check_close = FALSE;
-				if (search_prefs.suppress_dialogs)
-					check_close = TRUE;
+				check_close = search_prefs.hide_find_dialog;
 				break;
 			}
 			case GEANY_RESPONSE_FIND_IN_FILE:
diff --git a/src/search.h b/src/search.h
index b074bf4..6d84cef 100644
--- a/src/search.h
+++ b/src/search.h
@@ -55,9 +55,10 @@ enum GeanyFindSelOptions
 /** Search preferences */
 typedef struct GeanySearchPrefs
 {
-	gboolean	suppress_dialogs;
+	gboolean	always_wrap;			/* don't ask whether to wrap search */
 	gboolean	use_current_word;		/**< Use current word for default search text */
 	gboolean	use_current_file_dir;	/* find in files directory to use on showing dialog */
+	gboolean	hide_find_dialog;		/* hide the find dialog on next or previous */
 	enum GeanyFindSelOptions find_selection_type;
 }
 GeanySearchPrefs;
-- 
1.7.7.3

