[pulseaudio-commits] 2 commits - src/mainwindow.cc src/mainwindow.h src/pavucontrol.cc src/pavucontrol.glade
Colin Guthrie
colin at kemper.freedesktop.org
Mon Jun 6 03:19:35 PDT 2011
src/mainwindow.cc | 43 +++++++++++++++++++++++++++++++++++++++++++
src/mainwindow.h | 3 +++
src/pavucontrol.cc | 33 ++++++++++++++++++++++++++-------
src/pavucontrol.glade | 2 +-
4 files changed, 73 insertions(+), 8 deletions(-)
New commits:
commit 53c38faa8a792a077dbc4c23219ee703e5fa3c8c
Author: Colin Guthrie <colin at mageia.org>
Date: Mon Jun 6 12:07:26 2011 +0200
Handle simple key events.
* Use ctrl+w or ctrl+q or esc to quit.
* Uset ctrl+1-5 to change tabs.
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 6a7e04c..ac41831 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -159,6 +159,39 @@ void MainWindow::on_realize() {
#endif /* HAVE_GTK3 */
}
+bool MainWindow::on_key_press_event(GdkEventKey* event) {
+
+ if (GDK_KEY_Escape == event->keyval) {
+ Gtk::Main::quit();
+ return true;
+ }
+ if (event->state & GDK_CONTROL_MASK) {
+ switch (event->keyval) {
+ case GDK_KEY_KP_1:
+ case GDK_KEY_KP_2:
+ case GDK_KEY_KP_3:
+ case GDK_KEY_KP_4:
+ case GDK_KEY_KP_5:
+ notebook->set_current_page(event->keyval - GDK_KEY_KP_1);
+ return true;
+ case GDK_KEY_1:
+ case GDK_KEY_2:
+ case GDK_KEY_3:
+ case GDK_KEY_4:
+ case GDK_KEY_5:
+ notebook->set_current_page(event->keyval - GDK_KEY_1);
+ return true;
+ case GDK_KEY_W:
+ case GDK_KEY_Q:
+ case GDK_KEY_w:
+ case GDK_KEY_q:
+ Gtk::Main::quit();
+ return true;
+ }
+ }
+ return Gtk::Window::on_key_press_event(event);
+}
+
MainWindow::~MainWindow() {
GKeyFile* config = g_key_file_new();
g_assert(config);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index bad9e47..559b639 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -100,6 +100,7 @@ public:
protected:
virtual void on_realize();
+ virtual bool on_key_press_event(GdkEventKey* event);
private:
gboolean m_connected;
commit 933b8a7009f72bccb378ed018a6578ccd443e748
Author: Colin Guthrie <colin at mageia.org>
Date: Mon Jun 6 11:28:45 2011 +0200
Deal more gracefully with disconnections.
As pavucontrol is often used for debugging PA, it should
be quite robust and not popup messages etc. under 'normal'
testing conditions. This adds quite a verbose message under
some specific conditions that do crop up from time to time.
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 6d629ad..6a7e04c 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -967,6 +967,16 @@ void MainWindow::removeAllWidgets() {
deleteEventRoleWidget();
}
+void MainWindow::setConnectingMessage(const char *string) {
+ Glib::ustring markup = "<i>";
+ if (!string)
+ markup += _("Establishing connection to PulseAudio. Please wait...");
+ else
+ markup += string;
+ markup += "</i>";
+ connectingLabel->set_markup(markup);
+}
+
void MainWindow::onSinkTypeComboBoxChanged() {
showSinkType = (SinkType) sinkTypeComboBox->get_active_row_number();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 87a0898..bad9e47 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -57,6 +57,8 @@ public:
void removeAllWidgets();
+ void setConnectingMessage(const char *string = NULL);
+
Gtk::Notebook *notebook;
Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel, *connectingLabel;
diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index aa71b3e..4270fa7 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -46,6 +46,7 @@ static pa_context* context = NULL;
static pa_mainloop_api* api = NULL;
static int n_outstanding = 0;
static int default_tab = 0;
+static int reconnect_timeout = 1;
void show_error(const char *txt) {
char buf[256];
@@ -399,6 +400,8 @@ void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_READY: {
pa_operation *o;
+ reconnect_timeout = 1;
+
/* Create event widget immediately so it's first in the list */
w->createEventRoleWidget();
@@ -499,8 +502,6 @@ void context_state_callback(pa_context *c, void *userdata) {
}
case PA_CONTEXT_FAILED:
- g_debug(_("Connection failed, attempting reconnect"));
-
w->setConnectionState(false);
w->removeAllWidgets();
@@ -508,7 +509,10 @@ void context_state_callback(pa_context *c, void *userdata) {
pa_context_unref(context);
context = NULL;
- g_timeout_add_seconds(1, connect_to_pulse, w);
+ if (reconnect_timeout > 0) {
+ g_debug(_("Connection failed, attempting reconnect"));
+ g_timeout_add_seconds(reconnect_timeout, connect_to_pulse, w);
+ }
return;
case PA_CONTEXT_TERMINATED:
@@ -541,10 +545,21 @@ gboolean connect_to_pulse(gpointer userdata) {
pa_context_set_state_callback(context, context_state_callback, w);
+ w->setConnectingMessage();
if (pa_context_connect(context, NULL, PA_CONTEXT_NOFAIL, NULL) < 0) {
- show_error(_("Fatal Error: Unable to connect context"));
- Gtk::Main::quit();
- return false;
+ if (pa_context_errno(context) == PA_ERR_INVALID) {
+ w->setConnectingMessage(_("Connection to PulseAudio failed. Automatic retry in 5s\n\n"
+ "In this case this is likely because PULSE_SERVER in the Environment/X11 Root Window Properties\n"
+ "or default-server in client.conf is misconfigured.\n"
+ "This situation can also arrise when PulseAudio crashed and left stale details in the X11 Root Window.\n"
+ "If this is the case, then PulseAudio should autospawn again, or if this is not configured you should\n"
+ "run start-pulseaudio-x11 manually."));
+ reconnect_timeout = 5;
+ }
+ else {
+ reconnect_timeout = -1;
+ Gtk::Main::quit();
+ }
}
return false;
@@ -587,8 +602,12 @@ int main(int argc, char *argv[]) {
g_assert(api);
connect_to_pulse(mainWindow);
+ if (reconnect_timeout >= 0)
+ Gtk::Main::run(*mainWindow);
+
+ if (reconnect_timeout < 0)
+ show_error(_("Fatal Error: Unable to connect to PulseAudio"));
- Gtk::Main::run(*mainWindow);
delete mainWindow;
if (context)
diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade
index 3077a88..2e7afe8 100644
--- a/src/pavucontrol.glade
+++ b/src/pavucontrol.glade
@@ -1069,7 +1069,7 @@
<child>
<object class="GtkLabel" id="connectingLabel">
<property name="can_focus">False</property>
- <property name="label" translatable="yes"><i>Establishing connection to PulseAudio. Please wait...</i></property>
+ <property name="label" translatable="no">...</property>
<property name="use_markup">True</property>
</object>
<packing>
More information about the pulseaudio-commits
mailing list