diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2018-11-21 11:06:51 +0200 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2018-11-21 11:40:02 +0200 |
commit | c760edaf24263c5f7772e4c32c064ec4ac5d1e4b (patch) | |
tree | de0df81ce1b4a6f1a985a799b477b9bafda7c4d7 /src | |
parent | d3b3bee3787523df31a885febb16da582d60f1aa (diff) |
move some widget initializations from MinimalStreamWidget to subclasses
Current Glade versions want object IDs to be unique, but currently
pavucontrol.glade shares some IDs between the top-level windows. I guess
this used to be OK in the past, and the "interface-naming-policy
toplevel-contextual" comment in the beginning of the .glade file
probably has something to do with this. I want to update the .glade file
to be easy to work with current Glade versions, so I will remove the
duplicated object IDs.
The first IDs to change are the "channelsVBox", "nameLabel",
"boldNameLabel" and "iconImage" IDs. These were used by
MinimalStreamWidget to create widgets for both devices and streams, but
now that the IDs are different for devices and streams, the widgets have
to be created by the subclasses.
MinimalStreamWidget doesn't need the Gtk::Builder in its constructor any
more, so remove that parameter to avoid warnings about an unused
variable.
Diffstat (limited to 'src')
-rw-r--r-- | src/devicewidget.cc | 10 | ||||
-rw-r--r-- | src/minimalstreamwidget.cc | 18 | ||||
-rw-r--r-- | src/minimalstreamwidget.h | 11 | ||||
-rw-r--r-- | src/pavucontrol.glade | 16 | ||||
-rw-r--r-- | src/streamwidget.cc | 10 |
5 files changed, 49 insertions, 16 deletions
diff --git a/src/devicewidget.cc b/src/devicewidget.cc index 18d6714..b4cf9dd 100644 --- a/src/devicewidget.cc +++ b/src/devicewidget.cc @@ -32,9 +32,15 @@ /*** DeviceWidget ***/ DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x) : - MinimalStreamWidget(cobject, x), + MinimalStreamWidget(cobject), offsetButtonEnabled(false) { + /* MinimalStreamWidget member variables. */ + x->get_widget("deviceChannelsVBox", channelsVBox); + x->get_widget("deviceNameLabel", nameLabel); + x->get_widget("deviceBoldNameLabel", boldNameLabel); + x->get_widget("deviceIconImage", iconImage); + x->get_widget("lockToggleButton", lockToggleButton); x->get_widget("muteToggleButton", muteToggleButton); x->get_widget("defaultToggleButton", defaultToggleButton); @@ -76,6 +82,8 @@ DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Buil void DeviceWidget::init(MainWindow* mainWindow, Glib::ustring deviceType) { mpMainWindow = mainWindow; mDeviceType = deviceType; + + MinimalStreamWidget::init(); } void DeviceWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) { diff --git a/src/minimalstreamwidget.cc b/src/minimalstreamwidget.cc index 02c6e4a..017b2ed 100644 --- a/src/minimalstreamwidget.cc +++ b/src/minimalstreamwidget.cc @@ -25,23 +25,31 @@ #include "minimalstreamwidget.h" /*** MinimalStreamWidget ***/ -MinimalStreamWidget::MinimalStreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x) : +MinimalStreamWidget::MinimalStreamWidget(BaseObjectType* cobject) : Gtk::VBox(cobject), + channelsVBox(NULL), + nameLabel(NULL), + boldNameLabel(NULL), + iconImage(NULL), peakProgressBar(), lastPeak(0), peak(NULL), updating(false), volumeMeterEnabled(false), volumeMeterVisible(true) { +} - x->get_widget("channelsVBox", channelsVBox); - x->get_widget("nameLabel", nameLabel); - x->get_widget("boldNameLabel", boldNameLabel); - x->get_widget("iconImage", iconImage); +void MinimalStreamWidget::init() { + /* Set up the peak meter. This is not done in the constructor, because + * channelsVBox is initialized by the subclasses, so it's not yet available + * in the constructor. */ peakProgressBar.set_size_request(-1, 10); channelsVBox->pack_end(peakProgressBar, false, false); + /* XXX: Why is the peak meter hidden by default? Maybe the idea is that if + * setting up the monitoring stream fails for whatever reason, then we + * shouldn't show the peak meter at all. */ peakProgressBar.hide(); } diff --git a/src/minimalstreamwidget.h b/src/minimalstreamwidget.h index e4f7e19..e5d774c 100644 --- a/src/minimalstreamwidget.h +++ b/src/minimalstreamwidget.h @@ -25,11 +25,15 @@ class MinimalStreamWidget : public Gtk::VBox { public: - MinimalStreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x); + MinimalStreamWidget(BaseObjectType* cobject); + /* Subclass constructors are expected to initialize these variables. + * MinimalStreamWidget can't initialize these, because the glade object + * id's depend on the subclass type. */ Gtk::VBox *channelsVBox; Gtk::Label *nameLabel, *boldNameLabel; Gtk::Image *iconImage; + Gtk::ProgressBar peakProgressBar; double lastPeak; pa_stream *peak; @@ -45,6 +49,11 @@ public: void updatePeak(double v); void setVolumeMeterVisible(bool v); +protected: + /* Subclasses must call this after the constructor to finalize the initial + * layout. */ + virtual void init(); + private : bool volumeMeterVisible; diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade index a9c86b2..c8497a1 100644 --- a/src/pavucontrol.glade +++ b/src/pavucontrol.glade @@ -222,7 +222,7 @@ <property name="can_focus">False</property> <property name="spacing">6</property> <child> - <object class="GtkImage" id="iconImage"> + <object class="GtkImage" id="deviceIconImage"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-missing-image</property> @@ -238,7 +238,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <child> - <object class="GtkLabel" id="boldNameLabel"> + <object class="GtkLabel" id="deviceBoldNameLabel"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="use_markup">True</property> @@ -250,7 +250,7 @@ </packing> </child> <child> - <object class="GtkLabel" id="nameLabel"> + <object class="GtkLabel" id="deviceNameLabel"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="xalign">0</property> @@ -393,7 +393,7 @@ </packing> </child> <child> - <object class="GtkVBox" id="channelsVBox"> + <object class="GtkVBox" id="deviceChannelsVBox"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> @@ -1437,7 +1437,7 @@ <property name="can_focus">False</property> <property name="spacing">6</property> <child> - <object class="GtkImage" id="iconImage"> + <object class="GtkImage" id="streamIconImage"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-missing-image</property> @@ -1454,7 +1454,7 @@ <property name="can_focus">False</property> <property name="spacing">2</property> <child> - <object class="GtkLabel" id="boldNameLabel"> + <object class="GtkLabel" id="streamBoldNameLabel"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="use_markup">True</property> @@ -1466,7 +1466,7 @@ </packing> </child> <child> - <object class="GtkLabel" id="nameLabel"> + <object class="GtkLabel" id="streamNameLabel"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="xalign">0</property> @@ -1583,7 +1583,7 @@ </packing> </child> <child> - <object class="GtkVBox" id="channelsVBox"> + <object class="GtkVBox" id="streamChannelsVBox"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> diff --git a/src/streamwidget.cc b/src/streamwidget.cc index 6085550..1682a70 100644 --- a/src/streamwidget.cc +++ b/src/streamwidget.cc @@ -30,9 +30,15 @@ /*** StreamWidget ***/ StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x) : - MinimalStreamWidget(cobject, x), + MinimalStreamWidget(cobject), mpMainWindow(NULL) { + /* MinimalStreamWidget member variables. */ + x->get_widget("streamChannelsVBox", channelsVBox); + x->get_widget("streamNameLabel", nameLabel); + x->get_widget("streamBoldNameLabel", boldNameLabel); + x->get_widget("streamIconImage", iconImage); + x->get_widget("lockToggleButton", lockToggleButton); x->get_widget("muteToggleButton", muteToggleButton); x->get_widget("directionLabel", directionLabel); @@ -55,6 +61,8 @@ StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Buil void StreamWidget::init(MainWindow* mainWindow) { mpMainWindow = mainWindow; + + MinimalStreamWidget::init(); } bool StreamWidget::onContextTriggerEvent(GdkEventButton* event) { |