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
diff options
context:
space:
mode:
authorLluis Sanchez <slluis.devel@gmail.com>2011-11-29 13:32:45 +0400
committerLluis Sanchez <slluis.devel@gmail.com>2011-11-29 13:32:45 +0400
commit4f811b86823fe6b802925ec8f6222768695ef086 (patch)
tree12e92557f00993aed4fdc124ccba2ac64898d4df
parent5dd405cf9dfe2b70d4289cc79bf90d1cbcdd6668 (diff)
parent1ca7e9ed13c19ed486a935520108ea97b78af67b (diff)
Merge pull request #134 from pavlos256/master
Fixed 'Bug 627 - When renaming a file, only select the name and not the extension'
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs37
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs7
3 files changed, 47 insertions, 1 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs
index 4278258cde..5220e7fd4d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs
@@ -211,6 +211,7 @@ namespace MonoDevelop.Ide.Gui.Components
}
text_render.Ypad = 0;
IdeApp.Preferences.CustomPadFontChanged += CustomFontPropertyChanged;;
+ text_render.EditingStarted += HandleEditingStarted;
text_render.Edited += HandleOnEdit;
text_render.EditingCanceled += HandleOnEditCancelled;
@@ -1171,19 +1172,52 @@ namespace MonoDevelop.Ide.Gui.Components
node.ExpandToNode (); //make sure the parent of the node that is being edited is expanded
- store.SetValue (iter, ExtensibleTreeView.TextColumn, node.NodeName);
+ string nodeName = node.NodeName;
+ store.SetValue (iter, ExtensibleTreeView.TextColumn, nodeName);
+ // Get and validate the initial text selection
+ int nameLength = nodeName != null ? nodeName.Length : 0,
+ selectionStart = 0, selectionLength = nameLength;
+ foreach (NodeBuilder b in node.NodeBuilderChain) {
+ try {
+ NodeCommandHandler handler = b.CommandHandler;
+ handler.SetCurrentNode(node);
+ handler.OnRenameStarting(ref selectionStart, ref selectionLength);
+ } catch (Exception ex) {
+ LoggingService.LogError (ex.ToString ());
+ }
+ }
+ if (selectionStart < 0 || selectionStart >= nameLength)
+ selectionStart = 0;
+ if (selectionStart + selectionLength > nameLength)
+ selectionLength = nameLength - selectionStart;
+ // This will apply the selection as soon as possible
+ GLib.Idle.Add (() => {
+ var editable = currentLabelEditable;
+ if (editable == null)
+ return false;
+
+ editable.SelectRegion (selectionStart, selectionStart + selectionLength);
+ return false;
+ });
text_render.Editable = true;
tree.SetCursor (store.GetPath (iter), complete_column, true);
editingText = true;
}
+ Gtk.Editable currentLabelEditable;
+ void HandleEditingStarted (object o, Gtk.EditingStartedArgs e)
+ {
+ currentLabelEditable = e.Editable as Gtk.Entry;
+ }
+
void HandleOnEdit (object o, Gtk.EditedArgs e)
{
try {
editingText = false;
text_render.Editable = false;
+ currentLabelEditable = null;
Gtk.TreeIter iter;
if (!store.GetIterFromString (out iter, e.Path))
@@ -1227,6 +1261,7 @@ namespace MonoDevelop.Ide.Gui.Components
{
editingText = false;
text_render.Editable = false;
+ currentLabelEditable = null;
TreeNodeNavigator node = (TreeNodeNavigator) GetSelectedNode ();
if (node == null)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs
index 9e7efa2362..bf5ad2227a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs
@@ -86,6 +86,10 @@ namespace MonoDevelop.Ide.Gui.Components
get { return tree; }
}
+ public virtual void OnRenameStarting (ref int selectionStart, ref int selectionLength)
+ {
+ }
+
public virtual void RenameItem (string newName)
{
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs
index 81010e6413..d1ee44287a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs
@@ -137,6 +137,13 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
public class ProjectFileNodeCommandHandler: NodeCommandHandler
{
+ public override void OnRenameStarting (ref int selectionStart, ref int selectionLength)
+ {
+ string name = CurrentNode.NodeName;
+ selectionStart = 0;
+ selectionLength = Path.GetFileNameWithoutExtension(name).Length;
+ }
+
public override void RenameItem (string newName)
{
ProjectFile file = (ProjectFile) CurrentNode.DataItem;