Author: lluis
Date: 2007-12-13 18:25:50 -0500 (Thu, 13 Dec 2007)
New Revision: 91258

Modified:
   trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog
   
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs
   
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
   trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
Log:
* MonoDevelop.Ide.Commands/EditCommands.cs, MonoDevelop.Ide.addin.xml,
  MonoDevelop.Ide.Gui/ViewCommandHandlers.cs: Implemented default
  handler for SelectAll. Disable Edit commands if the selected
  control is not editable. Fixes bug #348599.

Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog   2007-12-13 
23:21:30 UTC (rev 91257)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog   2007-12-13 
23:25:50 UTC (rev 91258)
@@ -1,3 +1,10 @@
+2007-12-14  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.Ide.Commands/EditCommands.cs, MonoDevelop.Ide.addin.xml,
+         MonoDevelop.Ide.Gui/ViewCommandHandlers.cs: Implemented default 
handler
+         for SelectAll. Disable Edit commands if the selected control is not
+         editable. Fixes bug #348599.
+
 2007-12-13  Michael Hutchinson <[EMAIL PROTECTED]> 
 
        * MonoDevelop.Ide.addin.xml: Use Home for unindent command and End for

Modified: 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs
===================================================================
--- 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs
    2007-12-13 23:21:30 UTC (rev 91257)
+++ 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs
    2007-12-13 23:25:50 UTC (rev 91258)
@@ -101,7 +101,12 @@
                protected override void Update (CommandInfo info)
                {
                        object focus = IdeApp.Workbench.RootWindow.Focus;
-                       info.Enabled = (focus is Gtk.Editable || focus is 
Gtk.TextView); 
+                       if (focus is Gtk.Editable)
+                               info.Enabled = ((Gtk.Editable)focus).IsEditable;
+                       else if (focus is Gtk.TextView)
+                               info.Enabled =  ((Gtk.TextView)focus).Editable;
+                       else
+                               info.Enabled = false;
                }
        }
        
@@ -153,7 +158,12 @@
                protected override void Update (CommandInfo info)
                {
                        object focus = 
IdeApp.Workbench.RootWindow.HasToplevelFocus ? 
IdeApp.Workbench.RootWindow.Focus : null;
-                       info.Enabled = (focus is Gtk.Editable || focus is 
Gtk.TextView); 
+                       if (focus is Gtk.Editable)
+                               info.Enabled = ((Gtk.Editable)focus).IsEditable;
+                       else if (focus is Gtk.TextView)
+                               info.Enabled =  ((Gtk.TextView)focus).Editable;
+                       else
+                               info.Enabled = false;
                }
        }
        
@@ -179,7 +189,12 @@
                protected override void Update (CommandInfo info)
                {
                        object focus = 
IdeApp.Workbench.RootWindow.HasToplevelFocus ? 
IdeApp.Workbench.RootWindow.Focus : null;
-                       info.Enabled = (focus is Gtk.Editable || (focus is 
Gtk.TextView && ((Gtk.TextView)focus).Editable)); 
+                       if (focus is Gtk.Editable)
+                               info.Enabled = ((Gtk.Editable)focus).IsEditable;
+                       else if (focus is Gtk.TextView)
+                               info.Enabled =  ((Gtk.TextView)focus).Editable;
+                       else
+                               info.Enabled = false;
                }
        }
        
@@ -203,4 +218,29 @@
                                info.Enabled = false;
                }
        }       
+       
+       internal class DefaultSelectAllHandler: CommandHandler
+       {
+               protected override void Run ()
+               {
+                       if (IdeApp.Workbench.RootWindow.HasToplevelFocus) {
+                               Gtk.Editable editable = 
IdeApp.Workbench.RootWindow.Focus as Gtk.Editable;
+                               if (editable != null) {
+                                       editable.SelectRegion (0, -1);
+                                       return;
+                               }
+                               Gtk.TextView tv = 
IdeApp.Workbench.RootWindow.Focus as Gtk.TextView;
+                               if (tv != null) {
+                                       tv.Buffer.SelectRange 
(tv.Buffer.StartIter, tv.Buffer.EndIter);
+                                       return;
+                               }
+                       }
+               }
+               
+               protected override void Update (CommandInfo info)
+               {
+                       object focus = 
IdeApp.Workbench.RootWindow.HasToplevelFocus ? 
IdeApp.Workbench.RootWindow.Focus : null;
+                       info.Enabled = (focus is Gtk.Editable || focus is 
Gtk.TextView); 
+               }
+       }       
 }

Modified: 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
===================================================================
--- 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
  2007-12-13 23:21:30 UTC (rev 91257)
+++ 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
  2007-12-13 23:25:50 UTC (rev 91258)
@@ -234,7 +234,10 @@
                protected void OnUpdateSelectAll (CommandInfo info)
                {
                        IEditableTextBuffer editable = GetContent 
<IEditableTextBuffer> ();
-                       info.Enabled = editable != null && 
editable.ClipboardHandler.EnableSelectAll;
+                       if (editable != null)
+                               info.Enabled = 
editable.ClipboardHandler.EnableSelectAll;
+                       else
+                               info.Bypass = true;
                }
                
                [CommandHandler (EditCommands.WordCount)]

Modified: 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml   
2007-12-13 23:21:30 UTC (rev 91257)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml   
2007-12-13 23:25:50 UTC (rev 91258)
@@ -277,6 +277,7 @@
                                _label = "Select _All" 
                                description = "Select all text" 
                                shortcut = "Control|A"
+                               defaultHandler = 
"MonoDevelop.Ide.Commands.DefaultSelectAllHandler"
                                icon = "md-select-all" />
                <Command id = 
"MonoDevelop.Ide.Commands.EditCommands.CommentCode"
                                shortcut = "Control|Alt|C"

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to