2009-03-16 12:45:53 +00:00
|
|
|
/***
|
|
|
|
This file is part of pavucontrol.
|
|
|
|
|
|
|
|
Copyright 2006-2008 Lennart Poettering
|
|
|
|
Copyright 2009 Colin Guthrie
|
|
|
|
|
|
|
|
pavucontrol is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
pavucontrol is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with pavucontrol. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
|
2009-03-18 20:58:17 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2009-03-16 12:45:53 +00:00
|
|
|
#include "sourcewidget.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2011-03-03 14:31:14 +00:00
|
|
|
SourceWidget::SourceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x) :
|
2009-03-16 23:21:40 +00:00
|
|
|
DeviceWidget(cobject, x) {
|
2009-03-16 12:45:53 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 14:57:59 +00:00
|
|
|
SourceWidget* SourceWidget::create(MainWindow* mainWindow) {
|
2009-03-16 12:45:53 +00:00
|
|
|
SourceWidget* w;
|
2011-03-03 14:31:14 +00:00
|
|
|
Glib::RefPtr<Gtk::Builder> x = Gtk::Builder::create_from_file(GLADE_FILE, "deviceWidget");
|
2009-03-16 17:05:53 +00:00
|
|
|
x->get_widget_derived("deviceWidget", w);
|
2009-06-28 14:57:59 +00:00
|
|
|
w->init(mainWindow, "source");
|
2014-08-28 10:58:05 +00:00
|
|
|
w->reference();
|
2009-03-16 12:45:53 +00:00
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SourceWidget::executeVolumeUpdate() {
|
|
|
|
pa_operation* o;
|
|
|
|
|
|
|
|
if (!(o = pa_context_set_source_volume_by_index(get_context(), index, &volume, NULL, NULL))) {
|
|
|
|
show_error(_("pa_context_set_source_volume_by_index() failed"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pa_operation_unref(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SourceWidget::onMuteToggleButton() {
|
2009-03-16 17:05:53 +00:00
|
|
|
DeviceWidget::onMuteToggleButton();
|
2009-03-16 12:45:53 +00:00
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pa_operation* o;
|
|
|
|
if (!(o = pa_context_set_source_mute_by_index(get_context(), index, muteToggleButton->get_active(), NULL, NULL))) {
|
|
|
|
show_error(_("pa_context_set_source_mute_by_index() failed"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pa_operation_unref(o);
|
|
|
|
}
|
|
|
|
|
2009-03-16 23:21:40 +00:00
|
|
|
void SourceWidget::onDefaultToggleButton() {
|
2009-03-16 12:45:53 +00:00
|
|
|
pa_operation* o;
|
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(o = pa_context_set_default_source(get_context(), name.c_str(), NULL, NULL))) {
|
|
|
|
show_error(_("pa_context_set_default_source() failed"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pa_operation_unref(o);
|
|
|
|
}
|
2009-06-27 17:14:05 +00:00
|
|
|
|
|
|
|
void SourceWidget::onPortChange() {
|
|
|
|
Gtk::TreeModel::iterator iter;
|
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
|
|
|
|
|
|
|
iter = portList->get_active();
|
|
|
|
if (iter)
|
|
|
|
{
|
|
|
|
Gtk::TreeModel::Row row = *iter;
|
|
|
|
if (row)
|
|
|
|
{
|
|
|
|
pa_operation* o;
|
|
|
|
Glib::ustring port = row[portModel.name];
|
|
|
|
|
|
|
|
if (!(o = pa_context_set_source_port_by_index(get_context(), index, port.c_str(), NULL, NULL))) {
|
|
|
|
show_error(_("pa_context_set_source_port_by_index() failed"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pa_operation_unref(o);
|
|
|
|
}
|
|
|
|
}
|
2009-06-28 14:57:59 +00:00
|
|
|
}
|