added right-click context menu to the scheduler window entries

added Delete menu item to the context menu
This commit is contained in:
maroy 2005-01-11 06:32:35 +00:00
parent 7c50117bf9
commit dc08d6c938
6 changed files with 111 additions and 7 deletions

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.13 $ Version : $Revision: 1.14 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -431,6 +431,18 @@ GLiveSupport :: schedulePlaylist(Ptr<Playlist>::Ref playlist,
} }
/*------------------------------------------------------------------------------
* Remove a scheduled entry.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: removeFromSchedule(Ptr<UniqueId>::Ref scheduleEntryId)
throw (XmlRpcException)
{
scheduler->removeFromSchedule(sessionId, scheduleEntryId);
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Delete a playable object from the storage. * Delete a playable object from the storage.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.15 $ Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -95,7 +95,7 @@ class MasterPanelWindow;
* respective documentation. * respective documentation.
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.15 $ * @version $Revision: 1.16 $
* @see LocalizedObject#getBundle(const xmlpp::Element &) * @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory * @see AuthenticationClientFactory
* @see StorageClientFactory * @see StorageClientFactory
@ -455,6 +455,17 @@ class GLiveSupport : public LocalizedConfigurable,
throw (XmlRpcException); throw (XmlRpcException);
/**
* Remove a scheduled item.
*
* @param sessionId a valid, authenticated session id.
* @param scheduledEntryId the id of the scheduled entry to remove.
* @exception XmlRpcException in case of XML-RPC errors.
*/
virtual void
removeFromSchedule(Ptr<UniqueId>::Ref scheduleEntryId)
throw (XmlRpcException);
/** /**
* Delete a playable object from storage. * Delete a playable object from storage.
* *

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SchedulerWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SchedulerWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -96,6 +96,19 @@ SchedulerWindow :: SchedulerWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
} }
// register the signal handler for entries view entries being clicked
entriesView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
&SchedulerWindow::onEntryClicked));
// create the right-click entry context menu for audio clips
entryMenu.reset(new Gtk::Menu());
Gtk::Menu::MenuList& menuList = entryMenu->items();
// register the signal handlers for the popup menu
menuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("deleteMenuItem"),
sigc::mem_fun(*this,
&SchedulerWindow::onDeleteItem)));
entryMenu->accelerate(*this);
layout.reset(new Gtk::Table()); layout.reset(new Gtk::Table());
@ -226,6 +239,52 @@ SchedulerWindow :: showContents(void) throw ()
} }
/*------------------------------------------------------------------------------
* Event handler for an entry being clicked in the list
*----------------------------------------------------------------------------*/
void
SchedulerWindow :: onEntryClicked (GdkEventButton * event) throw ()
{
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
// only show the context menu, if something is already selected
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
entriesView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) {
entryMenu->popup(event->button, event->time);
}
}
}
}
/*------------------------------------------------------------------------------
* Event handler for the Delete menu item selected from the entry conext menu
*----------------------------------------------------------------------------*/
void
SchedulerWindow :: onDeleteItem(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
entriesView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) {
Ptr<const UniqueId>::Ref uid = (*iter)[entryColumns->idColumn];
Ptr<UniqueId>::Ref entryId(new UniqueId(uid->getId()));
try {
gLiveSupport->removeFromSchedule(entryId);
} catch (XmlRpcException &e) {
// TODO: signal error here
}
showContents();
}
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler for the close button getting clicked. * Event handler for the close button getting clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SchedulerWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SchedulerWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -88,7 +88,7 @@ using namespace LiveSupport::Core;
* </pre></code> * </pre></code>
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
class SchedulerWindow : public Gtk::Window, public LocalizedObject class SchedulerWindow : public Gtk::Window, public LocalizedObject
{ {
@ -100,7 +100,7 @@ class SchedulerWindow : public Gtk::Window, public LocalizedObject
* Lists one scheduled item per row. * Lists one scheduled item per row.
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
class ModelColumns : public Gtk::TreeModel::ColumnRecord class ModelColumns : public Gtk::TreeModel::ColumnRecord
{ {
@ -179,6 +179,11 @@ class SchedulerWindow : public Gtk::Window, public LocalizedObject
*/ */
Glib::RefPtr<Gtk::ListStore> entriesModel; Glib::RefPtr<Gtk::ListStore> entriesModel;
/**
* The right-click context menu for schedule entries.
*/
Ptr<Gtk::Menu>::Ref entryMenu;
/** /**
* The close button. * The close button.
*/ */
@ -190,6 +195,21 @@ class SchedulerWindow : public Gtk::Window, public LocalizedObject
virtual void virtual void
onDateSelected(void) throw (); onDateSelected(void) throw ();
/**
* Signal handler for the mouse clicked on one of the entries.
*
* @param event the button event recieved
*/
virtual void
onEntryClicked(GdkEventButton * event) throw ();
/**
* Signal handler for the "delete" menu item selected from
* the entry context menu.
*/
virtual void
onDeleteItem(void) throw ();
/** /**
* Signal handler for the close button clicked. * Signal handler for the close button clicked.
*/ */

View File

@ -94,6 +94,7 @@ hu:table
startColumnLabel:string { "kezdet" } startColumnLabel:string { "kezdet" }
titleColumnLabel:string { "cím" } titleColumnLabel:string { "cím" }
endColumnLabel:string { "vég" } endColumnLabel:string { "vég" }
deleteMenuItem:string { "_Töröl" }
closeButtonLabel:string { "bezár" } closeButtonLabel:string { "bezár" }
} }

View File

@ -94,6 +94,7 @@ root:table
startColumnLabel:string { "start" } startColumnLabel:string { "start" }
titleColumnLabel:string { "title" } titleColumnLabel:string { "title" }
endColumnLabel:string { "end" } endColumnLabel:string { "end" }
deleteMenuItem:string { "_Delete" }
closeButtonLabel:string { "close" } closeButtonLabel:string { "close" }