UI for #1650; doesn't do anything yet
This commit is contained in:
parent
e41fc29eb6
commit
41fbc53944
3 changed files with 195 additions and 26 deletions
|
@ -37,6 +37,7 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Widgets/ScrolledNotebook.h"
|
||||
#include "SchedulerWindow.h"
|
||||
|
||||
|
||||
|
@ -78,15 +79,58 @@ SchedulerWindow :: SchedulerWindow (
|
|||
WidgetConstants::schedulerWindowTitleImage,
|
||||
windowOpenerButton)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Box * scheduleView = constructScheduleView();
|
||||
Gtk::Box * statusView = constructStatusView();
|
||||
|
||||
ScrolledNotebook * notebook = Gtk::manage(new ScrolledNotebook);
|
||||
try {
|
||||
set_title(*getResourceUstring("windowTitle"));
|
||||
closeButton = Gtk::manage(new Gtk::Button(
|
||||
*getResourceUstring("closeButtonLabel")));
|
||||
closeButton = Gtk::manage(wf->createButton(*getResourceUstring(
|
||||
"closeButtonLabel")));
|
||||
notebook->appendPage(*scheduleView, *getResourceUstring(
|
||||
"scheduleTab"));
|
||||
notebook->appendPage(*statusView, *getResourceUstring(
|
||||
"statusTab"));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onCloseButtonClicked));
|
||||
|
||||
Gtk::ButtonBox * bottomButtonBox = Gtk::manage(new Gtk::HButtonBox(
|
||||
Gtk::BUTTONBOX_END, 5));
|
||||
bottomButtonBox->pack_start(*closeButton);
|
||||
|
||||
Gtk::VBox * bigBox = Gtk::manage(new Gtk::VBox);
|
||||
bigBox->pack_start(*notebook, Gtk::PACK_EXPAND_WIDGET);
|
||||
bigBox->pack_start(*bottomButtonBox, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
add(*bigBox);
|
||||
set_name(windowName);
|
||||
set_default_size(330, 400);
|
||||
showContents();
|
||||
show_all();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
SchedulerWindow :: ~SchedulerWindow (void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the Schedule view.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Gtk::VBox *
|
||||
SchedulerWindow :: constructScheduleView(void) throw ()
|
||||
{
|
||||
calendar = Gtk::manage(new Gtk::Calendar());
|
||||
dateLabel = Gtk::manage(new Gtk::Label());
|
||||
|
||||
|
@ -135,9 +179,6 @@ SchedulerWindow :: SchedulerWindow (
|
|||
layout->attach(*dateLabel, 0, 1, 1, 2);
|
||||
layout->attach(*entriesView, 0, 1, 2, 3);
|
||||
|
||||
// register the signal handler for the button getting clicked.
|
||||
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onCloseButtonClicked));
|
||||
// register the signal handle for when a date is selected in the calendar
|
||||
calendar->signal_day_selected().connect(sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onDateSelected));
|
||||
|
@ -145,22 +186,56 @@ SchedulerWindow :: SchedulerWindow (
|
|||
// initialize the selected date for today
|
||||
selectedDate.reset(new gregorian::date(TimeConversion::now()->date()));
|
||||
|
||||
Gtk::VBox * mainBox = Gtk::manage(new Gtk::VBox);
|
||||
mainBox->add(*layout);
|
||||
add(*mainBox);
|
||||
// make a new box and pack the main components into it
|
||||
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
|
||||
view->pack_start(*layout, Gtk::PACK_SHRINK);
|
||||
|
||||
set_name(windowName);
|
||||
show_all();
|
||||
|
||||
showContents();
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
* Construct the Status view.
|
||||
*----------------------------------------------------------------------------*/
|
||||
SchedulerWindow :: ~SchedulerWindow (void) throw ()
|
||||
Gtk::VBox *
|
||||
SchedulerWindow :: constructStatusView(void) throw ()
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Label * statusTextLabel;
|
||||
Button * startButton;
|
||||
Button * stopButton;
|
||||
try {
|
||||
statusTextLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
|
||||
"statusText")));
|
||||
startButton = Gtk::manage(wf->createButton(*getResourceUstring(
|
||||
"startButtonLabel")));
|
||||
stopButton = Gtk::manage(wf->createButton(*getResourceUstring(
|
||||
"stopButtonLabel")));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
startButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onStartButtonClicked));
|
||||
stopButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&SchedulerWindow::onStopButtonClicked));
|
||||
|
||||
Gtk::HBox * statusReportBox = Gtk::manage(new Gtk::HBox);
|
||||
statusReportBox->pack_start(*statusTextLabel, Gtk::PACK_SHRINK, 5);
|
||||
statusReportLabel = Gtk::manage(new Gtk::Label);
|
||||
statusReportBox->pack_start(*statusReportLabel, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
Gtk::ButtonBox * startStopButtons = Gtk::manage(new Gtk::HButtonBox(
|
||||
Gtk::BUTTONBOX_SPREAD, 20));
|
||||
startStopButtons->pack_start(*startButton);
|
||||
startStopButtons->pack_start(*stopButton);
|
||||
|
||||
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
|
||||
view->pack_start(*statusReportBox, Gtk::PACK_SHRINK, 20);
|
||||
view->pack_start(*startStopButtons, Gtk::PACK_SHRINK);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,6 +328,8 @@ SchedulerWindow :: showContents(void) throw ()
|
|||
|
||||
++it;
|
||||
}
|
||||
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,3 +377,42 @@ SchedulerWindow :: onDeleteItem(void) throw ()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Signal handler for the Start button getting clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerWindow :: onStartButtonClicked(void) throw ()
|
||||
{
|
||||
// TODO: handle this event
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Signal handler for the Stop button getting clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerWindow :: onStopButtonClicked(void) throw ()
|
||||
{
|
||||
// TODO: handle this event
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Update the status display in the Status tab.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerWindow :: updateStatus(void) throw ()
|
||||
{
|
||||
try {
|
||||
if (gLiveSupport->isSchedulerAvailable()) {
|
||||
statusReportLabel->set_text(*getResourceUstring("runningStatus"));
|
||||
} else {
|
||||
statusReportLabel->set_text(*getResourceUstring("stoppedStatus"));
|
||||
}
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,10 @@ using namespace LiveSupport::Core;
|
|||
/**
|
||||
* The Scheduler window, showing and allowing scheduling of playlists.
|
||||
*
|
||||
* The rough layout of the window is:
|
||||
* The window is tabbed, with a main Schedule tab, and a Status tab showing
|
||||
* the status of the scheduler daemon (running/stopped).
|
||||
*
|
||||
* The rough layout of the Schedule tab:
|
||||
* <code><pre>
|
||||
* +--- scheduler window ----------------------------+
|
||||
* | +--- calendar --------------------------------+ |
|
||||
|
@ -93,6 +96,31 @@ using namespace LiveSupport::Core;
|
|||
*/
|
||||
class SchedulerWindow : public GuiWindow
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Construct the Schedule view.
|
||||
* This displays the list of scheduled playlists.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
constructScheduleView(void) throw ();
|
||||
|
||||
/**
|
||||
* Construct the Status view.
|
||||
* This shows the status of the scheduler daemon.
|
||||
*
|
||||
* @return a pointer to the new box (already Gtk::manage()'ed)
|
||||
*/
|
||||
Gtk::VBox*
|
||||
constructStatusView(void) throw ();
|
||||
|
||||
/**
|
||||
* Update the status display in the Status tab.
|
||||
*/
|
||||
void
|
||||
updateStatus(void) throw ();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -185,6 +213,11 @@ class SchedulerWindow : public GuiWindow
|
|||
*/
|
||||
Gtk::Button * closeButton;
|
||||
|
||||
/**
|
||||
* The label showing the current status of the scheduler.
|
||||
*/
|
||||
Gtk::Label * statusReportLabel;
|
||||
|
||||
/**
|
||||
* Signal handler for when a date is selected in the calendar.
|
||||
*/
|
||||
|
@ -206,6 +239,18 @@ class SchedulerWindow : public GuiWindow
|
|||
virtual void
|
||||
onDeleteItem(void) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the Start button getting clicked.
|
||||
*/
|
||||
virtual void
|
||||
onStartButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the Stop button getting clicked.
|
||||
*/
|
||||
virtual void
|
||||
onStopButtonClicked(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -154,13 +154,21 @@ root:table
|
|||
{
|
||||
windowTitle:string { "Scheduler" }
|
||||
|
||||
scheduleTab:string { "Schedule" }
|
||||
statusTab:string { "Status" }
|
||||
|
||||
startColumnLabel:string { "start" }
|
||||
titleColumnLabel:string { "title" }
|
||||
endColumnLabel:string { "end" }
|
||||
deleteMenuItem:string { "_Delete" }
|
||||
|
||||
closeButtonLabel:string { "close" }
|
||||
statusText:string { "The scheduler is" }
|
||||
runningStatus:string { "running." }
|
||||
stoppedStatus:string { "stopped." }
|
||||
|
||||
startButtonLabel:string { "Start" }
|
||||
stopButtonLabel:string { "Stop" }
|
||||
closeButtonLabel:string { "Close" }
|
||||
}
|
||||
|
||||
schedulePlaylistWindow:table
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue