~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
using Gtk;
34
34
using Mono.TextEditor;
35
35
using Gdk;
 
36
using MonoDevelop.Ide;
36
37
 
37
38
namespace MonoDevelop.SourceEditor
38
39
{
65
66
        {
66
67
                ObjectValueTreeView tree;
67
68
                ScrolledWindow sw;
 
69
                PinWindow pinWindow;
 
70
                TreeIter currentPinIter;
68
71
                
69
72
                public DebugValueWindow (Mono.TextEditor.TextEditor editor, int offset, StackFrame frame, ObjectValue value, PinnedWatch watch)
70
73
                {
86
89
                        tree.AllowAdding = false;
87
90
                        tree.AllowEditing = true;
88
91
                        tree.HeadersVisible = false;
89
 
                        tree.AllowPinning = true;
 
92
                        tree.AllowPinning = false;
90
93
                        tree.PinnedWatch = watch;
91
94
                        DocumentLocation location = editor.Document.OffsetToLocation (offset);
92
95
                        tree.PinnedWatchLine = location.Line + 1;
99
102
                                Destroy ();
100
103
                        };
101
104
                        
 
105
                        tree.MotionNotifyEvent += HandleTreeMotionNotifyEvent;
 
106
                        
102
107
                        sw.ShowAll ();
103
108
                        
 
109
                        pinWindow = new PinWindow (this);
 
110
                        pinWindow.SetPinned (false);
 
111
                        pinWindow.ButtonPressEvent += HandlePinWindowButtonPressEvent;
 
112
                        
104
113
                        tree.StartEditing += delegate {
105
114
                                Modal = true;
106
115
                        };
109
118
                                Modal = false;
110
119
                        };
111
120
                }
 
121
 
 
122
                void HandlePinWindowButtonPressEvent (object o, ButtonPressEventArgs args)
 
123
                {
 
124
                        tree.CreatePinnedWatch (currentPinIter);
 
125
                }
 
126
                
 
127
                [GLib.ConnectBefore]
 
128
                void HandleTreeMotionNotifyEvent (object o, MotionNotifyEventArgs args)
 
129
                {
 
130
                        PlacePinWindow ();
 
131
                }
 
132
                
 
133
                protected override void OnSizeAllocated (Rectangle allocation)
 
134
                {
 
135
                        base.OnSizeAllocated (allocation);
 
136
                        PlacePinWindow ();
 
137
                }
 
138
                
 
139
                void PlacePinWindow ()
 
140
                {
 
141
                        int mx, my;
 
142
                        ModifierType mm;
 
143
                        if (tree.BinWindow == null)
 
144
                                return;
 
145
                        tree.BinWindow.GetPointer (out mx, out my, out mm);
 
146
                        
 
147
                        int cx, cy;
 
148
                        TreePath path;
 
149
                        TreeViewColumn col;
 
150
                        if (!tree.GetPathAtPos (mx, my, out path, out col, out cx, out cy))
 
151
                                return;
 
152
                        
 
153
                        tree.Model.GetIter (out currentPinIter, path);
 
154
                        Rectangle cr = tree.GetCellArea (path, tree.Columns [1]);
 
155
                
 
156
                        int ox, oy;
 
157
                        tree.BinWindow.GetOrigin (out ox, out oy);
 
158
                        
 
159
                        if (mx < cr.Right - 30) {
 
160
                                pinWindow.Hide ();
 
161
                                return;
 
162
                        }
 
163
                        
 
164
                        int x, y, w, h;
 
165
                        GetPosition (out x, out y);
 
166
                        GetSize (out w, out h);
 
167
                        pinWindow.Move (x + w, oy + cr.Y);
 
168
                        pinWindow.Show ();
 
169
                }
112
170
                
113
171
                protected override bool OnEnterNotifyEvent (EventCrossing evnt)
114
172
                {
144
202
                        }
145
203
                }
146
204
        }
 
205
        
 
206
        
 
207
        // This class shows the pin button, to be used to pin a watch value
 
208
        // This window is used instead of the pin support in ObjectValueTreeView
 
209
        // to avoid some flickering caused by some weird gtk# behavior when scrolling
 
210
        // (see bug #632215).
 
211
        
 
212
        class PinWindow: BaseWindow
 
213
        {
 
214
                Gtk.Image icon;
 
215
                
 
216
                public PinWindow (Gtk.Window parent)
 
217
                {
 
218
                        Events |= EventMask.ButtonPressMask;
 
219
                        TransientFor = parent;
 
220
                        DestroyWithParent = true;
 
221
                        
 
222
                        icon = new Gtk.Image ();
 
223
                        Add (icon);
 
224
                        icon.ShowAll ();
 
225
                        AcceptFocus = false;
 
226
                }
 
227
                
 
228
                public void SetPinned (bool pinned)
 
229
                {
 
230
                        if (pinned)
 
231
                                icon.Pixbuf = ImageService.GetPixbuf ("md-pin-down");
 
232
                        else
 
233
                                icon.Pixbuf = ImageService.GetPixbuf ("md-pin-up");
 
234
                }
 
235
        }
147
236
}