#include #include "paman.hh" #include "SourceOutputWindow.hh" #define GLADE_NAME "sourceOutputWindow" SourceOutputWindow::SourceOutputWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : Gtk::Window(cobject), nameLabel(NULL), indexLabel(NULL), sampleTypeLabel(NULL), sourceLabel(NULL), clientLabel(NULL), ownerModuleLabel(NULL), closeButton(NULL), toOwnerModuleButton(NULL), toClientButton(NULL), toSourceButton(NULL) { refGlade->get_widget("nameLabel", nameLabel); refGlade->get_widget("indexLabel", indexLabel); refGlade->get_widget("sampleTypeLabel", sampleTypeLabel); refGlade->get_widget("sourceLabel", sourceLabel); 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("toSourceButton", toSourceButton); closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onCloseButton)); toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onToOwnerModuleButton)); toClientButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onToClientButton)); toSourceButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onToSourceButton)); } SourceOutputWindow* SourceOutputWindow::create() { SourceOutputWindow *w = NULL; Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); refXml->get_widget_derived(GLADE_NAME, w); return w; } void SourceOutputWindow::updateInfo(const SourceOutputInfo &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); 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); } SourceInfo *source = serverInfoManager->getSourceInfo(i.source); sourceLabel->set_text(source->name); if (i.client == PA_INVALID_INDEX) clientLabel->set_markup("n/a"); else { ClientInfo *client = serverInfoManager->getClientInfo(i.client); clientLabel->set_text(client->name); } set_title("Source Output: "+i.name); this->source = i.source; owner_module = i.owner_module; client = i.client; toOwnerModuleButton->set_sensitive(owner_module != PA_INVALID_INDEX); toClientButton->set_sensitive(client != PA_INVALID_INDEX); } void SourceOutputWindow::onCloseButton() { hide(); } void SourceOutputWindow::onToOwnerModuleButton() { if (owner_module != PA_INVALID_INDEX) serverInfoManager->showModuleWindow(owner_module); } void SourceOutputWindow::onToClientButton() { if (client != PA_INVALID_INDEX) serverInfoManager->showClientWindow(client); } void SourceOutputWindow::onToSourceButton() { if (source != PA_INVALID_INDEX) serverInfoManager->showSourceWindow(source); } bool SourceOutputWindow::on_delete_event(GdkEventAny* e) { hide(); return false; }