From b3f41bd9945792ac7869db78fd75983546222622 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 15 Aug 2004 15:57:51 +0000 Subject: create new window files git-svn-id: file:///home/lennart/svn/public/paman/trunk@11 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- src/SinkInputWindow.cc | 111 ++++++++++++++++++++++++++++++++++++++++++++++ src/SinkInputWindow.hh | 45 +++++++++++++++++++ src/SourceOutputWindow.cc | 111 ++++++++++++++++++++++++++++++++++++++++++++++ src/SourceOutputWindow.hh | 45 +++++++++++++++++++ 4 files changed, 312 insertions(+) create mode 100644 src/SinkInputWindow.cc create mode 100644 src/SinkInputWindow.hh create mode 100644 src/SourceOutputWindow.cc create mode 100644 src/SourceOutputWindow.hh 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 + +#include "paman.hh" +#include "SinkWindow.hh" + +#define GLADE_NAME "sinkWindow" + +SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& 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 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 +#include + +class SinkWindow; + +#include "ServerInfoManager.hh" + +class SinkWindow : public Gtk::Window { +public: + SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& 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 + +#include "paman.hh" +#include "SinkWindow.hh" + +#define GLADE_NAME "sinkWindow" + +SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& 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 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 +#include + +class SinkWindow; + +#include "ServerInfoManager.hh" + +class SinkWindow : public Gtk::Window { +public: + SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& 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 -- cgit