#include #include "paman.hh" #include "SinkInputWindow.hh" #define GLADE_NAME "sinkInputWindow" SinkInputWindow::SinkInputWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : Gtk::Window(cobject), nameLabel(NULL), indexLabel(NULL), sampleTypeLabel(NULL), latencyLabel(NULL), sinkLabel(NULL), clientLabel(NULL), ownerModuleLabel(NULL), volumeLabel(NULL), closeButton(NULL), toOwnerModuleButton(NULL), toClientButton(NULL), toSinkButton(NULL), volumeResetButton(NULL), volumeMuteButton(NULL), volumeScale(NULL) { refGlade->get_widget("nameLabel", nameLabel); refGlade->get_widget("indexLabel", indexLabel); refGlade->get_widget("sampleTypeLabel", sampleTypeLabel); refGlade->get_widget("latencyLabel", latencyLabel); refGlade->get_widget("sinkLabel", sinkLabel); refGlade->get_widget("clientLabel", clientLabel); refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); refGlade->get_widget("closeButton", closeButton); refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton); refGlade->get_widget("toClientButton", toClientButton); refGlade->get_widget("toSinkButton", toSinkButton); 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, &SinkInputWindow::onCloseButton)); toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToOwnerModuleButton)); toClientButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToClientButton)); toSinkButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToSinkButton)); volumeScale->signal_value_changed().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeScaleValueChanged)); volumeResetButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeResetButton)); volumeMuteButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeMuteButton)); } SinkInputWindow* SinkInputWindow::create() { SinkInputWindow *w = NULL; Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); refXml->get_widget_derived(GLADE_NAME, w); return w; } void SinkInputWindow::updateInfo(const SinkInputInfo &i) { char t[80], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; nameLabel->set_text(i.name); snprintf(t, sizeof(t), "#%u", i.index); indexLabel->set_text(t); pa_sample_spec_snprint(ss, sizeof(ss), &i.sample_spec); sampleTypeLabel->set_text(ss); if (i.owner_module == PA_INVALID_INDEX) ownerModuleLabel->set_markup("n/a"); else { snprintf(t, sizeof(t), "#%u", i.owner_module); ownerModuleLabel->set_text(t); } snprintf(t, sizeof(t), "%u μs (= buffer: %u μs + sink: %u μs)", i.buffer_usec+i.sink_usec, i.buffer_usec, i.sink_usec); latencyLabel->set_markup(t); SinkInfo *sink = serverInfoManager->getSinkInfo(i.sink); sinkLabel->set_text(sink->name); if (i.client == PA_INVALID_INDEX) clientLabel->set_markup("n/a"); else { ClientInfo *client = serverInfoManager->getClientInfo(i.client); clientLabel->set_text(client->name); } volumeScale->set_value((double) i.volume * 100 / 0x100); snprintf(t, sizeof(t), "%u%%", (i.volume * 100)/ 0x100); volumeLabel->set_text(t); set_title("Sink Input: "+i.name); this->sink = i.sink; client = i.client; owner_module = i.owner_module; index = i.index; toOwnerModuleButton->set_sensitive(owner_module != PA_INVALID_INDEX); toClientButton->set_sensitive(client != PA_INVALID_INDEX); } void SinkInputWindow::onCloseButton() { hide(); } void SinkInputWindow::onToOwnerModuleButton() { if (owner_module != PA_INVALID_INDEX) serverInfoManager->showModuleWindow(owner_module); } void SinkInputWindow::onToSinkButton() { serverInfoManager->showSinkWindow(sink); } void SinkInputWindow::onToClientButton() { serverInfoManager->showClientWindow(client); } void SinkInputWindow::onVolumeScaleValueChanged() { serverInfoManager->setSinkInputVolume(index, (uint32_t) ((volumeScale->get_value()*0x100)/100)); } void SinkInputWindow::onVolumeResetButton() { serverInfoManager->setSinkInputVolume(index, PA_VOLUME_NORM); } void SinkInputWindow::onVolumeMuteButton() { serverInfoManager->setSinkInputVolume(index, PA_VOLUME_MUTED); }