diff options
author | Lluis Sanchez <lluis@novell.com> | 2010-04-19 13:55:02 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@novell.com> | 2010-04-19 13:55:02 +0400 |
commit | 19ab751a545e9d968e2bb78cb98e0e7b8f9542a0 (patch) | |
tree | eeb36430c45a14a26c0fcc64b69878109f0fe3df /main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer | |
parent | 3a3c2ab6dca94a302d2dc5c4e20041f6b460afd8 (diff) |
* Makefile.am:
* gtk-gui/gui.stetic:
* MonoDevelop.Debugger.csproj:
* MonoDevelop.Debugger.addin.xml:
* MonoDevelop.Debugger.Visualizer:
* MonoDevelop.Debugger/DebuggingService.cs:
* MonoDevelop.Debugger/ObjectValueTreeView.cs:
* MonoDevelop.Debugger.Visualizer/TextVisualizer.cs:
* MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs:
* MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs:
* gtk-gui/MonoDevelop.Debugger.ExceptionCaughtDialog.cs:
* MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs:
* gtk-gui/MonoDevelop.Debugger.ExpressionEvaluatorDialog.cs:
* gtk-gui/MonoDevelop.Debugger.BreakpointPropertiesDialog.cs:
* gtk-gui/MonoDevelop.Debugger.Viewers.ValueVisualizerDialog.cs: Add
basic support for custom visualizers.
* MonoDevelop.Debugger/PinnedWatch.cs: Set the correct expression
name.
svn path=/trunk/monodevelop/; revision=155709
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer')
4 files changed, 281 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs new file mode 100644 index 0000000000..da5c4a6c42 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs @@ -0,0 +1,40 @@ +// +// ValueVisualizer.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Mono.Debugging.Client; + +namespace MonoDevelop.Debugger +{ + public interface IValueVisualizer + { + string Name { get; } + bool CanVisualize (ObjectValue val); + Gtk.Widget GetVisualizerWidget (ObjectValue val); + bool StoreValue (ObjectValue val); + } +} + diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs new file mode 100644 index 0000000000..8578739a99 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs @@ -0,0 +1,78 @@ +// +// PixbufVisualizer.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.IO; +using Mono.Debugging.Client; + +namespace MonoDevelop.Debugger.Visualizer +{ + public class PixbufVisualizer: IValueVisualizer + { + #region IValueVisualizer implementation + public bool CanVisualize (ObjectValue val) + { + return val.TypeName == "Gdk.Pixbuf"; + } + + public Gtk.Widget GetVisualizerWidget (ObjectValue val) + { + Gdk.Pixbuf pixbuf; + string file = Path.GetTempFileName (); + try { + RawValue pix = (RawValue) val.RawValue; + pix.CallMethod ("Save", file, "png"); + pixbuf = new Gdk.Pixbuf (file); + } finally { + File.Delete (file); + } + Gtk.ScrolledWindow sc = new Gtk.ScrolledWindow (); + sc.ShadowType = Gtk.ShadowType.In; + sc.HscrollbarPolicy = Gtk.PolicyType.Automatic; + sc.VscrollbarPolicy = Gtk.PolicyType.Automatic; + Gtk.Image image = new Gtk.Image (pixbuf); + sc.AddWithViewport (image); + sc.ShowAll (); + return sc; + } + + + public bool StoreValue (ObjectValue val) + { + return true; + } + + + public string Name { + get { + return "Pixbuf"; + } + } + + #endregion + } +} + diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/TextVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/TextVisualizer.cs new file mode 100644 index 0000000000..fdf40c6032 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/TextVisualizer.cs @@ -0,0 +1,86 @@ +// +// TextVisualizer.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Mono.Debugging.Client; +using Gtk; +using MonoDevelop.Core; + +namespace MonoDevelop.Debugger.Visualizer +{ + public class TextVisualizer: IValueVisualizer + { + TextView textView; + + public TextVisualizer () + { + } + + public string Name { + get { + return GettextCatalog.GetString ("Text"); + } + } + + + public bool CanVisualize (ObjectValue val) + { + return val.TypeName == "string"; + } + + public Gtk.Widget GetVisualizerWidget (ObjectValue val) + { + VBox box = new VBox (false, 6); + textView = new TextView (); + textView.Buffer.Text = val.RawValue as string; + textView.WrapMode = WrapMode.Char; + Gtk.ScrolledWindow scrolled = new Gtk.ScrolledWindow (); + scrolled.HscrollbarPolicy = PolicyType.Automatic; + scrolled.VscrollbarPolicy = PolicyType.Automatic; + scrolled.ShadowType = ShadowType.In; + scrolled.Add (textView); + box.PackStart (scrolled, true, true, 0); + CheckButton cb = new CheckButton (GettextCatalog.GetString ("Wrap text")); + cb.Active = true; + cb.Toggled += delegate { + if (cb.Active) + textView.WrapMode = WrapMode.Char; + else + textView.WrapMode = WrapMode.None; + }; + box.PackStart (cb, false, false, 0); + box.ShowAll (); + return box; + } + + public bool StoreValue (ObjectValue val) + { + val.RawValue = textView.Buffer.Text; + return true; + } + } +} + diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs new file mode 100644 index 0000000000..4dc0fb582b --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs @@ -0,0 +1,77 @@ +// +// ValueViewerDialog.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Collections.Generic; +using Mono.Debugging.Client; +namespace MonoDevelop.Debugger.Viewers +{ + public partial class ValueVisualizerDialog : Gtk.Dialog + { + List<IValueVisualizer> visualizers; + Gtk.Widget currentWidget; + IValueVisualizer currentVisualizer; + ObjectValue value; + + public ValueVisualizerDialog () + { + this.Build (); + } + + public void Show (ObjectValue val) + { + value = val; + visualizers = new List<IValueVisualizer> (DebuggingService.GetValueVisualizers (val)); + visualizers.Sort (delegate (IValueVisualizer v1, IValueVisualizer v2) { + return v1.Name.CompareTo (v2.Name); + }); + foreach (IValueVisualizer vis in visualizers) + comboVisualizers.AppendText (vis.Name); + comboVisualizers.Active = 0; + } + + protected virtual void OnComboVisualizersChanged (object sender, System.EventArgs e) + { + if (currentWidget != null) + mainBox.Remove (currentWidget); + if (comboVisualizers.Active == -1) { + buttonOk.Sensitive = false; + return; + } + buttonOk.Sensitive = true; + currentVisualizer = visualizers [comboVisualizers.Active]; + currentWidget = currentVisualizer.GetVisualizerWidget (value); + mainBox.PackStart (currentWidget, true, true, 0); + currentWidget.Show (); + } + + protected virtual void OnButtonOkClicked (object sender, System.EventArgs e) + { + if (currentVisualizer.StoreValue (value)) + Respond (Gtk.ResponseType.Ok); + } + } +} + |