Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMarius Ungureanu <marius.ungureanu@xamarin.com>2015-02-14 03:05:26 +0300
committerMarius Ungureanu <marius.ungureanu@xamarin.com>2015-02-14 03:05:26 +0300
commit22eb9b3abc1ad2fe5389cf96eebe38eba0b21d01 (patch)
tree57a479177e05b5bf223dc01ced35fa24db32ab51 /main
parent1d325dae13985318a8bd2c09a5ce1925f55b522f (diff)
[Toolbar] Move more logic into Controller.
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs11
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs25
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs16
3 files changed, 35 insertions, 17 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs
index 6c0f967821..2b35d8bdcb 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs
@@ -149,10 +149,21 @@ namespace MonoDevelop.Components.MainToolbar
event EventHandler SearchEntryResized;
/// <summary>
+ /// Occurs when the search entry lost focus.
+ /// </summary>
+ event EventHandler SearchEntryLostFocus;
+
+ /// <summary>
/// Gets the UI widget for the popup window to use as an anchor.
/// </summary>
/// <value>The popup anchor.</value>
Gtk.Widget PopupAnchor { get; }
+
+ /// <summary>
+ /// Sets the search entry placeholder message.
+ /// </summary>
+ /// <value>The placeholder message.</value>
+ string SearchPlaceholderMessage { set; }
#endregion
#region StatusBar
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs
index a843c79af4..10768d8af7 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs
@@ -265,14 +265,10 @@ namespace MonoDevelop.Components.MainToolbar
matchEntry = new SearchEntry ();
matchEntry.ForceFilterButtonVisible = true;
- matchEntry.Entry.FocusOutEvent += delegate {
- matchEntry.Entry.Text = "";
+ matchEntry.Entry.FocusOutEvent += (o, e) => {
+ if (SearchEntryLostFocus != null)
+ SearchEntryLostFocus (o, e);
};
- var cmd = IdeApp.CommandService.GetCommand (Commands.NavigateTo);
- cmd.KeyBindingChanged += delegate {
- UpdateSearchEntryLabel ();
- };
- UpdateSearchEntryLabel ();
matchEntry.Ready = true;
matchEntry.Visible = true;
@@ -398,16 +394,6 @@ namespace MonoDevelop.Components.MainToolbar
UpdateCombos ();
}
- void UpdateSearchEntryLabel ()
- {
- var info = IdeApp.CommandService.GetCommand (Commands.NavigateTo);
- if (!string.IsNullOrEmpty (info.AccelKey)) {
- matchEntry.EmptyMessage = GettextCatalog.GetString ("Press '{0}' to search", KeyBindingManager.BindingToDisplayLabel (info.AccelKey, false));
- } else {
- matchEntry.EmptyMessage = GettextCatalog.GetString ("Search solution");
- }
- }
-
void SetDefaultSizes (int comboHeight, int height)
{
configurationCombo.SetSizeRequest (150, comboHeight);
@@ -908,6 +894,7 @@ namespace MonoDevelop.Components.MainToolbar
public event EventHandler SearchEntryActivated;
public event EventHandler<Xwt.KeyEventArgs> SearchEntryKeyPressed;
public event EventHandler SearchEntryResized;
+ public event EventHandler SearchEntryLostFocus;
public Widget PopupAnchor {
get { return matchEntry; }
@@ -917,6 +904,10 @@ namespace MonoDevelop.Components.MainToolbar
get { return matchEntry.Entry.Text; }
set { matchEntry.Entry.Text = value; }
}
+
+ public string SearchPlaceholderMessage {
+ set { matchEntry.EmptyMessage = value; }
+ }
#endregion
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
index f0a23e7605..92579c6d93 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
@@ -69,16 +69,32 @@ namespace MonoDevelop.Components.MainToolbar
ToolbarView.SearchEntryActivated += HandleSearchEntryActivated;
ToolbarView.SearchEntryKeyPressed += HandleSearchEntryKeyPressed;
ToolbarView.SearchEntryResized += (o, e) => PositionPopup ();
+ ToolbarView.SearchEntryLostFocus += (o, e) => ToolbarView.SearchText = "";
IdeApp.Workbench.RootWindow.WidgetEvent += delegate(object o, WidgetEventArgs args) {
if (args.Event is Gdk.EventConfigure)
PositionPopup ();
};
+ // Update Search Entry label initially and on keybinding change.
+ var cmd = IdeApp.CommandService.GetCommand (Commands.NavigateTo);
+ cmd.KeyBindingChanged += delegate {
+ UpdateSearchEntryLabel ();
+ };
+ UpdateSearchEntryLabel ();
+
// Register this controller as a commandbar.
IdeApp.CommandService.RegisterCommandBar (this);
}
+ void UpdateSearchEntryLabel ()
+ {
+ var info = IdeApp.CommandService.GetCommand (Commands.NavigateTo);
+ ToolbarView.SearchPlaceholderMessage = !string.IsNullOrEmpty (info.AccelKey) ?
+ GettextCatalog.GetString ("Press '{0}' to search", KeyBindingManager.BindingToDisplayLabel (info.AccelKey, false)) :
+ GettextCatalog.GetString ("Search solution");
+ }
+
SearchPopupWindow popup = null;
static readonly SearchPopupSearchPattern emptyColonPattern = SearchPopupSearchPattern.ParsePattern (":");
void PositionPopup ()