diff --git a/livesupport/src/products/gLiveSupport/etc/Makefile.in b/livesupport/src/products/gLiveSupport/etc/Makefile.in
index 5d369e6fd..b2d5d0747 100644
--- a/livesupport/src/products/gLiveSupport/etc/Makefile.in
+++ b/livesupport/src/products/gLiveSupport/etc/Makefile.in
@@ -259,6 +259,7 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/CuePlayer.o \
${TMP_DIR}/KeyboardShortcut.o \
${TMP_DIR}/KeyboardShortcutContainer.o \
+ ${TMP_DIR}/KeyboardShortcutList.o \
${TMP_DIR}/OptionsWindow.o
G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
diff --git a/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml b/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml
index aa3eaccee..a374544c8 100644
--- a/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml
+++ b/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml
@@ -11,7 +11,7 @@
cuePlayer,
stationLogo,
metadataTypeContainer,
- keyboardShortcutContainer*) >
+ keyboardShortcutList) >
@@ -98,6 +98,7 @@
+
@@ -340,79 +341,81 @@
/>
-
- masterPanelWindow
-
- playAudio
- X
- Space
-
-
- pauseAudio
- V
-
-
- stopAudio
- C
-
-
- nextTrack
- B
-
-
+
+
+ masterPanelWindow
+
+ playAudio
+ X
+ Space
+
+
+ pauseAudio
+ V
+
+
+ stopAudio
+ C
+
+
+ nextTrack
+ B
+
+
-
- liveModeWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
- playAudio
- X
- Space
-
-
+
+ liveModeWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
+ playAudio
+ X
+ Space
+
+
-
- scratchpadWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
+
+ scratchpadWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
-
- simplePlaylistManagementWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
+
+ simplePlaylistManagementWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
+
diff --git a/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.template b/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.template
index c8fb78b54..3603f68db 100644
--- a/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.template
+++ b/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.template
@@ -11,7 +11,7 @@
cuePlayer,
stationLogo,
metadataTypeContainer,
- keyboardShortcutContainer*) >
+ keyboardShortcutList) >
@@ -98,6 +98,7 @@
+
@@ -340,79 +341,81 @@
/>
-
- masterPanelWindow
-
- playAudio
- X
- Space
-
-
- pauseAudio
- V
-
-
- stopAudio
- C
-
-
- nextTrack
- B
-
-
+
+
+ masterPanelWindow
+
+ playAudio
+ X
+ Space
+
+
+ pauseAudio
+ V
+
+
+ stopAudio
+ C
+
+
+ nextTrack
+ B
+
+
-
- liveModeWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
- playAudio
- X
- Space
-
-
+
+ liveModeWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
+ playAudio
+ X
+ Space
+
+
-
- scratchpadWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
+
+ scratchpadWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
-
- simplePlaylistManagementWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
+
+ simplePlaylistManagementWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
+
diff --git a/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.user-template b/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.user-template
index 0b791f01e..b9281df49 100644
--- a/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.user-template
+++ b/livesupport/src/products/gLiveSupport/etc/gLiveSupport.xml.user-template
@@ -11,7 +11,7 @@
cuePlayer,
stationLogo,
metadataTypeContainer,
- keyboardShortcutContainer*) >
+ keyboardShortcutList) >
@@ -98,6 +98,7 @@
+
@@ -340,79 +341,81 @@
/>
-
- masterPanelWindow
-
- playAudio
- X
- Space
-
-
- pauseAudio
- V
-
-
- stopAudio
- C
-
-
- nextTrack
- B
-
-
+
+
+ masterPanelWindow
+
+ playAudio
+ X
+ Space
+
+
+ pauseAudio
+ V
+
+
+ stopAudio
+ C
+
+
+ nextTrack
+ B
+
+
-
- liveModeWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
- playAudio
- X
- Space
-
-
+
+ liveModeWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
+ playAudio
+ X
+ Space
+
+
-
- scratchpadWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
+
+ scratchpadWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
-
- simplePlaylistManagementWindow
-
- moveItemUp
- Alt-Up
-
-
- moveItemDown
- Alt-Down
-
-
- removeItem
- Delete
-
-
+
+ simplePlaylistManagementWindow
+
+ moveItemUp
+ Alt-Up
+
+
+ moveItemDown
+ Alt-Down
+
+
+ removeItem
+ Delete
+
+
+
diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx
index 7eccd3b50..89b89224d 100644
--- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx
+++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx
@@ -196,7 +196,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
if (nodes.size() < 1) {
throw std::invalid_argument("no supportedLanguages element");
}
- configSupportedLanguages(*((const xmlpp::Element*) *(nodes.begin())) );
+ configSupportedLanguages(*((const xmlpp::Element*) nodes.front()));
// configure the resource bundle
nodes = element.get_children(LocalizedObject::getConfigElementName());
@@ -204,7 +204,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
throw std::invalid_argument("no resourceBundle element");
}
LocalizedConfigurable::configure(
- *((const xmlpp::Element*) *(nodes.begin())));
+ *((const xmlpp::Element*) nodes.front()));
// configure the AuthenticationClientFactory
nodes = element.get_children(
@@ -214,7 +214,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
}
Ptr::Ref acf
= AuthenticationClientFactory::getInstance();
- acf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
+ acf->configure( *((const xmlpp::Element*) nodes.front()) );
authentication = acf->getAuthenticationClient();
@@ -224,7 +224,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
throw std::invalid_argument("no storageClientFactory element");
}
Ptr::Ref stcf = StorageClientFactory::getInstance();
- stcf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
+ stcf->configure( *((const xmlpp::Element*) nodes.front()) );
storage = stcf->getStorageClient();
@@ -234,7 +234,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
throw std::invalid_argument("no widgetFactory element");
}
widgetFactory = WidgetFactory::getInstance();
- widgetFactory->configure( *((const xmlpp::Element*) *(nodes.begin())) );
+ widgetFactory->configure( *((const xmlpp::Element*) nodes.front()) );
// configure the SchedulerClientFactory
nodes = element.get_children(
@@ -244,7 +244,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
}
Ptr::Ref schcf
= SchedulerClientFactory::getInstance();
- schcf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
+ schcf->configure( *((const xmlpp::Element*) nodes.front()) );
scheduler = schcf->getSchedulerClient();
@@ -261,7 +261,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
throw std::invalid_argument("no audioPlayer element");
}
apf = AudioPlayerFactory::getInstance();
- apf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
+ apf->configure( *((const xmlpp::Element*) nodes.front()) );
outputPlayer = apf->getAudioPlayer();
outputPlayer->initialize();
@@ -278,7 +278,7 @@ GLiveSupport :: configure(const xmlpp::Element & element)
throw std::invalid_argument("no audioPlayer element");
}
apf = AudioPlayerFactory::getInstance();
- apf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
+ apf->configure( *((const xmlpp::Element*) nodes.front()) );
cuePlayer = apf->getAudioPlayer();
cuePlayer->initialize();
@@ -304,26 +304,20 @@ GLiveSupport :: configure(const xmlpp::Element & element)
if (nodes.size() < 1) {
throw std::invalid_argument("no metadataTypeContainer element");
}
- Ptr::Ref metadataBundle;
- try {
- metadataBundle = getBundle("metadataTypes");
- } catch (std::invalid_argument &e) {
- throw std::invalid_argument(e.what());
- }
+ Ptr::Ref metadataBundle = getBundle("metadataTypes");
metadataTypeContainer.reset(new MetadataTypeContainer(metadataBundle));
metadataTypeContainer->configure(
- *((const xmlpp::Element*) *(nodes.begin())) );
+ *((const xmlpp::Element*) nodes.front()) );
- // configure the KeyboardShortcutContainer classes
+ // configure the KeyboardShortcutList
nodes = element.get_children(
- KeyboardShortcutContainer::getConfigElementName());
- xmlpp::Node::NodeList::const_iterator it = nodes.begin();
- while (it != nodes.end()) {
- Ptr::Ref ksc(new KeyboardShortcutContainer);
- ksc->configure(*((const xmlpp::Element*) *it));
- keyboardShortcutList[*ksc->getWindowName()] = ksc;
- ++it;
+ KeyboardShortcutList::getConfigElementName());
+ if (nodes.size() < 1) {
+ throw std::invalid_argument("no keyboardShortcutList element");
}
+ keyboardShortcutList.reset(new KeyboardShortcutList);
+ keyboardShortcutList->configure(
+ *((const xmlpp::Element*) nodes.front()) );
// save the configuration so we can modify it later
// TODO: move configuration code to the OptionsContainer class?
@@ -1333,22 +1327,28 @@ GLiveSupport :: getStationLogoImage(void) throw()
/*------------------------------------------------------------------------------
- * Find the action triggered by the given key in the given window.
+ * Get the localized name of the keyboard shortcut action.
*----------------------------------------------------------------------------*/
-KeyboardShortcut::Action
+Ptr::Ref
LiveSupport :: GLiveSupport ::
-GLiveSupport :: findAction(const Glib::ustring & windowName,
- unsigned int modifiers,
- unsigned int key) const throw ()
+GLiveSupport :: getLocalizedKeyboardActionName(
+ Ptr::Ref actionName)
+ throw (std::invalid_argument)
{
- KeyboardShortcutListType::const_iterator it = keyboardShortcutList.find(
- windowName);
- if (it != keyboardShortcutList.end()) {
- Ptr::Ref ksc = it->second;
- return ksc->findAction(modifiers, key);
- } else {
- return KeyboardShortcut::noAction;
- }
+ return getResourceUstring("keyboardShortcuts", actionName->c_str());
+}
+
+
+/*------------------------------------------------------------------------------
+ * Get the localized name of the window.
+ *----------------------------------------------------------------------------*/
+Ptr::Ref
+LiveSupport :: GLiveSupport ::
+GLiveSupport :: getLocalizedWindowName(
+ Ptr::Ref windowName)
+ throw (std::invalid_argument)
+{
+ return getResourceUstring(windowName->c_str(), "windowTitle");
}
diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h
index 98011e5b8..8150128c6 100644
--- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h
+++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h
@@ -55,7 +55,7 @@
#include "LiveSupport/SchedulerClient/SchedulerClientInterface.h"
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
#include "LiveSupport/Widgets/WidgetFactory.h"
-#include "KeyboardShortcutContainer.h"
+#include "KeyboardShortcutList.h"
namespace LiveSupport {
@@ -287,17 +287,10 @@ class GLiveSupport : public LocalizedConfigurable,
void
uncachePlaylist(Ptr::Ref id) throw ();
- /**
- * The type for storing the keyboard shortcuts.
- */
- typedef std::map::Ref>
- KeyboardShortcutListType;
-
/**
* The list of keyboard shortcuts for the various windows.
*/
- KeyboardShortcutListType keyboardShortcutList;
+ Ptr::Ref keyboardShortcutList;
/**
* The type for a single window position.
@@ -986,7 +979,50 @@ class GLiveSupport : public LocalizedConfigurable,
KeyboardShortcut::Action
findAction(const Glib::ustring & windowName,
unsigned int modifiers,
- unsigned int key) const throw ();
+ unsigned int key) const throw ()
+ {
+ return keyboardShortcutList->findAction(windowName, modifiers, key);
+ }
+
+ /**
+ * The list of all KeyboardShortcutContainer objects.
+ * Used in the Key bindings section of the OptionsWindow class.
+ *
+ * @return a const pointer to the list (implemented as a std::map).
+ */
+ Ptr::Ref
+ getKeyboardShortcutList(void) throw ()
+ {
+ return keyboardShortcutList;
+ }
+
+ /**
+ * Get the localized name of the window.
+ * Used in the Key bindings section of the OptionsWindow class.
+ *
+ * @param windowName the name of the window.
+ * @return the localized name.
+ * @exception std::invalid_argument if the resource bundle is
+ * not found
+ */
+ Ptr::Ref
+ getLocalizedWindowName(Ptr::Ref windowName)
+ throw (std::invalid_argument);
+
+ /**
+ * Get the localized name of the keyboard shortcut action.
+ * Used in the Key bindings section of the OptionsWindow class.
+ *
+ * @param actionName the name of the action.
+ * @return the localized name.
+ * @exception std::invalid_argument if the resource bundle is
+ * not found
+ * @see KeyboardShortcut::getActionString()
+ */
+ Ptr::Ref
+ getLocalizedKeyboardActionName(
+ Ptr::Ref actionName)
+ throw (std::invalid_argument);
/**
* Save the position and size of the window.
diff --git a/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.cxx b/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.cxx
index 189b478fb..668ac5042 100644
--- a/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.cxx
+++ b/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.cxx
@@ -83,11 +83,11 @@ static const unsigned int modifiersChecked = GDK_SHIFT_MASK
* Add a shortcut key for this object.
*----------------------------------------------------------------------------*/
void
-KeyboardShortcut :: addKey(const Glib::ustring & modifiedKeyName)
+KeyboardShortcut :: addKey(Ptr::Ref modifiedKeyName)
throw (std::invalid_argument)
{
Ptr::Ref inputString(new Glib::ustring(
- modifiedKeyName ));
+ *modifiedKeyName ));
Ptr::Ref keyName = getToken(inputString);
if (!keyName) {
@@ -142,13 +142,13 @@ KeyboardShortcut :: configure(const xmlpp::Element & element)
}
const xmlpp::Element* actionElement = dynamic_cast(
children.front());
- const Glib::ustring actionString = actionElement->get_child_text()
- ->get_content();
+ actionString.reset(new Glib::ustring(actionElement->get_child_text()
+ ->get_content() ));
try {
action = stringToAction(actionString);
} catch (std::invalid_argument &e) {
std::string eMsg = "Invalid action specification ";
- eMsg += actionString;
+ eMsg += *actionString;
eMsg += ".";
throw std::invalid_argument(eMsg);
}
@@ -159,19 +159,25 @@ KeyboardShortcut :: configure(const xmlpp::Element & element)
throw std::invalid_argument("missing "
+ keyElementName + " element");
}
+ bool firstRun = true;
xmlpp::Node::NodeList::const_iterator it;
for (it = children.begin(); it != children.end(); ++it) {
const xmlpp::Element* keyElement =
dynamic_cast(*it);
- const Glib::ustring keyString = keyElement->get_child_text()
- ->get_content();
+ Ptr::Ref keyString(new Glib::ustring(
+ keyElement->get_child_text()
+ ->get_content() ));
+ if (firstRun) {
+ firstKeyString = keyString;
+ firstRun = false;
+ }
try {
addKey(keyString);
} catch (std::invalid_argument &e) {
std::string eMsg = "Invalid key specification ";
- eMsg += keyString;
+ eMsg += *keyString;
eMsg += " for action ";
- eMsg += actionString;
+ eMsg += *actionString;
eMsg += ".";
throw std::invalid_argument(eMsg);
}
@@ -208,24 +214,24 @@ KeyboardShortcut :: isTriggeredBy(unsigned int modifiers,
* Convert an action name string to an enumeration value.
*----------------------------------------------------------------------------*/
KeyboardShortcut::Action
-KeyboardShortcut :: stringToAction(const Glib::ustring & actionName)
+KeyboardShortcut :: stringToAction(Ptr::Ref actionName)
throw (std::invalid_argument)
{
- if (actionName == "playAudio") {
+ if (*actionName == "playAudio") {
return playAudio;
- } else if (actionName == "pauseAudio") {
+ } else if (*actionName == "pauseAudio") {
return pauseAudio;
- } else if (actionName == "stopAudio") {
+ } else if (*actionName == "stopAudio") {
return stopAudio;
- } else if (actionName == "nextTrack") {
+ } else if (*actionName == "nextTrack") {
return nextTrack;
- } else if (actionName == "fadeOut") {
+ } else if (*actionName == "fadeOut") {
return fadeOut;
- } else if (actionName == "moveItemUp") {
+ } else if (*actionName == "moveItemUp") {
return moveItemUp;
- } else if (actionName == "moveItemDown") {
+ } else if (*actionName == "moveItemDown") {
return moveItemDown;
- } else if (actionName == "removeItem") {
+ } else if (*actionName == "removeItem") {
return removeItem;
} else {
throw std::invalid_argument("");
diff --git a/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.h b/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.h
index 0d6c1ab12..d90e146b1 100644
--- a/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.h
+++ b/livesupport/src/products/gLiveSupport/src/KeyboardShortcut.h
@@ -63,9 +63,6 @@ using namespace LiveSupport::Core;
/* =============================================================== data types */
-// class KeyboardShortcutContainer; // TODO: remove or activate
-
-
/**
* A class for representing a keyboard shortcut.
*
@@ -139,6 +136,11 @@ class KeyboardShortcut : public Configurable
*/
Action action;
+ /**
+ * A string representation of the action.
+ */
+ Ptr::Ref actionString;
+
/**
* The type for storing key and modifier values.
*/
@@ -163,6 +165,11 @@ class KeyboardShortcut : public Configurable
*/
KeyListType keyList;
+ /**
+ * A string representation of the first item in the key list.
+ */
+ Ptr::Ref firstKeyString;
+
/**
* Convert an action name string to an enumeration value.
* If no matching enumeration value is found, noAction is returned.
@@ -170,7 +177,7 @@ class KeyboardShortcut : public Configurable
* @param actionName a string containing the name of the action.
*/
Action
- stringToAction(const Glib::ustring & actionName)
+ stringToAction(Ptr::Ref actionName)
throw(std::invalid_argument);
/**
@@ -238,7 +245,7 @@ class KeyboardShortcut : public Configurable
* key description.
*/
void
- addKey(const Glib::ustring & modifiedKeyName)
+ addKey(Ptr::Ref modifiedKeyName)
throw (std::invalid_argument);
/**
@@ -306,6 +313,29 @@ class KeyboardShortcut : public Configurable
bool
isTriggeredBy(unsigned int modifiers,
unsigned int key) const throw ();
+
+ /**
+ * Return a string corresponding to the action of this shortcut.
+ *
+ * @return a string representing the action of this shortcut.
+ */
+ Ptr::Ref
+ getActionString(void) const throw ()
+ {
+ return actionString;
+ }
+
+ /**
+ * Return the first key associated with this shortcut.
+ *
+ * @return a string representing the first modifier-key pair of
+ * this shortcut.
+ */
+ Ptr::Ref
+ getKeyString(void) const throw ()
+ {
+ return firstKeyString;
+ }
};
diff --git a/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.cxx b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.cxx
index 55ea88bf5..b3b7b2351 100644
--- a/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.cxx
+++ b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.cxx
@@ -106,7 +106,7 @@ KeyboardShortcutContainer :: configure(const xmlpp::Element & element)
*----------------------------------------------------------------------------*/
KeyboardShortcut::Action
KeyboardShortcutContainer :: findAction(unsigned int modifiers,
- unsigned int key) throw ()
+ unsigned int key) const throw ()
{
ShortcutListType::const_iterator it = shortcutList.begin();
diff --git a/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.h b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.h
index 34e267d69..04fc3ef77 100644
--- a/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.h
+++ b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutContainer.h
@@ -105,7 +105,7 @@ class KeyboardShortcutContainer : public Configurable
/**
* A vector type holding contant KeyboardShortcut references.
*/
- typedef std::vector::Ref>
+ typedef std::vector::Ref>
ShortcutListType;
/**
@@ -168,7 +168,7 @@ class KeyboardShortcutContainer : public Configurable
* @return the action; or noAction if none is found.
*/
KeyboardShortcut::Action
- findAction(unsigned int modifiers, unsigned int key) throw ();
+ findAction(unsigned int modifiers, unsigned int key) const throw ();
/**
* Return the name of the window the shortcuts are for.
@@ -177,10 +177,34 @@ class KeyboardShortcutContainer : public Configurable
* the object has not been configured yet.
*/
Ptr::Ref
- getWindowName(void) throw ()
+ getWindowName(void) const throw ()
{
return windowName;
}
+
+ /**
+ * The iterator for cycling through the keyboard shortcuts.
+ * Dereference an iterator to get a Ptr::Ref.
+ */
+ typedef ShortcutListType::const_iterator iterator;
+
+ /**
+ * The first item in the list.
+ */
+ iterator
+ begin(void) const throw ()
+ {
+ return shortcutList.begin();
+ }
+
+ /**
+ * One after the last item in the list.
+ */
+ iterator
+ end(void) const throw ()
+ {
+ return shortcutList.end();
+ }
};
diff --git a/livesupport/src/products/gLiveSupport/src/KeyboardShortcutList.cxx b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutList.cxx
new file mode 100644
index 000000000..39cb639b4
--- /dev/null
+++ b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutList.cxx
@@ -0,0 +1,100 @@
+/*------------------------------------------------------------------------------
+
+ Copyright (c) 2004 Media Development Loan Fund
+
+ This file is part of the LiveSupport project.
+ http://livesupport.campware.org/
+ To report bugs, send an e-mail to bugs@campware.org
+
+ LiveSupport is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ LiveSupport is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LiveSupport; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+ Author : $Author$
+ Version : $Revision$
+ Location : $URL$
+
+------------------------------------------------------------------------------*/
+
+/* ============================================================ include files */
+
+#ifdef HAVE_CONFIG_H
+#include "configure.h"
+#endif
+
+#include "KeyboardShortcutList.h"
+
+
+using namespace LiveSupport::Core;
+using namespace LiveSupport::GLiveSupport;
+
+/* =================================================== local data structures */
+
+
+/* ================================================ local constants & macros */
+
+/**
+ * The name of the config element for this class
+ */
+const std::string KeyboardShortcutList::configElementName
+ = "keyboardShortcutList";
+
+
+/* =============================================== local function prototypes */
+
+
+/* ============================================================= module code */
+
+/*------------------------------------------------------------------------------
+ * Create a metadata type container element object based on an XML element.
+ *----------------------------------------------------------------------------*/
+void
+KeyboardShortcutList :: configure(const xmlpp::Element & element)
+ throw (std::invalid_argument)
+{
+ if (element.get_name() != configElementName) {
+ throw std::invalid_argument("bad coniguration element "
+ + element.get_name());
+ }
+
+ xmlpp::Node::NodeList nodes = element.get_children(
+ KeyboardShortcutContainer::getConfigElementName());
+ xmlpp::Node::NodeList::const_iterator it = nodes.begin();
+ while (it != nodes.end()) {
+ Ptr::Ref ksc(new KeyboardShortcutContainer);
+ ksc->configure(*((const xmlpp::Element*) *it));
+ containerList.push_back(ksc);
+ ++it;
+ }
+}
+
+/*------------------------------------------------------------------------------
+ * Find the action triggered by the given key in the given window.
+ *----------------------------------------------------------------------------*/
+KeyboardShortcut::Action
+KeyboardShortcutList :: findAction(const Glib::ustring & windowName,
+ unsigned int modifiers,
+ unsigned int key) const
+ throw ()
+{
+ for (iterator it = begin(); it != end(); ++it) {
+ Ptr::Ref ksc = *it;
+ if (*ksc->getWindowName() == windowName) {
+ return ksc->findAction(modifiers, key);
+ }
+ }
+
+ return KeyboardShortcut::noAction;
+}
+
diff --git a/livesupport/src/products/gLiveSupport/src/KeyboardShortcutList.h b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutList.h
new file mode 100644
index 000000000..e97dc6b29
--- /dev/null
+++ b/livesupport/src/products/gLiveSupport/src/KeyboardShortcutList.h
@@ -0,0 +1,194 @@
+/*------------------------------------------------------------------------------
+
+ Copyright (c) 2004 Media Development Loan Fund
+
+ This file is part of the LiveSupport project.
+ http://livesupport.campware.org/
+ To report bugs, send an e-mail to bugs@campware.org
+
+ LiveSupport is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ LiveSupport is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LiveSupport; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+ Author : $Author$
+ Version : $Revision$
+ Location : $URL$
+
+------------------------------------------------------------------------------*/
+#ifndef LiveSupport_GLiveSupport_KeyboardShortcutList_h
+#define LiveSupport_GLiveSupport_KeyboardShortcutList_h
+
+#ifndef __cplusplus
+#error This is a C++ include file
+#endif
+
+
+/* ============================================================ include files */
+
+#ifdef HAVE_CONFIG_H
+#include "configure.h"
+#endif
+
+#include