diff --git a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx index d21fe6d42..154338ad2 100644 --- a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx +++ b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.20 $ + Version : $Revision: 1.21 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -74,28 +74,35 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, Ptr::Ref widgetFactory = WidgetFactory::getInstance(); try { + addToPlaylistButton = Gtk::manage(widgetFactory->createButton( + *getResourceUstring("addToPlaylistButtonLabel"))); clearListButton = Gtk::manage(widgetFactory->createButton( - *getResourceUstring("clearListButtonLabel"))); + *getResourceUstring("clearListButtonLabel"))); removeButton = Gtk::manage(widgetFactory->createButton( - *getResourceUstring("removeButtonLabel"))); + *getResourceUstring("removeButtonLabel"))); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; std::exit(1); } + addToPlaylistButton->set_name("addToPlaylistButton"); + addToPlaylistButton->signal_clicked().connect(sigc::mem_fun(*this, + &ScratchpadWindow::onAddToPlaylistButtonClicked)); + clearListButton->set_name("clearListButton"); clearListButton->signal_clicked().connect(sigc::mem_fun(*this, - &ScratchpadWindow::onClearListButtonClicked)); + &ScratchpadWindow::onClearListButtonClicked)); removeButton->set_name("removeButton"); removeButton->signal_clicked().connect(sigc::mem_fun(*this, - &ScratchpadWindow::onRemoveItem)); + &ScratchpadWindow::onRemoveItemButtonClicked)); add(vBox); // Create the Tree model: treeModel = Gtk::ListStore::create(modelColumns); treeView = Gtk::manage(widgetFactory->createTreeView(treeModel)); + treeView->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); // Add the TreeView's view columns: try { @@ -118,19 +125,25 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, // Only show the scrollbars when they are necessary: scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - vBox.pack_start(topButtonBox, Gtk::PACK_SHRINK, 5); - vBox.pack_start(scrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5); - vBox.pack_start(bottomButtonBox, Gtk::PACK_SHRINK, 5); - audioButtonBox = Gtk::manage(new CuePlayer( gLiveSupport, treeView, modelColumns )); topButtonBox.pack_start(*audioButtonBox, Gtk::PACK_EXPAND_PADDING); + middleButtonBox.set_layout(Gtk::BUTTONBOX_END); + middleButtonBox.set_spacing(5); + middleButtonBox.pack_start(*addToPlaylistButton); + bottomButtonBox.set_layout(Gtk::BUTTONBOX_END); bottomButtonBox.set_spacing(5); bottomButtonBox.pack_start(*clearListButton); bottomButtonBox.pack_start(*removeButton); + // pack everything in the main box + vBox.pack_start(topButtonBox, Gtk::PACK_SHRINK, 5); + vBox.pack_start(scrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5); + vBox.pack_start(middleButtonBox, Gtk::PACK_SHRINK, 5); + vBox.pack_start(bottomButtonBox, Gtk::PACK_SHRINK, 5); + // create the right-click entry context menu for audio clips audioClipMenu = Gtk::manage(new Gtk::Menu()); Gtk::Menu::MenuList& audioClipMenuList = audioClipMenu->items(); @@ -218,7 +231,7 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, // show set_name("scratchpadWindow"); - set_default_size(300, 300); + set_default_size(300, 330); set_modal(false); property_window_position().set_value(Gtk::WIN_POS_NONE); @@ -271,6 +284,28 @@ ScratchpadWindow :: showContents(void) throw () } +/*------------------------------------------------------------------------------ + * Event handler for the create playlist button getting clicked. + *----------------------------------------------------------------------------*/ +void +ScratchpadWindow :: onAddToPlaylistButtonClicked (void) throw () +{ + Glib::RefPtr + selection = treeView->get_selection(); + std::vector + selectedRows = selection->get_selected_rows(); + + std::vector::iterator iter; + for (iter = selectedRows.begin(); iter != selectedRows.end(); ++iter) { + Gtk::TreeIter ti = treeModel->get_iter(*iter); + if (ti) { + Ptr::Ref playable = (*ti)[modelColumns.playableColumn]; + gLiveSupport->addToPlaylist(playable->getId()); + } + } +} + + /*------------------------------------------------------------------------------ * Event handler for the clear list button getting clicked. *----------------------------------------------------------------------------*/ @@ -284,6 +319,29 @@ ScratchpadWindow :: onClearListButtonClicked (void) throw () } +/*------------------------------------------------------------------------------ + * Event handler for the Remove menu button getting clicked. + *----------------------------------------------------------------------------*/ +void +ScratchpadWindow :: onRemoveItemButtonClicked(void) throw () +{ + Glib::RefPtr + selection = treeView->get_selection(); + std::vector + selectedRows = selection->get_selected_rows(); + + std::vector::iterator iter; + for (iter = selectedRows.begin(); iter != selectedRows.end(); ++iter) { + Gtk::TreeIter ti = treeModel->get_iter(*iter); + if (ti) { + Ptr::Ref playable = (*ti)[modelColumns.playableColumn]; + removeItem(playable->getId()); + } + } + showContents(); +} + + /*------------------------------------------------------------------------------ * Event handler for an entry being clicked in the list *----------------------------------------------------------------------------*/ @@ -291,29 +349,23 @@ void ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw () { if (event->type == GDK_BUTTON_PRESS && event->button == 3) { - Glib::RefPtr refSelection = - treeView->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 (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 (foundValidRow) { + Gtk::TreeIter iter = treeModel->get_iter(currentPath); if (iter) { - Ptr::Ref playable = - (*iter)[modelColumns.playableColumn]; - + currentRow = *iter; + + Ptr::Ref + playable = currentRow[modelColumns.playableColumn]; + switch (playable->getType()) { case Playable::AudioClipType: audioClipMenu->popup(event->button, event->time); @@ -322,7 +374,7 @@ ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw () case Playable::PlaylistType: playlistMenu->popup(event->button, event->time); break; - + default: break; } @@ -338,18 +390,9 @@ ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw () void ScratchpadWindow :: onRemoveItem(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]; - - removeItem(playable->getId()); - showContents(); - } - } + Ptr::Ref playable = currentRow[modelColumns.playableColumn]; + removeItem(playable->getId()); + showContents(); } @@ -359,42 +402,33 @@ ScratchpadWindow :: onRemoveItem(void) throw () void ScratchpadWindow :: onUpItem(void) throw () { - Glib::RefPtr refSelection = - treeView->get_selection(); + Ptr::Ref playable = currentRow[modelColumns.playableColumn]; - if (refSelection) { - Gtk::TreeModel::iterator iter = refSelection->get_selected(); - if (iter) { - Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; + Ptr::Ref scratchpadContents; + GLiveSupport::PlayableList::iterator it; + GLiveSupport::PlayableList::iterator end; - Ptr::Ref scratchpadContents; - GLiveSupport::PlayableList::iterator it; - GLiveSupport::PlayableList::iterator end; + scratchpadContents = gLiveSupport->getScratchpadContents(); + it = scratchpadContents->begin(); + end = scratchpadContents->end(); + while (it != end) { + Ptr::Ref p= *it; - scratchpadContents = gLiveSupport->getScratchpadContents(); - it = scratchpadContents->begin(); - end = scratchpadContents->end(); - while (it != end) { - Ptr::Ref p= *it; - - if (*p->getId() == *playable->getId()) { - // move one up, and insert the same before that - if (it == scratchpadContents->begin()) { - break; - } - scratchpadContents->insert(--it, playable); - // move back to what we've found, and erase it - scratchpadContents->erase(++it); - - showContents(); - break; - } - - it++; + if (*p->getId() == *playable->getId()) { + // move one up, and insert the same before that + if (it == scratchpadContents->begin()) { + break; } - } - } + scratchpadContents->insert(--it, playable); + // move back to what we've found, and erase it + scratchpadContents->erase(++it); + showContents(); + break; + } + + it++; + } } @@ -404,45 +438,36 @@ ScratchpadWindow :: onUpItem(void) throw () void ScratchpadWindow :: onDownItem(void) throw () { - Glib::RefPtr refSelection = - treeView->get_selection(); + Ptr::Ref playable = currentRow[modelColumns.playableColumn]; - if (refSelection) { - Gtk::TreeModel::iterator iter = refSelection->get_selected(); - if (iter) { - Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; + Ptr::Ref scratchpadContents; + GLiveSupport::PlayableList::iterator it; + GLiveSupport::PlayableList::iterator end; - Ptr::Ref scratchpadContents; - GLiveSupport::PlayableList::iterator it; - GLiveSupport::PlayableList::iterator end; + scratchpadContents = gLiveSupport->getScratchpadContents(); + it = scratchpadContents->begin(); + end = scratchpadContents->end(); + while (it != end) { + Ptr::Ref p= *it; - scratchpadContents = gLiveSupport->getScratchpadContents(); - it = scratchpadContents->begin(); - end = scratchpadContents->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; - } - scratchpadContents->insert(++it, playable); - // move back to what we've found, and erase it - --it; - --it; - scratchpadContents->erase(--it); - - showContents(); - break; - } - - it++; + if (*p->getId() == *playable->getId()) { + // move two down, and insert the same before that + ++it; + if (it == end) { + break; } - } - } + scratchpadContents->insert(++it, playable); + // move back to what we've found, and erase it + --it; + --it; + scratchpadContents->erase(--it); + showContents(); + break; + } + + it++; + } } @@ -452,22 +477,14 @@ ScratchpadWindow :: onDownItem(void) throw () void ScratchpadWindow :: onDeleteItem(void) throw () { - Glib::RefPtr refSelection = - treeView->get_selection(); + Ptr::Ref playable = currentRow[modelColumns.playableColumn]; - if (refSelection) { - Gtk::TreeModel::iterator iter = refSelection->get_selected(); - if (iter) { - Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; - - try { - deleteItem(playable); - } catch (XmlRpcException &e) { - // TODO: signal error here - } - showContents(); - } + try { + deleteItem(playable); + } catch (XmlRpcException &e) { + // TODO: signal error here } + showContents(); } @@ -516,17 +533,8 @@ ScratchpadWindow :: deleteItem(Ptr::Ref playable) void ScratchpadWindow :: onAddToPlaylist(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]; - - gLiveSupport->addToPlaylist(playable->getId()); - } - } + Ptr::Ref playable = currentRow[modelColumns.playableColumn]; + gLiveSupport->addToPlaylist(playable->getId()); } @@ -537,42 +545,34 @@ ScratchpadWindow :: onAddToPlaylist(void) throw () void ScratchpadWindow :: onSchedulePlaylist(void) throw () { - Glib::RefPtr refSelection = - treeView->get_selection(); + Ptr::Ref playable = currentRow[modelColumns.playableColumn]; + Ptr::Ref uid = playable->getId(); - if (refSelection) { - Gtk::TreeModel::iterator iter = refSelection->get_selected(); - if (iter) { - Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; - Ptr::Ref uid = playable->getId(); + Ptr::Ref sessionId = + gLiveSupport->getSessionId(); + Ptr::Ref storage = + gLiveSupport->getStorage(); - Ptr::Ref sessionId = - gLiveSupport->getSessionId(); - Ptr::Ref storage = - gLiveSupport->getStorage(); - - if (!storage->existsPlaylist(sessionId, uid)) { - return; - } - - Ptr::Ref playlist = storage->getPlaylist(sessionId, uid); - - Ptr::Ref bundle; - try { - bundle = gLiveSupport->getBundle("schedulePlaylistWindow"); - } catch (std::invalid_argument &e) { - std::cerr << e.what() << std::endl; - return; - } - - Ptr::Ref scheduleWindow; - scheduleWindow.reset(new SchedulePlaylistWindow(gLiveSupport, - bundle, - playlist)); - - Gtk::Main::run(*scheduleWindow); - } + if (!storage->existsPlaylist(sessionId, uid)) { + return; } + + Ptr::Ref playlist = storage->getPlaylist(sessionId, uid); + + Ptr::Ref bundle; + try { + bundle = gLiveSupport->getBundle("schedulePlaylistWindow"); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + return; + } + + Ptr::Ref scheduleWindow; + scheduleWindow.reset(new SchedulePlaylistWindow(gLiveSupport, + bundle, + playlist)); + + Gtk::Main::run(*scheduleWindow); } @@ -583,16 +583,7 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw () void ScratchpadWindow :: onAddToLiveMode(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]; - - gLiveSupport->addToLiveMode(playable); - } - } + Ptr::Ref playable = currentRow[modelColumns.playableColumn]; + gLiveSupport->addToLiveMode(playable); } diff --git a/livesupport/products/gLiveSupport/src/ScratchpadWindow.h b/livesupport/products/gLiveSupport/src/ScratchpadWindow.h index c4310231d..177d3aef8 100644 --- a/livesupport/products/gLiveSupport/src/ScratchpadWindow.h +++ b/livesupport/products/gLiveSupport/src/ScratchpadWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets; * playlists. * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class ScratchpadWindow : public WhiteWindow, public LocalizedObject @@ -87,7 +87,7 @@ class ScratchpadWindow : public WhiteWindow, * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class ModelColumns : public PlayableTreeModelColumnRecord { @@ -113,16 +113,31 @@ class ScratchpadWindow : public WhiteWindow, }; - /** - * The GLiveSupport object, holding the state of the application. - */ - Ptr::Ref gLiveSupport; - /** * The column model. */ ModelColumns modelColumns; + /** + * The tree model, as a GTK reference. + */ + Glib::RefPtr treeModel; + + /** + * The tree view, now only showing rows. + */ + ZebraTreeView * treeView; + + /** + * The model row at the mouse pointer, set by onEntryClicked() + */ + Gtk::TreeRow currentRow; + + /** + * The GLiveSupport object, holding the state of the application. + */ + Ptr::Ref gLiveSupport; + /** * The main container in the window. */ @@ -133,16 +148,6 @@ class ScratchpadWindow : public WhiteWindow, */ Gtk::ScrolledWindow scrolledWindow; - /** - * The tree view, now only showing rows. - */ - ZebraTreeView * treeView; - - /** - * The tree model, as a GTK reference. - */ - Glib::RefPtr treeModel; - /** * The box containing the box containing the audio buttons. */ @@ -153,11 +158,21 @@ class ScratchpadWindow : public WhiteWindow, */ CuePlayer * audioButtonBox; + /** + * The box containing the close button. + */ + Gtk::HButtonBox middleButtonBox; + /** * The box containing the close button. */ Gtk::HButtonBox bottomButtonBox; + /** + * The "add to playlist" button. + */ + Button * addToPlaylistButton; + /** * The "clear list" button. */ @@ -180,12 +195,24 @@ class ScratchpadWindow : public WhiteWindow, */ Gtk::Menu * playlistMenu; + /** + * Signal handler for the add to playlist button clicked. + */ + virtual void + onAddToPlaylistButtonClicked(void) throw (); + /** * Signal handler for the clear list button clicked. */ virtual void onClearListButtonClicked(void) throw (); + /** + * Signal handler for the remove item button clicked. + */ + virtual void + onRemoveItemButtonClicked(void) throw (); + /** * Signal handler for the mouse clicked on one of the entries. * diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index 134053846..fdf292935 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -8,7 +8,7 @@ hu:table liveModeButtonLabel:string { "élő adás" } uploadFileButtonLabel:string { "filefeltöltés" } scratchpadButtonLabel:string { "praktikus csupor" } - simplePlaylistMgmtButtonLabel:string { "playlistkezelés" } + simplePlaylistMgmtButtonLabel:string { "műsorkezelés" } schedulerButtonLabel:string { "időzítő" } searchButtonLabel:string { "keresés" } @@ -42,29 +42,30 @@ hu:table scratchpadWindow:table { - windowTitle:string { "LiveSupport Praktikus csupor" } + windowTitle:string { "LiveSupport Praktikus csupor" } - typeColumnLabel:string { "típus" } - titleColumnLabel:string { "cím" } - clearListButtonLabel:string { "Lista törlése" } - removeButtonLabel:string { "Kiválasztott törlése" } + typeColumnLabel:string { "típus" } + titleColumnLabel:string { "cím" } + createPlaylistButtonLabel:string { "Műsorhoz hozzáadni" } + clearListButtonLabel:string { "Lista törlése" } + removeButtonLabel:string { "Kiválasztottak törlése" } - upMenuItem:string { "_Fel" } - downMenuItem:string { "_Le" } - removeMenuItem:string { "_Eltávolítani" } - addToPlaylistMenuItem:string { "Playlisthez _hozzáadni" } - schedulePlaylistMenuItem:string { "_Playlist időzítése" } - deleteMenuItem:string { "_Törölni" } - cueMenuItem:string { "_Belehallgatni" } - addToLiveModeMenuItem:string { "Élő _adásba" } + upMenuItem:string { "_Fel" } + downMenuItem:string { "_Le" } + removeMenuItem:string { "_Eltávolítani" } + addToPlaylistMenuItem:string { "Műsorhoz _hozzáadni" } + schedulePlaylistMenuItem:string { "_Műsor időzítése" } + deleteMenuItem:string { "_Törölni" } + cueMenuItem:string { "_Belehallgatni" } + addToLiveModeMenuItem:string { "Élő _adásba" } } playlistListWindow:table { - windowTitle:string { "LiveSupport Playlist ablak" } + windowTitle:string { "LiveSupport Műsorszerkesztő ablak" } - listBoxLabel { "Playlistek" } - detailBoxLabel { "Playlist részletek" } + listBoxLabel { "Műsorok" } + detailBoxLabel { "Műsor adatai" } idColumnLabel:string { "azonosító" } lengthColumnLabel:string { "hossz" } @@ -98,7 +99,7 @@ hu:table simplePlaylistManagementWindow:table { - windowTitle:string { "LiveSupport Egyszerű playlistszerkesztő ablak" } + windowTitle:string { "LiveSupport Egyszerű műsorszerkesztő ablak" } startColumnLabel:string { "kezdet" } titleColumnLabel:string { "cím" } @@ -107,7 +108,7 @@ hu:table saveButtonLabel:string { "elment" } closeButtonLabel:string { "bezár" } statusBar:string { "állapotsor" } - playlistSavedMessage:string { "playlist {0} elmentve" } + playlistSavedMessage:string { "a {0} műsor elmentve" } } schedulerWindow:table @@ -124,7 +125,7 @@ hu:table schedulePlaylistWindow:table { - windowTitle:string { "LiveSupport Playlist Időzítő Ablak" } + windowTitle:string { "LiveSupport Műsoridőzítő ablak" } hourLabel:string { "óra: " } minuteLabel:string { "perc: " } diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index 9aaff3f0a..884af8c44 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -43,21 +43,22 @@ root:table scratchpadWindow:table { - windowTitle:string { "LiveSupport Scratchpad" } + windowTitle:string { "LiveSupport Scratchpad" } - typeColumnLabel:string { "type" } - titleColumnLabel:string { "title" } - clearListButtonLabel:string { "Clear List" } - removeButtonLabel:string { "Remove Item" } + typeColumnLabel:string { "type" } + titleColumnLabel:string { "title" } + addToPlaylistButtonLabel:string { "Add to playlist" } + clearListButtonLabel:string { "Clear list" } + removeButtonLabel:string { "Remove item(s)" } - upMenuItem:string { "Move _Up" } - downMenuItem:string { "Move D_own" } - removeMenuItem:string { "_Remove" } - addToPlaylistMenuItem:string { "_Add To Playlist" } - schedulePlaylistMenuItem:string { "_Schedule Playlist" } - deleteMenuItem:string { "_Delete" } - cueMenuItem:string { "Pre_view" } - addToLiveModeMenuItem:string { "Add To _Live Mode" } + upMenuItem:string { "Move _Up" } + downMenuItem:string { "Move D_own" } + removeMenuItem:string { "_Remove" } + addToPlaylistMenuItem:string { "_Add To Playlist" } + schedulePlaylistMenuItem:string { "_Schedule Playlist" } + deleteMenuItem:string { "_Delete" } + cueMenuItem:string { "Pre_view" } + addToLiveModeMenuItem:string { "Add To _Live Mode" } } playlistListWindow:table