diff options
author | Colin Guthrie <cguthrie@mandriva.org> | 2009-06-28 16:38:39 +0100 |
---|---|---|
committer | Colin Guthrie <cguthrie@mandriva.org> | 2009-06-28 16:38:39 +0100 |
commit | f1a23af603dfb250c10f8a4ec6a6f9acbd80d972 (patch) | |
tree | 09cf272b4870b6d33085d2d4b1d9b4ad3dd5aec3 | |
parent | ac052e1a30d1aeb7c514f9dd4eb8e6fb50382185 (diff) |
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.
-rw-r--r-- | src/rolewidget.cc | 4 | ||||
-rw-r--r-- | src/rolewidget.h | 1 | ||||
-rw-r--r-- | src/sinkinputwidget.cc | 19 | ||||
-rw-r--r-- | src/sinkinputwidget.h | 7 | ||||
-rw-r--r-- | src/sourceoutputwidget.cc | 19 | ||||
-rw-r--r-- | src/sourceoutputwidget.h | 7 | ||||
-rw-r--r-- | src/streamwidget.cc | 24 | ||||
-rw-r--r-- | src/streamwidget.h | 10 |
8 files changed, 39 insertions, 52 deletions
diff --git a/src/rolewidget.cc b/src/rolewidget.cc index 4da818f..31be005 100644 --- a/src/rolewidget.cc +++ b/src/rolewidget.cc @@ -43,6 +43,10 @@ RoleWidget* RoleWidget::create() { return w; } +bool RoleWidget::onContextTriggerEvent(GdkEventButton*) { + return false; +} + void RoleWidget::onMuteToggleButton() { StreamWidget::onMuteToggleButton(); diff --git a/src/rolewidget.h b/src/rolewidget.h index bbd39d6..c7b198c 100644 --- a/src/rolewidget.h +++ b/src/rolewidget.h @@ -35,6 +35,7 @@ public: virtual void onMuteToggleButton(); virtual void executeVolumeUpdate(); + virtual bool onContextTriggerEvent(GdkEventButton*); }; #endif diff --git a/src/sinkinputwidget.cc b/src/sinkinputwidget.cc index f956885..76d865f 100644 --- a/src/sinkinputwidget.cc +++ b/src/sinkinputwidget.cc @@ -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))) { diff --git a/src/sinkinputwidget.h b/src/sinkinputwidget.h index bab7f4b..11893ff 100644 --- a/src/sinkinputwidget.h +++ b/src/sinkinputwidget.h @@ -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(); diff --git a/src/sourceoutputwidget.cc b/src/sourceoutputwidget.cc index 19290f0..cb995b5 100644 --- a/src/sourceoutputwidget.cc +++ b/src/sourceoutputwidget.cc @@ -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))) { diff --git a/src/sourceoutputwidget.h b/src/sourceoutputwidget.h index 162551f..0b88d06 100644 --- a/src/sourceoutputwidget.h +++ b/src/sourceoutputwidget.h @@ -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(); diff --git a/src/streamwidget.cc b/src/streamwidget.cc index 3a76d1a..8817515 100644 --- a/src/streamwidget.cc +++ b/src/streamwidget.cc @@ -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() { +} diff --git a/src/streamwidget.h b/src/streamwidget.h index 7c052ad..e322fc3 100644 --- a/src/streamwidget.h +++ b/src/streamwidget.h @@ -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 |