summaryrefslogtreecommitdiffstats
path: root/src/paman.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/paman.cc')
-rw-r--r--src/paman.cc32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/paman.cc b/src/paman.cc
index 4b9b364..f08be5d 100644
--- a/src/paman.cc
+++ b/src/paman.cc
@@ -39,6 +39,8 @@ static void context_state_callback(struct pa_context *c, void *userdata) {
mainWindow->showSuccess("Ready");
g_assert(!serverInfoManager);
serverInfoManager = new ServerInfoManager(*c);
+ mainWindow->statButton->set_sensitive(true);
+ mainWindow->disconnectButton->set_sensitive(true);
return;
case PA_CONTEXT_TERMINATED:
@@ -52,21 +54,27 @@ static void context_state_callback(struct pa_context *c, void *userdata) {
}
- if (context) {
- pa_context_unref(context);
- context = NULL;
- }
+ killConnection();
+}
+void createConnection() {
if (serverInfoManager) {
delete serverInfoManager;
serverInfoManager = NULL;
}
- mainWindow->connectButton->set_sensitive(true);
- mainWindow->clearAllData();
+ if (context) {
+ pa_context_unref(context);
+ context = NULL;
+ }
+
+ context = pa_context_new(mainloop_api, "Polypaudio Manager");
+ g_assert(context);
+ pa_context_set_state_callback(context, context_state_callback, NULL);
+ pa_context_connect(context, NULL);
}
-void create_connection() {
+void killConnection() {
if (serverInfoManager) {
delete serverInfoManager;
serverInfoManager = NULL;
@@ -77,10 +85,10 @@ void create_connection() {
context = NULL;
}
- context = pa_context_new(mainloop_api, "Polypaudio Manager");
- g_assert(context);
- pa_context_set_state_callback(context, context_state_callback, NULL);
- pa_context_connect(context, NULL);
+ mainWindow->connectButton->set_sensitive(true);
+ mainWindow->disconnectButton->set_sensitive(false);
+ mainWindow->statButton->set_sensitive(false);
+ mainWindow->clearAllData();
}
int main(int argc, char *argv[]) {
@@ -98,7 +106,7 @@ int main(int argc, char *argv[]) {
mainloop_api = pa_glib_mainloop_get_api(m);
g_assert(mainloop_api);
- create_connection();
+ createConnection();
Gtk::Main::run(*mainWindow);