added keyboard shortcuts for play/pause/stop in the Master Panel;

removed stupid search function from Scratchpad and Live Mode (so that
    now these windows can receive keyboard events [a-zA-Z]).
this fixes #1036 (except for fade, which may or may not be addressed later)
This commit is contained in:
fgerlits 2005-10-27 15:22:40 +00:00
parent f9787f47d3
commit 14dbddd7c2
12 changed files with 201 additions and 2 deletions

View File

@ -335,6 +335,31 @@
/>
</metadataTypeContainer>
<keyboardShortcutContainer>
<windowName>masterPanelWindow</windowName>
<keyboardShortcut>
<action>playAudio</action>
<key>x</key>
<key>X</key>
<key>Space</key>
</keyboardShortcut>
<keyboardShortcut>
<action>pauseAudio</action>
<key>v</key>
<key>V</key>
</keyboardShortcut>
<keyboardShortcut>
<action>stopAudio</action>
<key>c</key>
<key>C</key>
</keyboardShortcut>
<keyboardShortcut>
<action>nextTrack</action>
<key>b</key>
<key>B</key>
</keyboardShortcut>
</keyboardShortcutContainer>
<keyboardShortcutContainer>
<windowName>liveModeWindow</windowName>
<keyboardShortcut>
@ -349,6 +374,12 @@
<action>removeItem</action>
<key>Delete</key>
</keyboardShortcut>
<keyboardShortcut>
<action>playAudio</action>
<key>x</key>
<key>X</key>
<key>Space</key>
</keyboardShortcut>
</keyboardShortcutContainer>
<keyboardShortcutContainer>

View File

@ -335,6 +335,31 @@
/>
</metadataTypeContainer>
<keyboardShortcutContainer>
<windowName>masterPanelWindow</windowName>
<keyboardShortcut>
<action>playAudio</action>
<key>x</key>
<key>X</key>
<key>Space</key>
</keyboardShortcut>
<keyboardShortcut>
<action>pauseAudio</action>
<key>v</key>
<key>V</key>
</keyboardShortcut>
<keyboardShortcut>
<action>stopAudio</action>
<key>c</key>
<key>C</key>
</keyboardShortcut>
<keyboardShortcut>
<action>nextTrack</action>
<key>b</key>
<key>B</key>
</keyboardShortcut>
</keyboardShortcutContainer>
<keyboardShortcutContainer>
<windowName>liveModeWindow</windowName>
<keyboardShortcut>
@ -349,6 +374,12 @@
<action>removeItem</action>
<key>Delete</key>
</keyboardShortcut>
<keyboardShortcut>
<action>playAudio</action>
<key>x</key>
<key>X</key>
<key>Space</key>
</keyboardShortcut>
</keyboardShortcutContainer>
<keyboardShortcutContainer>

View File

@ -335,6 +335,31 @@
/>
</metadataTypeContainer>
<keyboardShortcutContainer>
<windowName>masterPanelWindow</windowName>
<keyboardShortcut>
<action>playAudio</action>
<key>x</key>
<key>X</key>
<key>Space</key>
</keyboardShortcut>
<keyboardShortcut>
<action>pauseAudio</action>
<key>v</key>
<key>V</key>
</keyboardShortcut>
<keyboardShortcut>
<action>stopAudio</action>
<key>c</key>
<key>C</key>
</keyboardShortcut>
<keyboardShortcut>
<action>nextTrack</action>
<key>b</key>
<key>B</key>
</keyboardShortcut>
</keyboardShortcutContainer>
<keyboardShortcutContainer>
<windowName>liveModeWindow</windowName>
<keyboardShortcut>
@ -349,6 +374,12 @@
<action>removeItem</action>
<key>Delete</key>
</keyboardShortcut>
<keyboardShortcut>
<action>playAudio</action>
<key>x</key>
<key>X</key>
<key>Space</key>
</keyboardShortcut>
</keyboardShortcutContainer>
<keyboardShortcutContainer>

View File

@ -284,7 +284,7 @@ KeyboardShortcut :: stringToKey(Ptr<const Glib::ustring>::Ref keyName)
} else if (c >= 'A' && c <= 'Z') {
return GDK_A + (c - 'A');
} else if (c >= 'a' && c <= 'z') {
return GDK_A + (c - 'a');
return GDK_a + (c - 'a');
}
} else if (*keyName == "Space") {
return GDK_space;

View File

@ -95,6 +95,7 @@ LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
// ... and the tree view:
treeView = Gtk::manage(wf->createTreeView(treeModel));
treeView->set_headers_visible(false);
treeView->set_enable_search(false);
// Add the TreeView's view columns:
try {
@ -362,6 +363,10 @@ LiveModeWindow :: onKeyPressed(GdkEventKey * event) throw ()
treeView->onRemoveMenuOption();
return true;
case KeyboardShortcut::playAudio :
onOutputPlay();
return true;
default : break;
}
}

View File

@ -181,7 +181,9 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
* Signal handler for a key pressed at one of the entries.
* The keys can be customized by the keyboardShortcutContainer
* element in the gLiveSupport configuration file.
* The actions handled are: moveItemUp, moveItemDown and removeItem.
*
* The actions handled are: moveItemUp, moveItemDown, removeItem,
* and playAudio (which plays the item in the output player).
*
* @param event the button event received
* @return true if the key press was fully handled, false if not

View File

@ -51,6 +51,11 @@ using namespace LiveSupport::GLiveSupport;
/* ================================================ local constants & macros */
/**
* The name of the window, used by the keyboard shortcuts (or by the .gtkrc).
*/
static const Glib::ustring windowName = "masterPanelWindow";
/* =============================================== local function prototypes */
@ -155,6 +160,10 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
0, 0);
add(*layout);
// register the signal handler for keyboard key presses
this->signal_key_press_event().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onKeyPressed));
// set the background to white
bgColor = Colors::getColor(Colors::White);
modify_bg(Gtk::STATE_NORMAL, bgColor);
@ -168,6 +177,9 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
set_default_size(width, height);
move(0, 0);
set_decorated(false);
set_name(windowName);
// need to make it focusable first
// set_focus(*nowPlayingWidget);
// set the localized resources
liveModeButton = 0;
@ -584,6 +596,7 @@ MasterPanelWindow :: setNowPlaying(Ptr<Playable>::Ref playable)
throw ()
{
nowPlayingWidget->setPlayable(playable);
present(); // this moves the global keyboard focus to the master panel
}
@ -612,3 +625,40 @@ resizeImage(Gtk::Image* image, int width, int height) throw ()
}
}
/*------------------------------------------------------------------------------
* Event handler for a key pressed.
*----------------------------------------------------------------------------*/
bool
MasterPanelWindow :: onKeyPressed(GdkEventKey * event) throw ()
{
if (event->type == GDK_KEY_PRESS) {
KeyboardShortcut::Action action = gLiveSupport->findAction(
windowName,
event->state,
event->keyval);
switch (action) {
case KeyboardShortcut::playAudio :
nowPlayingWidget->onPlayAudio();
return true;
case KeyboardShortcut::pauseAudio :
nowPlayingWidget->onPauseAudio();
return true;
case KeyboardShortcut::stopAudio :
nowPlayingWidget->onStopAudio();
return true;
case KeyboardShortcut::nextTrack :
gLiveSupport->stopOutputAudio();
gLiveSupport->onStop();
return true;
default : break;
}
}
return false;
}

View File

@ -358,6 +358,20 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
}
}
/**
* Signal handler for a key pressed at one of the entries.
* The keys can be customized by the keyboardShortcutContainer
* element in the gLiveSupport configuration file.
*
* The action handled is: playAudio, pauseAudio, stopAudio,
* and nextTrack.
*
* @param event the button event received
* @return true if the key press was fully handled, false if not
*/
bool
onKeyPressed(GdkEventKey * event) throw ();
public:
/**

View File

@ -193,6 +193,38 @@ class NowPlaying : public Gtk::HBox,
void
onUpdateTime(void) throw ();
/**
* Public interface for restarting the audio.
*
* This is used by MasterPanelWindow::onKeyPressed().
*/
void
onPlayAudio(void) throw ()
{
onPlayButtonClicked();
}
/**
* Public interface for pausing the audio.
*
* This is used by MasterPanelWindow::onKeyPressed().
*/
void
onPauseAudio(void) throw ()
{
onPauseButtonClicked();
}
/**
* Public interface for stopping the audio.
*
* This is used by MasterPanelWindow::onKeyPressed().
*/
void
onStopAudio(void) throw ()
{
onStopButtonClicked();
}
};

View File

@ -109,6 +109,7 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
treeModel = Gtk::ListStore::create(modelColumns);
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel));
treeView->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
treeView->set_enable_search(false);
// Add the TreeView's view columns:
try {

View File

@ -258,6 +258,7 @@ class ScratchpadWindow : public WhiteWindow,
* Signal handler for a key pressed at one of the entries.
* The keys can be customized by the keyboardShortcutContainer
* element in the gLiveSupport configuration file.
*
* The actions handled are: moveItemUp, moveItemDown and removeItem.
*
* @param event the button event received

View File

@ -156,6 +156,7 @@ class SimplePlaylistManagementWindow : public WhiteWindow,
* Signal handler for a key pressed at one of the entries.
* The keys can be customized by the keyboardShortcutContainer
* element in the gLiveSupport configuration file.
*
* The actions handled are: moveItemUp, moveItemDown and removeItem.
*
* @param event the button event received