Index: src/interface.c
===================================================================
--- src/interface.c	(revision 1004)
+++ src/interface.c	(working copy)
@@ -2140,6 +2140,7 @@
   GtkWidget *check_switch_pages;
   GtkWidget *check_vte;
   GtkWidget *check_ask_for_quit;
+  GtkWidget *check_ask_suppress_search_dialogs;
   GtkWidget *label163;
   GtkWidget *frame15;
   GtkWidget *alignment18;
@@ -2393,6 +2394,13 @@
   gtk_tooltips_set_tip (tooltips, check_ask_for_quit, _("Shows a confirmation dialog on exit."), NULL);
   gtk_button_set_focus_on_click (GTK_BUTTON (check_ask_for_quit), FALSE);
 
+  check_ask_suppress_search_dialogs = gtk_check_button_new_with_mnemonic (_("Suppress Search and Find Next Dialog"));
+  gtk_widget_show (check_ask_suppress_search_dialogs);
+  gtk_box_pack_start (GTK_BOX (vbox4), check_ask_suppress_search_dialogs, FALSE, FALSE, 0);
+  GTK_WIDGET_UNSET_FLAGS (check_ask_suppress_search_dialogs, GTK_CAN_FOCUS);
+  gtk_tooltips_set_tip (tooltips, check_ask_suppress_search_dialogs, _("Search Dialog and Find Next Dialog are suppressed"), NULL);
+  gtk_button_set_focus_on_click (GTK_BUTTON (check_ask_suppress_search_dialogs), FALSE);
+
   label163 = gtk_label_new (" ");
   gtk_widget_show (label163);
   gtk_box_pack_start (GTK_BOX (vbox4), label163, FALSE, FALSE, 0);
@@ -3417,6 +3425,7 @@
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_switch_pages, "check_switch_pages");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_vte, "check_vte");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_ask_for_quit, "check_ask_for_quit");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, check_ask_suppress_search_dialogs, "check_ask_suppress_search_dialogs");
   GLADE_HOOKUP_OBJECT (prefs_dialog, label163, "label163");
   GLADE_HOOKUP_OBJECT (prefs_dialog, frame15, "frame15");
   GLADE_HOOKUP_OBJECT (prefs_dialog, alignment18, "alignment18");
Index: src/geany.h
===================================================================
--- src/geany.h	(revision 1004)
+++ src/geany.h	(working copy)
@@ -113,6 +113,7 @@
 	gboolean			 pref_main_load_session;
 	gboolean			 pref_main_save_winpos;
 	gboolean			 pref_main_confirm_exit;
+	gboolean			 pref_main_suppress_search_dialogs;
 	gboolean			 pref_toolbar_show_search;
 	gboolean			 pref_toolbar_show_goto;
 	gboolean			 pref_toolbar_show_undo;
Index: src/keyfile.c
===================================================================
--- src/keyfile.c	(revision 1004)
+++ src/keyfile.c	(working copy)
@@ -153,6 +153,7 @@
 	}
 	g_key_file_set_integer(config, PACKAGE, "pref_editor_tab_width", app->pref_editor_tab_width);
 	g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", app->pref_main_confirm_exit);
+	g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", app->pref_main_suppress_search_dialogs);
 	g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", app->pref_main_load_session);
 	g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", app->pref_main_save_winpos);
 	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", app->toolbar_visible);
@@ -361,6 +362,7 @@
 		g_free(tmp_string);
 	}
 	app->pref_main_confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", TRUE);
+	app->pref_main_suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", TRUE);
 	app->pref_main_load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
 	app->pref_main_save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
 	app->pref_toolbar_show_search = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_search", TRUE);
Index: src/search.c
===================================================================
--- src/search.c	(revision 1004)
+++ src/search.c	(working copy)
@@ -770,6 +770,8 @@
 			document_find_text(idx, search_data.text, search_data.flags,
 				(response == GEANY_RESPONSE_FIND_PREVIOUS), TRUE);
 			check_close = FALSE;
+			if (app->pref_main_suppress_search_dialogs)
+				check_close = TRUE;
 			break;
 
 			case GEANY_RESPONSE_FIND_IN_FILE:
Index: src/document.c
===================================================================
--- src/document.c	(revision 1004)
+++ src/document.c	(working copy)
@@ -999,13 +999,15 @@
 gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search_backwards,
 		gboolean scroll)
 {
-	gint selection_end, selection_start, search_pos;
+	gint selection_end, selection_start, search_pos, first_visible_line;
 
 	g_return_val_if_fail(text != NULL, -1);
 	if (idx == -1 || ! *text) return -1;
 	// Sci doesn't support searching backwards with a regex
 	if (flags & SCFIND_REGEXP) search_backwards = FALSE;
 
+	first_visible_line = SSM(doc_list[idx].sci, SCI_GETFIRSTVISIBLELINE, 0, 0);
+	
 	selection_start = sci_get_selection_start(doc_list[idx].sci);
 	selection_end = sci_get_selection_end(doc_list[idx].sci);
 	if ((selection_end - selection_start) > 0)
@@ -1043,15 +1045,19 @@
 		}
 
 		// we searched only part of the document, so ask whether to wraparound.
-		if (dialogs_show_question_full(GTK_STOCK_FIND, GTK_STOCK_CANCEL,
+		if (app->pref_main_suppress_search_dialogs || dialogs_show_question_full(GTK_STOCK_FIND, GTK_STOCK_CANCEL,
 			_("Wrap search and find again?"),
 			_("\"%s\" was not found."), text))
 		{
 			gint ret;
 			sci_goto_pos(doc_list[idx].sci, (search_backwards) ? sci_len : 0, TRUE);
 			ret = document_find_text(idx, text, flags, search_backwards, scroll);
-			if (ret == -1)	// return to original cursor position if not found
-				sci_goto_pos(doc_list[idx].sci, selection_end, FALSE);
+			if (ret == -1)	{ // return to original cursor position if not found
+				gint new_visible_line;
+				sci_goto_pos(doc_list[idx].sci, selection_start, FALSE);
+				new_visible_line = SSM(doc_list[idx].sci, SCI_GETFIRSTVISIBLELINE, 0, 0);
+				sci_scroll_lines(doc_list[idx].sci, first_visible_line - new_visible_line);
+			}
 			return ret;
 		}
 	}
Index: src/prefs.c
===================================================================
--- src/prefs.c	(revision 1004)
+++ src/prefs.c	(working copy)
@@ -88,6 +88,9 @@
 	widget = lookup_widget(app->prefs_dialog, "check_ask_for_quit");
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_main_confirm_exit);
 
+	widget = lookup_widget(app->prefs_dialog, "check_ask_suppress_search_dialogs");
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_main_suppress_search_dialogs);
+
 	widget = lookup_widget(app->prefs_dialog, "check_show_notebook_tabs");
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->show_notebook_tabs);
 	// disable following setting if notebook tabs are hidden
@@ -394,6 +397,9 @@
 		widget = lookup_widget(app->prefs_dialog, "check_ask_for_quit");
 		app->pref_main_confirm_exit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
+		widget = lookup_widget(app->prefs_dialog, "check_ask_suppress_search_dialogs");
+		app->pref_main_suppress_search_dialogs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
 		widget = lookup_widget(app->prefs_dialog, "check_switch_pages");
 		app->switch_msgwin_pages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 1004)
+++ ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2006-11-15  Bob Doan  <bdoan@sicompos.com>
+	* geany.glade: Implement Search Preference and keep SCI window "put" when we have an unsuccessful search
+	* src/document.c: 
+	* src/geany.h:
+	* src/interface.c: 
+	* src/keyfile.c: 
+	* src/prefs.c: 
+	* src/search.c: 
+
 2006-11-15  Enrico Tröger  <enrico.troeger@uvena.de>
 
  * src/vte.c: Don't unload the VTE module on exit to avoid crashes on
Index: geany.glade
===================================================================
--- geany.glade	(revision 1004)
+++ geany.glade	(working copy)
@@ -2870,6 +2870,25 @@
 		      </child>
 
 		      <child>
+			<widget class="GtkCheckButton" id="check_ask_suppress_search_dialogs">
+			  <property name="visible">True</property>
+			  <property name="tooltip" translatable="yes">Search Dialog and Find Next Dialog are suppressed</property>
+			  <property name="label" translatable="yes">Suppress Search and Find Next Dialog</property>
+			  <property name="use_underline">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">False</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="GtkLabel" id="label163">
 			  <property name="visible">True</property>
 			  <property name="label"> </property>
