progress bar

This commit is contained in:
fgerlits 2007-10-25 13:17:05 +00:00
parent bdb8db1c19
commit 0fe02bffcc
3 changed files with 46 additions and 4 deletions

View File

@ -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<Playable>::Ref nullPointer;
setPlayable(nullPointer);
}
@ -175,6 +177,7 @@ NowPlaying :: setPlayable (Ptr<Playable>::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

View File

@ -107,6 +107,11 @@ class NowPlaying : public GuiComponent
*/
Gtk::Label * playlistLabel;
/**
* The progress bar.
*/
Gtk::ProgressBar * progressBar;
/**
* The label which says "elapsed time".
*/

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.0 on Tue Aug 14 14:08:34 2007 by fgerlits@desktop-->
<!--Generated with glade3 3.2.0 on Thu Oct 25 15:07:19 2007 by fgerlits@desktop-->
<glade-interface>
<widget class="GtkWindow" id="mainWindow1">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -119,6 +119,28 @@
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkProgressBar" id="progressBar1">
<property name="width_request">322</property>
<property name="height_request">8</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="text" translatable="yes"></property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="nowPlayingTimeBox1">
<property name="visible">True</property>
@ -214,7 +236,7 @@
</child>
</widget>
<packing>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
@ -227,7 +249,7 @@
<property name="single_line_mode">True</property>
</widget>
<packing>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
</widget>