Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit a1995a3

Browse files
authored
Merge pull request #6926 from mono/fix750263-references-search-vo-order
[Ide] Let the references search be a child of the notebook
2 parents ddacb6c + 737c2fb commit a1995a3

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/SelectReferenceDialog.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using MonoDevelop.Components;
3737
using MonoDevelop.Components.Commands;
3838
using System.IO;
39+
using System.Runtime.InteropServices;
3940

4041
namespace MonoDevelop.Ide.Projects
4142
{
@@ -157,16 +158,21 @@ TreeIter AddPackageReference (ProjectReference refInfo)
157158
}
158159
return refTreeStore.AppendValues (txt, secondaryTxt, GetTypeText (refInfo), refInfo.Reference, refInfo, ImageService.GetIcon ("md-package", IconSize.Dnd));
159160
}
160-
161+
162+
[DllImport ("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
163+
private static extern void gtk_notebook_set_action_widget (IntPtr notebook, IntPtr widget, int packType);
164+
161165
public SelectReferenceDialog ()
162166
{
163167
Build ();
164168

165169
combinedBox = new CombinedBox ();
166170
combinedBox.Show ();
167171
mainBook = new Notebook ();
168-
combinedBox.Add (mainBook);
169-
alignment1.Add (combinedBox);
172+
173+
gtk_notebook_set_action_widget (mainBook.Handle, combinedBox.Handle, (int)PackType.End);
174+
175+
alignment1.Add (mainBook);
170176
mainBook.ShowAll ();
171177

172178
filterEntry = combinedBox.FilterEntry;
@@ -250,7 +256,6 @@ public SelectReferenceDialog ()
250256

251257
void InsertFilterEntry ()
252258
{
253-
filterEntry.KeyPressEvent += HandleFilterEntryKeyPressEvent;
254259
filterEntry.Activated += HandleFilterEntryActivated;
255260
filterEntry.Changed += delegate {
256261
foreach (var p in panels)
@@ -264,19 +269,9 @@ void HandleFilterEntryActivated (object sender, EventArgs e)
264269
mainBook.ChildFocus (DirectionType.TabForward);
265270
}
266271

267-
void HandleFilterEntryKeyPressEvent (object o, KeyPressEventArgs args)
268-
{
269-
if (args.Event.Key == Gdk.Key.Tab) {
270-
mainBook.HasFocus = true;
271-
mainBook.ChildFocus (DirectionType.TabForward);
272-
args.RetVal = true;
273-
}
274-
}
275-
276272
protected override void OnShown ()
277273
{
278274
base.OnShown ();
279-
filterEntry.HasFocus = true;
280275
}
281276

282277
protected override bool OnKeyPressEvent (Gdk.EventKey evnt)
@@ -538,22 +533,24 @@ protected override void OnRemoved (Widget widget)
538533

539534
protected override void OnSizeAllocated (Gdk.Rectangle allocation)
540535
{
536+
allocation.Y -= 2;
541537
base.OnSizeAllocated (allocation);
542538
RepositionFilter ();
543539
}
544540

545541
protected override void OnSizeRequested (ref Requisition requisition)
546542
{
547-
if (Child != null)
548-
requisition = Child.SizeRequest ();
549-
requisition.Width += filterEntry.SizeRequest ().Width;
543+
requisition = Child?.SizeRequest () ?? Requisition.Zero;
544+
var entryRequest = filterEntry.SizeRequest ();
545+
requisition.Width += entryRequest.Width;
546+
requisition.Height = Math.Max (requisition.Height, entryRequest.Height);
550547
}
551548

552549
void RepositionFilter ()
553550
{
554-
int w = filterEntry.SizeRequest ().Width;
555-
int h = filterEntry.SizeRequest ().Height;
556-
filterEntry.SizeAllocate (new Gdk.Rectangle (Allocation.Width - w - 1, 0, w, h));
551+
var req = filterEntry.SizeRequest ();
552+
int h = Math.Min (Allocation.Height, req.Height);
553+
filterEntry.SizeAllocate (new Gdk.Rectangle (Allocation.Width - req.Width - 1, 0, req.Width, h));
557554
}
558555
}
559556

0 commit comments

Comments
 (0)