[kupfer] Allow user to disable single-keystroke accelerators (/, .= and space)



commit b69dc5befba4aaf4d9892e66f7fafa9428ed902d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Apr 7 22:13:13 2005 +0200

    Allow user to disable single-keystroke accelerators (/,.= and space)

 data/defaults.cfg        |    1 +
 data/preferences.ui      |   14 ++++++++++++++
 kupfer/core/settings.py  |    7 +++++++
 kupfer/ui/browser.py     |    5 +++--
 kupfer/ui/preferences.py |    6 ++++++
 5 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/data/defaults.cfg b/data/defaults.cfg
index ef36c5e..158b469 100644
--- a/data/defaults.cfg
+++ b/data/defaults.cfg
@@ -11,6 +11,7 @@
 Keybinding = <Ctrl>space
 MagicKeybinding =
 ShowStatusIcon = True
+UseCommandKeys = True
 
 [Keybindings]
 activate = <Alt>a
diff --git a/data/preferences.ui b/data/preferences.ui
index 4894af0..846973a 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -350,6 +350,20 @@
                         <property name="position">3</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkCheckButton" id="checkusecommandkeys">
+                        <property name="label" translatable="yes">Use single keystroke commands (Space, /, period, comma etc.)</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="draw_indicator">True</property>
+                        <signal name="toggled" handler="on_checkusecommandkeys_toggled"/>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">4</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="position">1</property>
diff --git a/kupfer/core/settings.py b/kupfer/core/settings.py
index 4a2ba36..6136c13 100644
--- a/kupfer/core/settings.py
+++ b/kupfer/core/settings.py
@@ -35,6 +35,7 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
 			"keybinding" : "" ,
 			"magickeybinding": "",
 			"showstatusicon" : True,
+			"usecommandkeys" : True,
 		},
 		"Directories" : { "direct" : default_directories, "catalog" : (), },
 		"DeepDirectories" : { "direct" : (), "catalog" : (), "depth" : 1, },
@@ -263,6 +264,12 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
 		}
 		return M[key](val)
 
+	def get_use_command_keys(self):
+		return self.get_config("Kupfer", "usecommandkeys")
+
+	def set_use_command_keys(self, enabled):
+		return self._set_config("Kupfer", "usecommandkeys", enabled)
+
 	def get_show_status_icon(self):
 		"""Convenience: Show icon in notification area as bool"""
 		return strbool(self.get_config("Kupfer", "showstatusicon"))
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index e14385c..0b93308 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -891,6 +891,7 @@ class Interface (gobject.GObject):
 		from kupfer.core import settings
 		setctl = settings.GetSettingsController()
 		keybindings = setctl.get_accelerators()
+		use_command_keys = setctl.get_use_command_keys()
 
 		direct_text_key = gtk.gdk.keyval_from_name("period")
 		init_text_keys = map(gtk.gdk.keyval_from_name, ("slash", "equal"))
@@ -922,7 +923,7 @@ class Interface (gobject.GObject):
 				return True
 
 		has_selection = (self.current.get_match_state() is State.Match)
-		if not text_mode:
+		if not text_mode and use_command_keys:
 			# translate extra commands to normal commands here
 			# and remember skipped chars
 			if keyv == key_book["space"]:
@@ -943,7 +944,7 @@ class Interface (gobject.GObject):
 					# swallow if it is the direct key
 					swallow = (keyv == direct_text_key)
 					return swallow
-		elif keyv in (key_book["Left"], key_book["Right"]):
+		if text_mode and keyv in (key_book["Left"], key_book["Right"]):
 			# pass these through in text mode
 			return False
 
diff --git a/kupfer/ui/preferences.py b/kupfer/ui/preferences.py
index cfe9bd9..efcc5ba 100644
--- a/kupfer/ui/preferences.py
+++ b/kupfer/ui/preferences.py
@@ -64,6 +64,7 @@ class PreferencesWindowController (pretty.OutputMixin):
 		self.buttonremovedirectory = builder.get_object("buttonremovedirectory")
 		checkautostart = builder.get_object("checkautostart")
 		checkstatusicon = builder.get_object("checkstatusicon")
+		checkusecommandkeys = builder.get_object("checkusecommandkeys")
 		self.entry_plugins_filter = builder.get_object('entry_plugins_filter')
 		self.keybindings_list_parent = builder.get_object('keybindings_list_parent')
 		self.gkeybindings_list_parent = builder.get_object('gkeybindings_list_parent')
@@ -71,6 +72,7 @@ class PreferencesWindowController (pretty.OutputMixin):
 		setctl = settings.GetSettingsController()
 		checkautostart.set_active(self._get_should_autostart())
 		checkstatusicon.set_active(setctl.get_show_status_icon())
+		checkusecommandkeys.set_active(setctl.get_use_command_keys())
 
 		# Plugin List
 		columns = [
@@ -683,6 +685,10 @@ class PreferencesWindowController (pretty.OutputMixin):
 			setctl.reset_accelerators()
 			self._show_gkeybindings(setctl)
 
+	def on_checkusecommandkeys_toggled(self, widget):
+		setctl = settings.GetSettingsController()
+		setctl.set_use_command_keys(widget.get_active())
+
 	def dir_table_cursor_changed(self, table):
 		curpath, curcol = table.get_cursor()
 		if not curpath or not self.dir_store:



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