From 4b682a9eba6590d8fe090f68dda6afe59ae64f85 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 15 Aug 2004 11:27:34 +0000 Subject: Move everything to src/ directory git-svn-id: file:///home/lennart/svn/public/paman/trunk@8 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- ClientWindow.cc | 59 -- ClientWindow.hh | 32 - MainWindow.cc | 290 ------ MainWindow.hh | 117 --- Makefile | 9 - ModuleWindow.cc | 58 -- ModuleWindow.hh | 29 - ServerInfo.cc | 398 -------- ServerInfo.hh | 130 --- SinkWindow.cc | 111 --- SinkWindow.hh | 45 - SourceWindow.cc | 82 -- SourceWindow.hh | 32 - paman.cc | 117 --- paman.glade | 2600 --------------------------------------------------- paman.gladep | 12 - paman.hh | 15 - src/ClientWindow.cc | 59 ++ src/ClientWindow.hh | 32 + src/MainWindow.cc | 290 ++++++ src/MainWindow.hh | 117 +++ src/Makefile | 9 + src/ModuleWindow.cc | 58 ++ src/ModuleWindow.hh | 29 + src/ServerInfo.cc | 398 ++++++++ src/ServerInfo.hh | 130 +++ src/SinkWindow.cc | 111 +++ src/SinkWindow.hh | 45 + src/SourceWindow.cc | 82 ++ src/SourceWindow.hh | 32 + src/paman.cc | 117 +++ src/paman.glade | 2600 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/paman.gladep | 12 + src/paman.hh | 15 + 34 files changed, 4136 insertions(+), 4136 deletions(-) delete mode 100644 ClientWindow.cc delete mode 100644 ClientWindow.hh delete mode 100644 MainWindow.cc delete mode 100644 MainWindow.hh delete mode 100644 Makefile delete mode 100644 ModuleWindow.cc delete mode 100644 ModuleWindow.hh delete mode 100644 ServerInfo.cc delete mode 100644 ServerInfo.hh delete mode 100644 SinkWindow.cc delete mode 100644 SinkWindow.hh delete mode 100644 SourceWindow.cc delete mode 100644 SourceWindow.hh delete mode 100644 paman.cc delete mode 100644 paman.glade delete mode 100644 paman.gladep delete mode 100644 paman.hh create mode 100644 src/ClientWindow.cc create mode 100644 src/ClientWindow.hh create mode 100644 src/MainWindow.cc create mode 100644 src/MainWindow.hh create mode 100644 src/Makefile create mode 100644 src/ModuleWindow.cc create mode 100644 src/ModuleWindow.hh create mode 100644 src/ServerInfo.cc create mode 100644 src/ServerInfo.hh create mode 100644 src/SinkWindow.cc create mode 100644 src/SinkWindow.hh create mode 100644 src/SourceWindow.cc create mode 100644 src/SourceWindow.hh create mode 100644 src/paman.cc create mode 100644 src/paman.glade create mode 100644 src/paman.gladep create mode 100644 src/paman.hh diff --git a/ClientWindow.cc b/ClientWindow.cc deleted file mode 100644 index 88e2ad3..0000000 --- a/ClientWindow.cc +++ /dev/null @@ -1,59 +0,0 @@ -#include - -#include "paman.hh" -#include "ClientWindow.hh" - -#define GLADE_NAME "clientWindow" - -ClientWindow::ClientWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : - Gtk::Window(cobject), - nameLabel(NULL), - protocolLabel(NULL), - indexLabel(NULL), - ownerModuleLabel(NULL), - closeButton(NULL), - toOwnerModuleButton(NULL) { - - refGlade->get_widget("nameLabel", nameLabel); - refGlade->get_widget("protocolLabel", protocolLabel); - refGlade->get_widget("indexLabel", indexLabel); - refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); - refGlade->get_widget("closeButton", closeButton); - refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton); - - closeButton->signal_clicked().connect(sigc::mem_fun(*this, &ClientWindow::onCloseButton)); - toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &ClientWindow::onToOwnerModuleButton)); -} - -ClientWindow* ClientWindow::create() { - ClientWindow *w = NULL; - Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); - refXml->get_widget_derived(GLADE_NAME, w); - return w; -} - -void ClientWindow::updateInfo(const ClientInfo &i) { - char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; - - nameLabel->set_text(i.name); - protocolLabel->set_text(i.protocol_name); - snprintf(t, sizeof(t), "#%u", i.index); - indexLabel->set_text(t); - - snprintf(t, sizeof(t), "#%u", i.owner_module); - ownerModuleLabel->set_text(t); - - set_title("Client: "+i.name); - - owner_module = i.owner_module; - toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1); -} - -void ClientWindow::onCloseButton() { - hide(); -} - -void ClientWindow::onToOwnerModuleButton() { - if (owner_module != (uint32_t) -1) - serverInfoManager->showModuleWindow(owner_module); -} diff --git a/ClientWindow.hh b/ClientWindow.hh deleted file mode 100644 index 61a1973..0000000 --- a/ClientWindow.hh +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef fooclientwindowhhfoo -#define fooclientwindowhhfoo - -#include -#include - -class ClientWindow; - -#include "ServerInfo.hh" - -class ClientWindow : public Gtk::Window { -public: - ClientWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - static ClientWindow* create(); - - Gtk::Label *nameLabel, - *protocolLabel, - *indexLabel, - *ownerModuleLabel; - - Gtk::Button *closeButton, - *toOwnerModuleButton; - - uint32_t owner_module; - - void updateInfo(const ClientInfo &i); - - virtual void onCloseButton(); - virtual void onToOwnerModuleButton(); -}; - -#endif diff --git a/MainWindow.cc b/MainWindow.cc deleted file mode 100644 index fdb817a..0000000 --- a/MainWindow.cc +++ /dev/null @@ -1,290 +0,0 @@ -#include -#include -#include - -#include "paman.hh" -#include "MainWindow.hh" - -#define GLADE_NAME "mainWindow" - -enum { - ROW_TYPE_SINK_CATEGORY, - ROW_TYPE_SOURCE_CATEGORY, - ROW_TYPE_SINK, - ROW_TYPE_SOURCE, -}; - -MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : - Gtk::Window(cobject), - statusLabel(NULL), - serverNameLabel(NULL), - serverVersionLabel(NULL), - defaultSampleTypeLabel(NULL), - userNameLabel(NULL), - hostNameLabel(NULL), - deviceOpenButton(NULL), - clientOpenButton(NULL), - moduleOpenButton(NULL), - connectButton(NULL), - deviceTreeView(NULL), - clientTreeView(NULL), - moduleTreeView(NULL) { - - refGlade->get_widget("statusLabel", statusLabel); - refGlade->get_widget("serverNameLabel", serverNameLabel); - refGlade->get_widget("serverVersionLabel", serverVersionLabel); - refGlade->get_widget("defaultSampleTypeLabel", defaultSampleTypeLabel); - refGlade->get_widget("hostNameLabel", hostNameLabel); - refGlade->get_widget("userNameLabel", userNameLabel); - refGlade->get_widget("deviceTreeView", deviceTreeView); - refGlade->get_widget("clientTreeView", clientTreeView); - refGlade->get_widget("moduleTreeView", moduleTreeView); - refGlade->get_widget("deviceOpenButton", deviceOpenButton); - refGlade->get_widget("clientOpenButton", clientOpenButton); - refGlade->get_widget("moduleOpenButton", moduleOpenButton); - refGlade->get_widget("connectButton", connectButton); - - deviceTreeStore = Gtk::TreeStore::create(deviceTreeModelColumns); - deviceTreeView->set_model(deviceTreeStore); - deviceTreeView->append_column("Name", deviceTreeModelColumns.name); - deviceTreeView->append_column("Description", deviceTreeModelColumns.description); - deviceTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onDeviceTreeViewRowActivated)); - deviceTreeView->signal_cursor_changed().connect(sigc::mem_fun(*this, &MainWindow::onDeviceTreeViewCursorChanged)); - - clientTreeStore = Gtk::TreeStore::create(clientTreeModelColumns); - clientTreeView->set_model(clientTreeStore); - clientTreeView->append_column("Name", clientTreeModelColumns.name); - clientTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onClientTreeViewRowActivated)); - - moduleTreeStore = Gtk::TreeStore::create(moduleTreeModelColumns); - moduleTreeView->set_model(moduleTreeStore); - moduleTreeView->append_column("Name", moduleTreeModelColumns.name); - moduleTreeView->append_column("Argument", moduleTreeModelColumns.argument); - moduleTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onModuleTreeViewRowActivated)); - - connectButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onConnectButton)); - deviceOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onDeviceOpenButton)); - clientOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onClientOpenButton)); - moduleOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onModuleOpenButton)); - - statusLabel->set_text("Connecting ..."); - - clearAllData(); -} - -MainWindow::~MainWindow() { -} - -MainWindow* MainWindow::create() { - MainWindow *w; - Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); - refXml->get_widget_derived(GLADE_NAME, w); - return w; -} - -void MainWindow::updateInfo(SinkInfo &i) { - if (!i.treeRef) { - Gtk::TreeIter iter = deviceTreeStore->get_iter(sinkRef.get_path()); - i.treeRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(deviceTreeStore->append(iter->children()))); - } - - Gtk::TreeRow row = *(deviceTreeStore->get_iter(i.treeRef.get_path())); - row[deviceTreeModelColumns.name] = i.name; - row[deviceTreeModelColumns.description] = i.description; - row[deviceTreeModelColumns.index] = i.index; - row[deviceTreeModelColumns.type] = ROW_TYPE_SINK; - - deviceTreeView->expand_row(sinkRef.get_path(), false); - onDeviceTreeViewCursorChanged(); -} - -void MainWindow::updateInfo(SourceInfo &i) { - if (!i.treeRef) { - Gtk::TreeIter iter = deviceTreeStore->get_iter(sourceRef.get_path()); - i.treeRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(deviceTreeStore->append(iter->children()))); - } - - Gtk::TreeRow row = *(deviceTreeStore->get_iter(i.treeRef.get_path())); - row[deviceTreeModelColumns.name] = i.name; - row[deviceTreeModelColumns.description] = i.description; - row[deviceTreeModelColumns.index] = i.index; - row[deviceTreeModelColumns.type] = ROW_TYPE_SOURCE; - - deviceTreeView->expand_row(sourceRef.get_path(), false); - onDeviceTreeViewCursorChanged(); -} - -void MainWindow::updateInfo(ClientInfo &i) { - - if (!i.treeRef) - i.treeRef = Gtk::TreeRowReference(clientTreeStore, Gtk::TreePath(clientTreeStore->append())); - - Gtk::TreeRow row = *(clientTreeStore->get_iter(i.treeRef.get_path())); - row[clientTreeModelColumns.name] = i.name; - row[clientTreeModelColumns.index] = i.index; - clientOpenButton->set_sensitive(true); -} - -void MainWindow::updateInfo(ModuleInfo &i) { - if (!i.treeRef) - i.treeRef = Gtk::TreeRowReference(moduleTreeStore, Gtk::TreePath(moduleTreeStore->append())); - - Gtk::TreeRow row = *(moduleTreeStore->get_iter(i.treeRef.get_path())); - row[moduleTreeModelColumns.name] = i.name; - row[moduleTreeModelColumns.argument] = i.argument; - row[moduleTreeModelColumns.index] = i.index; - moduleOpenButton->set_sensitive(true); -} - -void MainWindow::removeInfo(SinkInfo &i) { - if (i.treeRef) - deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); - - onDeviceTreeViewCursorChanged(); -} - -void MainWindow::removeInfo(SourceInfo &i) { - if (!i.treeRef) - deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); - - onDeviceTreeViewCursorChanged(); -} - -void MainWindow::removeInfo(ClientInfo &i) { - if (i.treeRef) - clientTreeStore->erase(clientTreeStore->get_iter(i.treeRef.get_path())); - - clientOpenButton->set_sensitive(!moduleTreeStore->children().empty()); -} - -void MainWindow::removeInfo(ModuleInfo &i) { - if (i.treeRef) - moduleTreeStore->erase(moduleTreeStore->get_iter(i.treeRef.get_path())); - - moduleOpenButton->set_sensitive(!moduleTreeStore->children().empty()); -} - -void MainWindow::onDeviceTreeViewCursorChanged() { - Gtk::TreeModel::Path p; - Gtk::TreeViewColumn *c; - deviceTreeView->get_cursor(p, c); - - if (!p.gobj()) - return; - - deviceOpenButton->set_sensitive((sourceRef.get_path() != p) && (sinkRef.get_path() != p)); -} - -void MainWindow::onDeviceTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { - showDeviceWindow(path); -} - -void MainWindow::onClientTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { - showClientWindow(path); -} - -void MainWindow::onModuleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { - showModuleWindow(path); -} - -void MainWindow::updateInfo(const struct pa_server_info &i) { - char t[PA_SAMPLE_SNPRINT_MAX_LENGTH]; - serverNameLabel->set_text(i.server_name); - serverVersionLabel->set_text(i.server_version); - pa_sample_snprint(t, sizeof(t), &i.sample_spec); - defaultSampleTypeLabel->set_text(t); - hostNameLabel->set_text(i.host_name); - userNameLabel->set_text(i.user_name); -} - -void MainWindow::showSuccess(const char *t) { - statusLabel->set_text(t); -} - -void MainWindow::showFailure(const char *t) { - char s[256]; - snprintf(s, sizeof(s), "Failure: %s", t); - statusLabel->set_markup(s); -} - -void MainWindow::clearAllData() { - deviceTreeStore->clear(); - - Gtk::TreeIter i = deviceTreeStore->append(); - sinkRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(i)); - (*i)[deviceTreeModelColumns.name] = "Sinks"; - (*i)[deviceTreeModelColumns.index] = (uint32_t) -1; - (*i)[deviceTreeModelColumns.type] = ROW_TYPE_SINK_CATEGORY; - - i = deviceTreeStore->append(); - sourceRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(i)); - (*i)[deviceTreeModelColumns.name] = "Sources"; - (*i)[deviceTreeModelColumns.index] = (uint32_t) -1; - (*i)[deviceTreeModelColumns.type] = ROW_TYPE_SOURCE_CATEGORY; - - clientTreeStore->clear(); - moduleTreeStore->clear(); - - deviceOpenButton->set_sensitive(false); - clientOpenButton->set_sensitive(false); - moduleOpenButton->set_sensitive(false); - - serverNameLabel->set_markup("n/a"); - serverVersionLabel->set_markup("n/a"); - defaultSampleTypeLabel->set_markup("n/a"); - hostNameLabel->set_markup("n/a"); - userNameLabel->set_markup("n/a"); -} - -void MainWindow::onDeviceOpenButton() { - Gtk::TreeModel::Path p; - Gtk::TreeViewColumn *c; - deviceTreeView->get_cursor(p, c); - showDeviceWindow(p); -} - -void MainWindow::onClientOpenButton() { - Gtk::TreeModel::Path p; - Gtk::TreeViewColumn *c; - clientTreeView->get_cursor(p, c); - showClientWindow(p); -} - -void MainWindow::onModuleOpenButton() { - Gtk::TreeModel::Path p; - Gtk::TreeViewColumn *c; - moduleTreeView->get_cursor(p, c); - showModuleWindow(p); -} - -void MainWindow::onConnectButton() { - create_connection(); -} - -void MainWindow::showDeviceWindow(const Gtk::TreePath &p) { - if (!serverInfoManager) - return; - - Gtk::TreeModel::Row row = *(deviceTreeStore->get_iter(p)); - - if (row[deviceTreeModelColumns.type] == ROW_TYPE_SINK) - serverInfoManager->showSinkWindow(row[deviceTreeModelColumns.index]); - else if (row[deviceTreeModelColumns.type] == ROW_TYPE_SOURCE) - serverInfoManager->showSourceWindow(row[deviceTreeModelColumns.index]); -} - -void MainWindow::showClientWindow(const Gtk::TreePath &p) { - if (!serverInfoManager) - return; - - Gtk::TreeModel::Row row = *(clientTreeStore->get_iter(p)); - serverInfoManager->showClientWindow(row[clientTreeModelColumns.index]); -} - -void MainWindow::showModuleWindow(const Gtk::TreePath &p) { - if (!serverInfoManager) - return; - - Gtk::TreeModel::Row row = *(moduleTreeStore->get_iter(p)); - serverInfoManager->showModuleWindow(row[moduleTreeModelColumns.index]); -} diff --git a/MainWindow.hh b/MainWindow.hh deleted file mode 100644 index 2d5f173..0000000 --- a/MainWindow.hh +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef foomainwindowhhfoo -#define foomainwindowhhfoo - -#include -#include -#include - -class MainWinow; - -#include "ServerInfo.hh" - -class MainWindow : public Gtk::Window { -public: - MainWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - virtual ~MainWindow(); - static MainWindow* create(); - - Gtk::Label *statusLabel, - *serverNameLabel, - *serverVersionLabel, - *defaultSampleTypeLabel, - *userNameLabel, - *hostNameLabel; - - Gtk::Button *deviceOpenButton, - *clientOpenButton, - *moduleOpenButton, - *connectButton; - - Gtk::TreeView *deviceTreeView, - *clientTreeView, - *moduleTreeView; - -protected: - - class DeviceTreeModelColumns : public Gtk::TreeModel::ColumnRecord { - public: - - DeviceTreeModelColumns() { - add(name); - add(description); - add(index); - add(type); - } - - Gtk::TreeModelColumn name; - Gtk::TreeModelColumn description; - Gtk::TreeModelColumn index; - Gtk::TreeModelColumn type; - }; - - DeviceTreeModelColumns deviceTreeModelColumns; - Glib::RefPtr deviceTreeStore; - Gtk::TreeRowReference sinkRef, sourceRef; - - class ClientTreeModelColumns : public Gtk::TreeModel::ColumnRecord { - public: - ClientTreeModelColumns() { - add(name); - add(index); - } - - Gtk::TreeModelColumn name; - Gtk::TreeModelColumn index; - }; - - ClientTreeModelColumns clientTreeModelColumns; - Glib::RefPtr clientTreeStore; - - class ModuleTreeModelColumns : public Gtk::TreeModel::ColumnRecord { - public: - ModuleTreeModelColumns() { - add(name); - add(argument); - add(index); - } - - Gtk::TreeModelColumn name; - Gtk::TreeModelColumn argument; - Gtk::TreeModelColumn index; - }; - - ModuleTreeModelColumns moduleTreeModelColumns; - Glib::RefPtr moduleTreeStore; - -public: - virtual void updateInfo(const struct pa_server_info &i); - virtual void updateInfo(SinkInfo &i); - virtual void updateInfo(SourceInfo &i); - virtual void updateInfo(ClientInfo &i); - virtual void updateInfo(ModuleInfo &i); - - virtual void removeInfo(SinkInfo &i); - virtual void removeInfo(SourceInfo &i); - virtual void removeInfo(ClientInfo &i); - virtual void removeInfo(ModuleInfo &i); - - virtual void onDeviceTreeViewCursorChanged(); - virtual void onDeviceTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); - virtual void onClientTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); - virtual void onModuleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); - - virtual void showSuccess(const char *t); - virtual void showFailure(const char *t); - virtual void clearAllData(); - - virtual void onDeviceOpenButton(); - virtual void onClientOpenButton(); - virtual void onModuleOpenButton(); - virtual void onConnectButton(); - - virtual void showDeviceWindow(const Gtk::TreePath &p); - virtual void showClientWindow(const Gtk::TreePath &p); - virtual void showModuleWindow(const Gtk::TreePath &p); -}; - -#endif diff --git a/Makefile b/Makefile deleted file mode 100644 index 8a9cb3a..0000000 --- a/Makefile +++ /dev/null @@ -1,9 +0,0 @@ - -CXXFLAGS=`pkg-config gtkmm-2.4 libglademm-2.4 --cflags` -Wall -W -pipe -O0 -g -Wno-unused -I../polypaudio -LIBS=`pkg-config gtkmm-2.4 libglademm-2.4 --libs` -L../polypaudio/polyp/.libs -lpolyp -lpolyp-mainloop-glib -lpolyp-error - -paman: paman.o MainWindow.o SinkWindow.o SourceWindow.o ServerInfo.o ClientWindow.o ModuleWindow.o - $(CXX) $^ -o $@ $(LIBS) - -clean: - rm -rf *.o paman diff --git a/ModuleWindow.cc b/ModuleWindow.cc deleted file mode 100644 index 04d8fb5..0000000 --- a/ModuleWindow.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include - -#include "paman.hh" -#include "ModuleWindow.hh" - -#define GLADE_NAME "moduleWindow" - -ModuleWindow::ModuleWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : - Gtk::Window(cobject), - nameLabel(NULL), - argumentLabel(NULL), - indexLabel(NULL), - autoloadedLabel(NULL), - usageLabel(NULL), - closeButton(NULL) { - - refGlade->get_widget("nameLabel", nameLabel); - refGlade->get_widget("argumentLabel", argumentLabel); - refGlade->get_widget("indexLabel", indexLabel); - refGlade->get_widget("autoloadedLabel", autoloadedLabel); - refGlade->get_widget("usageLabel", usageLabel); - refGlade->get_widget("closeButton", closeButton); - - closeButton->signal_clicked().connect(sigc::mem_fun(*this, &ModuleWindow::onCloseButton)); -} - -ModuleWindow* ModuleWindow::create() { - ModuleWindow *w = NULL; - Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); - refXml->get_widget_derived(GLADE_NAME, w); - return w; -} - -void ModuleWindow::updateInfo(const ModuleInfo &i) { - char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; - - nameLabel->set_text(i.name); - if (!i.argument.empty()) - argumentLabel->set_text(i.argument); - else - argumentLabel->set_markup("None specified"); - - snprintf(t, sizeof(t), "#%u", i.index); - indexLabel->set_text(t); - autoloadedLabel->set_text(i.autoloaded ? "Yes" : "No"); - - if (i.used != (uint32_t) -1) { - snprintf(t, sizeof(t), "%u", i.used); - usageLabel->set_text(t); - } else - usageLabel->set_markup("n/a"); - - set_title("Module: "+i.name); -} - -void ModuleWindow::onCloseButton() { - hide(); -} diff --git a/ModuleWindow.hh b/ModuleWindow.hh deleted file mode 100644 index c28af52..0000000 --- a/ModuleWindow.hh +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef foomodulewindowhhfoo -#define foomodulewindowhhfoo - -#include -#include - -class ModuleWindow; - -#include "ServerInfo.hh" - -class ModuleWindow : public Gtk::Window { -public: - ModuleWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - static ModuleWindow* create(); - - Gtk::Label *nameLabel, - *argumentLabel, - *indexLabel, - *autoloadedLabel, - *usageLabel; - - Gtk::Button *closeButton; - - void updateInfo(const ModuleInfo &i); - - virtual void onCloseButton(); -}; - -#endif diff --git a/ServerInfo.cc b/ServerInfo.cc deleted file mode 100644 index fc7fe4e..0000000 --- a/ServerInfo.cc +++ /dev/null @@ -1,398 +0,0 @@ -#include -#include - -#include "ServerInfo.hh" -#include "paman.hh" - -SinkInfo::SinkInfo(const struct pa_sink_info &i) : - name(i.name), - description(i.description), - index(i.index), - sample_spec(i.sample_spec), - monitor_source(i.monitor_source), - owner_module(i.owner_module), - volume(i.volume), - latency(i.latency), - window(NULL) { -} - -SinkInfo::~SinkInfo() { - if (window) - delete window; -} - -void SinkInfo::update(const struct pa_sink_info &i) { - name = Glib::ustring(i.name); - description = i.description; - index = i.index; - sample_spec = i.sample_spec; - monitor_source = i.monitor_source; - owner_module = i.owner_module; - volume = i.volume; - latency = i.latency; - - if (window) - window->updateInfo(*this); - g_assert(mainWindow); - mainWindow->updateInfo(*this); -} - -void SinkInfo::showWindow() { - if (window) - window->present(); - else { - window = SinkWindow::create(); - window->updateInfo(*this); - window->show(); - } -} - -SourceInfo::SourceInfo(const struct pa_source_info &i) : - name(i.name), - description(i.description), - index(i.index), - sample_spec(i.sample_spec), - owner_module(i.owner_module), - monitor_of_sink(i.monitor_of_sink), - window(NULL) { -} - -SourceInfo::~SourceInfo() { - if (window) - delete window; -} - -void SourceInfo::update(const struct pa_source_info &i) { - name = i.name; - description = i.description; - index = i.index; - sample_spec = i.sample_spec; - owner_module = i.owner_module; - monitor_of_sink = i.monitor_of_sink; - - if (window) - window->updateInfo(*this); - g_assert(mainWindow); - mainWindow->updateInfo(*this); -} - -void SourceInfo::showWindow() { - if (window) - window->present(); - else { - window = SourceWindow::create(); - window->updateInfo(*this); - window->show(); - } -} - -ClientInfo::ClientInfo(const struct pa_client_info &i) : - index(i.index), - name(i.name), - protocol_name(i.protocol_name), - owner_module(i.owner_module), - window(NULL) { -} - -ClientInfo::~ClientInfo() { - if (window) - delete window; -} - -void ClientInfo::update(const struct pa_client_info &i) { - name = i.name; - protocol_name = i.protocol_name; - index = i.index; - owner_module = i.owner_module; - - if (window) - window->updateInfo(*this); - - g_assert(mainWindow); - mainWindow->updateInfo(*this); -} - -void ClientInfo::showWindow() { - if (window) - window->present(); - else { - window = ClientWindow::create(); - window->updateInfo(*this); - window->show(); - } -} - -ModuleInfo::ModuleInfo(const struct pa_module_info &i) : - index(i.index), - name(i.name), - argument(i.argument), - autoloaded(i.auto_unload), - used(i.n_used), - window(NULL) { -} - -ModuleInfo::~ModuleInfo() { - if (window) - delete window; -} - -void ModuleInfo::update(const struct pa_module_info &i) { - name = i.name; - argument = i.argument; - index = i.index; - autoloaded = i.auto_unload; - used = i.n_used; - - if (window) - window->updateInfo(*this); - g_assert(mainWindow); - mainWindow->updateInfo(*this); -} - -void ModuleInfo::showWindow() { - if (window) - window->present(); - else { - window = ModuleWindow::create(); - window->updateInfo(*this); - window->show(); - } -} - -static void server_info_callback(struct pa_context *c, const struct pa_server_info *i, void *userdata) { - ServerInfoManager *si = (ServerInfoManager*) userdata; - - if (!i) { - mainWindow->showFailure(pa_strerror(pa_context_errno(c))); - return; - } - - mainWindow->updateInfo(*i); -} - -static void sink_info_callback(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata) { - ServerInfoManager *si = (ServerInfoManager*) userdata; - if (i) si->updateInfo(*i); -} - -static void source_info_callback(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata) { - ServerInfoManager *si = (ServerInfoManager*) userdata; - if (i) si->updateInfo(*i); -} - -static void client_info_callback(struct pa_context *c, const struct pa_client_info *i, int is_last, void *userdata) { - ServerInfoManager *si = (ServerInfoManager*) userdata; - if (i) si->updateInfo(*i); -} - -static void module_info_callback(struct pa_context *c, const struct pa_module_info *i, int is_last, void *userdata) { - ServerInfoManager *si = (ServerInfoManager*) userdata; - if (i) si->updateInfo(*i); -} - -static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) { - ServerInfoManager *si = (ServerInfoManager*) userdata; - - //fprintf(stderr, "EV: %u %u\n", t, index); - - switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { - case PA_SUBSCRIPTION_EVENT_SINK: - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) - si->removeSinkInfo(index); - else - pa_operation_unref(pa_context_get_sink_info_by_index(c, index, sink_info_callback, si)); - break; - case PA_SUBSCRIPTION_EVENT_SOURCE: - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) - si->removeSourceInfo(index); - else - pa_operation_unref(pa_context_get_source_info_by_index(c, index, source_info_callback, si)); - break; - case PA_SUBSCRIPTION_EVENT_MODULE: - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) - si->removeModuleInfo(index); - else - pa_operation_unref(pa_context_get_module_info(c, index, module_info_callback, si)); - break; - case PA_SUBSCRIPTION_EVENT_CLIENT: - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) - si->removeClientInfo(index); - else - pa_operation_unref(pa_context_get_client_info(c, index, client_info_callback, si)); - break; - case PA_SUBSCRIPTION_EVENT_SINK_INPUT: -// fprintf(stderr, "SINK INPUT EVENT\n"); - break; - case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: -// fprintf(stderr, "SOURCE OUTPUT EVENT\n"); - break; - default: -// fprintf(stderr, "OTHER EVENT\n"); - break; - } -} - -ServerInfoManager::ServerInfoManager(struct pa_context &c) : - context(c) { - pa_operation_unref(pa_context_get_server_info(&c, server_info_callback, this)); - pa_operation_unref(pa_context_get_sink_info_list(&c, sink_info_callback, this)); - pa_operation_unref(pa_context_get_source_info_list(&c, source_info_callback, this)); - pa_operation_unref(pa_context_get_module_info_list(&c, module_info_callback, this)); - pa_operation_unref(pa_context_get_client_info_list(&c, client_info_callback, this)); - - pa_context_set_subscribe_callback(&c, subscribe_callback, this); - - pa_operation_unref(pa_context_subscribe(&c, (enum pa_subscription_mask) - (PA_SUBSCRIPTION_MASK_SINK| - PA_SUBSCRIPTION_MASK_SOURCE| - PA_SUBSCRIPTION_MASK_MODULE| - PA_SUBSCRIPTION_MASK_SINK_INPUT| - PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT| - PA_SUBSCRIPTION_MASK_CLIENT), NULL, NULL)); -} - - -ServerInfoManager::~ServerInfoManager() { - for (std::map::iterator i = sinks.begin(); i != sinks.end(); i++) - delete i->second; - - for (std::map::iterator i = sources.begin(); i != sources.end(); i++) - delete i->second; - - for (std::map::iterator i = clients.begin(); i != clients.end(); i++) - delete i->second; - - for (std::map::iterator i = modules.begin(); i != modules.end(); i++) - delete i->second; -} - -void ServerInfoManager::updateInfo(const struct pa_sink_info &i) { - SinkInfo *si; - if ((si = sinks[i.index])) - si->update(i); - else { - SinkInfo *n = new SinkInfo(i); - sinks[i.index] = n; - mainWindow->updateInfo(*n); - } -} - -void ServerInfoManager::updateInfo(const struct pa_source_info &i) { - SourceInfo *si; - if ((si = sources[i.index])) - si->update(i); - else { - SourceInfo *n = new SourceInfo(i); - sources[i.index] = n; - mainWindow->updateInfo(*n); - } -} - -void ServerInfoManager::updateInfo(const struct pa_client_info &i) { - ClientInfo *ci; - - if ((ci = clients[i.index])) - ci->update(i); - else { - ClientInfo *n = new ClientInfo(i); - clients[i.index] = n; - mainWindow->updateInfo(*n); - } -} -void ServerInfoManager::updateInfo(const struct pa_module_info &i) { - ModuleInfo *si; - if ((si = modules[i.index])) - si->update(i); - else { - ModuleInfo *n = new ModuleInfo(i); - modules[i.index] = n; - mainWindow->updateInfo(*n); - } -} - -void ServerInfoManager::showSinkWindow(uint32_t index) { - SinkInfo *i; - - if ((i = sinks[index])) - i->showWindow(); -} - -void ServerInfoManager::showSourceWindow(uint32_t index) { - SourceInfo *i; - - if ((i = sources[index])) - i->showWindow(); -} - -void ServerInfoManager::showClientWindow(uint32_t index) { - ClientInfo *i; - - if ((i = clients[index])) - i->showWindow(); -} - -void ServerInfoManager::showModuleWindow(uint32_t index) { - ModuleInfo *i; - - if ((i = modules[index])) - i->showWindow(); -} - - -SourceInfo* ServerInfoManager::getSourceInfo(uint32_t index) { - return sources[index]; -} - -SinkInfo* ServerInfoManager::getSinkInfo(uint32_t index) { - return sinks[index]; -} - -ClientInfo* ServerInfoManager::getClientInfo(uint32_t index) { - return clients[index]; -} - -ModuleInfo* ServerInfoManager::getModuleInfo(uint32_t index) { - return modules[index]; -} - -void ServerInfoManager::removeSinkInfo(uint32_t index) { - SinkInfo *i; - - if ((i = sinks[index])) { - sinks.erase(index); - mainWindow->removeInfo(*i); - delete i; - } -} - -void ServerInfoManager::removeSourceInfo(uint32_t index) { - SourceInfo *i; - if ((i = sources[index])) { - sources.erase(index); - mainWindow->removeInfo(*i); - delete i; - } -} - -void ServerInfoManager::removeClientInfo(uint32_t index) { - ClientInfo *i; - - if ((i = clients[index])) { - clients.erase(index); - mainWindow->removeInfo(*i); - delete i; - } -} - -void ServerInfoManager::removeModuleInfo(uint32_t index) { - ModuleInfo *i; - if ((i = modules[index])) { - modules.erase(index); - mainWindow->removeInfo(*i); - delete i; - } -} - -void ServerInfoManager::setSinkVolume(uint32_t index, uint32_t volume) { - pa_operation_unref(pa_context_set_sink_volume_by_index(&context, index, volume, NULL, NULL)); -} diff --git a/ServerInfo.hh b/ServerInfo.hh deleted file mode 100644 index 5c22f64..0000000 --- a/ServerInfo.hh +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef fooserverinfohhfoo -#define fooserverinfohhfoo - -#include -#include - -#include - -class SinkInfo; -class SourceInfo; -class ServerInfo; -class ClientInfo; -class ModuleInfo; - -#include "SinkWindow.hh" -#include "SourceWindow.hh" -#include "ClientWindow.hh" -#include "ModuleWindow.hh" -#include "MainWindow.hh" - -class SinkInfo { -public: - - SinkInfo(const struct pa_sink_info &i); - ~SinkInfo(); - - void update(const struct pa_sink_info &i); - void showWindow(); - - Glib::ustring name, description; - uint32_t index; - struct pa_sample_spec sample_spec; - uint32_t monitor_source; - uint32_t owner_module; - uint32_t volume; - uint32_t latency; - - Gtk::TreeRowReference treeRef; - - SinkWindow *window; -}; - -class SourceInfo { -public: - SourceInfo(const struct pa_source_info &i); - ~SourceInfo(); - - void update(const struct pa_source_info &i); - void showWindow(); - - Glib::ustring name, description; - uint32_t index; - struct pa_sample_spec sample_spec; - uint32_t owner_module; - uint32_t monitor_of_sink; - - Gtk::TreeRowReference treeRef; - SourceWindow *window; -}; - -class ModuleInfo { -public: - ModuleInfo(const struct pa_module_info &i); - ~ModuleInfo(); - - void update(const struct pa_module_info &i); - void showWindow(); - - uint32_t index; - Glib::ustring name, argument; - bool autoloaded; - uint32_t used; - - Gtk::TreeRowReference treeRef; - ModuleWindow *window; -}; - -class ClientInfo { -public: - ClientInfo(const struct pa_client_info &i); - ~ClientInfo(); - - void update(const struct pa_client_info &i); - void showWindow(); - - uint32_t index; - Glib::ustring name, protocol_name; - uint32_t owner_module; - - Gtk::TreeRowReference treeRef; - ClientWindow *window; -}; - -class ServerInfoManager { -public: - ServerInfoManager(struct pa_context &c); - ~ServerInfoManager(); - - void updateInfo(const struct pa_sink_info &i); - void updateInfo(const struct pa_source_info &i); - void updateInfo(const struct pa_client_info &i); - void updateInfo(const struct pa_module_info &i); - - void showSinkWindow(uint32_t index); - void showSourceWindow(uint32_t index); - void showClientWindow(uint32_t index); - void showModuleWindow(uint32_t index); - - SourceInfo* getSourceInfo(uint32_t index); - SinkInfo* getSinkInfo(uint32_t index); - ClientInfo* getClientInfo(uint32_t index); - ModuleInfo* getModuleInfo(uint32_t index); - - void removeSinkInfo(uint32_t index); - void removeSourceInfo(uint32_t index); - void removeClientInfo(uint32_t index); - void removeModuleInfo(uint32_t index); - - void setSinkVolume(uint32_t index, uint32_t volume); - -protected: - std::map sinks; - std::map sources; - std::map clients; - std::map modules; - - struct pa_context &context; -}; - -#endif diff --git a/SinkWindow.cc b/SinkWindow.cc deleted file mode 100644 index 68d3ec4..0000000 --- a/SinkWindow.cc +++ /dev/null @@ -1,111 +0,0 @@ -#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/SinkWindow.hh b/SinkWindow.hh deleted file mode 100644 index 32557c4..0000000 --- a/SinkWindow.hh +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef foosinkwindowhhfoo -#define foosinkwindowhhfoo - -#include -#include - -class SinkWindow; - -#include "ServerInfo.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/SourceWindow.cc b/SourceWindow.cc deleted file mode 100644 index b5119d9..0000000 --- a/SourceWindow.cc +++ /dev/null @@ -1,82 +0,0 @@ -#include "paman.hh" -#include "SourceWindow.hh" - -#define GLADE_NAME "sourceWindow" - -SourceWindow::SourceWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : - Gtk::Window(cobject), - nameLabel(NULL), - descriptionLabel(NULL), - indexLabel(NULL), - sampleTypeLabel(NULL), - ownerModuleLabel(NULL), - monitorOfSinkLabel(NULL), - closeButton(NULL), - toParentSinkButton(NULL), - toOwnerModuleButton(NULL) { - - refGlade->get_widget("nameLabel", nameLabel); - refGlade->get_widget("descriptionLabel", descriptionLabel); - refGlade->get_widget("indexLabel", indexLabel); - refGlade->get_widget("sampleTypeLabel", sampleTypeLabel); - refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); - refGlade->get_widget("monitorOfSinkLabel", monitorOfSinkLabel); - refGlade->get_widget("closeButton", closeButton); - refGlade->get_widget("toParentSinkButton", toParentSinkButton); - refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton); - - closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceWindow::onCloseButton)); - toParentSinkButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceWindow::onParentSinkButton)); - toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceWindow::onToOwnerModuleButton)); -} - -SourceWindow* SourceWindow::create() { - SourceWindow *w = NULL; - Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); - refXml->get_widget_derived(GLADE_NAME, w); - return w; -} - -void SourceWindow::updateInfo(const SourceInfo &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); - - monitorOfSinkLabel->set_markup("n/a"); - toParentSinkButton->set_sensitive(false); - if (i.monitor_of_sink != (uint32_t) -1) { - SinkInfo *sink = serverInfoManager->getSinkInfo(i.monitor_of_sink); - if (sink) { - monitorOfSinkLabel->set_text(sink->name); - toParentSinkButton->set_sensitive(true); - } - } - - monitor_of_sink = i.monitor_of_sink; - - set_title("Source: "+i.name); - - owner_module = i.owner_module; - toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1); -} - -void SourceWindow::onCloseButton() { - hide(); -} - -void SourceWindow::onParentSinkButton() { - if (monitor_of_sink != (uint32_t) -1) - serverInfoManager->showSinkWindow(monitor_of_sink); -} - -void SourceWindow::onToOwnerModuleButton() { - if (owner_module != (uint32_t) -1) - serverInfoManager->showModuleWindow(owner_module); -} diff --git a/SourceWindow.hh b/SourceWindow.hh deleted file mode 100644 index 964d64f..0000000 --- a/SourceWindow.hh +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef foosourcewindowhhfoo -#define foosourcewindowhhfoo - -#include -#include - -class SourceWindow : public Gtk::Window { -public: - SourceWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - static SourceWindow* create(); - - Gtk::Label *nameLabel, - *descriptionLabel, - *indexLabel, - *sampleTypeLabel, - *ownerModuleLabel, - *monitorOfSinkLabel; - - Gtk::Button *closeButton, - *toParentSinkButton, - *toOwnerModuleButton; - - uint32_t monitor_of_sink, owner_module; - - void updateInfo(const SourceInfo &i); - - virtual void onCloseButton(); - virtual void onParentSinkButton(); - virtual void onToOwnerModuleButton(); -}; - -#endif diff --git a/paman.cc b/paman.cc deleted file mode 100644 index 0c1741d..0000000 --- a/paman.cc +++ /dev/null @@ -1,117 +0,0 @@ -#include - -#include -#include - -#include -#include -#include - -#include "paman.hh" -#include "SinkWindow.hh" -#include "MainWindow.hh" - -MainWindow *mainWindow = NULL; -ServerInfoManager *serverInfoManager = NULL; -struct pa_context *context = NULL; -struct pa_mainloop_api *mainloop_api = NULL; - -static void context_state_callback(struct pa_context *c, void *userdata) { - g_assert(c && mainWindow); - - switch (pa_context_get_state(c)) { - case PA_CONTEXT_CONNECTING: - mainWindow->showSuccess("Connecting ..."); - mainWindow->connectButton->set_sensitive(false); - return; - - case PA_CONTEXT_AUTHORIZING: - mainWindow->showSuccess("Authorizing ..."); - return; - - case PA_CONTEXT_SETTING_NAME: - mainWindow->showSuccess("Setting name ..."); - return; - - case PA_CONTEXT_READY: - mainWindow->showSuccess("Ready"); - g_assert(!serverInfoManager); - serverInfoManager = new ServerInfoManager(*c); - return; - - case PA_CONTEXT_TERMINATED: - mainWindow->showSuccess("Disconnected"); - break; - - case PA_CONTEXT_FAILED: - default: - mainWindow->showFailure(pa_strerror(pa_context_errno(c))); - break; - - } - - if (context) { - pa_context_unref(context); - context = NULL; - } - - if (serverInfoManager) { - delete serverInfoManager; - serverInfoManager = NULL; - } - - mainWindow->connectButton->set_sensitive(true); - mainWindow->clearAllData(); -} - -void create_connection() { - if (serverInfoManager) { - delete serverInfoManager; - serverInfoManager = NULL; - } - - if (context) { - pa_context_unref(context); - context = NULL; - } - - context = pa_context_new(mainloop_api, "Polypaudio Manager"); - g_assert(context); - pa_context_set_state_callback(context, context_state_callback, NULL); - pa_context_connect(context, NULL); -} - -int main(int argc, char *argv[]) { - struct pa_glib_mainloop *m; - - signal(SIGPIPE, SIG_IGN); - - Gtk::Main kit(argc, argv); - - mainWindow = MainWindow::create(); - g_assert(mainWindow); - - m = pa_glib_mainloop_new(g_main_context_default()); - g_assert(m); - mainloop_api = pa_glib_mainloop_get_api(m); - g_assert(mainloop_api); - - create_connection(); - - Gtk::Main::run(*mainWindow); - -quit: - if (serverInfoManager) - delete serverInfoManager; - - if (context) - pa_context_unref(context); - - mainloop_api = NULL; - if (mainWindow) - delete mainWindow; - - pa_glib_mainloop_free(m); - - return 0; -} diff --git a/paman.glade b/paman.glade deleted file mode 100644 index e8915e9..0000000 --- a/paman.glade +++ /dev/null @@ -1,2600 +0,0 @@ - - - - - - - 5 - True - Polypaudio Manager - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 500 - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - - - - True - False - 5 - - - - True - True - True - True - GTK_POS_TOP - False - False - - - - 5 - True - False - 5 - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - 10 - True - 5 - 2 - True - 5 - 10 - - - - True - <b>Host Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - <b>User Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - <b>Server Version:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - <b>Server Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 1 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - <b>Default Sample Type:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - True - - False - True - GTK_JUSTIFY_LEFT - False - True - 0 - 1 - 0 - 0 - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - True - - False - True - GTK_JUSTIFY_LEFT - False - True - 0 - 0 - 0 - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 4 - 5 - fill - - - - - - - True - True - - False - True - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 0 - - - - True - True - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-network - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Connect - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - 0 - False - False - - - - - False - True - - - - - - True - _Server Information - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - 5 - True - False - 5 - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 5 - - - - True - True - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-jump-to - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Open - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - 0 - False - False - - - - - False - True - - - - - - True - _Devices - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - 5 - True - False - 5 - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 0 - - - - True - False - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-jump-to - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Open - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - 0 - False - False - - - - - False - True - - - - - - True - _Clients - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - 5 - True - False - 5 - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 5 - - - - True - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-jump-to - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Open - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - 0 - False - False - - - - - False - True - - - - - - True - _Modules - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - True - label36 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - 5 - Sink - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - - - - True - False - 5 - - - - True - True - True - True - GTK_POS_TOP - False - False - - - - 5 - True - False - 5 - - - - 5 - True - 8 - 2 - False - 5 - 10 - - - - True - <b>Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - <b>Description:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - <b>Monitor Source:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 6 - 7 - fill - - - - - - - True - <b>Owner Module:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 5 - 6 - fill - - - - - - - True - <b>Latency:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - <b>Sample Type:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - <b>Index:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 4 - 5 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 3 - 4 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 2 - 3 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 1 - 2 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 0 - 1 - - - - - - - True - <b>Volume:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 7 - 8 - fill - - - - - - - True - False - 5 - - - - 40 - True - True - 100% - False - True - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - 100 - True - True - False - GTK_POS_LEFT - 0 - GTK_UPDATE_DISCONTINUOUS - False - 147.692 0 500 10 100 20 - - - 0 - True - True - - - - - - True - Reset to 100%, i.e. normal volume - True - Reset - True - GTK_RELIEF_NONE - True - - - 0 - False - False - - - - - - True - Mute to 0%, i.e. turn this sink off - True - Mute - True - GTK_RELIEF_NONE - True - - - 0 - False - False - - - - - 1 - 2 - 7 - 8 - fill - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 6 - 7 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 5 - 6 - - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_START - 0 - - - - True - True - True - To Owner Module - True - GTK_RELIEF_NORMAL - True - - - - - - True - True - True - To Monitor Source - True - GTK_RELIEF_NORMAL - True - - - - - 0 - True - True - - - - - False - True - - - - - - True - Basic - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 0 - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - - - - - 0 - False - True - - - - - - - - 5 - Source - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - - - - True - False - 5 - - - - True - True - True - True - GTK_POS_TOP - False - False - - - - 5 - True - False - 5 - - - - 5 - True - 6 - 2 - False - 5 - 10 - - - - True - <b>Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - <b>Description:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - <b>Sample Type:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - <b>Index:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 4 - 5 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 3 - 4 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 2 - 3 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 1 - 2 - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 0 - 1 - - - - - - - True - <b>Owner Module:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - <b>Monitor of Sink:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 5 - 6 - fill - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 5 - 6 - fill - - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_START - 0 - - - - True - True - True - To Owner Module - True - GTK_RELIEF_NORMAL - True - - - - - - True - True - True - To Parent Sink - True - GTK_RELIEF_NORMAL - True - - - - - 0 - True - True - - - - - False - True - - - - - - True - Basic - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 0 - - - - True - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - - - - - 0 - False - True - - - - - - - - Module - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - - - - 5 - True - False - 5 - - - - True - True - True - True - GTK_POS_TOP - False - False - - - - 5 - True - 5 - 2 - False - 5 - 10 - - - - True - <b>Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - <b>Autoloaded:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - label4724 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 4 - 5 - fill - - - - - - - True - label4725 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - True - <b>Usage Counter:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - label4727 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - foo - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - label4729 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - <b>Argument:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - <b>Index:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - False - True - - - - - - True - Basic - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 0 - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - - - - - 0 - False - False - - - - - - - - Client - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - - - - 5 - True - False - 5 - - - - True - True - True - True - GTK_POS_TOP - False - False - - - - 5 - True - False - 5 - - - - True - 4 - 2 - False - 5 - 10 - - - - True - <b>Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - <b>Owner Module:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - label4725 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - True - label4727 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - foo - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - label4729 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - <b>Protocol:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - <b>Index:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_START - 0 - - - - True - True - True - To Owner Module - True - GTK_RELIEF_NORMAL - True - - - - - 0 - False - False - - - - - False - True - - - - - - True - Basic - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 0 - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - - - - - 0 - False - False - - - - - - - diff --git a/paman.gladep b/paman.gladep deleted file mode 100644 index f50f504..0000000 --- a/paman.gladep +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Paman - paman - FALSE - FALSE - FALSE - FALSE - FALSE - diff --git a/paman.hh b/paman.hh deleted file mode 100644 index 7f2127f..0000000 --- a/paman.hh +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef foopamanhhfoo -#define foopamanhhfoo - -#include "ServerInfo.hh" - -#define GLADE_FILE "paman.glade" - -extern ServerInfoManager *serverInfoManager; -extern MainWindow *mainWindow; -extern struct pa_context *context; - -void create_connection(); - - -#endif diff --git a/src/ClientWindow.cc b/src/ClientWindow.cc new file mode 100644 index 0000000..88e2ad3 --- /dev/null +++ b/src/ClientWindow.cc @@ -0,0 +1,59 @@ +#include + +#include "paman.hh" +#include "ClientWindow.hh" + +#define GLADE_NAME "clientWindow" + +ClientWindow::ClientWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : + Gtk::Window(cobject), + nameLabel(NULL), + protocolLabel(NULL), + indexLabel(NULL), + ownerModuleLabel(NULL), + closeButton(NULL), + toOwnerModuleButton(NULL) { + + refGlade->get_widget("nameLabel", nameLabel); + refGlade->get_widget("protocolLabel", protocolLabel); + refGlade->get_widget("indexLabel", indexLabel); + refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); + refGlade->get_widget("closeButton", closeButton); + refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton); + + closeButton->signal_clicked().connect(sigc::mem_fun(*this, &ClientWindow::onCloseButton)); + toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &ClientWindow::onToOwnerModuleButton)); +} + +ClientWindow* ClientWindow::create() { + ClientWindow *w = NULL; + Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); + refXml->get_widget_derived(GLADE_NAME, w); + return w; +} + +void ClientWindow::updateInfo(const ClientInfo &i) { + char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; + + nameLabel->set_text(i.name); + protocolLabel->set_text(i.protocol_name); + snprintf(t, sizeof(t), "#%u", i.index); + indexLabel->set_text(t); + + snprintf(t, sizeof(t), "#%u", i.owner_module); + ownerModuleLabel->set_text(t); + + set_title("Client: "+i.name); + + owner_module = i.owner_module; + toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1); +} + +void ClientWindow::onCloseButton() { + hide(); +} + +void ClientWindow::onToOwnerModuleButton() { + if (owner_module != (uint32_t) -1) + serverInfoManager->showModuleWindow(owner_module); +} diff --git a/src/ClientWindow.hh b/src/ClientWindow.hh new file mode 100644 index 0000000..61a1973 --- /dev/null +++ b/src/ClientWindow.hh @@ -0,0 +1,32 @@ +#ifndef fooclientwindowhhfoo +#define fooclientwindowhhfoo + +#include +#include + +class ClientWindow; + +#include "ServerInfo.hh" + +class ClientWindow : public Gtk::Window { +public: + ClientWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + static ClientWindow* create(); + + Gtk::Label *nameLabel, + *protocolLabel, + *indexLabel, + *ownerModuleLabel; + + Gtk::Button *closeButton, + *toOwnerModuleButton; + + uint32_t owner_module; + + void updateInfo(const ClientInfo &i); + + virtual void onCloseButton(); + virtual void onToOwnerModuleButton(); +}; + +#endif diff --git a/src/MainWindow.cc b/src/MainWindow.cc new file mode 100644 index 0000000..fdb817a --- /dev/null +++ b/src/MainWindow.cc @@ -0,0 +1,290 @@ +#include +#include +#include + +#include "paman.hh" +#include "MainWindow.hh" + +#define GLADE_NAME "mainWindow" + +enum { + ROW_TYPE_SINK_CATEGORY, + ROW_TYPE_SOURCE_CATEGORY, + ROW_TYPE_SINK, + ROW_TYPE_SOURCE, +}; + +MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : + Gtk::Window(cobject), + statusLabel(NULL), + serverNameLabel(NULL), + serverVersionLabel(NULL), + defaultSampleTypeLabel(NULL), + userNameLabel(NULL), + hostNameLabel(NULL), + deviceOpenButton(NULL), + clientOpenButton(NULL), + moduleOpenButton(NULL), + connectButton(NULL), + deviceTreeView(NULL), + clientTreeView(NULL), + moduleTreeView(NULL) { + + refGlade->get_widget("statusLabel", statusLabel); + refGlade->get_widget("serverNameLabel", serverNameLabel); + refGlade->get_widget("serverVersionLabel", serverVersionLabel); + refGlade->get_widget("defaultSampleTypeLabel", defaultSampleTypeLabel); + refGlade->get_widget("hostNameLabel", hostNameLabel); + refGlade->get_widget("userNameLabel", userNameLabel); + refGlade->get_widget("deviceTreeView", deviceTreeView); + refGlade->get_widget("clientTreeView", clientTreeView); + refGlade->get_widget("moduleTreeView", moduleTreeView); + refGlade->get_widget("deviceOpenButton", deviceOpenButton); + refGlade->get_widget("clientOpenButton", clientOpenButton); + refGlade->get_widget("moduleOpenButton", moduleOpenButton); + refGlade->get_widget("connectButton", connectButton); + + deviceTreeStore = Gtk::TreeStore::create(deviceTreeModelColumns); + deviceTreeView->set_model(deviceTreeStore); + deviceTreeView->append_column("Name", deviceTreeModelColumns.name); + deviceTreeView->append_column("Description", deviceTreeModelColumns.description); + deviceTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onDeviceTreeViewRowActivated)); + deviceTreeView->signal_cursor_changed().connect(sigc::mem_fun(*this, &MainWindow::onDeviceTreeViewCursorChanged)); + + clientTreeStore = Gtk::TreeStore::create(clientTreeModelColumns); + clientTreeView->set_model(clientTreeStore); + clientTreeView->append_column("Name", clientTreeModelColumns.name); + clientTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onClientTreeViewRowActivated)); + + moduleTreeStore = Gtk::TreeStore::create(moduleTreeModelColumns); + moduleTreeView->set_model(moduleTreeStore); + moduleTreeView->append_column("Name", moduleTreeModelColumns.name); + moduleTreeView->append_column("Argument", moduleTreeModelColumns.argument); + moduleTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onModuleTreeViewRowActivated)); + + connectButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onConnectButton)); + deviceOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onDeviceOpenButton)); + clientOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onClientOpenButton)); + moduleOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onModuleOpenButton)); + + statusLabel->set_text("Connecting ..."); + + clearAllData(); +} + +MainWindow::~MainWindow() { +} + +MainWindow* MainWindow::create() { + MainWindow *w; + Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); + refXml->get_widget_derived(GLADE_NAME, w); + return w; +} + +void MainWindow::updateInfo(SinkInfo &i) { + if (!i.treeRef) { + Gtk::TreeIter iter = deviceTreeStore->get_iter(sinkRef.get_path()); + i.treeRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(deviceTreeStore->append(iter->children()))); + } + + Gtk::TreeRow row = *(deviceTreeStore->get_iter(i.treeRef.get_path())); + row[deviceTreeModelColumns.name] = i.name; + row[deviceTreeModelColumns.description] = i.description; + row[deviceTreeModelColumns.index] = i.index; + row[deviceTreeModelColumns.type] = ROW_TYPE_SINK; + + deviceTreeView->expand_row(sinkRef.get_path(), false); + onDeviceTreeViewCursorChanged(); +} + +void MainWindow::updateInfo(SourceInfo &i) { + if (!i.treeRef) { + Gtk::TreeIter iter = deviceTreeStore->get_iter(sourceRef.get_path()); + i.treeRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(deviceTreeStore->append(iter->children()))); + } + + Gtk::TreeRow row = *(deviceTreeStore->get_iter(i.treeRef.get_path())); + row[deviceTreeModelColumns.name] = i.name; + row[deviceTreeModelColumns.description] = i.description; + row[deviceTreeModelColumns.index] = i.index; + row[deviceTreeModelColumns.type] = ROW_TYPE_SOURCE; + + deviceTreeView->expand_row(sourceRef.get_path(), false); + onDeviceTreeViewCursorChanged(); +} + +void MainWindow::updateInfo(ClientInfo &i) { + + if (!i.treeRef) + i.treeRef = Gtk::TreeRowReference(clientTreeStore, Gtk::TreePath(clientTreeStore->append())); + + Gtk::TreeRow row = *(clientTreeStore->get_iter(i.treeRef.get_path())); + row[clientTreeModelColumns.name] = i.name; + row[clientTreeModelColumns.index] = i.index; + clientOpenButton->set_sensitive(true); +} + +void MainWindow::updateInfo(ModuleInfo &i) { + if (!i.treeRef) + i.treeRef = Gtk::TreeRowReference(moduleTreeStore, Gtk::TreePath(moduleTreeStore->append())); + + Gtk::TreeRow row = *(moduleTreeStore->get_iter(i.treeRef.get_path())); + row[moduleTreeModelColumns.name] = i.name; + row[moduleTreeModelColumns.argument] = i.argument; + row[moduleTreeModelColumns.index] = i.index; + moduleOpenButton->set_sensitive(true); +} + +void MainWindow::removeInfo(SinkInfo &i) { + if (i.treeRef) + deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); + + onDeviceTreeViewCursorChanged(); +} + +void MainWindow::removeInfo(SourceInfo &i) { + if (!i.treeRef) + deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); + + onDeviceTreeViewCursorChanged(); +} + +void MainWindow::removeInfo(ClientInfo &i) { + if (i.treeRef) + clientTreeStore->erase(clientTreeStore->get_iter(i.treeRef.get_path())); + + clientOpenButton->set_sensitive(!moduleTreeStore->children().empty()); +} + +void MainWindow::removeInfo(ModuleInfo &i) { + if (i.treeRef) + moduleTreeStore->erase(moduleTreeStore->get_iter(i.treeRef.get_path())); + + moduleOpenButton->set_sensitive(!moduleTreeStore->children().empty()); +} + +void MainWindow::onDeviceTreeViewCursorChanged() { + Gtk::TreeModel::Path p; + Gtk::TreeViewColumn *c; + deviceTreeView->get_cursor(p, c); + + if (!p.gobj()) + return; + + deviceOpenButton->set_sensitive((sourceRef.get_path() != p) && (sinkRef.get_path() != p)); +} + +void MainWindow::onDeviceTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { + showDeviceWindow(path); +} + +void MainWindow::onClientTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { + showClientWindow(path); +} + +void MainWindow::onModuleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { + showModuleWindow(path); +} + +void MainWindow::updateInfo(const struct pa_server_info &i) { + char t[PA_SAMPLE_SNPRINT_MAX_LENGTH]; + serverNameLabel->set_text(i.server_name); + serverVersionLabel->set_text(i.server_version); + pa_sample_snprint(t, sizeof(t), &i.sample_spec); + defaultSampleTypeLabel->set_text(t); + hostNameLabel->set_text(i.host_name); + userNameLabel->set_text(i.user_name); +} + +void MainWindow::showSuccess(const char *t) { + statusLabel->set_text(t); +} + +void MainWindow::showFailure(const char *t) { + char s[256]; + snprintf(s, sizeof(s), "Failure: %s", t); + statusLabel->set_markup(s); +} + +void MainWindow::clearAllData() { + deviceTreeStore->clear(); + + Gtk::TreeIter i = deviceTreeStore->append(); + sinkRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(i)); + (*i)[deviceTreeModelColumns.name] = "Sinks"; + (*i)[deviceTreeModelColumns.index] = (uint32_t) -1; + (*i)[deviceTreeModelColumns.type] = ROW_TYPE_SINK_CATEGORY; + + i = deviceTreeStore->append(); + sourceRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(i)); + (*i)[deviceTreeModelColumns.name] = "Sources"; + (*i)[deviceTreeModelColumns.index] = (uint32_t) -1; + (*i)[deviceTreeModelColumns.type] = ROW_TYPE_SOURCE_CATEGORY; + + clientTreeStore->clear(); + moduleTreeStore->clear(); + + deviceOpenButton->set_sensitive(false); + clientOpenButton->set_sensitive(false); + moduleOpenButton->set_sensitive(false); + + serverNameLabel->set_markup("n/a"); + serverVersionLabel->set_markup("n/a"); + defaultSampleTypeLabel->set_markup("n/a"); + hostNameLabel->set_markup("n/a"); + userNameLabel->set_markup("n/a"); +} + +void MainWindow::onDeviceOpenButton() { + Gtk::TreeModel::Path p; + Gtk::TreeViewColumn *c; + deviceTreeView->get_cursor(p, c); + showDeviceWindow(p); +} + +void MainWindow::onClientOpenButton() { + Gtk::TreeModel::Path p; + Gtk::TreeViewColumn *c; + clientTreeView->get_cursor(p, c); + showClientWindow(p); +} + +void MainWindow::onModuleOpenButton() { + Gtk::TreeModel::Path p; + Gtk::TreeViewColumn *c; + moduleTreeView->get_cursor(p, c); + showModuleWindow(p); +} + +void MainWindow::onConnectButton() { + create_connection(); +} + +void MainWindow::showDeviceWindow(const Gtk::TreePath &p) { + if (!serverInfoManager) + return; + + Gtk::TreeModel::Row row = *(deviceTreeStore->get_iter(p)); + + if (row[deviceTreeModelColumns.type] == ROW_TYPE_SINK) + serverInfoManager->showSinkWindow(row[deviceTreeModelColumns.index]); + else if (row[deviceTreeModelColumns.type] == ROW_TYPE_SOURCE) + serverInfoManager->showSourceWindow(row[deviceTreeModelColumns.index]); +} + +void MainWindow::showClientWindow(const Gtk::TreePath &p) { + if (!serverInfoManager) + return; + + Gtk::TreeModel::Row row = *(clientTreeStore->get_iter(p)); + serverInfoManager->showClientWindow(row[clientTreeModelColumns.index]); +} + +void MainWindow::showModuleWindow(const Gtk::TreePath &p) { + if (!serverInfoManager) + return; + + Gtk::TreeModel::Row row = *(moduleTreeStore->get_iter(p)); + serverInfoManager->showModuleWindow(row[moduleTreeModelColumns.index]); +} diff --git a/src/MainWindow.hh b/src/MainWindow.hh new file mode 100644 index 0000000..2d5f173 --- /dev/null +++ b/src/MainWindow.hh @@ -0,0 +1,117 @@ +#ifndef foomainwindowhhfoo +#define foomainwindowhhfoo + +#include +#include +#include + +class MainWinow; + +#include "ServerInfo.hh" + +class MainWindow : public Gtk::Window { +public: + MainWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + virtual ~MainWindow(); + static MainWindow* create(); + + Gtk::Label *statusLabel, + *serverNameLabel, + *serverVersionLabel, + *defaultSampleTypeLabel, + *userNameLabel, + *hostNameLabel; + + Gtk::Button *deviceOpenButton, + *clientOpenButton, + *moduleOpenButton, + *connectButton; + + Gtk::TreeView *deviceTreeView, + *clientTreeView, + *moduleTreeView; + +protected: + + class DeviceTreeModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + + DeviceTreeModelColumns() { + add(name); + add(description); + add(index); + add(type); + } + + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn description; + Gtk::TreeModelColumn index; + Gtk::TreeModelColumn type; + }; + + DeviceTreeModelColumns deviceTreeModelColumns; + Glib::RefPtr deviceTreeStore; + Gtk::TreeRowReference sinkRef, sourceRef; + + class ClientTreeModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + ClientTreeModelColumns() { + add(name); + add(index); + } + + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn index; + }; + + ClientTreeModelColumns clientTreeModelColumns; + Glib::RefPtr clientTreeStore; + + class ModuleTreeModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + ModuleTreeModelColumns() { + add(name); + add(argument); + add(index); + } + + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn argument; + Gtk::TreeModelColumn index; + }; + + ModuleTreeModelColumns moduleTreeModelColumns; + Glib::RefPtr moduleTreeStore; + +public: + virtual void updateInfo(const struct pa_server_info &i); + virtual void updateInfo(SinkInfo &i); + virtual void updateInfo(SourceInfo &i); + virtual void updateInfo(ClientInfo &i); + virtual void updateInfo(ModuleInfo &i); + + virtual void removeInfo(SinkInfo &i); + virtual void removeInfo(SourceInfo &i); + virtual void removeInfo(ClientInfo &i); + virtual void removeInfo(ModuleInfo &i); + + virtual void onDeviceTreeViewCursorChanged(); + virtual void onDeviceTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); + virtual void onClientTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); + virtual void onModuleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); + + virtual void showSuccess(const char *t); + virtual void showFailure(const char *t); + virtual void clearAllData(); + + virtual void onDeviceOpenButton(); + virtual void onClientOpenButton(); + virtual void onModuleOpenButton(); + virtual void onConnectButton(); + + virtual void showDeviceWindow(const Gtk::TreePath &p); + virtual void showClientWindow(const Gtk::TreePath &p); + virtual void showModuleWindow(const Gtk::TreePath &p); +}; + +#endif diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..8a9cb3a --- /dev/null +++ b/src/Makefile @@ -0,0 +1,9 @@ + +CXXFLAGS=`pkg-config gtkmm-2.4 libglademm-2.4 --cflags` -Wall -W -pipe -O0 -g -Wno-unused -I../polypaudio +LIBS=`pkg-config gtkmm-2.4 libglademm-2.4 --libs` -L../polypaudio/polyp/.libs -lpolyp -lpolyp-mainloop-glib -lpolyp-error + +paman: paman.o MainWindow.o SinkWindow.o SourceWindow.o ServerInfo.o ClientWindow.o ModuleWindow.o + $(CXX) $^ -o $@ $(LIBS) + +clean: + rm -rf *.o paman diff --git a/src/ModuleWindow.cc b/src/ModuleWindow.cc new file mode 100644 index 0000000..04d8fb5 --- /dev/null +++ b/src/ModuleWindow.cc @@ -0,0 +1,58 @@ +#include + +#include "paman.hh" +#include "ModuleWindow.hh" + +#define GLADE_NAME "moduleWindow" + +ModuleWindow::ModuleWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : + Gtk::Window(cobject), + nameLabel(NULL), + argumentLabel(NULL), + indexLabel(NULL), + autoloadedLabel(NULL), + usageLabel(NULL), + closeButton(NULL) { + + refGlade->get_widget("nameLabel", nameLabel); + refGlade->get_widget("argumentLabel", argumentLabel); + refGlade->get_widget("indexLabel", indexLabel); + refGlade->get_widget("autoloadedLabel", autoloadedLabel); + refGlade->get_widget("usageLabel", usageLabel); + refGlade->get_widget("closeButton", closeButton); + + closeButton->signal_clicked().connect(sigc::mem_fun(*this, &ModuleWindow::onCloseButton)); +} + +ModuleWindow* ModuleWindow::create() { + ModuleWindow *w = NULL; + Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); + refXml->get_widget_derived(GLADE_NAME, w); + return w; +} + +void ModuleWindow::updateInfo(const ModuleInfo &i) { + char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; + + nameLabel->set_text(i.name); + if (!i.argument.empty()) + argumentLabel->set_text(i.argument); + else + argumentLabel->set_markup("None specified"); + + snprintf(t, sizeof(t), "#%u", i.index); + indexLabel->set_text(t); + autoloadedLabel->set_text(i.autoloaded ? "Yes" : "No"); + + if (i.used != (uint32_t) -1) { + snprintf(t, sizeof(t), "%u", i.used); + usageLabel->set_text(t); + } else + usageLabel->set_markup("n/a"); + + set_title("Module: "+i.name); +} + +void ModuleWindow::onCloseButton() { + hide(); +} diff --git a/src/ModuleWindow.hh b/src/ModuleWindow.hh new file mode 100644 index 0000000..c28af52 --- /dev/null +++ b/src/ModuleWindow.hh @@ -0,0 +1,29 @@ +#ifndef foomodulewindowhhfoo +#define foomodulewindowhhfoo + +#include +#include + +class ModuleWindow; + +#include "ServerInfo.hh" + +class ModuleWindow : public Gtk::Window { +public: + ModuleWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + static ModuleWindow* create(); + + Gtk::Label *nameLabel, + *argumentLabel, + *indexLabel, + *autoloadedLabel, + *usageLabel; + + Gtk::Button *closeButton; + + void updateInfo(const ModuleInfo &i); + + virtual void onCloseButton(); +}; + +#endif diff --git a/src/ServerInfo.cc b/src/ServerInfo.cc new file mode 100644 index 0000000..fc7fe4e --- /dev/null +++ b/src/ServerInfo.cc @@ -0,0 +1,398 @@ +#include +#include + +#include "ServerInfo.hh" +#include "paman.hh" + +SinkInfo::SinkInfo(const struct pa_sink_info &i) : + name(i.name), + description(i.description), + index(i.index), + sample_spec(i.sample_spec), + monitor_source(i.monitor_source), + owner_module(i.owner_module), + volume(i.volume), + latency(i.latency), + window(NULL) { +} + +SinkInfo::~SinkInfo() { + if (window) + delete window; +} + +void SinkInfo::update(const struct pa_sink_info &i) { + name = Glib::ustring(i.name); + description = i.description; + index = i.index; + sample_spec = i.sample_spec; + monitor_source = i.monitor_source; + owner_module = i.owner_module; + volume = i.volume; + latency = i.latency; + + if (window) + window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); +} + +void SinkInfo::showWindow() { + if (window) + window->present(); + else { + window = SinkWindow::create(); + window->updateInfo(*this); + window->show(); + } +} + +SourceInfo::SourceInfo(const struct pa_source_info &i) : + name(i.name), + description(i.description), + index(i.index), + sample_spec(i.sample_spec), + owner_module(i.owner_module), + monitor_of_sink(i.monitor_of_sink), + window(NULL) { +} + +SourceInfo::~SourceInfo() { + if (window) + delete window; +} + +void SourceInfo::update(const struct pa_source_info &i) { + name = i.name; + description = i.description; + index = i.index; + sample_spec = i.sample_spec; + owner_module = i.owner_module; + monitor_of_sink = i.monitor_of_sink; + + if (window) + window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); +} + +void SourceInfo::showWindow() { + if (window) + window->present(); + else { + window = SourceWindow::create(); + window->updateInfo(*this); + window->show(); + } +} + +ClientInfo::ClientInfo(const struct pa_client_info &i) : + index(i.index), + name(i.name), + protocol_name(i.protocol_name), + owner_module(i.owner_module), + window(NULL) { +} + +ClientInfo::~ClientInfo() { + if (window) + delete window; +} + +void ClientInfo::update(const struct pa_client_info &i) { + name = i.name; + protocol_name = i.protocol_name; + index = i.index; + owner_module = i.owner_module; + + if (window) + window->updateInfo(*this); + + g_assert(mainWindow); + mainWindow->updateInfo(*this); +} + +void ClientInfo::showWindow() { + if (window) + window->present(); + else { + window = ClientWindow::create(); + window->updateInfo(*this); + window->show(); + } +} + +ModuleInfo::ModuleInfo(const struct pa_module_info &i) : + index(i.index), + name(i.name), + argument(i.argument), + autoloaded(i.auto_unload), + used(i.n_used), + window(NULL) { +} + +ModuleInfo::~ModuleInfo() { + if (window) + delete window; +} + +void ModuleInfo::update(const struct pa_module_info &i) { + name = i.name; + argument = i.argument; + index = i.index; + autoloaded = i.auto_unload; + used = i.n_used; + + if (window) + window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); +} + +void ModuleInfo::showWindow() { + if (window) + window->present(); + else { + window = ModuleWindow::create(); + window->updateInfo(*this); + window->show(); + } +} + +static void server_info_callback(struct pa_context *c, const struct pa_server_info *i, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + + if (!i) { + mainWindow->showFailure(pa_strerror(pa_context_errno(c))); + return; + } + + mainWindow->updateInfo(*i); +} + +static void sink_info_callback(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + if (i) si->updateInfo(*i); +} + +static void source_info_callback(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + if (i) si->updateInfo(*i); +} + +static void client_info_callback(struct pa_context *c, const struct pa_client_info *i, int is_last, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + if (i) si->updateInfo(*i); +} + +static void module_info_callback(struct pa_context *c, const struct pa_module_info *i, int is_last, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + if (i) si->updateInfo(*i); +} + +static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + + //fprintf(stderr, "EV: %u %u\n", t, index); + + switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { + case PA_SUBSCRIPTION_EVENT_SINK: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + si->removeSinkInfo(index); + else + pa_operation_unref(pa_context_get_sink_info_by_index(c, index, sink_info_callback, si)); + break; + case PA_SUBSCRIPTION_EVENT_SOURCE: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + si->removeSourceInfo(index); + else + pa_operation_unref(pa_context_get_source_info_by_index(c, index, source_info_callback, si)); + break; + case PA_SUBSCRIPTION_EVENT_MODULE: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + si->removeModuleInfo(index); + else + pa_operation_unref(pa_context_get_module_info(c, index, module_info_callback, si)); + break; + case PA_SUBSCRIPTION_EVENT_CLIENT: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + si->removeClientInfo(index); + else + pa_operation_unref(pa_context_get_client_info(c, index, client_info_callback, si)); + break; + case PA_SUBSCRIPTION_EVENT_SINK_INPUT: +// fprintf(stderr, "SINK INPUT EVENT\n"); + break; + case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: +// fprintf(stderr, "SOURCE OUTPUT EVENT\n"); + break; + default: +// fprintf(stderr, "OTHER EVENT\n"); + break; + } +} + +ServerInfoManager::ServerInfoManager(struct pa_context &c) : + context(c) { + pa_operation_unref(pa_context_get_server_info(&c, server_info_callback, this)); + pa_operation_unref(pa_context_get_sink_info_list(&c, sink_info_callback, this)); + pa_operation_unref(pa_context_get_source_info_list(&c, source_info_callback, this)); + pa_operation_unref(pa_context_get_module_info_list(&c, module_info_callback, this)); + pa_operation_unref(pa_context_get_client_info_list(&c, client_info_callback, this)); + + pa_context_set_subscribe_callback(&c, subscribe_callback, this); + + pa_operation_unref(pa_context_subscribe(&c, (enum pa_subscription_mask) + (PA_SUBSCRIPTION_MASK_SINK| + PA_SUBSCRIPTION_MASK_SOURCE| + PA_SUBSCRIPTION_MASK_MODULE| + PA_SUBSCRIPTION_MASK_SINK_INPUT| + PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT| + PA_SUBSCRIPTION_MASK_CLIENT), NULL, NULL)); +} + + +ServerInfoManager::~ServerInfoManager() { + for (std::map::iterator i = sinks.begin(); i != sinks.end(); i++) + delete i->second; + + for (std::map::iterator i = sources.begin(); i != sources.end(); i++) + delete i->second; + + for (std::map::iterator i = clients.begin(); i != clients.end(); i++) + delete i->second; + + for (std::map::iterator i = modules.begin(); i != modules.end(); i++) + delete i->second; +} + +void ServerInfoManager::updateInfo(const struct pa_sink_info &i) { + SinkInfo *si; + if ((si = sinks[i.index])) + si->update(i); + else { + SinkInfo *n = new SinkInfo(i); + sinks[i.index] = n; + mainWindow->updateInfo(*n); + } +} + +void ServerInfoManager::updateInfo(const struct pa_source_info &i) { + SourceInfo *si; + if ((si = sources[i.index])) + si->update(i); + else { + SourceInfo *n = new SourceInfo(i); + sources[i.index] = n; + mainWindow->updateInfo(*n); + } +} + +void ServerInfoManager::updateInfo(const struct pa_client_info &i) { + ClientInfo *ci; + + if ((ci = clients[i.index])) + ci->update(i); + else { + ClientInfo *n = new ClientInfo(i); + clients[i.index] = n; + mainWindow->updateInfo(*n); + } +} +void ServerInfoManager::updateInfo(const struct pa_module_info &i) { + ModuleInfo *si; + if ((si = modules[i.index])) + si->update(i); + else { + ModuleInfo *n = new ModuleInfo(i); + modules[i.index] = n; + mainWindow->updateInfo(*n); + } +} + +void ServerInfoManager::showSinkWindow(uint32_t index) { + SinkInfo *i; + + if ((i = sinks[index])) + i->showWindow(); +} + +void ServerInfoManager::showSourceWindow(uint32_t index) { + SourceInfo *i; + + if ((i = sources[index])) + i->showWindow(); +} + +void ServerInfoManager::showClientWindow(uint32_t index) { + ClientInfo *i; + + if ((i = clients[index])) + i->showWindow(); +} + +void ServerInfoManager::showModuleWindow(uint32_t index) { + ModuleInfo *i; + + if ((i = modules[index])) + i->showWindow(); +} + + +SourceInfo* ServerInfoManager::getSourceInfo(uint32_t index) { + return sources[index]; +} + +SinkInfo* ServerInfoManager::getSinkInfo(uint32_t index) { + return sinks[index]; +} + +ClientInfo* ServerInfoManager::getClientInfo(uint32_t index) { + return clients[index]; +} + +ModuleInfo* ServerInfoManager::getModuleInfo(uint32_t index) { + return modules[index]; +} + +void ServerInfoManager::removeSinkInfo(uint32_t index) { + SinkInfo *i; + + if ((i = sinks[index])) { + sinks.erase(index); + mainWindow->removeInfo(*i); + delete i; + } +} + +void ServerInfoManager::removeSourceInfo(uint32_t index) { + SourceInfo *i; + if ((i = sources[index])) { + sources.erase(index); + mainWindow->removeInfo(*i); + delete i; + } +} + +void ServerInfoManager::removeClientInfo(uint32_t index) { + ClientInfo *i; + + if ((i = clients[index])) { + clients.erase(index); + mainWindow->removeInfo(*i); + delete i; + } +} + +void ServerInfoManager::removeModuleInfo(uint32_t index) { + ModuleInfo *i; + if ((i = modules[index])) { + modules.erase(index); + mainWindow->removeInfo(*i); + delete i; + } +} + +void ServerInfoManager::setSinkVolume(uint32_t index, uint32_t volume) { + pa_operation_unref(pa_context_set_sink_volume_by_index(&context, index, volume, NULL, NULL)); +} diff --git a/src/ServerInfo.hh b/src/ServerInfo.hh new file mode 100644 index 0000000..5c22f64 --- /dev/null +++ b/src/ServerInfo.hh @@ -0,0 +1,130 @@ +#ifndef fooserverinfohhfoo +#define fooserverinfohhfoo + +#include +#include + +#include + +class SinkInfo; +class SourceInfo; +class ServerInfo; +class ClientInfo; +class ModuleInfo; + +#include "SinkWindow.hh" +#include "SourceWindow.hh" +#include "ClientWindow.hh" +#include "ModuleWindow.hh" +#include "MainWindow.hh" + +class SinkInfo { +public: + + SinkInfo(const struct pa_sink_info &i); + ~SinkInfo(); + + void update(const struct pa_sink_info &i); + void showWindow(); + + Glib::ustring name, description; + uint32_t index; + struct pa_sample_spec sample_spec; + uint32_t monitor_source; + uint32_t owner_module; + uint32_t volume; + uint32_t latency; + + Gtk::TreeRowReference treeRef; + + SinkWindow *window; +}; + +class SourceInfo { +public: + SourceInfo(const struct pa_source_info &i); + ~SourceInfo(); + + void update(const struct pa_source_info &i); + void showWindow(); + + Glib::ustring name, description; + uint32_t index; + struct pa_sample_spec sample_spec; + uint32_t owner_module; + uint32_t monitor_of_sink; + + Gtk::TreeRowReference treeRef; + SourceWindow *window; +}; + +class ModuleInfo { +public: + ModuleInfo(const struct pa_module_info &i); + ~ModuleInfo(); + + void update(const struct pa_module_info &i); + void showWindow(); + + uint32_t index; + Glib::ustring name, argument; + bool autoloaded; + uint32_t used; + + Gtk::TreeRowReference treeRef; + ModuleWindow *window; +}; + +class ClientInfo { +public: + ClientInfo(const struct pa_client_info &i); + ~ClientInfo(); + + void update(const struct pa_client_info &i); + void showWindow(); + + uint32_t index; + Glib::ustring name, protocol_name; + uint32_t owner_module; + + Gtk::TreeRowReference treeRef; + ClientWindow *window; +}; + +class ServerInfoManager { +public: + ServerInfoManager(struct pa_context &c); + ~ServerInfoManager(); + + void updateInfo(const struct pa_sink_info &i); + void updateInfo(const struct pa_source_info &i); + void updateInfo(const struct pa_client_info &i); + void updateInfo(const struct pa_module_info &i); + + void showSinkWindow(uint32_t index); + void showSourceWindow(uint32_t index); + void showClientWindow(uint32_t index); + void showModuleWindow(uint32_t index); + + SourceInfo* getSourceInfo(uint32_t index); + SinkInfo* getSinkInfo(uint32_t index); + ClientInfo* getClientInfo(uint32_t index); + ModuleInfo* getModuleInfo(uint32_t index); + + void removeSinkInfo(uint32_t index); + void removeSourceInfo(uint32_t index); + void removeClientInfo(uint32_t index); + void removeModuleInfo(uint32_t index); + + void setSinkVolume(uint32_t index, uint32_t volume); + +protected: + std::map sinks; + std::map sources; + std::map clients; + std::map modules; + + struct pa_context &context; +}; + +#endif diff --git a/src/SinkWindow.cc b/src/SinkWindow.cc new file mode 100644 index 0000000..68d3ec4 --- /dev/null +++ b/src/SinkWindow.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/SinkWindow.hh b/src/SinkWindow.hh new file mode 100644 index 0000000..32557c4 --- /dev/null +++ b/src/SinkWindow.hh @@ -0,0 +1,45 @@ +#ifndef foosinkwindowhhfoo +#define foosinkwindowhhfoo + +#include +#include + +class SinkWindow; + +#include "ServerInfo.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/SourceWindow.cc b/src/SourceWindow.cc new file mode 100644 index 0000000..b5119d9 --- /dev/null +++ b/src/SourceWindow.cc @@ -0,0 +1,82 @@ +#include "paman.hh" +#include "SourceWindow.hh" + +#define GLADE_NAME "sourceWindow" + +SourceWindow::SourceWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : + Gtk::Window(cobject), + nameLabel(NULL), + descriptionLabel(NULL), + indexLabel(NULL), + sampleTypeLabel(NULL), + ownerModuleLabel(NULL), + monitorOfSinkLabel(NULL), + closeButton(NULL), + toParentSinkButton(NULL), + toOwnerModuleButton(NULL) { + + refGlade->get_widget("nameLabel", nameLabel); + refGlade->get_widget("descriptionLabel", descriptionLabel); + refGlade->get_widget("indexLabel", indexLabel); + refGlade->get_widget("sampleTypeLabel", sampleTypeLabel); + refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); + refGlade->get_widget("monitorOfSinkLabel", monitorOfSinkLabel); + refGlade->get_widget("closeButton", closeButton); + refGlade->get_widget("toParentSinkButton", toParentSinkButton); + refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton); + + closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceWindow::onCloseButton)); + toParentSinkButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceWindow::onParentSinkButton)); + toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceWindow::onToOwnerModuleButton)); +} + +SourceWindow* SourceWindow::create() { + SourceWindow *w = NULL; + Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); + refXml->get_widget_derived(GLADE_NAME, w); + return w; +} + +void SourceWindow::updateInfo(const SourceInfo &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); + + monitorOfSinkLabel->set_markup("n/a"); + toParentSinkButton->set_sensitive(false); + if (i.monitor_of_sink != (uint32_t) -1) { + SinkInfo *sink = serverInfoManager->getSinkInfo(i.monitor_of_sink); + if (sink) { + monitorOfSinkLabel->set_text(sink->name); + toParentSinkButton->set_sensitive(true); + } + } + + monitor_of_sink = i.monitor_of_sink; + + set_title("Source: "+i.name); + + owner_module = i.owner_module; + toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1); +} + +void SourceWindow::onCloseButton() { + hide(); +} + +void SourceWindow::onParentSinkButton() { + if (monitor_of_sink != (uint32_t) -1) + serverInfoManager->showSinkWindow(monitor_of_sink); +} + +void SourceWindow::onToOwnerModuleButton() { + if (owner_module != (uint32_t) -1) + serverInfoManager->showModuleWindow(owner_module); +} diff --git a/src/SourceWindow.hh b/src/SourceWindow.hh new file mode 100644 index 0000000..964d64f --- /dev/null +++ b/src/SourceWindow.hh @@ -0,0 +1,32 @@ +#ifndef foosourcewindowhhfoo +#define foosourcewindowhhfoo + +#include +#include + +class SourceWindow : public Gtk::Window { +public: + SourceWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + static SourceWindow* create(); + + Gtk::Label *nameLabel, + *descriptionLabel, + *indexLabel, + *sampleTypeLabel, + *ownerModuleLabel, + *monitorOfSinkLabel; + + Gtk::Button *closeButton, + *toParentSinkButton, + *toOwnerModuleButton; + + uint32_t monitor_of_sink, owner_module; + + void updateInfo(const SourceInfo &i); + + virtual void onCloseButton(); + virtual void onParentSinkButton(); + virtual void onToOwnerModuleButton(); +}; + +#endif diff --git a/src/paman.cc b/src/paman.cc new file mode 100644 index 0000000..0c1741d --- /dev/null +++ b/src/paman.cc @@ -0,0 +1,117 @@ +#include + +#include +#include + +#include +#include +#include + +#include "paman.hh" +#include "SinkWindow.hh" +#include "MainWindow.hh" + +MainWindow *mainWindow = NULL; +ServerInfoManager *serverInfoManager = NULL; +struct pa_context *context = NULL; +struct pa_mainloop_api *mainloop_api = NULL; + +static void context_state_callback(struct pa_context *c, void *userdata) { + g_assert(c && mainWindow); + + switch (pa_context_get_state(c)) { + case PA_CONTEXT_CONNECTING: + mainWindow->showSuccess("Connecting ..."); + mainWindow->connectButton->set_sensitive(false); + return; + + case PA_CONTEXT_AUTHORIZING: + mainWindow->showSuccess("Authorizing ..."); + return; + + case PA_CONTEXT_SETTING_NAME: + mainWindow->showSuccess("Setting name ..."); + return; + + case PA_CONTEXT_READY: + mainWindow->showSuccess("Ready"); + g_assert(!serverInfoManager); + serverInfoManager = new ServerInfoManager(*c); + return; + + case PA_CONTEXT_TERMINATED: + mainWindow->showSuccess("Disconnected"); + break; + + case PA_CONTEXT_FAILED: + default: + mainWindow->showFailure(pa_strerror(pa_context_errno(c))); + break; + + } + + if (context) { + pa_context_unref(context); + context = NULL; + } + + if (serverInfoManager) { + delete serverInfoManager; + serverInfoManager = NULL; + } + + mainWindow->connectButton->set_sensitive(true); + mainWindow->clearAllData(); +} + +void create_connection() { + if (serverInfoManager) { + delete serverInfoManager; + serverInfoManager = NULL; + } + + if (context) { + pa_context_unref(context); + context = NULL; + } + + context = pa_context_new(mainloop_api, "Polypaudio Manager"); + g_assert(context); + pa_context_set_state_callback(context, context_state_callback, NULL); + pa_context_connect(context, NULL); +} + +int main(int argc, char *argv[]) { + struct pa_glib_mainloop *m; + + signal(SIGPIPE, SIG_IGN); + + Gtk::Main kit(argc, argv); + + mainWindow = MainWindow::create(); + g_assert(mainWindow); + + m = pa_glib_mainloop_new(g_main_context_default()); + g_assert(m); + mainloop_api = pa_glib_mainloop_get_api(m); + g_assert(mainloop_api); + + create_connection(); + + Gtk::Main::run(*mainWindow); + +quit: + if (serverInfoManager) + delete serverInfoManager; + + if (context) + pa_context_unref(context); + + mainloop_api = NULL; + if (mainWindow) + delete mainWindow; + + pa_glib_mainloop_free(m); + + return 0; +} diff --git a/src/paman.glade b/src/paman.glade new file mode 100644 index 0000000..e8915e9 --- /dev/null +++ b/src/paman.glade @@ -0,0 +1,2600 @@ + + + + + + + 5 + True + Polypaudio Manager + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 500 + 400 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + + + + True + False + 5 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 5 + True + False + 5 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 10 + True + 5 + 2 + True + 5 + 10 + + + + True + <b>Host Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + <b>User Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + <b>Server Version:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + <b>Server Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 1 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Default Sample Type:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + + False + True + GTK_JUSTIFY_LEFT + False + True + 0 + 1 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + True + + False + True + GTK_JUSTIFY_LEFT + False + True + 0 + 0 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + + False + True + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-network + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Connect + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + False + + + + + False + True + + + + + + True + _Server Information + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 5 + True + False + 5 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 5 + + + + True + True + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-jump-to + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Open + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + False + + + + + False + True + + + + + + True + _Devices + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 5 + True + False + 5 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + False + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-jump-to + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Open + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + False + + + + + False + True + + + + + + True + _Clients + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 5 + True + False + 5 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 5 + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-jump-to + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Open + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + False + + + + + False + True + + + + + + True + _Modules + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + label36 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + 5 + Sink + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + True + False + 5 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 5 + True + False + 5 + + + + 5 + True + 8 + 2 + False + 5 + 10 + + + + True + <b>Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Description:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + <b>Monitor Source:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + <b>Owner Module:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + <b>Latency:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + <b>Sample Type:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + <b>Index:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + + + + + + + True + <b>Volume:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 7 + 8 + fill + + + + + + + True + False + 5 + + + + 40 + True + True + 100% + False + True + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 100 + True + True + False + GTK_POS_LEFT + 0 + GTK_UPDATE_DISCONTINUOUS + False + 147.692 0 500 10 100 20 + + + 0 + True + True + + + + + + True + Reset to 100%, i.e. normal volume + True + Reset + True + GTK_RELIEF_NONE + True + + + 0 + False + False + + + + + + True + Mute to 0%, i.e. turn this sink off + True + Mute + True + GTK_RELIEF_NONE + True + + + 0 + False + False + + + + + 1 + 2 + 7 + 8 + fill + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 6 + 7 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 5 + 6 + + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 0 + + + + True + True + True + To Owner Module + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + To Monitor Source + True + GTK_RELIEF_NORMAL + True + + + + + 0 + True + True + + + + + False + True + + + + + + True + Basic + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + True + + + + + + + + 5 + Source + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + True + False + 5 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 5 + True + False + 5 + + + + 5 + True + 6 + 2 + False + 5 + 10 + + + + True + <b>Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Description:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + <b>Sample Type:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + <b>Index:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + + + + + + + True + <b>Owner Module:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + <b>Monitor of Sink:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 5 + 6 + fill + + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 0 + + + + True + True + True + To Owner Module + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + To Parent Sink + True + GTK_RELIEF_NORMAL + True + + + + + 0 + True + True + + + + + False + True + + + + + + True + Basic + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + True + + + + + + + + Module + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + 5 + True + False + 5 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 5 + True + 5 + 2 + False + 5 + 10 + + + + True + <b>Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Autoloaded:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + label4724 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + label4725 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + <b>Usage Counter:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + label4727 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + foo + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + label4729 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + <b>Argument:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + <b>Index:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + False + True + + + + + + True + Basic + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + + + + Client + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + 5 + True + False + 5 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 5 + True + False + 5 + + + + True + 4 + 2 + False + 5 + 10 + + + + True + <b>Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Owner Module:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + label4725 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + label4727 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + foo + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + label4729 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + <b>Protocol:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + <b>Index:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 0 + + + + True + True + True + To Owner Module + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + False + True + + + + + + True + Basic + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + + + diff --git a/src/paman.gladep b/src/paman.gladep new file mode 100644 index 0000000..f50f504 --- /dev/null +++ b/src/paman.gladep @@ -0,0 +1,12 @@ + + + + + Paman + paman + FALSE + FALSE + FALSE + FALSE + FALSE + diff --git a/src/paman.hh b/src/paman.hh new file mode 100644 index 0000000..7f2127f --- /dev/null +++ b/src/paman.hh @@ -0,0 +1,15 @@ +#ifndef foopamanhhfoo +#define foopamanhhfoo + +#include "ServerInfo.hh" + +#define GLADE_FILE "paman.glade" + +extern ServerInfoManager *serverInfoManager; +extern MainWindow *mainWindow; +extern struct pa_context *context; + +void create_connection(); + + +#endif -- cgit