From 7de18201a38fc8bee15e6ef162fb35d242e6d00b Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Tue, 20 Apr 2010 20:22:38 +0100 Subject: connection: Show a nice label when connecting to PA. --- src/mainwindow.cc | 21 ++++++++++++++++++++- src/mainwindow.h | 6 +++++- src/pavucontrol.cc | 7 +++++-- src/pavucontrol.glade | 9 +++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 7a831e8..7ada1ca 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -73,7 +73,8 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("cardsVBox", cardsVBox); x->get_widget("streamsVBox", streamsVBox); @@ -85,6 +86,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("noRecsLabel", noRecsLabel); x->get_widget("noSinksLabel", noSinksLabel); x->get_widget("noSourcesLabel", noSourcesLabel); + x->get_widget("connectingLabel", connectingLabel); x->get_widget("sinkInputTypeComboBox", sinkInputTypeComboBox); x->get_widget("sourceOutputTypeComboBox", sourceOutputTypeComboBox); x->get_widget("sinkTypeComboBox", sinkTypeComboBox); @@ -106,6 +108,10 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrsignal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceOutputTypeComboBoxChanged)); sinkTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkTypeComboBoxChanged)); sourceTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceTypeComboBoxChanged)); + + /* Hide first and show when we're connected */ + notebook->hide(); + connectingLabel->show(); } MainWindow* MainWindow::create() { @@ -720,6 +726,19 @@ gboolean idle_cb(gpointer data) { return FALSE; } +void MainWindow::setConnectionState(gboolean connected) { + if (m_connected != connected) { + m_connected = connected; + if (m_connected) { + connectingLabel->hide(); + notebook->show(); + } else { + notebook->hide(); + connectingLabel->show(); + } + } +} + void MainWindow::updateDeviceVisibility() { if (idle_source) diff --git a/src/mainwindow.h b/src/mainwindow.h index 92db272..1d2f4b0 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -59,7 +59,7 @@ public: Gtk::Notebook *notebook; Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox; - Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel; + Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel, *connectingLabel; Gtk::ComboBox *sinkInputTypeComboBox, *sourceOutputTypeComboBox, *sinkTypeComboBox, *sourceTypeComboBox; std::map cardWidgets; @@ -79,6 +79,7 @@ public: virtual void onSinkTypeComboBoxChanged(); virtual void onSourceTypeComboBoxChanged(); + void setConnectionState(gboolean connected); void updateDeviceVisibility(); void reallyUpdateDeviceVisibility(); void createMonitorStreamForSource(uint32_t source_idx); @@ -97,6 +98,9 @@ public: protected: virtual void on_realize(); + +private: + gboolean m_connected; }; diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc index 1dd0147..0ad020d 100644 --- a/src/pavucontrol.cc +++ b/src/pavucontrol.cc @@ -61,8 +61,10 @@ static void dec_outstanding(MainWindow *w) { if (n_outstanding <= 0) return; - if (--n_outstanding <= 0) + if (--n_outstanding <= 0) { w->get_window()->set_cursor(); + w->setConnectionState(true); + } } void card_cb(pa_context *, const pa_card_info *i, int eol, void *userdata) { @@ -492,6 +494,8 @@ void context_state_callback(pa_context *c, void *userdata) { case PA_CONTEXT_FAILED: g_debug(_("Connection failed, attempting reconnect")); + w->setConnectionState(false); + w->removeAllWidgets(); w->updateDeviceVisibility(); pa_context_unref(context); @@ -536,7 +540,6 @@ gboolean connect_to_pulse(gpointer userdata) { return false; } - g_debug(_("Initialised and connected our context")); return false; } diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade index 52fc6df..82aca34 100644 --- a/src/pavucontrol.glade +++ b/src/pavucontrol.glade @@ -484,6 +484,15 @@ Monitors 0 + + + <i>Establishing connection to PulseAudio. Please wait...</i> + True + + + 1 + + -- cgit