diff options
author | Mike Krüger <mkrueger@novell.com> | 2010-08-12 17:55:55 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2010-08-12 17:55:55 +0400 |
commit | 6d8fcd244ebb1ed9a31cf82af8ab6b5e9024d8dc (patch) | |
tree | 61e5506a559d1e0611943b828cc8da409b0d1d17 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles | |
parent | 9d0535b793539c5603ce203293ed8d524716d8af (diff) |
fixed build on linux.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs | 131 |
1 files changed, 82 insertions, 49 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs index 4002cbc444..965385a5ea 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs @@ -25,10 +25,13 @@ // THE SOFTWARE. using System; -using System.Linq;
-using Gdk;
+using System.Linq; + +using Gdk; + using Gtk; -using Mono.TextEditor;
+using Mono.TextEditor; + using Mono.TextEditor.Highlighting; using System.Collections.Generic; using MonoDevelop.Core; @@ -43,10 +46,13 @@ using MonoDevelop.Ide.Navigation; namespace MonoDevelop.Ide.FindInFiles { [System.ComponentModel.ToolboxItem(true)] - sealed partial class SearchResultWidget : Bin, ILocationList - {
- ListStore store;
- readonly ToolButton buttonStop;
+ partial class SearchResultWidget : Bin, ILocationList + { + + ListStore store; + + readonly ToolButton buttonStop; + readonly ToggleToolButton buttonPin; const int SearchResultColumn = 0; @@ -84,12 +90,14 @@ namespace MonoDevelop.Ide.FindInFiles treeviewSearchResults.ButtonPressEvent += HandleButtonPressEvent; treeviewSearchResults.RulesHint = true; - var fileNameColumn = new TreeViewColumn {
- Resizable = false,
- SortColumnId = 0,
- Title = GettextCatalog.GetString("File")
- };
- fileNameColumn.FixedWidth = 200;
+ var fileNameColumn = new TreeViewColumn { + Resizable = false, + SortColumnId = 0, + Title = GettextCatalog.GetString("File") + }; + + fileNameColumn.FixedWidth = 200; + var fileNamePixbufRenderer = new CellRendererPixbuf (); fileNameColumn.PackStart (fileNamePixbufRenderer, false); fileNameColumn.SetCellDataFunc (fileNamePixbufRenderer, FileIconDataFunc); @@ -101,17 +109,20 @@ namespace MonoDevelop.Ide.FindInFiles TreeViewColumn lineColumn = treeviewSearchResults.AppendColumn (GettextCatalog.GetString ("Line"), new CellRendererText (), ResultLineDataFunc); lineColumn.SortColumnId = 1; - lineColumn.FixedWidth = 50;
+ lineColumn.FixedWidth = 50; + TreeViewColumn textColumn = treeviewSearchResults.AppendColumn (GettextCatalog.GetString ("Text"), new CellRendererText (), ResultTextDataFunc); textColumn.SortColumnId = 2; textColumn.Resizable = false; - textColumn.FixedWidth = 300;
+ textColumn.FixedWidth = 300; + TreeViewColumn pathColumn = treeviewSearchResults.AppendColumn (GettextCatalog.GetString ("Path"), new CellRendererText (), ResultPathDataFunc); pathColumn.SortColumnId = 3; pathColumn.Resizable = false; - pathColumn.FixedWidth = 500;
+ pathColumn.FixedWidth = 500; + store.SetSortFunc (0, CompareFileNames); store.SetSortFunc (1, CompareLineNumbers); @@ -119,7 +130,8 @@ namespace MonoDevelop.Ide.FindInFiles treeviewSearchResults.RowActivated += TreeviewSearchResultsRowActivated; - buttonStop = new ToolButton ("gtk-stop") { Sensitive = false };
+ buttonStop = new ToolButton ("gtk-stop") { Sensitive = false }; + buttonStop.Clicked += ButtonStopClicked; buttonStop.TooltipText = GettextCatalog.GetString ("Stop"); @@ -198,16 +210,20 @@ namespace MonoDevelop.Ide.FindInFiles treeviewSearchResults.FreezeChildNotify (); } - ListStore newStore;
+ ListStore newStore; + public void EndProgress () { buttonStop.Sensitive = false; newStore.SetSortFunc (0, CompareFileNames); newStore.SetSortFunc (1, CompareLineNumbers); - newStore.SetSortFunc (3, CompareFilePaths);
- treeviewSearchResults.Model = newStore;
+ newStore.SetSortFunc (3, CompareFilePaths); + + treeviewSearchResults.Model = newStore; + store.Dispose (); - store = newStore;
+ store = newStore; + treeviewSearchResults.ThawChildNotify (); } @@ -242,8 +258,10 @@ namespace MonoDevelop.Ide.FindInFiles OnPopupMenu (this, null); args.RetVal = treeviewSearchResults.Selection.GetSelectedRows ().Length > 1; } - }
-
+ } + + + static Color AdjustColor (Color baseColor, Color color) { double b1 = HslColor.Brightness (color); @@ -265,8 +283,10 @@ namespace MonoDevelop.Ide.FindInFiles { var result = new StringBuilder (); int idx = markup.IndexOf ("foreground=\""); - int offset = 0;
-
+ int offset = 0; + + + // This is a workaround for Bug 559804 - Strings in search result pad are near-invisible // On mac it's not possible to get the white background color with the Base or Background // methods. If this bug is fixed or a better work around is found - remove this hack. @@ -282,9 +302,12 @@ namespace MonoDevelop.Ide.FindInFiles offset = idx + 7; string colorStr = markup.Substring (idx, 7); - Color color = Color.Zero;
- if (Color.Parse(colorStr, ref color))
- colorStr = SyntaxMode.ColorToPangoMarkup(AdjustColor(baseColor, color));
+ Color color = Color.Zero; + + if (Color.Parse(colorStr, ref color)) + + colorStr = SyntaxMode.ColorToPangoMarkup(AdjustColor(baseColor, color)); + result.Append (colorStr); idx = markup.IndexOf ("foreground=\"", idx); } @@ -315,8 +338,10 @@ namespace MonoDevelop.Ide.FindInFiles if (searchResult == null) return; fileNamePixbufRenderer.Pixbuf = DesktopService.GetPixbufForFile (searchResult.FileName, IconSize.Menu); - }
-
+ } + + + static string MarkupText (string text, bool didRead) { return string.Format ("<span weight=\"{1}\">{0}</span>", GLib.Markup.EscapeText (text), didRead ? "normal" : "bold"); @@ -360,8 +385,10 @@ namespace MonoDevelop.Ide.FindInFiles var searchResult1 = (SearchResult)model.GetValue (first, SearchResultColumn); var searchResult2 = (SearchResult)model.GetValue (second, SearchResultColumn); if (searchResult1 == null || searchResult2 == null || searchResult1.FileName == null || searchResult2.FileName == null) - return -1;
- return System.IO.Path.GetDirectoryName (searchResult1.FileName).CompareTo (System.IO.Path.GetDirectoryName (searchResult2.FileName));
+ return -1; + + return System.IO.Path.GetDirectoryName (searchResult1.FileName).CompareTo (System.IO.Path.GetDirectoryName (searchResult2.FileName)); + } void ResultPathDataFunc (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) @@ -403,8 +430,8 @@ namespace MonoDevelop.Ide.FindInFiles Document doc = GetDocument (searchResult); int lineNr = doc.OffsetToLineNumber (searchResult.Offset); LineSegment line = doc.GetLine (lineNr); - bool isSelected = treeviewSearchResults.Selection.IterIsSelected (iter);
-
+ bool isSelected = treeviewSearchResults.Selection.IterIsSelected (iter); + string markup = doc.SyntaxMode != null ? doc.SyntaxMode.GetMarkup (doc, new TextEditorOptions (), highlightStyle, line.Offset, line.EditableLength, true, !isSelected, false) : GLib.Markup.EscapeText (doc.GetTextAt (line.Offset, line.EditableLength)); @@ -480,17 +507,20 @@ namespace MonoDevelop.Ide.FindInFiles if (realPos >= pos) return markup.Length; return -1; - }
-
+ } + + + readonly Dictionary<string, Document> documents = new Dictionary<string, Document> (); Document GetDocument (SearchResult result) { Document doc; if (!documents.TryGetValue (result.FileName, out doc)) { - TextReader reader = result.FileProvider.Open ();
- doc = Document.CreateImmutableDocument (reader.ReadToEnd ());
- doc.MimeType = DesktopService.GetMimeTypeForUri (result.FileName);
+ TextReader reader = result.FileProvider.Open (); + doc = Document.CreateImmutableDocument (reader.ReadToEnd ()); + doc.MimeType = DesktopService.GetMimeTypeForUri (result.FileName); + reader.Close (); documents[result.FileName] = doc; } @@ -516,10 +546,10 @@ namespace MonoDevelop.Ide.FindInFiles } public void AddRange (IEnumerable<SearchResult> results) - {
- foreach (var result in results) {
- Add (result);
- }
+ { + foreach (var result in results) { + Add (result); + } } void OpenDocumentAt (TreeIter iter) @@ -531,6 +561,7 @@ namespace MonoDevelop.Ide.FindInFiles IdeApp.Workbench.OpenDocument (result.FileName, loc.Line, loc.Column, true); } } + DocumentLocation GetLocation (SearchResult searchResult) { Document doc = GetDocument (searchResult); @@ -646,12 +677,14 @@ namespace MonoDevelop.Ide.FindInFiles protected override Gui.Document DoShow () { - var doc = base.DoShow ();
- if (doc == null)
- return null;
- var buf = doc.GetContent<IEditableTextBuffer> ();
- if (buf != null)
- buf.SetCaretTo (Math.Max (Line, 1), Math.Max (Column, 1));
+ var doc = base.DoShow (); + if (doc == null) + return null; + + var buf = doc.GetContent<IEditableTextBuffer> (); + if (buf != null) + buf.SetCaretTo (Math.Max (Line, 1), Math.Max (Column, 1)); + return doc; } |