very first version of master panel

This commit is contained in:
maroy 2004-12-16 14:28:38 +00:00
parent 44841fa9c1
commit 38cffd05fe
8 changed files with 709 additions and 12 deletions

View File

@ -21,7 +21,7 @@
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.10 $
# Version : $Revision: 1.11 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
#
# @configure_input@
@ -141,6 +141,8 @@ LDFLAGS = @LDFLAGS@ -pthread \
#-------------------------------------------------------------------------------
G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/UiTestMainWindow.o \
${TMP_DIR}/MasterPanelWindow.o \
${TMP_DIR}/MasterPanelUserInfoWidget.o \
${TMP_DIR}/GtkLocalizedObject.o \
${TMP_DIR}/LoginWindow.o \
${TMP_DIR}/AudioClipListWindow.o \

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
------------------------------------------------------------------------------*/
@ -40,7 +40,7 @@
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/SchedulerClient/SchedulerClientFactory.h"
#include "UiTestMainWindow.h"
#include "MasterPanelWindow.h"
#include "LoginWindow.h"
#include "GLiveSupport.h"
@ -137,12 +137,13 @@ void
LiveSupport :: GLiveSupport ::
GLiveSupport :: show(void) throw ()
{
Ptr<UiTestMainWindow>::Ref mainWindow;
Ptr<MasterPanelWindow>::Ref masterPanel;
mainWindow.reset(new UiTestMainWindow(shared_from_this(), resourceBundle));
masterPanel.reset(new MasterPanelWindow(shared_from_this(),
resourceBundle));
// Shows the window and returns when it is closed.
Gtk::Main::run(*mainWindow);
Gtk::Main::run(*masterPanel);
}

View File

@ -0,0 +1,175 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelUserInfoWidget.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <iostream>
#include <unicode/msgfmt.h>
#include <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
#include "LiveSupport/Core/TimeConversion.h"
#include "LoginWindow.h"
#include "MasterPanelUserInfoWidget.h"
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
MasterPanelUserInfoWidget :: MasterPanelUserInfoWidget (
Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ()
: GtkLocalizedObject(bundle)
{
this->gLiveSupport = gLiveSupport;
Ptr<Glib::ustring>::Ref loginButtonLabel;
Ptr<Glib::ustring>::Ref notLoggedInMsg;
try {
loginButtonLabel = getResourceUstring("loginButtonLabel");
notLoggedInMsg = getResourceUstring("notLoggedInMsg");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
logInOutButton.reset(new Gtk::Button(*loginButtonLabel));
logInOutSignalConnection =
logInOutButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelUserInfoWidget::onLoginButtonClicked));
userInfoLabel.reset(new Gtk::Label(*notLoggedInMsg));
// set up the main window, and show everything
attach(*logInOutButton, 0, 1, 0, 1);
attach(*userInfoLabel, 1, 2, 0, 1);
// show everything
show_all();
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
MasterPanelUserInfoWidget :: ~MasterPanelUserInfoWidget (void) throw ()
{
}
/*------------------------------------------------------------------------------
* Event handler for the logout button getting clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelUserInfoWidget :: onLogoutButtonClicked (void) throw ()
{
gLiveSupport->logout();
Ptr<Glib::ustring>::Ref notLoggedInMsg;
Ptr<Glib::ustring>::Ref loginButtonLabel;
try {
loginButtonLabel = getResourceUstring("loginButtonLabel");
notLoggedInMsg = getResourceUstring("notLoggedInMsg");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
userInfoLabel->set_label(*notLoggedInMsg);
// change the logout button to a login button
logInOutButton->set_label(*loginButtonLabel);
logInOutSignalConnection.disconnect();
logInOutSignalConnection =
logInOutButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelUserInfoWidget::onLoginButtonClicked));
}
/*------------------------------------------------------------------------------
* Event handler for the login button getting clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelUserInfoWidget :: onLoginButtonClicked (void) throw ()
{
Ptr<ResourceBundle>::Ref loginBundle;
Ptr<Glib::ustring>::Ref logoutButtonLabel;
try {
loginBundle = getBundle("loginWindow");
logoutButtonLabel = getResourceUstring("logoutButtonLabel");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
Ptr<LoginWindow>::Ref loginWindow(new LoginWindow(loginBundle));
Gtk::Main::run(*loginWindow);
Ptr<const Glib::ustring>::Ref login = loginWindow->getLogin();
Ptr<const Glib::ustring>::Ref password = loginWindow->getPassword();
bool loggedIn = gLiveSupport->login(login->raw(), password->raw());
if (loggedIn) {
Ptr<UnicodeString>::Ref uLogin = ustringToUnicodeString(login);
Formattable arguments[] = { *uLogin };
Ptr<Glib::ustring>::Ref msg = formatMessageUstring("loggedInMsg",
arguments, 1);
userInfoLabel->set_label(*msg);
// change the login button to a logout button
logInOutButton->set_label(*logoutButtonLabel);
logInOutSignalConnection.disconnect();
logInOutSignalConnection =
logInOutButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelUserInfoWidget::onLogoutButtonClicked));
}
}

View File

@ -0,0 +1,141 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelUserInfoWidget.h,v $
------------------------------------------------------------------------------*/
#ifndef MasterPanelUserInfoWidget_h
#define MasterPanelUserInfoWidget_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <gtkmm/button.h>
#include <gtkmm/table.h>
#include "LiveSupport/Core/Ptr.h"
#include "GtkLocalizedObject.h"
#include "GLiveSupport.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* The user info widget of the master panel.
*
* This widget handles login and login info display.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class MasterPanelUserInfoWidget : public Gtk::Table,
public GtkLocalizedObject
{
protected:
/**
* The login / logout button.
*/
Ptr<Gtk::Button>::Ref logInOutButton;
/**
* A label to display the currently logged in user.
*/
Ptr<Gtk::Label>::Ref userInfoLabel;
/**
* The gLiveSupport object, handling the logic of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The sigc connection object, that connects the button clicked
* event on the logInOutButton to either onLoginButtonClicked()
* or onLogoutButtonClicked().
*/
sigc::connection logInOutSignalConnection;
/**
* Signal handler for the login button clicked.
*/
virtual void
onLoginButtonClicked(void) throw ();
/**
* Signal handler for the logout button clicked.
*/
virtual void
onLogoutButtonClicked(void) throw ();
public:
/**
* Constructor.
*
* @param gLiveSupport the gLiveSupport object, handling the
* logic of the application
* @param bundle the resource bundle holding localized resources
*/
MasterPanelUserInfoWidget(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ();
/**
* Virtual destructor.
*/
virtual
~MasterPanelUserInfoWidget(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace GLiveSupport
} // namespace LiveSupport
#endif // MasterPanelUserInfoWidget_h

View File

@ -0,0 +1,174 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <iostream>
#include <unicode/msgfmt.h>
#include <gtkmm/label.h>
#include "LiveSupport/Core/TimeConversion.h"
#include "MasterPanelUserInfoWidget.h"
#include "MasterPanelWindow.h"
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ()
: GtkLocalizedObject(bundle)
{
this->gLiveSupport = gLiveSupport;
try {
set_title(*getResourceUstring("windowTitle"));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
lsLogoWidget.reset(new Gtk::Label("lsLogo"));
nowPlayingWidget.reset(new Gtk::Label("now playing"));
vuMeterWidget.reset(new Gtk::Label("VU meter"));
nextPlayingWidget.reset(new Gtk::Label("next playing"));
onAirWidget.reset(new Gtk::Label("on air"));
radioLogoWidget.reset(new Gtk::Label("radio logo"));
userInfoWidget.reset(new MasterPanelUserInfoWidget(gLiveSupport, bundle));
// set up the time label
timeWidget.reset(new Gtk::Label("time"));
// set up the layout, which is a button box
layout.reset(new Gtk::Table());
// set up the main window, and show everything
set_border_width(10);
layout->attach(*lsLogoWidget, 0, 1, 0, 2);
layout->attach(*timeWidget, 1, 2, 0, 2);
layout->attach(*nowPlayingWidget, 2, 3, 0, 2);
layout->attach(*vuMeterWidget, 3, 4, 0, 1);
layout->attach(*nextPlayingWidget, 3, 4, 1, 2);
layout->attach(*onAirWidget , 4, 5, 0, 1);
layout->attach(*radioLogoWidget , 5, 6, 0, 1);
layout->attach(*userInfoWidget , 4, 6, 1, 2);
add(*layout);
// show everything
show_all();
// set the timer, that will update timeWidget
setTimer();
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
MasterPanelWindow :: ~MasterPanelWindow (void) throw ()
{
resetTimer();
}
/*------------------------------------------------------------------------------
* Set the timer
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: setTimer(void) throw ()
{
sigc::slot<bool> slot = sigc::bind(sigc::mem_fun(*this,
&MasterPanelWindow::onUpdateTime),
0);
// set the timer to active once a second
timer.reset(new sigc::connection(
Glib::signal_timeout().connect(slot, 1000)));
}
/*------------------------------------------------------------------------------
* Clear the timer
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: resetTimer(void) throw ()
{
timer->disconnect();
timer.reset();
}
/*------------------------------------------------------------------------------
* Update the timeWidget display, with the current time
*----------------------------------------------------------------------------*/
bool
MasterPanelWindow :: onUpdateTime(int dummy) throw ()
{
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
if (sessionId.get()) {
Ptr<const ptime>::Ref now = gLiveSupport->getScheduler()
->getSchedulerTime(sessionId);
if (now.get()) {
time_duration dayTime = now->time_of_day();
// get the time of day, only up to a second precision
time_duration dayTimeSec(dayTime.hours(),
dayTime.minutes(),
dayTime.seconds(),
0);
timeWidget->set_text(to_simple_string(dayTimeSec));
}
} else {
timeWidget->set_text("time");
}
return true;
}

View File

@ -0,0 +1,200 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.h,v $
------------------------------------------------------------------------------*/
#ifndef MasterPanelWindow_h
#define MasterPanelWindow_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <gtkmm/button.h>
#include <gtkmm/table.h>
#include <gtkmm/window.h>
#include "LiveSupport/Core/Ptr.h"
#include "GtkLocalizedObject.h"
#include "GLiveSupport.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* The master panel window.
*
* The layout of the window is roughly the following:
* <pre><code>
* +--- master panel --------------------------------------------------------+
* | + LS logo + + time + + now ----+ + VU meter + + on-air + + radio logo + |
* | | | | | | playing | | | | | | | |
* | | | | | | | +----------+ +--------+ +------------+ |
* | | | | | | | + next ----+ + user info ------------+ |
* | | | | | | | | playing | | | |
* | +---------+ +------+ +---------+ +----------+ +-----------------------+ |
* +-------------------------------------------------------------------------+
* </code></pre>
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class MasterPanelWindow : public Gtk::Window, public GtkLocalizedObject
{
protected:
/**
* The layout used in the window.
*/
Ptr<Gtk::Table>::Ref layout;
/**
* The LiveSupport logo
*/
Ptr<Gtk::Widget>::Ref lsLogoWidget;
/**
* The time display
*/
Ptr<Gtk::Label>::Ref timeWidget;
/**
* The signal connection, that is notified by the GTK timer each
* second, and will update the time display on each wakeup.
*/
Ptr<sigc::connection>::Ref timer;
/**
* The 'now playing' display.
*/
Ptr<Gtk::Widget>::Ref nowPlayingWidget;
/**
* The VU meter display.
*/
Ptr<Gtk::Widget>::Ref vuMeterWidget;
/**
* The 'next playing' display.
*/
Ptr<Gtk::Widget>::Ref nextPlayingWidget;
/**
* The on-air indicator.
*/
Ptr<Gtk::Widget>::Ref onAirWidget;
/**
* The user info widget.
*/
Ptr<Gtk::Widget>::Ref userInfoWidget;
/**
* The radio logo.
*/
Ptr<Gtk::Widget>::Ref radioLogoWidget;
/**
* The gLiveSupport object, handling the logic of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* Function that updates timeLabel with the current time.
* This is called by GTK at regular intervals.
*
* @param dummy a dummy, unused parameter
* @return true if the timer should call this function again,
* false if the timer should be canceled
*/
virtual bool
onUpdateTime(int dummy) throw ();
/**
* Register onUpdateTime with the GTK timer.
*
* @see #resetTimer
*/
virtual void
setTimer(void) throw ();
/**
* Stop the timer, which was set by setTimer().
*
* @see #setTimer
*/
virtual void
resetTimer(void) throw ();
public:
/**
* Constructor.
*
* @param gLiveSupport the gLiveSupport object, handling the
* logic of the application
* @param bundle the resource bundle holding localized resources
*/
MasterPanelWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ();
/**
* Virtual destructor.
*/
virtual
~MasterPanelWindow(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace GLiveSupport
} // namespace LiveSupport
#endif // MasterPanelWindow_h

View File

@ -1,8 +1,10 @@
hu:table
{
windowTitle:string { "LiveSupport Teszt Ablak" }
welcomeMsg:string { "Üdvözöljük" }
loggedInMsg:string { "Bejelentkezve {0} felhasználóként" }
windowTitle:string { "LiveSupport Fő Panel" }
notLoggedInMsg:string { "Nincs bejelentkezve" }
loggedInMsg:string { "Bejelentkezve {0} felhasználóként" }
loginButtonLabel:string { "Bejelentkezés" }
logoutButtonLabel:string { "Kijelentkezés }
loginWindow:table
{

View File

@ -1,8 +1,10 @@
root:table
{
windowTitle:string { "LiveSupport Test Window" }
welcomeMsg:string { "welcome" }
loggedInMsg:string { "Logged in as {0}" }
windowTitle:string { "LiveSupport Master Panel" }
notLoggedInMsg:string { "Not logged in" }
loggedInMsg:string { "Logged in as {0}" }
loginButtonLabel:string { "Log in" }
logoutButtonLabel:string { "log out" }
loginWindow:table
{