added real time clock display
This commit is contained in:
parent
80d1a0915f
commit
86beeeab01
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
#include <gtkmm/main.h>
|
#include <gtkmm/main.h>
|
||||||
#include <gtkmm/messagedialog.h>
|
#include <gtkmm/messagedialog.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/TimeConversion.h"
|
||||||
#include "LoginWindow.h"
|
#include "LoginWindow.h"
|
||||||
#include "UiTestMainWindow.h"
|
#include "UiTestMainWindow.h"
|
||||||
|
|
||||||
|
@ -68,6 +69,9 @@ UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
// set up the status label
|
// set up the status label
|
||||||
statusLabel.reset(new Gtk::Label(*getResourceUstring("welcomeMsg")));
|
statusLabel.reset(new Gtk::Label(*getResourceUstring("welcomeMsg")));
|
||||||
|
|
||||||
|
// set up the time label
|
||||||
|
timeLabel.reset(new Gtk::Label(""));
|
||||||
|
|
||||||
// set up the login button
|
// set up the login button
|
||||||
loginButton.reset(new Gtk::Button("loginWindow"));
|
loginButton.reset(new Gtk::Button("loginWindow"));
|
||||||
loginButton->signal_clicked().connect(sigc::mem_fun(*this,
|
loginButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||||
|
@ -89,6 +93,7 @@ UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
// set up the main window, and show everything
|
// set up the main window, and show everything
|
||||||
set_border_width(10);
|
set_border_width(10);
|
||||||
layout->add(*statusLabel);
|
layout->add(*statusLabel);
|
||||||
|
layout->add(*timeLabel);
|
||||||
layout->add(*loginButton);
|
layout->add(*loginButton);
|
||||||
layout->add(*logoutButton);
|
layout->add(*logoutButton);
|
||||||
layout->add(*quitButton);
|
layout->add(*quitButton);
|
||||||
|
@ -96,11 +101,15 @@ UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
|
|
||||||
// show everything
|
// show everything
|
||||||
statusLabel->show();
|
statusLabel->show();
|
||||||
|
timeLabel->show();
|
||||||
loginButton->show();
|
loginButton->show();
|
||||||
logoutButton->show();
|
logoutButton->show();
|
||||||
quitButton->show();
|
quitButton->show();
|
||||||
layout->show();
|
layout->show();
|
||||||
show();
|
show();
|
||||||
|
|
||||||
|
// set the timer, that will update timeLabel
|
||||||
|
setTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,6 +118,34 @@ UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
UiTestMainWindow :: ~UiTestMainWindow (void) throw ()
|
UiTestMainWindow :: ~UiTestMainWindow (void) throw ()
|
||||||
{
|
{
|
||||||
|
resetTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Set the timer
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
UiTestMainWindow :: setTimer(void) throw ()
|
||||||
|
{
|
||||||
|
sigc::slot<bool> slot = sigc::bind(sigc::mem_fun(*this,
|
||||||
|
&UiTestMainWindow::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
|
||||||
|
UiTestMainWindow :: resetTimer(void) throw ()
|
||||||
|
{
|
||||||
|
timer->disconnect();
|
||||||
|
timer.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,3 +203,26 @@ UiTestMainWindow :: onLoginButtonClicked (void) throw ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Update the timeLabel display, with the current time
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
bool
|
||||||
|
UiTestMainWindow :: onUpdateTime(int dummy) throw ()
|
||||||
|
{
|
||||||
|
// TODO: read current time from scheduler server, via the gLiveSupport
|
||||||
|
// object
|
||||||
|
Ptr<ptime>::Ref now = TimeConversion::now();
|
||||||
|
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);
|
||||||
|
|
||||||
|
timeLabel->set_text(to_simple_string(dayTimeSec));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -66,7 +66,7 @@ using namespace LiveSupport::Core;
|
||||||
* A window, enabling interactive testing of UI components.
|
* A window, enabling interactive testing of UI components.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,17 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
*/
|
*/
|
||||||
Ptr<Gtk::Label>::Ref statusLabel;
|
Ptr<Gtk::Label>::Ref statusLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A label showing the current time, with second precision.
|
||||||
|
*/
|
||||||
|
Ptr<Gtk::Label>::Ref timeLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The signal connection, that is notified by the GTK timer each
|
||||||
|
* second, and will update timeLabel on each wakeup.
|
||||||
|
*/
|
||||||
|
Ptr<sigc::connection>::Ref timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The to quit the applicaiton.
|
* The to quit the applicaiton.
|
||||||
*/
|
*/
|
||||||
|
@ -119,6 +130,33 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
virtual void
|
virtual void
|
||||||
onLogoutButtonClicked(void) throw ();
|
onLogoutButtonClicked(void) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that updates timeLabel with the current time.
|
||||||
|
* This is called by GTK at regular intervals.
|
||||||
|
*
|
||||||
|
* @param param 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:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue