[banshee] Disable keybindings for IDisableKeybindings widgets



commit d6f45d7788dcf6f6c9ee0470cdf4ca20d6360d15
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Mar 3 13:46:39 2010 -0800

    Disable keybindings for IDisableKeybindings widgets
    
    Previously Nereid would disable the single-char keybindings only if the
    Focus was in a Gtk.Entry; now it will also disable them if in any Widget
    that implements Banshee.Gui.IDisableKeybindings

 src/Clients/Nereid/Nereid/PlayerInterface.cs       |   18 +++++++++-
 .../Banshee.Gui/IDisableKeybindings.cs             |   36 ++++++++++++++++++++
 .../Banshee.ThickClient/Banshee.ThickClient.csproj |    1 +
 src/Core/Banshee.ThickClient/Makefile.am           |    1 +
 4 files changed, 54 insertions(+), 2 deletions(-)
---
diff --git a/src/Clients/Nereid/Nereid/PlayerInterface.cs b/src/Clients/Nereid/Nereid/PlayerInterface.cs
index eae3df4..59ee625 100644
--- a/src/Clients/Nereid/Nereid/PlayerInterface.cs
+++ b/src/Clients/Nereid/Nereid/PlayerInterface.cs
@@ -548,8 +548,22 @@ namespace Nereid
         {
             bool focus_search = false;
 
-            if (Focus is Gtk.Entry && (GtkUtilities.NoImportantModifiersAreSet () &&
-                evnt.Key != Gdk.Key.Control_L && evnt.Key != Gdk.Key.Control_R)) {
+            bool disable_keybindings = Focus is Gtk.Entry;
+            if (!disable_keybindings) {
+                var widget = Focus;
+                while (widget != null) {
+                    if (widget is IDisableKeybindings) {
+                        disable_keybindings = true;
+                        break;
+                    }
+                    widget = widget.Parent;
+                }
+            }
+
+            disable_keybindings &= ((GtkUtilities.NoImportantModifiersAreSet () &&
+                evnt.Key != Gdk.Key.Control_L && evnt.Key != Gdk.Key.Control_R));
+
+            if (disable_keybindings) {
                 if (accel_group_active) {
                     RemoveAccelGroup (ActionService.UIManager.AccelGroup);
                     accel_group_active = false;
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/IDisableKeybindings.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/IDisableKeybindings.cs
new file mode 100644
index 0000000..fef8441
--- /dev/null
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/IDisableKeybindings.cs
@@ -0,0 +1,36 @@
+//
+// IDisableKeybindings.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Banshee.Gui
+{
+    public interface IDisableKeybindings
+    {
+    }
+}
diff --git a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
index 18244a6..2e2fecb 100644
--- a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
+++ b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
@@ -140,6 +140,7 @@
     <Compile Include="Banshee.Gui\InterfaceActionService.cs" />
     <Compile Include="Banshee.Gui\PlaybackActions.cs" />
     <Compile Include="Banshee.Gui\ViewActions.cs" />
+    <Compile Include="Banshee.Gui\IDisableKeybindings.cs" />
     <Compile Include="Banshee.Gui\GlobalActions.cs" />
     <Compile Include="Banshee.Gui.Widgets\ConnectedVolumeButton.cs" />
     <Compile Include="Banshee.Collection.Gui\ColumnCellStatusIndicator.cs" />
diff --git a/src/Core/Banshee.ThickClient/Makefile.am b/src/Core/Banshee.ThickClient/Makefile.am
index 82ae55c..b66a2f2 100644
--- a/src/Core/Banshee.ThickClient/Makefile.am
+++ b/src/Core/Banshee.ThickClient/Makefile.am
@@ -110,6 +110,7 @@ SOURCES =  \
 	Banshee.Gui/GtkElementsService.cs \
 	Banshee.Gui/IClientWindow.cs \
 	Banshee.Gui/IconThemeUtils.cs \
+	Banshee.Gui/IDisableKeybindings.cs \
 	Banshee.Gui/IHasSourceView.cs \
 	Banshee.Gui/InterfaceActionService.cs \
 	Banshee.Gui/PersistentPaneController.cs \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]