diff --git a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx index 3c609d4d6..1ee627894 100644 --- a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.cxx @@ -157,45 +157,9 @@ LiveModeWindow :: LiveModeWindow (Ptr::Ref gLiveSupport, outputPlayButton->signal_clicked().connect(sigc::mem_fun(*this, &LiveModeWindow::onOutputPlay )); - // create the right-click entry context menu - contextMenu = Gtk::manage(new Gtk::Menu()); - Gtk::Menu::MenuList& contextMenuList = contextMenu->items(); - // register the signal handlers for the popup menu - try { - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("cueMenuItem"), - sigc::mem_fun(*cueAudioButtons, - &CuePlayer::onPlayItem))); - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("upMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onUpMenuOption))); - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("downMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onDownMenuOption))); - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("removeMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onRemoveMenuOption))); - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("playMenuItem"), - sigc::mem_fun(*this, - &LiveModeWindow::onOutputPlay))); - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("exportPlaylistMenuItem"), - sigc::mem_fun(*this, - &LiveModeWindow::onExportPlaylist))); - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("uploadToHubMenuItem"), - sigc::mem_fun(*this, - &LiveModeWindow::onUploadToHub))); - } catch (std::invalid_argument &e) { - std::cerr << e.what() << std::endl; - std::exit(1); - } - - contextMenu->accelerate(*this); + // create the right-click context menus + audioClipContextMenu = constructAudioClipContextMenu(); + playlistContextMenu = constructPlaylistContextMenu(); // show set_name(windowName); @@ -321,26 +285,38 @@ void LiveModeWindow :: onEntryClicked(GdkEventButton * event) throw () { if (event->type == GDK_BUTTON_PRESS && event->button == 3) { - Glib::RefPtr refSelection = - treeView->get_selection(); - Gtk::TreeModel::iterator iter = refSelection->get_selected(); - - // if nothing is currently selected, select row at mouse pointer - if (!iter) { - Gtk::TreeModel::Path path; - Gtk::TreeViewColumn * column; - int cell_x, - cell_y; - if (treeView->get_path_at_pos(int(event->x), int(event->y), - path, column, - cell_x, cell_y)) { - refSelection->select(path); - iter = refSelection->get_selected(); - } - } + Gtk::TreePath currentPath; + Gtk::TreeViewColumn * column; + int cell_x, + cell_y; + bool foundValidRow = treeView->get_path_at_pos( + int(event->x), int(event->y), + currentPath, column, + cell_x, cell_y); - if (iter) { - contextMenu->popup(event->button, event->time); + if (foundValidRow) { + Gtk::TreeIter iter = treeModel->get_iter(currentPath); + if (iter) { + Ptr::Ref playable = + (*iter)[modelColumns.playableColumn]; + + if (playable) { + switch (playable->getType()) { + case Playable::AudioClipType: + audioClipContextMenu->popup(event->button, + event->time); + break; + + case Playable::PlaylistType: + playlistContextMenu->popup(event->button, + event->time); + break; + + default: + break; + } + } + } } } } @@ -471,3 +447,82 @@ LiveModeWindow :: refreshPlaylist(Ptr::Ref playlist) throw () } } + +/*------------------------------------------------------------------------------ + * Construct the right-click context menu for local audio clips. + *----------------------------------------------------------------------------*/ +Gtk::Menu * +LiveModeWindow :: constructAudioClipContextMenu(void) throw () +{ + Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); + Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); + + try { + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("playMenuItem"), + sigc::mem_fun(*this, + &LiveModeWindow::onOutputPlay))); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("cueMenuItem"), + sigc::mem_fun(*cueAudioButtons, + &CuePlayer::onPlayItem))); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("removeMenuItem"), + sigc::mem_fun(*treeView, + &ZebraTreeView::onRemoveMenuOption))); + contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("uploadToHubMenuItem"), + sigc::mem_fun(*this, + &LiveModeWindow::onUploadToHub))); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + + contextMenu->accelerate(*this); + return contextMenu; +} + + +/*------------------------------------------------------------------------------ + * Construct the right-click context menu for local playlists. + *----------------------------------------------------------------------------*/ +Gtk::Menu * +LiveModeWindow :: constructPlaylistContextMenu(void) throw () +{ + Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); + Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); + + try { + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("playMenuItem"), + sigc::mem_fun(*this, + &LiveModeWindow::onOutputPlay))); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("cueMenuItem"), + sigc::mem_fun(*cueAudioButtons, + &CuePlayer::onPlayItem))); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("removeMenuItem"), + sigc::mem_fun(*treeView, + &ZebraTreeView::onRemoveMenuOption))); + contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("exportPlaylistMenuItem"), + sigc::mem_fun(*this, + &LiveModeWindow::onExportPlaylist))); + contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("uploadToHubMenuItem"), + sigc::mem_fun(*this, + &LiveModeWindow::onUploadToHub))); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + + contextMenu->accelerate(*this); + return contextMenu; +} + diff --git a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h index cfee278e3..df05e4e67 100644 --- a/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h +++ b/campcaster/src/products/gLiveSupport/src/LiveModeWindow.h @@ -90,6 +90,22 @@ class LiveModeWindow : public GuiWindow */ CuePlayer * cueAudioButtons; + /** + * Construct the right-click context menu for local audio clips. + * + * @return the context menu created (already Gtk::manage()'ed). + */ + Gtk::Menu * + constructAudioClipContextMenu(void) throw (); + + /** + * Construct the right-click context menu for local playlists. + * + * @return the context menu created (already Gtk::manage()'ed). + */ + Gtk::Menu * + constructPlaylistContextMenu(void) throw (); + protected: @@ -151,10 +167,14 @@ class LiveModeWindow : public GuiWindow Glib::RefPtr treeModel; /** - * The right-click context menu, - * that comes up when right-clicking an entry in the entry list. + * The right-click context menu for audio clips. */ - Gtk::Menu * contextMenu; + Gtk::Menu * audioClipContextMenu; + + /** + * The right-click context menu for playlists. + */ + Gtk::Menu * playlistContextMenu; /** * Signal handler for the output play button clicked diff --git a/campcaster/src/products/gLiveSupport/src/ScratchpadWindow.cxx b/campcaster/src/products/gLiveSupport/src/ScratchpadWindow.cxx index 34dec7cc1..250509ec9 100644 --- a/campcaster/src/products/gLiveSupport/src/ScratchpadWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/ScratchpadWindow.cxx @@ -171,22 +171,6 @@ ScratchpadWindow :: ScratchpadWindow ( Gtk::Menu::MenuList& audioClipMenuList = audioClipMenu->items(); // register the signal handlers for the popup menu try { - audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("addToPlaylistMenuItem"), - sigc::mem_fun(*this, - &ScratchpadWindow::onAddToPlaylist))); - audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("upMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onUpMenuOption))); - audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("downMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onDownMenuOption))); - audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("removeMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onRemoveMenuOption))); audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("cueMenuItem"), sigc::mem_fun(*cueAudioButtons, @@ -195,6 +179,15 @@ ScratchpadWindow :: ScratchpadWindow ( *getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this, &ScratchpadWindow::onAddToLiveMode))); + audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("addToPlaylistMenuItem"), + sigc::mem_fun(*this, + &ScratchpadWindow::onAddToPlaylist))); + audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("removeMenuItem"), + sigc::mem_fun(*treeView, + &ZebraTreeView::onRemoveMenuOption))); + audioClipMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("uploadToHubMenuItem"), sigc::mem_fun(*this, @@ -212,30 +205,6 @@ ScratchpadWindow :: ScratchpadWindow ( // register the signal handlers for the popup menu try{ - playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("editPlaylistMenuItem"), - sigc::mem_fun(*this, - &ScratchpadWindow::onEditPlaylist))); - playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("addToPlaylistMenuItem"), - sigc::mem_fun(*this, - &ScratchpadWindow::onAddToPlaylist))); - playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("schedulePlaylistMenuItem"), - sigc::mem_fun(*this, - &ScratchpadWindow::onSchedulePlaylist))); - playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("upMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onUpMenuOption))); - playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("downMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onDownMenuOption))); - playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("removeMenuItem"), - sigc::mem_fun(*treeView, - &ZebraTreeView::onRemoveMenuOption))); playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("cueMenuItem"), sigc::mem_fun(*cueAudioButtons, @@ -244,10 +213,28 @@ ScratchpadWindow :: ScratchpadWindow ( *getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this, &ScratchpadWindow::onAddToLiveMode))); + playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("addToPlaylistMenuItem"), + sigc::mem_fun(*this, + &ScratchpadWindow::onAddToPlaylist))); + playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("removeMenuItem"), + sigc::mem_fun(*treeView, + &ZebraTreeView::onRemoveMenuOption))); + playlistMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); + playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("editPlaylistMenuItem"), + sigc::mem_fun(*this, + &ScratchpadWindow::onEditPlaylist))); + playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("schedulePlaylistMenuItem"), + sigc::mem_fun(*this, + &ScratchpadWindow::onSchedulePlaylist))); playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("exportPlaylistMenuItem"), sigc::mem_fun(*this, &ScratchpadWindow::onExportPlaylist))); + playlistMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("uploadToHubMenuItem"), sigc::mem_fun(*this, diff --git a/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx b/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx index 6c0f24d54..28706cd0d 100644 --- a/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx @@ -373,9 +373,10 @@ SearchWindow :: constructSearchResultsView(void) throw () searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun( *this, &SearchWindow::onDoubleClick)); - constructAudioClipContextMenu(); - constructPlaylistContextMenu(); - constructRemoteContextMenu(); + // create the right-click context menus + audioClipContextMenu = constructAudioClipContextMenu(); + playlistContextMenu = constructPlaylistContextMenu(); + remoteContextMenu = constructRemoteContextMenu(); // put the tree view inside a scrolled window ScrolledWindow * resultsWindow = Gtk::manage(new ScrolledWindow); @@ -739,26 +740,18 @@ void SearchWindow :: onEntryClicked (GdkEventButton * event) throw () { if (event->type == GDK_BUTTON_PRESS && event->button == 3) { - Glib::RefPtr refSelection = - searchResultsTreeView->get_selection(); - if (refSelection) { - Gtk::TreeModel::iterator iter = refSelection->get_selected(); - - // if nothing is currently selected, select row at mouse pointer - if (!iter) { - Gtk::TreeModel::Path path; - Gtk::TreeViewColumn * column; - int cell_x, - cell_y; - if (searchResultsTreeView->get_path_at_pos( - int(event->x), int(event->y), - path, column, - cell_x, cell_y )) { - refSelection->select(path); - iter = refSelection->get_selected(); - } - } + Gtk::TreePath currentPath; + Gtk::TreeViewColumn * column; + int cell_x, + cell_y; + bool foundValidRow = searchResultsTreeView->get_path_at_pos( + int(event->x), int(event->y), + currentPath, column, + cell_x, cell_y); + if (foundValidRow) { + Gtk::TreeIter iter = searchResultsTreeView->get_model() + ->get_iter(currentPath); if (iter) { Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; @@ -1026,21 +1019,22 @@ SearchWindow :: onTimer(void) throw () /*------------------------------------------------------------------------------ * Construct the right-click context menu for local audio clips. *----------------------------------------------------------------------------*/ -void +Gtk::Menu * SearchWindow :: constructAudioClipContextMenu(void) throw () { - audioClipContextMenu = Gtk::manage(new Gtk::Menu()); - Gtk::Menu::MenuList& contextMenuList = audioClipContextMenu->items(); + Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); + Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); try { - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("addToScratchpadMenuItem"), - sigc::mem_fun(*this, - &SearchWindow::onAddToScratchpad))); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this, &SearchWindow::onAddToLiveMode))); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("addToScratchpadMenuItem"), + sigc::mem_fun(*this, + &SearchWindow::onAddToScratchpad))); + contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("uploadToHubMenuItem"), sigc::mem_fun(*this, @@ -1050,32 +1044,35 @@ SearchWindow :: constructAudioClipContextMenu(void) throw () std::exit(1); } - audioClipContextMenu->accelerate(*this); + contextMenu->accelerate(*this); + return contextMenu; } /*------------------------------------------------------------------------------ * Construct the right-click context menu for local playlists. *----------------------------------------------------------------------------*/ -void +Gtk::Menu * SearchWindow :: constructPlaylistContextMenu(void) throw () { - playlistContextMenu = Gtk::manage(new Gtk::Menu()); - Gtk::Menu::MenuList& contextMenuList = playlistContextMenu->items(); + Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); + Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); try { - contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( - *getResourceUstring("addToScratchpadMenuItem"), - sigc::mem_fun(*this, - &SearchWindow::onAddToScratchpad))); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this, &SearchWindow::onAddToLiveMode))); + contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("addToScratchpadMenuItem"), + sigc::mem_fun(*this, + &SearchWindow::onAddToScratchpad))); + contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("exportPlaylistMenuItem"), sigc::mem_fun(*this, &SearchWindow::onExportPlaylist))); + contextMenuList.push_back(Gtk::Menu_Helpers::SeparatorElem()); contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("uploadToHubMenuItem"), sigc::mem_fun(*this, @@ -1085,18 +1082,19 @@ SearchWindow :: constructPlaylistContextMenu(void) throw () std::exit(1); } - playlistContextMenu->accelerate(*this); + contextMenu->accelerate(*this); + return contextMenu; } /*------------------------------------------------------------------------------ * Construct the right-click context menu for remote audio clips & playlists. *----------------------------------------------------------------------------*/ -void +Gtk::Menu * SearchWindow :: constructRemoteContextMenu(void) throw () { - remoteContextMenu = Gtk::manage(new Gtk::Menu()); - Gtk::Menu::MenuList& contextMenuList = remoteContextMenu->items(); + Gtk::Menu * contextMenu = Gtk::manage(new Gtk::Menu()); + Gtk::Menu::MenuList & contextMenuList = contextMenu->items(); try { contextMenuList.push_back(Gtk::Menu_Helpers::MenuElem( @@ -1108,7 +1106,8 @@ SearchWindow :: constructRemoteContextMenu(void) throw () std::exit(1); } - remoteContextMenu->accelerate(*this); + contextMenu->accelerate(*this); + return contextMenu; } diff --git a/campcaster/src/products/gLiveSupport/src/SearchWindow.h b/campcaster/src/products/gLiveSupport/src/SearchWindow.h index 74954bbb8..67f3bebec 100644 --- a/campcaster/src/products/gLiveSupport/src/SearchWindow.h +++ b/campcaster/src/products/gLiveSupport/src/SearchWindow.h @@ -201,21 +201,27 @@ class SearchWindow : public GuiWindow /** * Construct the right-click context menu for local audio clips. + * + * @return the context menu created (already Gtk::manage()'ed). */ - void + Gtk::Menu * constructAudioClipContextMenu(void) throw (); /** * Construct the right-click context menu for local playlists. + * + * @return the context menu created (already Gtk::manage()'ed). */ - void + Gtk::Menu * constructPlaylistContextMenu(void) throw (); /** * Construct the right-click context menu for remote audio clips * and playlists. + * + * @return the context menu created (already Gtk::manage()'ed). */ - void + Gtk::Menu * constructRemoteContextMenu(void) throw (); /**