summaryrefslogtreecommitdiffstats
path: root/src/SampleWindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/SampleWindow.cc')
-rw-r--r--src/SampleWindow.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/SampleWindow.cc b/src/SampleWindow.cc
new file mode 100644
index 0000000..b1ea149
--- /dev/null
+++ b/src/SampleWindow.cc
@@ -0,0 +1,55 @@
+#include <iostream>
+
+#include "paman.hh"
+#include "SampleWindow.hh"
+
+#define GLADE_NAME "sampleWindow"
+
+SampleWindow::SampleWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade) :
+ Gtk::Window(cobject),
+ nameLabel(NULL),
+ indexLabel(NULL),
+ volumeLabel(NULL),
+ sampleTypeLabel(NULL),
+ durationLabel(NULL),
+ closeButton(NULL) {
+
+ refGlade->get_widget("nameLabel", nameLabel);
+ refGlade->get_widget("indexLabel", indexLabel);
+ refGlade->get_widget("volumeLabel", volumeLabel);
+ refGlade->get_widget("sampleTypeLabel", sampleTypeLabel);
+ refGlade->get_widget("durationLabel", durationLabel);
+ refGlade->get_widget("closeButton", closeButton);
+
+ closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SampleWindow::onCloseButton));
+}
+
+SampleWindow* SampleWindow::create() {
+ SampleWindow *w = NULL;
+ Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME);
+ refXml->get_widget_derived(GLADE_NAME, w);
+ return w;
+}
+
+void SampleWindow::updateInfo(const SampleInfo &i) {
+ char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
+
+ nameLabel->set_text(i.name);
+ snprintf(t, sizeof(t), "#%u", i.index);
+ indexLabel->set_text(t);
+
+ snprintf(t, sizeof(t), "%0.0f%%", (double) i.volume / 0x100 * 100);
+ volumeLabel->set_text(t);
+
+ pa_sample_spec_snprint(ss, sizeof(ss), &i.sample_spec);
+ sampleTypeLabel->set_text(ss);
+
+ snprintf(t, sizeof(t), "%0.1fs", (double) i.duration/1000000);
+ durationLabel->set_text(t);
+
+ set_title("Sample: "+i.name);
+}
+
+void SampleWindow::onCloseButton() {
+ hide();
+}