[Monodevelop-patches-list] r754 - in trunk/MonoDevelop: data/resources/glade src/AddIns/DisplayBindings/TextEditor/Gui/Dialogs
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Mon Feb 2 04:39:27 EST 2004
Author: jba
Date: 2004-02-02 04:39:27 -0500 (Mon, 02 Feb 2004)
New Revision: 754
Modified:
trunk/MonoDevelop/data/resources/glade/texteditoraddin.glade
trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Dialogs/ReplaceDialog.cs
Log:
added a 20 item find and replace history - saved to properties even
Modified: trunk/MonoDevelop/data/resources/glade/texteditoraddin.glade
===================================================================
--- trunk/MonoDevelop/data/resources/glade/texteditoraddin.glade 2004-02-02 05:49:59 UTC (rev 753)
+++ trunk/MonoDevelop/data/resources/glade/texteditoraddin.glade 2004-02-02 09:39:27 UTC (rev 754)
@@ -446,7 +446,7 @@
<property name="visible">True</property>
<property name="title" translatable="yes">Replace Dialog</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_MOUSE</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">True</property>
@@ -947,7 +947,7 @@
<property name="visible">True</property>
<property name="title" translatable="yes">Find Dialog</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_MOUSE</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">True</property>
Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Dialogs/ReplaceDialog.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Dialogs/ReplaceDialog.cs 2004-02-02 05:49:59 UTC (rev 753)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Dialogs/ReplaceDialog.cs 2004-02-02 09:39:27 UTC (rev 754)
@@ -9,6 +9,7 @@
using System.IO;
using System.Drawing;
using System.ComponentModel;
+using System.Collections.Specialized;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
@@ -24,18 +25,24 @@
using Gtk;
using Glade;
-using Assembly = System.Reflection.Assembly;
-
namespace ICSharpCode.SharpDevelop.Gui.Dialogs
{
public class ReplaceDialog
{
+ private const int HISTORY_LIMIT = 20;
+ private const char HISTORY_SEPARATOR_CHAR = (char) 10;
+ // regular members
public bool replaceMode;
+ StringCollection findHistory = new StringCollection();
+ StringCollection replaceHistory = new StringCollection();
+
+ // services
ResourceService resourceService = (ResourceService)ServiceManager.Services.GetService(typeof(IResourceService));
static PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
static FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService (typeof (StringParserService));
+ // gtk widgets
[Glade.Widget] Gtk.Combo searchPatternComboBox;
[Glade.Widget] Gtk.Combo replacePatternComboBox;
[Glade.Widget] Gtk.Button findHelpButton;
@@ -115,10 +122,12 @@
}
}
- public ReplaceDialog(bool replaceMode)// : base ("Find")
+ public ReplaceDialog(bool replaceMode)
{
+ // some members needed to initialise this dialog based on replace mode
this.replaceMode = replaceMode;
string dialogName = (replaceMode) ? "ReplaceDialogWidget" : "FindDialogWidget";
+
// we must do it from *here* otherwise, we get this assembly, not the caller
Glade.XML glade = new XML (null, "texteditoraddin.glade", dialogName, null);
glade.Autoconnect (this);
@@ -135,6 +144,8 @@
//AcceptButton = (Button)ControlDictionary["findButton"];
//CancelButton = (Button)ControlDictionary["closeButton"];
+ LoadHistoryValues();
+
ignoreCaseCheckBox.Active = !SearchReplaceManager.SearchOptions.IgnoreCase;
searchWholeWordOnlyCheckBox.Active = SearchReplaceManager.SearchOptions.SearchWholeWordOnly;
@@ -185,6 +196,7 @@
// insert event handlers
findButton.Clicked += new EventHandler(FindNextEvent);
closeButton.Clicked += new EventHandler(CloseDialogEvent);
+ ReplaceDialogPointer.Close += new EventHandler(CloseDialogEvent);
ReplaceDialogPointer.DeleteEvent += new GtkSharp.DeleteEventHandler (OnDeleted);
if (replaceMode) {
@@ -208,13 +220,16 @@
SearchReplaceManager.ReplaceDialog = this;
}
- protected void OnClosed(EventArgs e)
+ protected void OnClosed()
{
- SearchReplaceManager.ReplaceDialog = null;
+ SaveHistoryValues();
+
}
void OnDeleted (object o, GtkSharp.DeleteEventArgs args)
{
+ // perform the standard closing windows event
+ OnClosed();
SearchReplaceManager.ReplaceDialog = null;
}
@@ -274,6 +289,8 @@
finally {
//Cursor = Cursors.Default;
}
+
+ AddSearchHistoryItem(findHistory, searchPatternComboBox.Entry.Text);
}
void ReplaceEvent(object sender, EventArgs e)
@@ -291,6 +308,8 @@
finally {
//Cursor = Cursors.Default;
}
+
+ AddSearchHistoryItem(replaceHistory, replacePatternComboBox.Entry.Text);
}
void ReplaceAllEvent(object sender, EventArgs e)
@@ -307,6 +326,8 @@
} finally {
//Cursor = Cursors.Default;
}
+
+ AddSearchHistoryItem(replaceHistory, replacePatternComboBox.Entry.Text);
}
void MarkAllEvent(object sender, EventArgs e)
@@ -323,12 +344,14 @@
} finally {
//Cursor = Cursors.Default;
}
+
+ AddSearchHistoryItem(findHistory, searchPatternComboBox.Entry.Text);
}
void CloseDialogEvent(object sender, EventArgs e)
{
ReplaceDialogPointer.Hide();
- OnClosed (null);
+ OnClosed ();
}
void SpecialSearchStrategyCheckBoxChangedEvent(object sender, EventArgs e)
@@ -338,6 +361,71 @@
}
}
+ // generic method to add a string to a history item
+ private void AddSearchHistoryItem(StringCollection history, string toAdd)
+ {
+ // add the item to the find history
+ if (history.Contains(toAdd)) {
+ // remove it so it gets added at the top
+ history.Remove(toAdd);
+ }
+ // make sure there is only 20
+ if (history.Count == HISTORY_LIMIT) {
+ history.RemoveAt(HISTORY_LIMIT - 1);
+ }
+ history.Insert(0, toAdd);
+
+ // update the drop down for the combobox
+ string[] stringArray = new string[history.Count];
+ history.CopyTo(stringArray, 0);
+ if (history == findHistory) {
+ searchPatternComboBox.SetPopdownStrings(stringArray);
+ } else if( history == replaceHistory) {
+ replacePatternComboBox.SetPopdownStrings(stringArray);
+ }
+ }
+
+ // loads the history arrays from the property service
+ // NOTE: this dialog uses a newline character to separate search history strings in the properties file
+ private void LoadHistoryValues()
+ {
+ object stringArray;
+ // set the history in properties
+ stringArray = propertyService.GetProperty("MonoDevelop.FindReplaceDialogs.FindHistory");
+
+ if(stringArray != null) {
+ findHistory.AddRange(stringArray.ToString().Split(HISTORY_SEPARATOR_CHAR));
+ searchPatternComboBox.SetPopdownStrings(stringArray.ToString().Split(HISTORY_SEPARATOR_CHAR));
+ }
+
+ // now do the replace history
+ if(replaceMode) {
+ stringArray = propertyService.GetProperty("MonoDevelop.FindReplaceDialogs.ReplaceHistory");
+ if(stringArray != null) {
+ replaceHistory.AddRange(stringArray.ToString().Split(HISTORY_SEPARATOR_CHAR));
+ replacePatternComboBox.SetPopdownStrings(stringArray.ToString().Split(HISTORY_SEPARATOR_CHAR));
+ }
+ }
+ }
+
+ // saves the history arrays to the property service
+ // NOTE: this dialog uses a newline character to separate search history strings in the properties file
+ private void SaveHistoryValues()
+ {
+ string[] stringArray;
+ // set the history in properties
+ stringArray = new string[findHistory.Count];
+ findHistory.CopyTo(stringArray, 0);
+ propertyService.SetProperty("MonoDevelop.FindReplaceDialogs.FindHistory", string.Join(HISTORY_SEPARATOR_CHAR.ToString(), stringArray));
+
+ // now do the replace history
+ if(replaceMode) {
+ stringArray = new string[replaceHistory.Count];
+ replaceHistory.CopyTo(stringArray, 0);
+ propertyService.SetProperty("MonoDevelop.FindReplaceDialogs.ReplaceHistory", string.Join(HISTORY_SEPARATOR_CHAR.ToString(), stringArray));
+ }
+ }
+
#region code to pretend to be a dialog (cause we can't inherit Dialog and use glade)
public void Present()
{
@@ -346,6 +434,8 @@
public void Destroy()
{
+ // save the search and replace history to properties
+ OnClosed ();
ReplaceDialogPointer.Destroy();
}
More information about the Monodevelop-patches-list
mailing list