[gedit-latex] Check tool action accels for validity
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-latex] Check tool action accels for validity
- Date: Wed, 29 Jun 2011 08:28:27 +0000 (UTC)
commit cc524c0ca8b9aca4bffa0c1b6791fda60c6989a1
Author: John Stowers <john stowers gmail com>
Date: Wed Jun 29 19:56:57 2011 +1200
Check tool action accels for validity
latex/base/windowactivatable.py | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/latex/base/windowactivatable.py b/latex/base/windowactivatable.py
index 3be7e3c..29628a5 100644
--- a/latex/base/windowactivatable.py
+++ b/latex/base/windowactivatable.py
@@ -283,12 +283,15 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
gtk_action = Gtk.Action(name, action.label, action.tooltip, action.stock_id)
self._action_handlers[gtk_action] = gtk_action.connect("activate", lambda gtk_action, action: action.activate(self._window_context), action)
- if not tool.accelerator is None and len(tool.accelerator) > 0:
- # TODO: validate accelerator!
- self._tool_action_group.add_action_with_accel(gtk_action, tool.accelerator)
- else:
- self._tool_action_group.add_action_with_accel(gtk_action, "<Ctrl><Alt>%s" % accel_counter)
+ accelerator = None
+ if tool.accelerator and len(tool.accelerator) > 0:
+ key,mods = Gtk.accelerator_parse(tool.accelerator)
+ if Gtk.accelerator_valid(key,mods):
+ accelerator = tool.accelerator
+ if not accelerator:
+ accelerator = "<Ctrl><Alt>%s" % accel_counter
accel_counter += 1
+ self._tool_action_group.add_action_with_accel(gtk_action, accelerator)
# add UI definition
items_ui += """<menuitem action="%s" />""" % name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]