Restructure the class inheritance a bit.

This just shuffles around the streamwidget a bit. The RoleWidget child class is the
exception, so try and gear things around SinkInput/SourceOutput widgets more to
save repeating the same code too much.
This commit is contained in:
Colin Guthrie 2009-06-28 16:38:39 +01:00
parent ac052e1a30
commit f1a23af603
8 changed files with 39 additions and 52 deletions

View File

@ -43,6 +43,10 @@ RoleWidget* RoleWidget::create() {
return w;
}
bool RoleWidget::onContextTriggerEvent(GdkEventButton*) {
return false;
}
void RoleWidget::onMuteToggleButton() {
StreamWidget::onMuteToggleButton();

View File

@ -35,6 +35,7 @@ public:
virtual void onMuteToggleButton();
virtual void executeVolumeUpdate();
virtual bool onContextTriggerEvent(GdkEventButton*);
};
#endif

View File

@ -29,21 +29,13 @@
#include "i18n.h"
SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
StreamWidget(cobject, x),
mpMainWindow(NULL) {
StreamWidget(cobject, x) {
gchar *txt;
directionLabel->set_label(txt = g_markup_printf_escaped("<i>%s</i>", _("on")));
g_free(txt);
terminate.set_label(_("Terminate Playback"));
terminate.signal_activate().connect(sigc::mem_fun(*this, &SinkInputWidget::onKill));
contextMenu.append(terminate);
contextMenu.show_all();
}
void SinkInputWidget::init(MainWindow* mainWindow) {
mpMainWindow = mainWindow;
}
SinkInputWidget* SinkInputWidget::create(MainWindow* mainWindow) {
@ -99,15 +91,6 @@ void SinkInputWidget::onMuteToggleButton() {
pa_operation_unref(o);
}
bool SinkInputWidget::onContextTriggerEvent(GdkEventButton* event) {
if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
contextMenu.popup(event->button, event->time);
return true;
}
return false;
}
void SinkInputWidget::onKill() {
pa_operation* o;
if (!(o = pa_context_kill_sink_input(get_context(), index, NULL, NULL))) {

View File

@ -33,8 +33,6 @@ public:
static SinkInputWidget* create(MainWindow* mainWindow);
~SinkInputWidget(void);
void init(MainWindow* mainWindow);
SinkInputType type;
uint32_t index, clientIndex;
@ -42,17 +40,12 @@ public:
uint32_t sinkIndex();
virtual void executeVolumeUpdate();
virtual void onDeviceChangePopup();
virtual bool onContextTriggerEvent(GdkEventButton*);
virtual void onMuteToggleButton();
virtual void onKill();
private:
MainWindow *mpMainWindow;
uint32_t mSinkIndex;
Gtk::Menu contextMenu;
Gtk::MenuItem terminate;
void clearMenu();
void buildMenu();

View File

@ -29,21 +29,13 @@
#include "i18n.h"
SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
StreamWidget(cobject, x),
mpMainWindow(NULL) {
StreamWidget(cobject, x) {
gchar *txt;
directionLabel->set_label(txt = g_markup_printf_escaped("<i>%s</i>", _("from")));
g_free(txt);
terminate.set_label(_("Terminate Recording"));
terminate.signal_activate().connect(sigc::mem_fun(*this, &SourceOutputWidget::onKill));
contextMenu.append(terminate);
contextMenu.show_all();
}
void SourceOutputWidget::init(MainWindow* mainWindow) {
mpMainWindow = mainWindow;
}
SourceOutputWidget* SourceOutputWidget::create(MainWindow* mainWindow) {
@ -73,15 +65,6 @@ uint32_t SourceOutputWidget::sourceIndex() {
return mSourceIndex;
}
bool SourceOutputWidget::onContextTriggerEvent(GdkEventButton* event) {
if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
contextMenu.popup(event->button, event->time);
return true;
}
return false;
}
void SourceOutputWidget::onKill() {
pa_operation* o;
if (!(o = pa_context_kill_source_output(get_context(), index, NULL, NULL))) {

View File

@ -33,24 +33,17 @@ public:
static SourceOutputWidget* create(MainWindow* mainWindow);
~SourceOutputWidget(void);
void init(MainWindow* mainWindow);
SourceOutputType type;
uint32_t index, clientIndex;
void setSourceIndex(uint32_t idx);
uint32_t sourceIndex();
virtual void onDeviceChangePopup();
virtual bool onContextTriggerEvent(GdkEventButton*);
virtual void onKill();
private:
MainWindow *mpMainWindow;
uint32_t mSourceIndex;
Gtk::Menu contextMenu;
Gtk::MenuItem terminate;
void clearMenu();
void buildMenu();

View File

@ -23,11 +23,15 @@
#endif
#include "streamwidget.h"
#include "mainwindow.h"
#include "channelwidget.h"
#include "i18n.h"
/*** StreamWidget ***/
StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
MinimalStreamWidget(cobject, x) {
MinimalStreamWidget(cobject, x),
mpMainWindow(NULL) {
x->get_widget("lockToggleButton", lockToggleButton);
x->get_widget("muteToggleButton", muteToggleButton);
@ -38,12 +42,25 @@ StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Gl
muteToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &StreamWidget::onMuteToggleButton));
deviceButton->signal_clicked().connect(sigc::mem_fun(*this, &StreamWidget::onDeviceChangePopup));
terminate.set_label(_("Terminate"));
terminate.signal_activate().connect(sigc::mem_fun(*this, &StreamWidget::onKill));
contextMenu.append(terminate);
contextMenu.show_all();
for (unsigned i = 0; i < PA_CHANNELS_MAX; i++)
channelWidgets[i] = NULL;
}
bool StreamWidget::onContextTriggerEvent(GdkEventButton*) {
void StreamWidget::init(MainWindow* mainWindow) {
mpMainWindow = mainWindow;
}
bool StreamWidget::onContextTriggerEvent(GdkEventButton* event) {
if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
contextMenu.popup(event->button, event->time);
return true;
}
return false;
}
@ -111,3 +128,6 @@ void StreamWidget::executeVolumeUpdate() {
void StreamWidget::onDeviceChangePopup() {
}
void StreamWidget::onKill() {
}

View File

@ -25,11 +25,13 @@
#include "minimalstreamwidget.h"
class MainWindow;
class ChannelWidget;
class StreamWidget : public MinimalStreamWidget {
public:
StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
void init(MainWindow* mainWindow);
void setChannelMap(const pa_channel_map &m, bool can_decibel);
void setVolume(const pa_cvolume &volume, bool force = false);
@ -53,6 +55,14 @@ public:
bool timeoutEvent();
virtual void executeVolumeUpdate();
virtual void onKill();
protected:
MainWindow* mpMainWindow;
Gtk::Menu contextMenu;
Gtk::MenuItem terminate;
};
#endif