SF.net SVN: geany: [2389] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Mar 23 16:29:44 UTC 2008


Revision: 2389
          http://geany.svn.sourceforge.net/geany/?rev=2389&view=rev
Author:   eht16
Date:     2008-03-23 09:29:43 -0700 (Sun, 23 Mar 2008)

Log Message:
-----------
Add preference for not using the current word under the cursor when opening Find dialogs.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/geany.glade
    trunk/src/callbacks.c
    trunk/src/editor.c
    trunk/src/editor.h
    trunk/src/interface.c
    trunk/src/keyfile.c
    trunk/src/prefs.c
    trunk/src/prefs.h
    trunk/src/search.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/ChangeLog	2008-03-23 16:29:43 UTC (rev 2389)
@@ -7,6 +7,11 @@
  * tagmanager/make.c, src/symbols.c:
    Update Makefile parser from CTags SVN and improve it to detect
    targets in Makefiles.
+ * geany.glade, src/interface.c, src/prefs.c, src/prefs.h, src/keyfile.c
+   src/callbacks.c, src/search.c, src/editor.c, src/editor.h,
+   geany.glade:
+   Add preference for not using the current word under the cursor when
+   opening Find dialogs.
 
 
 2008-03-21  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/geany.glade
===================================================================
--- trunk/geany.glade	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/geany.glade	2008-03-23 16:29:43 UTC (rev 2389)
@@ -3553,6 +3553,25 @@
 			      <property name="fill">False</property>
 			    </packing>
 			  </child>
+
+			  <child>
+			    <widget class="GtkCheckButton" id="check_search_use_current_word">
+			      <property name="visible">True</property>
+			      <property name="tooltip" translatable="yes">Use current word under the cursor when opening the Find, Find in Files or Replace dialog and there is no selection.</property>
+			      <property name="label" translatable="yes">Use the current word under the cursor for Find dialogs</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>
 			</widget>
 		      </child>
 		    </widget>

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/callbacks.c	2008-03-23 16:29:43 UTC (rev 2389)
@@ -1921,7 +1921,7 @@
 
 	if (! DOC_IDX_VALID(idx)) return;
 
-	sel = editor_get_default_selection(idx, GEANY_WORDCHARS"./");
+	sel = editor_get_default_selection(idx, TRUE, GEANY_WORDCHARS"./");
 
 	if (sel != NULL)
 	{

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/editor.c	2008-03-23 16:29:43 UTC (rev 2389)
@@ -2626,7 +2626,7 @@
 
 /* wordchars: NULL or a string containing characters to match a word.
  * Returns: the current selection or the current word. */
-gchar *editor_get_default_selection(gint idx, const gchar *wordchars)
+gchar *editor_get_default_selection(gint idx, gboolean use_current_word, const gchar *wordchars)
 {
 	gchar *s = NULL;
 
@@ -2640,7 +2640,7 @@
 		s = g_malloc(len + 1);
 		sci_get_selected_text(doc_list[idx].sci, s);
 	}
-	else if (sci_get_lines_selected(doc_list[idx].sci) == 0)
+	else if (sci_get_lines_selected(doc_list[idx].sci) == 0 && use_current_word)
 	{	/* use the word at current cursor position */
 		gchar word[GEANY_MAX_WORD_LENGTH];
 

Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/editor.h	2008-03-23 16:29:43 UTC (rev 2389)
@@ -145,7 +145,7 @@
 void editor_find_current_word(ScintillaObject *sci, gint pos, gchar *word, size_t wordlen,
 	const gchar *wc);
 
-gchar *editor_get_default_selection(gint idx, const gchar *wordchars);
+gchar *editor_get_default_selection(gint idx, gboolean use_current_word, const gchar *wordchars);
 
 void editor_select_word(ScintillaObject *sci);
 

Modified: trunk/src/interface.c
===================================================================
--- trunk/src/interface.c	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/interface.c	2008-03-23 16:29:43 UTC (rev 2389)
@@ -2499,6 +2499,7 @@
   GtkWidget *check_suppress_status_msgs;
   GtkWidget *check_auto_focus;
   GtkWidget *check_ask_suppress_search_dialogs;
+  GtkWidget *check_search_use_current_word;
   GtkWidget *label199;
   GtkWidget *frame25;
   GtkWidget *alignment28;
@@ -2937,6 +2938,13 @@
   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);
   gtk_button_set_focus_on_click (GTK_BUTTON (check_ask_suppress_search_dialogs), FALSE);
 
+  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);
+  gtk_box_pack_start (GTK_BOX (vbox21), check_search_use_current_word, FALSE, FALSE, 0);
+  GTK_WIDGET_UNSET_FLAGS (check_search_use_current_word, GTK_CAN_FOCUS);
+  gtk_tooltips_set_tip (tooltips, check_search_use_current_word, _("Use current word under the cursor when opening the Find, Find in Files or Replace dialog and there is no selection."), NULL);
+  gtk_button_set_focus_on_click (GTK_BUTTON (check_search_use_current_word), FALSE);
+
   label199 = gtk_label_new (_("<b>Miscellaneous</b>"));
   gtk_widget_show (label199);
   gtk_frame_set_label_widget (GTK_FRAME (frame19), label199);
@@ -4492,6 +4500,7 @@
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_suppress_status_msgs, "check_suppress_status_msgs");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_auto_focus, "check_auto_focus");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_ask_suppress_search_dialogs, "check_ask_suppress_search_dialogs");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, check_search_use_current_word, "check_search_use_current_word");
   GLADE_HOOKUP_OBJECT (prefs_dialog, label199, "label199");
   GLADE_HOOKUP_OBJECT (prefs_dialog, frame25, "frame25");
   GLADE_HOOKUP_OBJECT (prefs_dialog, alignment28, "alignment28");

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/keyfile.c	2008-03-23 16:29:43 UTC (rev 2389)
@@ -179,6 +179,7 @@
 	g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos);
 	g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", prefs.confirm_exit);
 	g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", prefs.suppress_search_dialogs);
+	g_key_file_set_boolean(config, PACKAGE, "pref_main_search_use_current_word", prefs.search_use_current_word);
 	g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_status_messages", prefs.suppress_status_messages);
 	g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_msgwin_pages);
 	g_key_file_set_boolean(config, PACKAGE, "beep_on_errors", prefs.beep_on_errors);
@@ -472,6 +473,7 @@
 	/* general */
 	prefs.confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", FALSE);
 	prefs.suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE);
+	prefs.search_use_current_word = utils_get_setting_boolean(config, PACKAGE, "pref_main_search_use_current_word", TRUE);
 	prefs.suppress_status_messages = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_status_messages", FALSE);
 	prefs.load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
 	project_prefs.project_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_session", TRUE);

Modified: trunk/src/prefs.c
===================================================================
--- trunk/src/prefs.c	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/prefs.c	2008-03-23 16:29:43 UTC (rev 2389)
@@ -198,6 +198,9 @@
 	widget = lookup_widget(ui_widgets.prefs_dialog, "check_ask_suppress_search_dialogs");
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.suppress_search_dialogs);
 
+	widget = lookup_widget(ui_widgets.prefs_dialog, "check_search_use_current_word");
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.search_use_current_word);
+
 	widget = lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction");
 	gtk_entry_set_text(GTK_ENTRY(widget), prefs.context_action_cmd);
 
@@ -597,6 +600,9 @@
 		widget = lookup_widget(ui_widgets.prefs_dialog, "check_suppress_status_msgs");
 		prefs.suppress_status_messages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
+		widget = lookup_widget(ui_widgets.prefs_dialog, "check_search_use_current_word");
+		prefs.search_use_current_word = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
 		widget = lookup_widget(ui_widgets.prefs_dialog, "check_auto_focus");
 		prefs.auto_focus = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 

Modified: trunk/src/prefs.h
===================================================================
--- trunk/src/prefs.h	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/prefs.h	2008-03-23 16:29:43 UTC (rev 2389)
@@ -36,6 +36,7 @@
 	gboolean		confirm_exit;
 	gboolean		beep_on_errors;
 	gboolean		suppress_search_dialogs;
+	gboolean		search_use_current_word;
 	gboolean		suppress_status_messages;
 	gboolean		switch_msgwin_pages;
 	gboolean		auto_focus;

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2008-03-23 15:25:42 UTC (rev 2388)
+++ trunk/src/search.c	2008-03-23 16:29:43 UTC (rev 2389)
@@ -247,7 +247,9 @@
 	}
 #endif
 
-	if (!s)	{ s=editor_get_default_selection(idx, NULL); }
+	if (!s)
+		s=editor_get_default_selection(idx, TRUE, NULL);
+
 	if (s)
 	{
 		setup_find_next(s);	/* allow find next/prev */
@@ -288,7 +290,7 @@
 
 	g_return_if_fail(DOC_IDX_VALID(idx));
 
-	sel = editor_get_default_selection(idx, NULL);
+	sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL);
 
 	if (widgets.find_dialog == NULL)
 	{
@@ -409,7 +411,7 @@
 
 	if (idx == -1 || ! doc_list[idx].is_valid) return;
 
-	sel = editor_get_default_selection(idx, NULL);
+	sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL);
 
 	if (widgets.replace_dialog == NULL)
 	{
@@ -708,13 +710,13 @@
 				G_CALLBACK(gtk_widget_hide_on_delete), NULL);
 
 		gtk_widget_show_all(widgets.find_in_files_dialog);
-		sel = editor_get_default_selection(idx, NULL);
+		sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL);
 	}
 
 	entry = GTK_BIN(combo)->child;
 	/* 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(idx, NULL);
+		sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL);
 	if (sel)
 		gtk_entry_set_text(GTK_ENTRY(entry), sel);
 	g_free(sel);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list