[pulseaudio-commits] [SCM] PulseAudio Volume Control branch, master, updated. v0.9.10-15-g870c3dd

Colin Guthrie gitmailer-noreply at 0pointer.de
Wed Apr 21 16:10:53 PDT 2010


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Volume Control" repository.

The master branch has been updated
      from  8959744e60d9561c2f824a7ce0b315d354e11718 (commit)

- Log -----------------------------------------------------------------
870c3dd mainwindow: Fix clearing out of clients
94add67 mainwindow: Save/restore window size
95e48d5 mainwindow: Compact iterator decls
9fe2020 main: Cleanup labels after connection rework
18c8945 source-outputs: Fix a bug where the 'no streams' label is sometimes shown along with the actual widget.
7de1820 connection: Show a nice label when connecting to PA.
84dc67b main: Automatically reconnect to PA upon disconnection
6c0bcb4 mainwindow: Add a method to remove all widgets (e.g. on disconnect)
b11f0b7 streamwidget: Fix a compile warning.
cbcdd0f Split out the creation of the PA context a little.
-----------------------------------------------------------------------

Summary of changes:
 src/mainwindow.cc     |   93 ++++++++++++++++++++++++++++++++++++++++++++++++-
 src/mainwindow.h      |    9 ++++-
 src/pavucontrol.cc    |   78 ++++++++++++++++++++++++++++-------------
 src/pavucontrol.glade |    9 +++++
 src/streamwidget.cc   |    4 +-
 5 files changed, 164 insertions(+), 29 deletions(-)

-----------------------------------------------------------------------

commit cbcdd0f49c0cdf570d2a4c90f8daf5f229e54bec
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Apr 20 19:06:01 2010 +0100

    Split out the creation of the PA context a little.
    
    This is a precursor to adding reconnection support.

diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index 867e523..f65298a 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -42,7 +42,8 @@
 #include "rolewidget.h"
 #include "mainwindow.h"
 
-static pa_context *context = NULL;
+static pa_context* context = NULL;
+static pa_mainloop_api* api = NULL;
 static int n_outstanding = 0;
 
 void show_error(const char *txt) {
@@ -386,6 +387,9 @@ void context_state_callback(pa_context *c, void *userdata) {
         case PA_CONTEXT_READY: {
             pa_operation *o;
 
+            /* Create event widget immediately so it's first in the list */
+            w->createEventRoleWidget();
+
             pa_context_set_subscribe_callback(c, subscribe_cb, w);
 
             if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t)
@@ -493,6 +497,25 @@ void context_state_callback(pa_context *c, void *userdata) {
     }
 }
 
+static pa_context* create_context(MainWindow* w) {
+    g_assert(api);
+
+    pa_proplist *proplist = pa_proplist_new();
+    pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, _("PulseAudio Volume Control"));
+    pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, "org.PulseAudio.pavucontrol");
+    pa_proplist_sets(proplist, PA_PROP_APPLICATION_ICON_NAME, "audio-card");
+    pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
+
+    pa_context* c = pa_context_new_with_proplist(api, NULL, proplist);
+    g_assert(c);
+
+    pa_proplist_free(proplist);
+
+    pa_context_set_state_callback(c, context_state_callback, w);
+
+    return c;
+}
+
 pa_context* get_context(void) {
   return context;
 }
@@ -512,27 +535,12 @@ int main(int argc, char *argv[]) {
 
     MainWindow* mainWindow = MainWindow::create();
 
-    /* Create event widget immediately so it's first in the list */
-    mainWindow->createEventRoleWidget();
-
-
     pa_glib_mainloop *m = pa_glib_mainloop_new(g_main_context_default());
     g_assert(m);
-    pa_mainloop_api *api = pa_glib_mainloop_get_api(m);
+    api = pa_glib_mainloop_get_api(m);
     g_assert(api);
 
-    pa_proplist *proplist = pa_proplist_new();
-    pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, _("PulseAudio Volume Control"));
-    pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, "org.PulseAudio.pavucontrol");
-    pa_proplist_sets(proplist, PA_PROP_APPLICATION_ICON_NAME, "audio-card");
-    pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
-
-    context = pa_context_new_with_proplist(api, NULL, proplist);
-    g_assert(context);
-
-    pa_proplist_free(proplist);
-
-    pa_context_set_state_callback(context, context_state_callback, mainWindow);
+    context = create_context(mainWindow);
 
     if (pa_context_connect(context, NULL, (pa_context_flags_t) 0, NULL) < 0)
         goto finish;

commit b11f0b72976ad3c757539291a22edf4750dac095
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Apr 20 19:46:30 2010 +0100

    streamwidget: Fix a compile warning.

diff --git a/src/streamwidget.cc b/src/streamwidget.cc
index 12c7d6d..c4ad15f 100644
--- a/src/streamwidget.cc
+++ b/src/streamwidget.cc
@@ -31,8 +31,8 @@
 /*** StreamWidget ***/
 StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
     MinimalStreamWidget(cobject, x),
-    mpMainWindow(NULL),
-    peak(NULL) {
+    peak(NULL),
+    mpMainWindow(NULL) {
 
     x->get_widget("lockToggleButton", lockToggleButton);
     x->get_widget("muteToggleButton", muteToggleButton);

commit 6c0bcb4c08d5ce96c8d5a498341a3a3bad8545fd
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Apr 20 20:00:37 2010 +0100

    mainwindow: Add a method to remove all widgets (e.g. on disconnect)

diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 99b9530..7a831e8 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -896,6 +896,35 @@ void MainWindow::removeClient(uint32_t index) {
     clientNames.erase(index);
 }
 
+void MainWindow::removeAllWidgets() {
+    {
+        std::map<uint32_t, SinkInputWidget*>::iterator it;
+        for (it = sinkInputWidgets.begin(); it != sinkInputWidgets.end(); ++it)
+            removeSinkInput(it->first);
+    }{
+        std::map<uint32_t, SourceOutputWidget*>::iterator it;
+        for (it = sourceOutputWidgets.begin(); it != sourceOutputWidgets.end(); ++it)
+            removeSourceOutput(it->first);
+    }{
+        std::map<uint32_t, SinkWidget*>::iterator it;
+        for (it = sinkWidgets.begin(); it != sinkWidgets.end(); ++it)
+            removeSink(it->first);
+    }{
+        std::map<uint32_t, SourceWidget*>::iterator it;
+        for (it = sourceWidgets.begin(); it != sourceWidgets.end(); ++it)
+            removeSource(it->first);
+    }{
+        std::map<uint32_t, CardWidget*>::iterator it;
+        for (it = cardWidgets.begin(); it != cardWidgets.end(); ++it)
+           removeCard(it->first);
+    }{
+        std::map<uint32_t, char*>::iterator it;
+        for (it = clientNames.begin(); it != clientNames.end(); ++it)
+            removeSourceOutput(it->first);
+    }
+    deleteEventRoleWidget();
+}
+
 void MainWindow::onSinkTypeComboBoxChanged() {
     showSinkType = (SinkType) sinkTypeComboBox->get_active_row_number();
 
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 0ee84b5..92db272 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -55,6 +55,8 @@ public:
     void removeSourceOutput(uint32_t index);
     void removeClient(uint32_t index);
 
+    void removeAllWidgets();
+
     Gtk::Notebook *notebook;
     Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
     Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel;

commit 84dc67b395dc5e8734c1245d839fb3058cf76ffe
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Apr 20 20:01:39 2010 +0100

    main: Automatically reconnect to PA upon disconnection

diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index f65298a..1dd0147 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -372,6 +372,9 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
     }
 }
 
+/* Forward Declaration */
+gboolean connect_to_pulse(gpointer userdata);
+
 void context_state_callback(pa_context *c, void *userdata) {
     MainWindow *w = static_cast<MainWindow*>(userdata);
 
@@ -487,7 +490,14 @@ void context_state_callback(pa_context *c, void *userdata) {
         }
 
         case PA_CONTEXT_FAILED:
-            show_error(_("Connection failed"));
+            g_debug(_("Connection failed, attempting reconnect"));
+
+            w->removeAllWidgets();
+            w->updateDeviceVisibility();
+            pa_context_unref(context);
+            context = NULL;
+
+            g_timeout_add_seconds(1, connect_to_pulse, w);
             return;
 
         case PA_CONTEXT_TERMINATED:
@@ -497,8 +507,15 @@ void context_state_callback(pa_context *c, void *userdata) {
     }
 }
 
-static pa_context* create_context(MainWindow* w) {
-    g_assert(api);
+pa_context* get_context(void) {
+  return context;
+}
+
+gboolean connect_to_pulse(gpointer userdata) {
+    MainWindow *w = static_cast<MainWindow*>(userdata);
+
+    if (context)
+        return false;
 
     pa_proplist *proplist = pa_proplist_new();
     pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, _("PulseAudio Volume Control"));
@@ -506,18 +523,21 @@ static pa_context* create_context(MainWindow* w) {
     pa_proplist_sets(proplist, PA_PROP_APPLICATION_ICON_NAME, "audio-card");
     pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
 
-    pa_context* c = pa_context_new_with_proplist(api, NULL, proplist);
-    g_assert(c);
+    context = pa_context_new_with_proplist(api, NULL, proplist);
+    g_assert(context);
 
     pa_proplist_free(proplist);
 
-    pa_context_set_state_callback(c, context_state_callback, w);
+    pa_context_set_state_callback(context, context_state_callback, w);
 
-    return c;
-}
+    if (pa_context_connect(context, NULL, PA_CONTEXT_NOFAIL, NULL) < 0) {
+        show_error(_("Fatal Error: Unable to connect context"));
+        Gtk::Main::quit();
+        return false;
+    }
 
-pa_context* get_context(void) {
-  return context;
+    g_debug(_("Initialised and connected our context"));
+    return false;
 }
 
 int main(int argc, char *argv[]) {
@@ -540,10 +560,7 @@ int main(int argc, char *argv[]) {
     api = pa_glib_mainloop_get_api(m);
     g_assert(api);
 
-    context = create_context(mainWindow);
-
-    if (pa_context_connect(context, NULL, (pa_context_flags_t) 0, NULL) < 0)
-        goto finish;
+    connect_to_pulse(mainWindow);
 
     Gtk::Main::run(*mainWindow);
     delete mainWindow;

commit 7de18201a38fc8bee15e6ef162fb35d242e6d00b
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Apr 20 20:22:38 2010 +0100

    connection: Show a nice label when connecting to PA.

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::RefPtr<Gnome::Glade:
     showSourceOutputType(SOURCE_OUTPUT_CLIENT),
     showSourceType(SOURCE_NO_MONITOR),
     eventRoleWidget(NULL),
-    canRenameDevices(false) {
+    canRenameDevices(false),
+    m_connected(false) {
 
     x->get_widget("cardsVBox", cardsVBox);
     x->get_widget("streamsVBox", streamsVBox);
@@ -85,6 +86,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
     x->get_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::RefPtr<Gnome::Glade:
     sourceOutputTypeComboBox->signal_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<uint32_t, CardWidget*> 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</property>
             <property name="position">0</property>
           </packing>
         </child>
+        <child>
+          <widget class="GtkLabel" id="connectingLabel">
+            <property name="label" translatable="yes">&lt;i&gt;Establishing connection to PulseAudio. Please wait...&lt;/i&gt;</property>
+            <property name="use_markup">True</property>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
       </widget>
     </child>
   </widget>

commit 18c89457084b8a75d423e3c720a8452ed63db830
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Apr 20 20:45:26 2010 +0100

    source-outputs: Fix a bug where the 'no streams' label is sometimes shown along with the actual widget.

diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 7ada1ca..25456a7 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -541,6 +541,7 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) {
         recsVBox->pack_start(*w, false, false, 0);
         w->index = info.index;
         w->clientIndex = info.client;
+        is_new = true;
     }
 
     w->updating = true;

commit 9fe20201f2a462cb51680cb939169c020d9bbdc3
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Apr 20 22:03:45 2010 +0100

    main: Cleanup labels after connection rework

diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index 0ad020d..b7bfa35 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -568,7 +568,7 @@ int main(int argc, char *argv[]) {
     Gtk::Main::run(*mainWindow);
     delete mainWindow;
 
-finish:
-    pa_context_unref(context);
+    if (context)
+        pa_context_unref(context);
     pa_glib_mainloop_free(m);
 }

commit 95e48d5c9e7d3fa3aa24d6e3b8326145712e33de
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Wed Apr 21 00:44:01 2010 +0100

    mainwindow: Compact iterator decls

diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 25456a7..c84ca7f 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -917,31 +917,18 @@ void MainWindow::removeClient(uint32_t index) {
 }
 
 void MainWindow::removeAllWidgets() {
-    {
-        std::map<uint32_t, SinkInputWidget*>::iterator it;
-        for (it = sinkInputWidgets.begin(); it != sinkInputWidgets.end(); ++it)
-            removeSinkInput(it->first);
-    }{
-        std::map<uint32_t, SourceOutputWidget*>::iterator it;
-        for (it = sourceOutputWidgets.begin(); it != sourceOutputWidgets.end(); ++it)
-            removeSourceOutput(it->first);
-    }{
-        std::map<uint32_t, SinkWidget*>::iterator it;
-        for (it = sinkWidgets.begin(); it != sinkWidgets.end(); ++it)
-            removeSink(it->first);
-    }{
-        std::map<uint32_t, SourceWidget*>::iterator it;
-        for (it = sourceWidgets.begin(); it != sourceWidgets.end(); ++it)
-            removeSource(it->first);
-    }{
-        std::map<uint32_t, CardWidget*>::iterator it;
-        for (it = cardWidgets.begin(); it != cardWidgets.end(); ++it)
-           removeCard(it->first);
-    }{
-        std::map<uint32_t, char*>::iterator it;
-        for (it = clientNames.begin(); it != clientNames.end(); ++it)
-            removeSourceOutput(it->first);
-    }
+    for (std::map<uint32_t, SinkInputWidget*>::iterator it = sinkInputWidgets.begin(); it != sinkInputWidgets.end(); ++it)
+        removeSinkInput(it->first);
+    for (std::map<uint32_t, SourceOutputWidget*>::iterator it = sourceOutputWidgets.begin(); it != sourceOutputWidgets.end(); ++it)
+        removeSourceOutput(it->first);
+    for (std::map<uint32_t, SinkWidget*>::iterator it = sinkWidgets.begin(); it != sinkWidgets.end(); ++it)
+        removeSink(it->first);
+    for (std::map<uint32_t, SourceWidget*>::iterator it = sourceWidgets.begin(); it != sourceWidgets.end(); ++it)
+        removeSource(it->first);
+    for (std::map<uint32_t, CardWidget*>::iterator it = cardWidgets.begin(); it != cardWidgets.end(); ++it)
+       removeCard(it->first);
+    for (std::map<uint32_t, char*>::iterator it = clientNames.begin(); it != clientNames.end(); ++it)
+        removeSourceOutput(it->first);
     deleteEventRoleWidget();
 }
 

commit 94add670c46806ed821ff52bdbf56d229c3b455d
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Thu Apr 22 00:04:56 2010 +0100

    mainwindow: Save/restore window size

diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index c84ca7f..c7008be 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -74,7 +74,8 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
     showSourceType(SOURCE_NO_MONITOR),
     eventRoleWidget(NULL),
     canRenameDevices(false),
-    m_connected(false) {
+    m_connected(false),
+    m_config_filename(NULL) {
 
     x->get_widget("cardsVBox", cardsVBox);
     x->get_widget("streamsVBox", streamsVBox);
@@ -109,6 +110,28 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
     sinkTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkTypeComboBoxChanged));
     sourceTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceTypeComboBoxChanged));
 
+    GKeyFile* config = g_key_file_new();
+    g_assert(config);
+    GKeyFileFlags flags = (GKeyFileFlags)( G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS);
+    GError *err = NULL;
+    m_config_filename = g_strconcat(g_get_user_config_dir(), "/pavucontrol.ini", NULL);
+
+    /* Load the GKeyFile from keyfile.conf or return. */
+    if (g_key_file_load_from_file (config, m_config_filename, flags, &err)) {
+        int width  = g_key_file_get_integer(config, "window", "width", NULL);
+        int height = g_key_file_get_integer(config, "window", "height", NULL);
+
+        int default_width, default_height;
+        get_default_size(default_width, default_height);
+        if (width >= default_width && height >= default_height)
+            resize(width, height);
+    } else {
+        g_debug(_("Error reading config file %s: %s"), m_config_filename, err->message);
+        g_error_free(err);
+    }
+    g_key_file_free(config);
+
+
     /* Hide first and show when we're connected */
     notebook->hide();
     connectingLabel->show();
@@ -128,6 +151,38 @@ void MainWindow::on_realize() {
 }
 
 MainWindow::~MainWindow() {
+    GKeyFile* config = g_key_file_new();
+    g_assert(config);
+
+    int width, height;
+    get_size(width, height);
+    g_key_file_set_integer(config, "window", "width", width);
+    g_key_file_set_integer(config, "window", "height", height);
+
+    gsize filelen;
+    GError *err = NULL;
+    gchar *filedata = g_key_file_to_data(config, &filelen, &err);
+    if (err) {
+        show_error(_("Error saving preferences"));
+        g_error_free(err);
+        goto finish;
+    }
+
+    g_file_set_contents(m_config_filename, filedata, filelen, &err);
+    g_free(filedata);
+    if (err) {
+        gchar* msg = g_strconcat(_("Error writing config file %s"), m_config_filename, NULL);
+        show_error(msg);
+        g_free(msg);
+        g_error_free(err);
+        goto finish;
+    }
+
+finish:
+
+    g_key_file_free(config);
+    g_free(m_config_filename);
+
     while (!clientNames.empty()) {
         std::map<uint32_t, char*>::iterator i = clientNames.begin();
         g_free(i->second);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 1d2f4b0..2b2dc5c 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -101,6 +101,7 @@ protected:
 
 private:
     gboolean m_connected;
+    gchar* m_config_filename;
 };
 
 

commit 870c3ddb2e5fbe78a16621c61952a31874864e4e
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Thu Apr 22 00:08:39 2010 +0100

    mainwindow: Fix clearing out of clients

diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index c7008be..4995b53 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -983,7 +983,7 @@ void MainWindow::removeAllWidgets() {
     for (std::map<uint32_t, CardWidget*>::iterator it = cardWidgets.begin(); it != cardWidgets.end(); ++it)
        removeCard(it->first);
     for (std::map<uint32_t, char*>::iterator it = clientNames.begin(); it != clientNames.end(); ++it)
-        removeSourceOutput(it->first);
+        removeClient(it->first);
     deleteEventRoleWidget();
 }
 

-- 
hooks/post-receive
PulseAudio Volume Control



More information about the pulseaudio-commits mailing list