show an watch cursor while loading device data

git-svn-id: file:///home/lennart/svn/public/pavucontrol/trunk@39 c17c95f2-f111-0410-90bf-f30a9569010c
This commit is contained in:
Lennart Poettering 2006-08-07 13:50:02 +00:00
parent 8a5e95797f
commit 6649ebede6
1 changed files with 31 additions and 4 deletions

View File

@ -36,6 +36,7 @@
#endif #endif
static pa_context *context = NULL; static pa_context *context = NULL;
static int n_outstanding = 0;
enum SinkType { enum SinkType {
SINK_ALL, SINK_ALL,
@ -165,6 +166,9 @@ public:
virtual void onSourceTypeComboBoxChanged(); virtual void onSourceTypeComboBoxChanged();
void updateDeviceVisibility(); void updateDeviceVisibility();
protected:
virtual void on_realize();
}; };
void show_error(const char *txt) { void show_error(const char *txt) {
@ -433,6 +437,12 @@ MainWindow* MainWindow::create() {
return w; return w;
} }
void MainWindow::on_realize() {
Gtk::Window::on_realize();
get_window()->set_cursor(Gdk::Cursor(Gdk::WATCH));
}
MainWindow::~MainWindow() { MainWindow::~MainWindow() {
for (std::map<int, char*>::iterator i = clientNames.begin(); i != clientNames.end(); ++i) for (std::map<int, char*>::iterator i = clientNames.begin(); i != clientNames.end(); ++i)
g_free(i->second); g_free(i->second);
@ -632,11 +642,20 @@ void MainWindow::onSourceTypeComboBoxChanged() {
updateDeviceVisibility(); updateDeviceVisibility();
} }
static void dec_outstanding(MainWindow *w) {
assert(n_outstanding > 0);
if (--n_outstanding <= 0)
w->get_window()->set_cursor();
}
void sink_cb(pa_context *, const pa_sink_info *i, int eol, void *userdata) { void sink_cb(pa_context *, const pa_sink_info *i, int eol, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata); MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol) if (eol) {
dec_outstanding(w);
return; return;
}
if (!i) { if (!i) {
show_error("Sink callback failure"); show_error("Sink callback failure");
@ -649,8 +668,10 @@ void sink_cb(pa_context *, const pa_sink_info *i, int eol, void *userdata) {
void source_cb(pa_context *, const pa_source_info *i, int eol, void *userdata) { void source_cb(pa_context *, const pa_source_info *i, int eol, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata); MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol) if (eol) {
dec_outstanding(w);
return; return;
}
if (!i) { if (!i) {
show_error("Source callback failure"); show_error("Source callback failure");
@ -663,8 +684,10 @@ void source_cb(pa_context *, const pa_source_info *i, int eol, void *userdata) {
void sink_input_cb(pa_context *, const pa_sink_input_info *i, int eol, void *userdata) { void sink_input_cb(pa_context *, const pa_sink_input_info *i, int eol, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata); MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol) if (eol) {
dec_outstanding(w);
return; return;
}
if (!i) { if (!i) {
show_error("Sink input callback failure"); show_error("Sink input callback failure");
@ -677,8 +700,10 @@ void sink_input_cb(pa_context *, const pa_sink_input_info *i, int eol, void *use
void client_cb(pa_context *, const pa_client_info *i, int eol, void *userdata) { void client_cb(pa_context *, const pa_client_info *i, int eol, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata); MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol) if (eol) {
dec_outstanding(w);
return; return;
}
if (!i) { if (!i) {
show_error("Client callback failure"); show_error("Client callback failure");
@ -789,6 +814,8 @@ void context_state_callback(pa_context *c, void *userdata) {
return; return;
} }
pa_operation_unref(o); pa_operation_unref(o);
n_outstanding = 4;
break; break;
} }