From 0fe02bffcc6aa67dc1e0e94b350c6242b2b5bc1d Mon Sep 17 00:00:00 2001 From: fgerlits Date: Thu, 25 Oct 2007 13:17:05 +0000 Subject: [PATCH] progress bar --- .../products/gLiveSupport/src/NowPlaying.cxx | 17 ++++++++++- .../products/gLiveSupport/src/NowPlaying.h | 5 ++++ .../var/glade/MasterPanelWindow.glade | 28 +++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/campcaster/src/products/gLiveSupport/src/NowPlaying.cxx b/campcaster/src/products/gLiveSupport/src/NowPlaying.cxx index 7e2f05d55..788c74f01 100644 --- a/campcaster/src/products/gLiveSupport/src/NowPlaying.cxx +++ b/campcaster/src/products/gLiveSupport/src/NowPlaying.cxx @@ -110,7 +110,9 @@ NowPlaying :: NowPlaying (GuiObject * parent) setStyle(remainsTimeText, 7); elapsedTimeText->set_text(*getResourceUstring("elapsedTimeLabel")); remainsTimeText->set_text(*getResourceUstring("remainingTimeLabel")); - + + glade->get_widget("progressBar1", progressBar); + Ptr::Ref nullPointer; setPlayable(nullPointer); } @@ -175,6 +177,7 @@ NowPlaying :: setPlayable (Ptr::Ref playable) throw () elapsedTimeLabel->set_text(""); remainsTimeLabel->set_text(""); playlistLabel->set_text(""); + progressBar->set_fraction(0); resetRemainsTimeState(); this->playable.reset(); this->currentInnerPlayable.reset(); @@ -324,6 +327,18 @@ NowPlaying :: onUpdateTime (void) throw () remainsTimeLabel->set_text(*TimeConversion::timeDurationToHhMmSsString( innerRemains )); + long elapsedMilliSec = innerElapsed->total_milliseconds(); + long totalMilliSec = elapsedMilliSec + + innerRemains->total_milliseconds(); + double fraction = double(elapsedMilliSec) / double(totalMilliSec); + if (fraction < 0.0) { + fraction = 0.0; // can't happen afaik + } + if (fraction > 1.0) { + fraction = 1.0; // can and does happen! + } + progressBar->set_fraction(fraction); + currentInnerPlayable = innerPlayable; // END synchronized block diff --git a/campcaster/src/products/gLiveSupport/src/NowPlaying.h b/campcaster/src/products/gLiveSupport/src/NowPlaying.h index 4bb1d3df8..2cde0a281 100644 --- a/campcaster/src/products/gLiveSupport/src/NowPlaying.h +++ b/campcaster/src/products/gLiveSupport/src/NowPlaying.h @@ -107,6 +107,11 @@ class NowPlaying : public GuiComponent */ Gtk::Label * playlistLabel; + /** + * The progress bar. + */ + Gtk::ProgressBar * progressBar; + /** * The label which says "elapsed time". */ diff --git a/campcaster/src/products/gLiveSupport/var/glade/MasterPanelWindow.glade b/campcaster/src/products/gLiveSupport/var/glade/MasterPanelWindow.glade index 288004008..c95d87e0c 100644 --- a/campcaster/src/products/gLiveSupport/var/glade/MasterPanelWindow.glade +++ b/campcaster/src/products/gLiveSupport/var/glade/MasterPanelWindow.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -119,6 +119,28 @@ 1 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 322 + 8 + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + False + False + + + + + 2 + + True @@ -214,7 +236,7 @@ - 2 + 3 @@ -227,7 +249,7 @@ True - 3 + 4