The branch, frodo has been updated
       via  aaf8244b72a06ccb59a4adf297082a08fdbc046d (commit)
      from  c2d805a736a0f3c7d5342c77288d1acb7505873c (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=aaf8244b72a06ccb59a4adf297082a08fdbc046d

commit aaf8244b72a06ccb59a4adf297082a08fdbc046d
Author: Martijn Kaijser <mcm.kaij...@gmail.com>
Date:   Fri Apr 11 14:15:35 2014 +0200

    [script.keymap] 0.9.3

diff --git a/script.keymap/addon.xml b/script.keymap/addon.xml
index 1efa9f8..692e7db 100644
--- a/script.keymap/addon.xml
+++ b/script.keymap/addon.xml
@@ -1,13 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="script.keymap"
        name="Keymap Editor"
-       version="0.9.2"
+       version="0.9.3"
        provider-name="takoi">
     <requires>
         <import addon="xbmc.python" version="2.1.0"/>
-        <import addon="script.module.elementtree" version="1.2.7"/>
     </requires>
-    <extension point="xbmc.python.script" library="default.py"/>
+    <extension point="xbmc.python.script" library="main.py"/>
     <extension point="xbmc.addon.metadata">
         <summary lang="en">An editor for keymap files</summary>
         <description lang="en">Keymap Editor is a GUI for configuring mappings 
for remotes, keyboard and other inputs supported by xbmc. Note: existing user 
defined key mappings will be removed.</description>
@@ -15,6 +14,6 @@
         <language/>
         <license>GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 2007</license>
         <forum>http://forum.xbmc.org/showthread.php?tid=168767</forum>
-        <source>https://github.com/takoi/xbmc-addon-keymap-config</source>
+        <source>https://github.com/tamland/xbmc-keymap-editor</source>
     </extension>
 </addon>
diff --git a/script.keymap/changelog.txt b/script.keymap/changelog.txt
index fb719ca..f9a4264 100644
--- a/script.keymap/changelog.txt
+++ b/script.keymap/changelog.txt
@@ -1,5 +1,10 @@
+[B]v0.9.3[/B]
+- Added actions for launching Add-ons
+- Added timeout to dialog that abort if no key is pressed
+- "Delete" option changed to load defaults instead of deleting keymap file
+
 [B]v0.9.2[/B]
-- added System.LogOff action
+- Added System.LogOff action
 
 [B]v0.9.1[/B]
-- fixed: script not working on os x due to missing python libraries
+- Fixed: script not working on os x due to missing python libraries
diff --git a/script.keymap/editor.py b/script.keymap/editor.py
index 50d35f0..e6da48f 100644
--- a/script.keymap/editor.py
+++ b/script.keymap/editor.py
@@ -12,78 +12,94 @@
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 '''
+from threading import Timer
 from collections_backport import OrderedDict
 from xbmcgui import Dialog, WindowXMLDialog
-from common import ACTIONS, WINDOWS, tr
+from actions import ACTIONS, WINDOWS
+from utils import tr
+
 
 class Editor(object):
-  def __init__(self, defaultkeymap, userkeymap):
-    self.defaultkeymap = defaultkeymap
-    self.userkeymap = userkeymap
-    self.dirty = False
-  
-  def start(self):
-    while True:
-      idx = Dialog().select(tr(30007), WINDOWS.values())
-      if idx == -1:
-        break
-      window = WINDOWS.keys()[idx]
-      
-      while True:
-        idx = Dialog().select(tr(30008), ACTIONS.keys())
-        if idx == -1:
-          break
-        category = ACTIONS.keys()[idx]
-        
+    def __init__(self, defaultkeymap, userkeymap):
+        self.defaultkeymap = defaultkeymap
+        self.userkeymap = userkeymap
+        self.dirty = False
+
+    def start(self):
         while True:
-          curr_keymap = self._current_keymap(window, category)
-          labels = [ "%s - %s" % (name, key) for _, key, name in curr_keymap ]
-          idx = Dialog().select(tr(30009), labels)
-          if idx == -1:
-            break
-          action, oldkey, _ = curr_keymap[idx]
-          newkey = self._record_key()
-          
-          old = (window, action, oldkey)
-          new = (window, action, newkey)
-          if old in self.userkeymap:
-            self.userkeymap.remove(old)
-          self.userkeymap.append(new)
-          if old != new:
-            self.dirty = True
-
-  def _current_keymap(self, window, category):
-    actions = OrderedDict([(action, "") for action in 
ACTIONS[category].keys()])
-    for w, a, k in self.defaultkeymap:
-      if w == window:
-        if a in actions.keys():
-          actions[a] = k
-    for w, a, k in self.userkeymap:
-      if w == window:
-        if a in actions.keys():
-          actions[a] = k
-    names = ACTIONS[category]
-    return [ (action, key, names[action]) for action, key in 
actions.iteritems() ]
-  
-  def _record_key(self):
-    dialog = KeyListener()
-    dialog.doModal()
-    key = dialog.key
-    del dialog
-    return str(key)
+            idx = Dialog().select(tr(30007), WINDOWS.values())
+            if idx == -1:
+                break
+            window = WINDOWS.keys()[idx]
+
+            while True:
+                idx = Dialog().select(tr(30008), ACTIONS.keys())
+                if idx == -1:
+                    break
+                category = ACTIONS.keys()[idx]
+
+                while True:
+                    curr_keymap = self._current_keymap(window, category)
+                    labels = ["%s - %s" % (name, key) for _, key, name in 
curr_keymap]
+                    idx = Dialog().select(tr(30009), labels)
+                    if idx == -1:
+                        break
+                    action, oldkey, _ = curr_keymap[idx]
+                    newkey = KeyListener.record_key()
+                    if newkey is None:
+                        continue
+
+                    old = (window, action, oldkey)
+                    new = (window, action, newkey)
+                    if old in self.userkeymap:
+                        self.userkeymap.remove(old)
+                    self.userkeymap.append(new)
+                    if old != new:
+                        self.dirty = True
+
+    def _current_keymap(self, window, category):
+        actions = OrderedDict([(action, "") for action in 
ACTIONS[category].keys()])
+        for w, a, k in self.defaultkeymap:
+            if w == window:
+                if a in actions.keys():
+                    actions[a] = k
+        for w, a, k in self.userkeymap:
+            if w == window:
+                if a in actions.keys():
+                    actions[a] = k
+        names = ACTIONS[category]
+        return [(action, key, names[action]) for action, key in 
actions.iteritems()]
+
 
 class KeyListener(WindowXMLDialog):
-  def __new__(cls):
-    return super(KeyListener, cls).__new__(cls, "DialogKaiToast.xml", "")
-  
-  def onInit(self):
-    try:
-      self.getControl(401).addLabel(tr(30001))
-      self.getControl(402).addLabel(tr(30002))
-    except:
-      self.getControl(401).setLabel(tr(30001))
-      self.getControl(402).setLabel(tr(30002))
-  
-  def onAction(self, action):
-    self.key = action.getButtonCode()
-    self.close()
+    TIMEOUT = 5
+
+    def __new__(cls):
+        return super(KeyListener, cls).__new__(cls, "DialogKaiToast.xml", "")
+
+    def __init__(self):
+        self.key = None
+
+    def onInit(self):
+        try:
+            self.getControl(401).addLabel(tr(30002))
+            self.getControl(402).addLabel(tr(30010) % self.TIMEOUT)
+        except AttributeError:
+            self.getControl(401).setLabel(tr(30002))
+            self.getControl(402).setLabel(tr(30010) % self.TIMEOUT)
+
+    def onAction(self, action):
+        code = action.getButtonCode()
+        self.key = None if code == 0 else str(code)
+        self.close()
+
+    @staticmethod
+    def record_key():
+        dialog = KeyListener()
+        timeout = Timer(KeyListener.TIMEOUT, dialog.close)
+        timeout.start()
+        dialog.doModal()
+        timeout.cancel()
+        key = dialog.key
+        del dialog
+        return key
diff --git a/script.keymap/resources/language/English/strings.xml 
b/script.keymap/resources/language/English/strings.xml
index 6f2c263..6296f99 100644
--- a/script.keymap/resources/language/English/strings.xml
+++ b/script.keymap/resources/language/English/strings.xml
@@ -1,14 +1,15 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <strings>
     <string id="30000">Keymap Editor</string>
-    <string id="30001">Press a key</string>
+    <string id="30001"></string>
     <string id="30002">Press the key you want to assign now</string>
     <string id="30003">Edit</string>
-    <string id="30004">Delete</string>
+    <string id="30004">Reset to default</string>
     <string id="30005">Save</string>
     <string id="30006">Discard changes?</string>
     <string id="30007">Select Window to manage shortcuts</string>
-    <string id="30008">Select category</string>
+    <string id="30008">Select action category</string>
     <string id="30009">Select the action to assign a key</string>
+    <string id="30010">Timeout in %.0f seconds...</string>
 </strings>
 

-----------------------------------------------------------------------

Summary of changes:
 script.keymap/{common.py => actions.py}            |   79 +++++++----
 script.keymap/addon.xml                            |    7 +-
 script.keymap/changelog.txt                        |    9 +-
 script.keymap/default.py                           |   82 -----------
 script.keymap/editor.py                            |  152 +++++++++++---------
 script.keymap/io.py                                |   49 -------
 script.keymap/main.py                              |   81 +++++++++++
 .../resources/language/English/strings.xml         |    7 +-
 script.keymap/utils.py                             |   58 ++++++++
 9 files changed, 288 insertions(+), 236 deletions(-)
 rename script.keymap/{common.py => actions.py} (90%)
 delete mode 100644 script.keymap/default.py
 delete mode 100644 script.keymap/io.py
 create mode 100644 script.keymap/main.py
 create mode 100644 script.keymap/utils.py


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Xbmc-addons mailing list
Xbmc-addons@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to