From 59c691ea39a3594e8ff08f4db6b88d77ee96a678 Mon Sep 17 00:00:00 2001 From: maroy Date: Tue, 11 Jan 2005 08:57:00 +0000 Subject: [PATCH] added up and down menus to dj bag entry context menus --- .../products/gLiveSupport/src/DjBagWindow.cxx | 111 +++++++++++++++++- .../products/gLiveSupport/src/DjBagWindow.h | 20 +++- livesupport/products/gLiveSupport/var/hu.txt | 2 + .../products/gLiveSupport/var/root.txt | 2 + 4 files changed, 131 insertions(+), 4 deletions(-) diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx index 29bd14e6f..24fff40e5 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -128,6 +128,14 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, *getResourceUstring("addToPlaylistMenuItem"), sigc::mem_fun(*this, &DjBagWindow::onAddToPlaylist))); + audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("upMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onUpItem))); + audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("downMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onDownItem))); audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("removeMenuItem"), sigc::mem_fun(*this, @@ -150,6 +158,14 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, *getResourceUstring("schedulePlaylistMenuItem"), sigc::mem_fun(*this, &DjBagWindow::onSchedulePlaylist))); + playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("upMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onUpItem))); + playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("downMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onDownItem))); playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("removeMenuItem"), sigc::mem_fun(*this, @@ -280,6 +296,99 @@ DjBagWindow :: onRemoveItem(void) throw () } +/*------------------------------------------------------------------------------ + * Event handler for the Up menu item selected from the entry conext menu + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onUpItem(void) throw () +{ + Glib::RefPtr refSelection = + treeView.get_selection(); + + if (refSelection) { + Gtk::TreeModel::iterator iter = refSelection->get_selected(); + if (iter) { + Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; + + Ptr::Ref djBagContents; + GLiveSupport::PlayableList::iterator it; + GLiveSupport::PlayableList::iterator end; + + djBagContents = gLiveSupport->getDjBagContents(); + it = djBagContents->begin(); + end = djBagContents->end(); + while (it != end) { + Ptr::Ref p= *it; + + if (*p->getId() == *playable->getId()) { + // move one up, and insert the same before that + if (it == djBagContents->begin()) { + break; + } + djBagContents->insert(--it, playable); + // move back to what we've found, and erase it + djBagContents->erase(++it); + + showContents(); + break; + } + + it++; + } + } + } + +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Down menu item selected from the entry conext menu + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onDownItem(void) throw () +{ + Glib::RefPtr refSelection = + treeView.get_selection(); + + if (refSelection) { + Gtk::TreeModel::iterator iter = refSelection->get_selected(); + if (iter) { + Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; + + Ptr::Ref djBagContents; + GLiveSupport::PlayableList::iterator it; + GLiveSupport::PlayableList::iterator end; + + djBagContents = gLiveSupport->getDjBagContents(); + it = djBagContents->begin(); + end = djBagContents->end(); + while (it != end) { + Ptr::Ref p= *it; + + if (*p->getId() == *playable->getId()) { + // move two down, and insert the same before that + ++it; + if (it == end) { + break; + } + djBagContents->insert(++it, playable); + // move back to what we've found, and erase it + --it; + --it; + djBagContents->erase(--it); + + showContents(); + break; + } + + it++; + } + } + } + +} + + /*------------------------------------------------------------------------------ * Event handler for the Delete menu item selected from the entry conext menu *----------------------------------------------------------------------------*/ diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.h b/livesupport/products/gLiveSupport/src/DjBagWindow.h index cf69dd20d..477de8a29 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.h +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -68,7 +68,7 @@ using namespace LiveSupport::Core; * playlists. * * @author $Author: maroy $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class DjBagWindow : public Gtk::Window, public LocalizedObject { @@ -80,7 +80,7 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject * Lists one clip per row. * * @author $Author: maroy $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class ModelColumns : public Gtk::TreeModel::ColumnRecord { @@ -192,6 +192,20 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject virtual void onDeleteItem(void) throw (); + /** + * Signal handler for the "up" menu item selected from + * the entry context menu. + */ + virtual void + onUpItem(void) throw (); + + /** + * Signal handler for the "down" menu item selected from + * the entry context menu. + */ + virtual void + onDownItem(void) throw (); + /** * Signal handler for the "add to playlist" menu item selected from * the entry context menu. diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index 206cffe61..d60a64321 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -39,6 +39,8 @@ hu:table titleColumnLabel:string { "cím" } closeButtonLabel:string { "bezár" } + upMenuItem:string { "_Fel" } + downMenuItem:string { "_Le" } removeMenuItem:string { "_Eltávolít" } addToPlaylistMenuItem:string { "_Hozzáad Playlist-hez" } schedulePlaylistMenuItem:string { "_Playlist időzítése" } diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index fab7af340..48969d9eb 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -39,6 +39,8 @@ root:table titleColumnLabel:string { "title" } closeButtonLabel:string { "close" } + upMenuItem:string { "Move _Up" } + downMenuItem:string { "Move D_own" } removeMenuItem:string { "_Remove" } addToPlaylistMenuItem:string { "_Add To Playlist" } schedulePlaylistMenuItem:string { "_Schedule Playlist" }