summaryrefslogtreecommitdiffstats
path: root/src/MainWindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/MainWindow.cc')
-rw-r--r--src/MainWindow.cc127
1 files changed, 120 insertions, 7 deletions
diff --git a/src/MainWindow.cc b/src/MainWindow.cc
index ae6836c..6e2dbe2 100644
--- a/src/MainWindow.cc
+++ b/src/MainWindow.cc
@@ -30,13 +30,17 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
deviceOpenButton(NULL),
clientOpenButton(NULL),
moduleOpenButton(NULL),
+ sampleOpenButton(NULL),
+ samplePlayButton(NULL),
connectButton(NULL),
disconnectButton(NULL),
statButton(NULL),
deviceTreeView(NULL),
clientTreeView(NULL),
moduleTreeView(NULL),
- titleEventBox(NULL) {
+ sampleTreeView(NULL),
+ titleEventBox(NULL),
+ sinkComboBox(NULL) {
refGlade->get_widget("statusLabel", statusLabel);
refGlade->get_widget("serverNameLabel", serverNameLabel);
@@ -48,15 +52,19 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
refGlade->get_widget("deviceTreeView", deviceTreeView);
refGlade->get_widget("clientTreeView", clientTreeView);
refGlade->get_widget("moduleTreeView", moduleTreeView);
+ refGlade->get_widget("sampleCacheTreeView", sampleTreeView);
refGlade->get_widget("deviceOpenButton", deviceOpenButton);
refGlade->get_widget("clientOpenButton", clientOpenButton);
refGlade->get_widget("moduleOpenButton", moduleOpenButton);
+ refGlade->get_widget("sampleCacheOpenButton", sampleOpenButton);
+ refGlade->get_widget("sampleCachePlayButton", samplePlayButton);
refGlade->get_widget("connectButton", connectButton);
refGlade->get_widget("disconnectButton", disconnectButton);
refGlade->get_widget("linkLibraryVersionLabel", linkLibraryVersionLabel);
refGlade->get_widget("compiledLibraryVersionLabel", compiledLibraryVersionLabel);
refGlade->get_widget("statButton", statButton);
refGlade->get_widget("titleEventBox", titleEventBox);
+ refGlade->get_widget("sinkComboBox", sinkComboBox);
deviceTreeStore = Gtk::TreeStore::create(deviceTreeModelColumns);
deviceTreeView->set_model(deviceTreeStore);
@@ -75,12 +83,23 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
moduleTreeView->append_column("Name", moduleTreeModelColumns.name);
moduleTreeView->append_column("Argument", moduleTreeModelColumns.argument);
moduleTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onModuleTreeViewRowActivated));
-
+
+ sampleTreeStore = Gtk::TreeStore::create(sampleTreeModelColumns);
+ sampleTreeView->set_model(sampleTreeStore);
+ sampleTreeView->append_column("Name", sampleTreeModelColumns.name);
+ sampleTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onSampleTreeViewRowActivated));
+
+ sinkListStore = Gtk::ListStore::create(sinkTreeModelColumns);
+ sinkComboBox->set_model(sinkListStore);
+// sinkComboBox->append_column("Name", sinkTreeModelColumns.name);
+
connectButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onConnectButton));
disconnectButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onDisconnectButton));
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));
+ sampleOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onSampleOpenButton));
+ samplePlayButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onSamplePlayButton));
statButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onStatButton));
linkLibraryVersionLabel->set_text(pa_get_library_version());
@@ -119,6 +138,20 @@ void MainWindow::updateInfo(SinkInfo &i) {
deviceTreeView->expand_row(sinkRef.get_path(), false);
onDeviceTreeViewCursorChanged();
+
+ if (!i.sinkComboBoxTreeRef)
+ i.sinkComboBoxTreeRef = Gtk::TreeRowReference(sinkListStore, Gtk::TreePath(sinkListStore->append()));
+
+ row = *(sinkListStore->get_iter(i.sinkComboBoxTreeRef.get_path()));
+ row[sinkTreeModelColumns.name] = i.name;
+ row[sinkTreeModelColumns.index] = i.index;
+
+ if (sinkComboBox->get_active_row_number() == -1)
+ sinkComboBox->set_active(0);
+
+ bool b = !sampleTreeStore->children().empty();
+ sinkComboBox->set_sensitive(b);
+ samplePlayButton->set_sensitive(b);
}
void MainWindow::updateInfo(SourceInfo &i) {
@@ -197,11 +230,32 @@ void MainWindow::updateInfo(SourceOutputInfo &i) {
onDeviceTreeViewCursorChanged();
}
+void MainWindow::updateInfo(SampleInfo &i) {
+ if (!i.treeRef)
+ i.treeRef = Gtk::TreeRowReference(sampleTreeStore, Gtk::TreePath(sampleTreeStore->append()));
+
+ Gtk::TreeRow row = *(sampleTreeStore->get_iter(i.treeRef.get_path()));
+ row[sampleTreeModelColumns.name] = i.name;
+ row[sampleTreeModelColumns.index] = i.index;
+ sampleOpenButton->set_sensitive(true);
+
+ bool b = !sinkListStore->children().empty();
+ samplePlayButton->set_sensitive(b);
+ sinkComboBox->set_sensitive(b);
+}
+
void MainWindow::removeInfo(SinkInfo &i) {
if (i.treeRef)
deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path()));
-
+
onDeviceTreeViewCursorChanged();
+
+ if (i.sinkComboBoxTreeRef)
+ sinkListStore->erase(sinkListStore->get_iter(i.sinkComboBoxTreeRef.get_path()));
+
+ bool b = !sinkListStore->children().empty() && !sampleTreeStore->children().empty();
+ samplePlayButton->set_sensitive(b);
+ sinkComboBox->set_sensitive(b);
}
void MainWindow::removeInfo(SourceInfo &i) {
@@ -233,13 +287,23 @@ void MainWindow::removeInfo(SinkInputInfo &i) {
}
void MainWindow::removeInfo(SourceOutputInfo &i) {
-
if (i.treeRef)
deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path()));
onDeviceTreeViewCursorChanged();
}
+void MainWindow::removeInfo(SampleInfo &i) {
+ if (i.treeRef)
+ sampleTreeStore->erase(sampleTreeStore->get_iter(i.treeRef.get_path()));
+
+ sampleOpenButton->set_sensitive(!sampleTreeStore->children().empty());
+
+ bool b = !sinkListStore->children().empty() && !sampleTreeStore->children().empty();
+ samplePlayButton->set_sensitive(b);
+ sinkComboBox->set_sensitive(b);
+}
+
void MainWindow::onDeviceTreeViewCursorChanged() {
Gtk::TreeModel::Path p;
Gtk::TreeViewColumn *c;
@@ -263,6 +327,10 @@ void MainWindow::onModuleTreeViewRowActivated(const Gtk::TreeModel::Path& path,
showModuleWindow(path);
}
+void MainWindow::onSampleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) {
+ showSampleWindow(path);
+}
+
void MainWindow::updateInfo(const struct pa_server_info &i) {
char t[PA_SAMPLE_SNPRINT_MAX_LENGTH];
serverNameLabel->set_text(i.server_name);
@@ -300,10 +368,15 @@ void MainWindow::clearAllData() {
clientTreeStore->clear();
moduleTreeStore->clear();
+ sampleTreeStore->clear();
+ sinkListStore->clear();
deviceOpenButton->set_sensitive(false);
clientOpenButton->set_sensitive(false);
moduleOpenButton->set_sensitive(false);
+ sampleOpenButton->set_sensitive(false);
+ samplePlayButton->set_sensitive(false);
+ sinkComboBox->set_sensitive(false);
serverNameLabel->set_markup("<i>n/a</i>");
serverVersionLabel->set_markup("<i>n/a</i>");
@@ -316,21 +389,36 @@ void MainWindow::onDeviceOpenButton() {
Gtk::TreeModel::Path p;
Gtk::TreeViewColumn *c;
deviceTreeView->get_cursor(p, c);
- showDeviceWindow(p);
+
+ if (p.gobj())
+ showDeviceWindow(p);
}
void MainWindow::onClientOpenButton() {
Gtk::TreeModel::Path p;
Gtk::TreeViewColumn *c;
clientTreeView->get_cursor(p, c);
- showClientWindow(p);
+
+ if (p.gobj())
+ showClientWindow(p);
}
void MainWindow::onModuleOpenButton() {
Gtk::TreeModel::Path p;
Gtk::TreeViewColumn *c;
moduleTreeView->get_cursor(p, c);
- showModuleWindow(p);
+
+ if (p.gobj())
+ showModuleWindow(p);
+}
+
+void MainWindow::onSampleOpenButton() {
+ Gtk::TreeModel::Path p;
+ Gtk::TreeViewColumn *c;
+ sampleTreeView->get_cursor(p, c);
+
+ if (p.gobj())
+ showSampleWindow(p);
}
void MainWindow::onConnectButton() {
@@ -373,9 +461,34 @@ void MainWindow::showModuleWindow(const Gtk::TreePath &p) {
serverInfoManager->showModuleWindow(row[moduleTreeModelColumns.index]);
}
+void MainWindow::showSampleWindow(const Gtk::TreePath &p) {
+ if (!serverInfoManager)
+ return;
+
+ Gtk::TreeModel::Row row = *(sampleTreeStore->get_iter(p));
+ serverInfoManager->showSampleWindow(row[sampleTreeModelColumns.index]);
+}
+
void MainWindow::onStatButton() {
if (!serverInfoManager)
return;
serverInfoManager->showStatWindow();
}
+
+void MainWindow::onSamplePlayButton() {
+ Gtk::TreeModel::Path p;
+ Gtk::TreeViewColumn *c;
+ sampleTreeView->get_cursor(p, c);
+
+ if (!p.gobj())
+ return;
+
+ Gtk::TreeModel::Row sampleRow = *(sampleTreeStore->get_iter(p));
+ Gtk::TreeModel::Row sinkRow = *sinkComboBox->get_active();
+
+ uint32_t sampleIndex = sampleRow[sampleTreeModelColumns.index];
+ uint32_t sinkIndex = sinkRow[sinkTreeModelColumns.index];
+
+ serverInfoManager->playSample(sampleIndex, sinkIndex);
+}