[gnac/devel] Cleaned gnac_on_destroy



commit 84e1620344eca8ba8ba289b3879ced805f2546d0
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Sun Jun 20 21:10:13 2010 +0100

    Cleaned gnac_on_destroy

 src/gnac-main.c |   59 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 39 insertions(+), 20 deletions(-)
---
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 4b0902c..ed55c41 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -416,26 +416,44 @@ gboolean
 gnac_on_ui_destroy_cb(GtkWidget *widget, 
                       gpointer   data)
 {
-  GError *error = NULL;
+  switch (state) {
 
-  if (state == GNAC_PLUGIN_INSTALL_STATE) {
-    return TRUE;
-  } else if (state == GNAC_AUDIO_CONVERT_STATE ||
-      state == GNAC_AUDIO_PAUSED_STATE) 
-  {
-    if (!gnac_confirm_exit()) return TRUE;
-    libgnac_converter_stop(converter, &error); 
-  } else if (state == GNAC_AUDIO_FILE_ACTION_STATE) {
-    GThread *thread = NULL;
-
-    //TODO atomicity?
-    if (file_action_thread != NULL) {
-      thread = file_action_thread; 
-      quit_app = TRUE;
-      continue_files_action = FALSE;
-      gnac_change_state(GNAC_AUDIO_READY_STATE);
+    /* Do not allow the destruction of the main window during
+     * the installation of a plugin */
+    case GNAC_PLUGIN_INSTALL_STATE:
+      return TRUE;
+
+    /* Ask the user for confirmation */
+    case GNAC_AUDIO_CONVERT_STATE:
+    case GNAC_AUDIO_PAUSED_STATE: {
+      GError *error = NULL;
+      if (!gnac_confirm_exit()) return TRUE;
+      libgnac_converter_stop(converter, &error);
+      if (error) {
+        libgnac_debug("Error: %s\n", error->message);
+        g_clear_error(&error);
+      }
+      break;
     }
-    if (thread != NULL) g_thread_join(thread);
+
+    case GNAC_AUDIO_FILE_ACTION_STATE: {
+      GThread *thread = NULL;
+      //TODO atomicity?
+      if (file_action_thread != NULL) {
+        thread = file_action_thread;
+        quit_app = TRUE;
+        continue_files_action = FALSE;
+        gnac_change_state(GNAC_AUDIO_READY_STATE);
+      }
+      if (thread != NULL) g_thread_join(thread);
+    }
+
+    case GNAC_AUDIO_EMPTY_STATE:
+    case GNAC_AUDIO_READY_STATE:
+    case GNAC_AUDIO_CLEAR_STATE:
+      // nothing particular to do
+      break;
+
   }
 
   g_object_unref(converter);
@@ -809,8 +827,9 @@ gnac_on_ui_convert_cb(GtkWidget *widget,
       g_return_if_reached();
     break;
   }
-  if (error)
-  {
+
+  if (error) {
+    libgnac_debug("Error: %s\n", error->message);
     g_clear_error(&error);
   }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]