Set the mainwindow pointer via an init() method rather than directly via public member variable.
This allows us to perform other general initialisation task (such as setting the tree model on the device combo)
This commit is contained in:
parent
7b7a12f1d2
commit
d617c39a08
|
@ -469,12 +469,11 @@ void MainWindow::updateSinkInput(const pa_sink_input_info &info) {
|
||||||
if (sinkInputWidgets.count(info.index))
|
if (sinkInputWidgets.count(info.index))
|
||||||
w = sinkInputWidgets[info.index];
|
w = sinkInputWidgets[info.index];
|
||||||
else {
|
else {
|
||||||
sinkInputWidgets[info.index] = w = SinkInputWidget::create();
|
sinkInputWidgets[info.index] = w = SinkInputWidget::create(this);
|
||||||
w->setChannelMap(info.channel_map, true);
|
w->setChannelMap(info.channel_map, true);
|
||||||
streamsVBox->pack_start(*w, false, false, 0);
|
streamsVBox->pack_start(*w, false, false, 0);
|
||||||
w->index = info.index;
|
w->index = info.index;
|
||||||
w->clientIndex = info.client;
|
w->clientIndex = info.client;
|
||||||
w->mainWindow = this;
|
|
||||||
is_new = true;
|
is_new = true;
|
||||||
|
|
||||||
if (pa_context_get_server_protocol_version(get_context()) >= 13)
|
if (pa_context_get_server_protocol_version(get_context()) >= 13)
|
||||||
|
@ -521,11 +520,10 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) {
|
||||||
if (sourceOutputWidgets.count(info.index))
|
if (sourceOutputWidgets.count(info.index))
|
||||||
w = sourceOutputWidgets[info.index];
|
w = sourceOutputWidgets[info.index];
|
||||||
else {
|
else {
|
||||||
sourceOutputWidgets[info.index] = w = SourceOutputWidget::create();
|
sourceOutputWidgets[info.index] = w = SourceOutputWidget::create(this);
|
||||||
recsVBox->pack_start(*w, false, false, 0);
|
recsVBox->pack_start(*w, false, false, 0);
|
||||||
w->index = info.index;
|
w->index = info.index;
|
||||||
w->clientIndex = info.client;
|
w->clientIndex = info.client;
|
||||||
w->mainWindow = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w->updating = true;
|
w->updating = true;
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
|
SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
|
||||||
StreamWidget(cobject, x),
|
StreamWidget(cobject, x),
|
||||||
mainWindow(NULL),
|
|
||||||
titleMenuItem(_("_Move Stream..."), true),
|
titleMenuItem(_("_Move Stream..."), true),
|
||||||
killMenuItem(_("_Terminate Stream"), true) {
|
killMenuItem(_("_Terminate Stream"), true),
|
||||||
|
mpMainWindow(NULL) {
|
||||||
|
|
||||||
directionLabel->set_label(_("<i>Playing on </i> "));
|
directionLabel->set_label(_("<i>Playing on </i> "));
|
||||||
|
|
||||||
|
@ -45,14 +45,20 @@ SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gno
|
||||||
killMenuItem.signal_activate().connect(sigc::mem_fun(*this, &SinkInputWidget::onKill));
|
killMenuItem.signal_activate().connect(sigc::mem_fun(*this, &SinkInputWidget::onKill));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SinkInputWidget::init(MainWindow* mainWindow) {
|
||||||
|
mpMainWindow = mainWindow;
|
||||||
|
deviceCombo->set_model(mpMainWindow->sinkTree);
|
||||||
|
}
|
||||||
|
|
||||||
SinkInputWidget::~SinkInputWidget() {
|
SinkInputWidget::~SinkInputWidget() {
|
||||||
clearMenu();
|
clearMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
SinkInputWidget* SinkInputWidget::create() {
|
SinkInputWidget* SinkInputWidget::create(MainWindow* mainWindow) {
|
||||||
SinkInputWidget* w;
|
SinkInputWidget* w;
|
||||||
Glib::RefPtr<Gnome::Glade::Xml> x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget");
|
Glib::RefPtr<Gnome::Glade::Xml> x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget");
|
||||||
x->get_widget_derived("streamWidget", w);
|
x->get_widget_derived("streamWidget", w);
|
||||||
|
w->init(mainWindow);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +103,7 @@ void SinkInputWidget::clearMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinkInputWidget::buildMenu() {
|
void SinkInputWidget::buildMenu() {
|
||||||
for (std::map<uint32_t, SinkWidget*>::iterator i = mainWindow->sinkWidgets.begin(); i != mainWindow->sinkWidgets.end(); ++i) {
|
for (std::map<uint32_t, SinkWidget*>::iterator i = mpMainWindow->sinkWidgets.begin(); i != mpMainWindow->sinkWidgets.end(); ++i) {
|
||||||
SinkMenuItem *m;
|
SinkMenuItem *m;
|
||||||
sinkMenuItems[i->second->index] = m = new SinkMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == sinkIndex);
|
sinkMenuItems[i->second->index] = m = new SinkMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == sinkIndex);
|
||||||
submenu.append(m->menuItem);
|
submenu.append(m->menuItem);
|
||||||
|
|
|
@ -30,9 +30,11 @@ class MainWindow;
|
||||||
class SinkInputWidget : public StreamWidget {
|
class SinkInputWidget : public StreamWidget {
|
||||||
public:
|
public:
|
||||||
SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
|
SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
|
||||||
static SinkInputWidget* create();
|
static SinkInputWidget* create(MainWindow* mainWindow);
|
||||||
virtual ~SinkInputWidget();
|
virtual ~SinkInputWidget();
|
||||||
|
|
||||||
|
void init(MainWindow* mainWindow);
|
||||||
|
|
||||||
SinkInputType type;
|
SinkInputType type;
|
||||||
|
|
||||||
uint32_t index, clientIndex, sinkIndex;
|
uint32_t index, clientIndex, sinkIndex;
|
||||||
|
@ -42,7 +44,6 @@ public:
|
||||||
virtual void onKill();
|
virtual void onKill();
|
||||||
virtual void prepareMenu();
|
virtual void prepareMenu();
|
||||||
|
|
||||||
MainWindow *mainWindow;
|
|
||||||
Gtk::Menu submenu;
|
Gtk::Menu submenu;
|
||||||
Gtk::MenuItem titleMenuItem, killMenuItem;
|
Gtk::MenuItem titleMenuItem, killMenuItem;
|
||||||
|
|
||||||
|
@ -66,6 +67,10 @@ public:
|
||||||
|
|
||||||
void clearMenu();
|
void clearMenu();
|
||||||
void buildMenu();
|
void buildMenu();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MainWindow *mpMainWindow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
|
SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
|
||||||
StreamWidget(cobject, x),
|
StreamWidget(cobject, x),
|
||||||
mainWindow(NULL),
|
|
||||||
titleMenuItem(_("_Move Stream..."), true),
|
titleMenuItem(_("_Move Stream..."), true),
|
||||||
killMenuItem(_("_Terminate Stream"), true) {
|
killMenuItem(_("_Terminate Stream"), true),
|
||||||
|
mpMainWindow(NULL) {
|
||||||
|
|
||||||
directionLabel->set_label(_("<i>Recording from </i> "));
|
directionLabel->set_label(_("<i>Recording from </i> "));
|
||||||
|
|
||||||
|
@ -45,14 +45,20 @@ SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefP
|
||||||
killMenuItem.signal_activate().connect(sigc::mem_fun(*this, &SourceOutputWidget::onKill));
|
killMenuItem.signal_activate().connect(sigc::mem_fun(*this, &SourceOutputWidget::onKill));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SourceOutputWidget::init(MainWindow* mainWindow) {
|
||||||
|
mpMainWindow = mainWindow;
|
||||||
|
deviceCombo->set_model(mpMainWindow->sourceTree);
|
||||||
|
}
|
||||||
|
|
||||||
SourceOutputWidget::~SourceOutputWidget() {
|
SourceOutputWidget::~SourceOutputWidget() {
|
||||||
clearMenu();
|
clearMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceOutputWidget* SourceOutputWidget::create() {
|
SourceOutputWidget* SourceOutputWidget::create(MainWindow* mainWindow) {
|
||||||
SourceOutputWidget* w;
|
SourceOutputWidget* w;
|
||||||
Glib::RefPtr<Gnome::Glade::Xml> x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget");
|
Glib::RefPtr<Gnome::Glade::Xml> x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget");
|
||||||
x->get_widget_derived("streamWidget", w);
|
x->get_widget_derived("streamWidget", w);
|
||||||
|
w->init(mainWindow);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +82,7 @@ void SourceOutputWidget::clearMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceOutputWidget::buildMenu() {
|
void SourceOutputWidget::buildMenu() {
|
||||||
for (std::map<uint32_t, SourceWidget*>::iterator i = mainWindow->sourceWidgets.begin(); i != mainWindow->sourceWidgets.end(); ++i) {
|
for (std::map<uint32_t, SourceWidget*>::iterator i = mpMainWindow->sourceWidgets.begin(); i != mpMainWindow->sourceWidgets.end(); ++i) {
|
||||||
SourceMenuItem *m;
|
SourceMenuItem *m;
|
||||||
sourceMenuItems[i->second->index] = m = new SourceMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == sourceIndex);
|
sourceMenuItems[i->second->index] = m = new SourceMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == sourceIndex);
|
||||||
submenu.append(m->menuItem);
|
submenu.append(m->menuItem);
|
||||||
|
|
|
@ -30,16 +30,17 @@ class MainWindow;
|
||||||
class SourceOutputWidget : public StreamWidget {
|
class SourceOutputWidget : public StreamWidget {
|
||||||
public:
|
public:
|
||||||
SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
|
SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
|
||||||
static SourceOutputWidget* create();
|
static SourceOutputWidget* create(MainWindow* mainWindow);
|
||||||
virtual ~SourceOutputWidget();
|
virtual ~SourceOutputWidget();
|
||||||
|
|
||||||
|
void init(MainWindow* mainWindow);
|
||||||
|
|
||||||
SourceOutputType type;
|
SourceOutputType type;
|
||||||
|
|
||||||
uint32_t index, clientIndex, sourceIndex;
|
uint32_t index, clientIndex, sourceIndex;
|
||||||
virtual void onDeviceChange();
|
virtual void onDeviceChange();
|
||||||
virtual void onKill();
|
virtual void onKill();
|
||||||
|
|
||||||
MainWindow *mainWindow;
|
|
||||||
Gtk::Menu submenu;
|
Gtk::Menu submenu;
|
||||||
Gtk::MenuItem titleMenuItem, killMenuItem;
|
Gtk::MenuItem titleMenuItem, killMenuItem;
|
||||||
|
|
||||||
|
@ -64,6 +65,10 @@ public:
|
||||||
void clearMenu();
|
void clearMenu();
|
||||||
void buildMenu();
|
void buildMenu();
|
||||||
virtual void prepareMenu();
|
virtual void prepareMenu();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MainWindow *mpMainWindow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue