summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-08-15 15:57:51 +0000
committerLennart Poettering <lennart@poettering.net>2004-08-15 15:57:51 +0000
commitb3f41bd9945792ac7869db78fd75983546222622 (patch)
tree1a20f5f3e9c99c61db2056597c82ab1c04e37c49
parent3f266e3460eeea05a7a80aa4d2a29d2f418c13da (diff)
create new window files
git-svn-id: file:///home/lennart/svn/public/paman/trunk@11 cdefa82f-4ce1-0310-97f5-ab6066f37c3c
-rw-r--r--src/SinkInputWindow.cc111
-rw-r--r--src/SinkInputWindow.hh45
-rw-r--r--src/SourceOutputWindow.cc111
-rw-r--r--src/SourceOutputWindow.hh45
4 files changed, 312 insertions, 0 deletions
diff --git a/src/SinkInputWindow.cc b/src/SinkInputWindow.cc
new file mode 100644
index 0000000..68d3ec4
--- /dev/null
+++ b/src/SinkInputWindow.cc
@@ -0,0 +1,111 @@
+#include <iostream>
+
+#include "paman.hh"
+#include "SinkWindow.hh"
+
+#define GLADE_NAME "sinkWindow"
+
+SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade) :
+ Gtk::Window(cobject),
+ nameLabel(NULL),
+ descriptionLabel(NULL),
+ indexLabel(NULL),
+ sampleTypeLabel(NULL),
+ latencyLabel(NULL),
+ ownerModuleLabel(NULL),
+ monitorSourceLabel(NULL),
+ volumeLabel(NULL),
+ closeButton(NULL),
+ toMonitorSourceButton(NULL),
+ toOwnerModuleButton(NULL),
+ volumeResetButton(NULL),
+ volumeMuteButton(NULL),
+ volumeScale(NULL) {
+
+ refGlade->get_widget("nameLabel", nameLabel);
+ refGlade->get_widget("descriptionLabel", descriptionLabel);
+ refGlade->get_widget("indexLabel", indexLabel);
+ refGlade->get_widget("sampleTypeLabel", sampleTypeLabel);
+ refGlade->get_widget("latencyLabel", latencyLabel);
+ refGlade->get_widget("ownerModuleLabel", ownerModuleLabel);
+ refGlade->get_widget("monitorSourceLabel", monitorSourceLabel);
+ refGlade->get_widget("closeButton", closeButton);
+ refGlade->get_widget("toMonitorSourceButton", toMonitorSourceButton);
+ refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton);
+ refGlade->get_widget("volumeLabel", volumeLabel);
+ refGlade->get_widget("volumeScale", volumeScale);
+ refGlade->get_widget("volumeResetButton", volumeResetButton);
+ refGlade->get_widget("volumeMuteButton", volumeMuteButton);
+
+ closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onCloseButton));
+ toMonitorSourceButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onToMonitorSourceButton));
+ toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onToOwnerModuleButton));
+ volumeScale->signal_value_changed().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeScaleValueChanged));
+ volumeResetButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeResetButton));
+ volumeMuteButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeMuteButton));
+}
+
+SinkWindow* SinkWindow::create() {
+ SinkWindow *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 SinkWindow::updateInfo(const SinkInfo &i) {
+ char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
+
+ nameLabel->set_text(i.name);
+ descriptionLabel->set_text(i.description);
+ snprintf(t, sizeof(t), "#%u", i.index);
+ indexLabel->set_text(t);
+ pa_sample_snprint(ss, sizeof(ss), &i.sample_spec);
+ sampleTypeLabel->set_text(ss);
+ snprintf(t, sizeof(t), "#%u", i.owner_module);
+ ownerModuleLabel->set_text(t);
+
+ snprintf(t, sizeof(t), "%u usec", i.latency);
+ latencyLabel->set_text(t);
+
+ SourceInfo *source = serverInfoManager->getSourceInfo(i.monitor_source);
+ monitorSourceLabel->set_text(source->name);
+
+ volumeScale->set_value(((double) i.volume / 0x100) * 100);
+ snprintf(t, sizeof(t), "%u%%", (i.volume*100)/0x100);
+ volumeLabel->set_text(t);
+
+ set_title("Sink: "+i.name);
+
+ monitor_source = i.monitor_source;
+ owner_module = i.owner_module;
+ index = i.index;
+
+ toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1);
+}
+
+void SinkWindow::onCloseButton() {
+ hide();
+}
+
+void SinkWindow::onToMonitorSourceButton() {
+ serverInfoManager->showSourceWindow(monitor_source);
+}
+
+void SinkWindow::onToOwnerModuleButton() {
+ if (owner_module != (uint32_t) -1)
+ serverInfoManager->showModuleWindow(owner_module);
+}
+
+void SinkWindow::onVolumeScaleValueChanged() {
+ serverInfoManager->setSinkVolume(index, (uint32_t) ((volumeScale->get_value()*0x100)/100));
+}
+
+void SinkWindow::onVolumeResetButton() {
+ serverInfoManager->setSinkVolume(index, PA_VOLUME_NORM);
+}
+
+void SinkWindow::onVolumeMuteButton() {
+ serverInfoManager->setSinkVolume(index, PA_VOLUME_MUTE);
+}
+
+
diff --git a/src/SinkInputWindow.hh b/src/SinkInputWindow.hh
new file mode 100644
index 0000000..b0417aa
--- /dev/null
+++ b/src/SinkInputWindow.hh
@@ -0,0 +1,45 @@
+#ifndef foosinkwindowhhfoo
+#define foosinkwindowhhfoo
+
+#include <gtkmm.h>
+#include <libglademm.h>
+
+class SinkWindow;
+
+#include "ServerInfoManager.hh"
+
+class SinkWindow : public Gtk::Window {
+public:
+ SinkWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
+ static SinkWindow* create();
+
+ Gtk::Label *nameLabel,
+ *descriptionLabel,
+ *indexLabel,
+ *sampleTypeLabel,
+ *latencyLabel,
+ *ownerModuleLabel,
+ *monitorSourceLabel,
+ *volumeLabel;
+
+ Gtk::Button *closeButton,
+ *toMonitorSourceButton,
+ *toOwnerModuleButton,
+ *volumeResetButton,
+ *volumeMuteButton;
+
+ Gtk::HScale *volumeScale;
+
+ uint32_t index, owner_module, monitor_source;
+
+ void updateInfo(const SinkInfo &i);
+
+ virtual void onCloseButton();
+ virtual void onToMonitorSourceButton();
+ virtual void onToOwnerModuleButton();
+ virtual void onVolumeScaleValueChanged();
+ virtual void onVolumeResetButton();
+ virtual void onVolumeMuteButton();
+};
+
+#endif
diff --git a/src/SourceOutputWindow.cc b/src/SourceOutputWindow.cc
new file mode 100644
index 0000000..68d3ec4
--- /dev/null
+++ b/src/SourceOutputWindow.cc
@@ -0,0 +1,111 @@
+#include <iostream>
+
+#include "paman.hh"
+#include "SinkWindow.hh"
+
+#define GLADE_NAME "sinkWindow"
+
+SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade) :
+ Gtk::Window(cobject),
+ nameLabel(NULL),
+ descriptionLabel(NULL),
+ indexLabel(NULL),
+ sampleTypeLabel(NULL),
+ latencyLabel(NULL),
+ ownerModuleLabel(NULL),
+ monitorSourceLabel(NULL),
+ volumeLabel(NULL),
+ closeButton(NULL),
+ toMonitorSourceButton(NULL),
+ toOwnerModuleButton(NULL),
+ volumeResetButton(NULL),
+ volumeMuteButton(NULL),
+ volumeScale(NULL) {
+
+ refGlade->get_widget("nameLabel", nameLabel);
+ refGlade->get_widget("descriptionLabel", descriptionLabel);
+ refGlade->get_widget("indexLabel", indexLabel);
+ refGlade->get_widget("sampleTypeLabel", sampleTypeLabel);
+ refGlade->get_widget("latencyLabel", latencyLabel);
+ refGlade->get_widget("ownerModuleLabel", ownerModuleLabel);
+ refGlade->get_widget("monitorSourceLabel", monitorSourceLabel);
+ refGlade->get_widget("closeButton", closeButton);
+ refGlade->get_widget("toMonitorSourceButton", toMonitorSourceButton);
+ refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton);
+ refGlade->get_widget("volumeLabel", volumeLabel);
+ refGlade->get_widget("volumeScale", volumeScale);
+ refGlade->get_widget("volumeResetButton", volumeResetButton);
+ refGlade->get_widget("volumeMuteButton", volumeMuteButton);
+
+ closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onCloseButton));
+ toMonitorSourceButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onToMonitorSourceButton));
+ toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onToOwnerModuleButton));
+ volumeScale->signal_value_changed().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeScaleValueChanged));
+ volumeResetButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeResetButton));
+ volumeMuteButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeMuteButton));
+}
+
+SinkWindow* SinkWindow::create() {
+ SinkWindow *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 SinkWindow::updateInfo(const SinkInfo &i) {
+ char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
+
+ nameLabel->set_text(i.name);
+ descriptionLabel->set_text(i.description);
+ snprintf(t, sizeof(t), "#%u", i.index);
+ indexLabel->set_text(t);
+ pa_sample_snprint(ss, sizeof(ss), &i.sample_spec);
+ sampleTypeLabel->set_text(ss);
+ snprintf(t, sizeof(t), "#%u", i.owner_module);
+ ownerModuleLabel->set_text(t);
+
+ snprintf(t, sizeof(t), "%u usec", i.latency);
+ latencyLabel->set_text(t);
+
+ SourceInfo *source = serverInfoManager->getSourceInfo(i.monitor_source);
+ monitorSourceLabel->set_text(source->name);
+
+ volumeScale->set_value(((double) i.volume / 0x100) * 100);
+ snprintf(t, sizeof(t), "%u%%", (i.volume*100)/0x100);
+ volumeLabel->set_text(t);
+
+ set_title("Sink: "+i.name);
+
+ monitor_source = i.monitor_source;
+ owner_module = i.owner_module;
+ index = i.index;
+
+ toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1);
+}
+
+void SinkWindow::onCloseButton() {
+ hide();
+}
+
+void SinkWindow::onToMonitorSourceButton() {
+ serverInfoManager->showSourceWindow(monitor_source);
+}
+
+void SinkWindow::onToOwnerModuleButton() {
+ if (owner_module != (uint32_t) -1)
+ serverInfoManager->showModuleWindow(owner_module);
+}
+
+void SinkWindow::onVolumeScaleValueChanged() {
+ serverInfoManager->setSinkVolume(index, (uint32_t) ((volumeScale->get_value()*0x100)/100));
+}
+
+void SinkWindow::onVolumeResetButton() {
+ serverInfoManager->setSinkVolume(index, PA_VOLUME_NORM);
+}
+
+void SinkWindow::onVolumeMuteButton() {
+ serverInfoManager->setSinkVolume(index, PA_VOLUME_MUTE);
+}
+
+
diff --git a/src/SourceOutputWindow.hh b/src/SourceOutputWindow.hh
new file mode 100644
index 0000000..b0417aa
--- /dev/null
+++ b/src/SourceOutputWindow.hh
@@ -0,0 +1,45 @@
+#ifndef foosinkwindowhhfoo
+#define foosinkwindowhhfoo
+
+#include <gtkmm.h>
+#include <libglademm.h>
+
+class SinkWindow;
+
+#include "ServerInfoManager.hh"
+
+class SinkWindow : public Gtk::Window {
+public:
+ SinkWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
+ static SinkWindow* create();
+
+ Gtk::Label *nameLabel,
+ *descriptionLabel,
+ *indexLabel,
+ *sampleTypeLabel,
+ *latencyLabel,
+ *ownerModuleLabel,
+ *monitorSourceLabel,
+ *volumeLabel;
+
+ Gtk::Button *closeButton,
+ *toMonitorSourceButton,
+ *toOwnerModuleButton,
+ *volumeResetButton,
+ *volumeMuteButton;
+
+ Gtk::HScale *volumeScale;
+
+ uint32_t index, owner_module, monitor_source;
+
+ void updateInfo(const SinkInfo &i);
+
+ virtual void onCloseButton();
+ virtual void onToMonitorSourceButton();
+ virtual void onToOwnerModuleButton();
+ virtual void onVolumeScaleValueChanged();
+ virtual void onVolumeResetButton();
+ virtual void onVolumeMuteButton();
+};
+
+#endif