[gnac/devel] Added 'gnac_exit' function



commit 01e8c03ad7ddd9322c70d84fa43d5d8798c5387e
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Tue Sep 28 20:28:34 2010 +0100

    Added 'gnac_exit' function

 src/gnac-gconf.c                             |    3 ++-
 src/gnac-main.c                              |    8 ++++++++
 src/gnac-main.h                              |    3 +++
 src/gnac-options.c                           |    4 ++--
 src/gnac-ui.c                                |    2 +-
 src/profiles/formats/gnac-profiles-unknown.c |    3 ++-
 src/profiles/gnac-profiles-default.c         |    5 +++--
 src/profiles/gnac-profiles-manager.c         |    3 ++-
 src/profiles/gnac-profiles-properties.c      |    4 ++--
 9 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/src/gnac-gconf.c b/src/gnac-gconf.c
index 0942923..703b89b 100644
--- a/src/gnac-gconf.c
+++ b/src/gnac-gconf.c
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 
 #include "gnac-gconf.h"
+#include "gnac-main.h"
 
 static const gchar *gnac_gconf_paths[] = {
   "/apps/gnac/display/tray_icon",
@@ -56,7 +57,7 @@ gnac_gconf_init(void)
 
   if (gconf_client == NULL) {
     g_critical(_("Could not create GConf client."));
-    exit(EXIT_FAILURE);
+    gnac_exit(EXIT_FAILURE);
   }
 
   /* Watch the directory */
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 331b9d7..c99467f 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -431,6 +431,14 @@ gnac_on_ui_focus_in_event_cb(GtkWidget     *widget,
 }
 
 
+G_GNUC_NORETURN void
+gnac_exit(gint status)
+{
+  gnac_on_ui_destroy_cb(NULL, NULL);
+  exit(status);
+}
+
+
 gboolean
 gnac_on_ui_destroy_cb(GtkWidget *widget, 
                       gpointer   data)
diff --git a/src/gnac-main.h b/src/gnac-main.h
index f4356d6..98d19c2 100644
--- a/src/gnac-main.h
+++ b/src/gnac-main.h
@@ -84,6 +84,9 @@ gnac_on_ui_focus_in_event_cb(GtkWidget     *widget,
                              GdkEventFocus *event,
                              gpointer       data);
 
+G_GNUC_NORETURN void
+gnac_exit(gint status);
+
 gboolean
 gnac_on_ui_destroy_cb(GtkWidget *widget, 
                       gpointer   data);
diff --git a/src/gnac-options.c b/src/gnac-options.c
index 587409a..f2f15cb 100644
--- a/src/gnac-options.c
+++ b/src/gnac-options.c
@@ -125,7 +125,7 @@ gnac_options_version_cb(const gchar  *option_name,
                         GError      **error)
 {
   g_print("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
-  exit(EXIT_SUCCESS);
+  gnac_exit(EXIT_SUCCESS);
 }
 
 
@@ -173,7 +173,7 @@ gnac_options_init(gint    argc,
               "of available command line options."),
               argv[0]);
     g_print("\n");
-    exit(EXIT_FAILURE);
+    gnac_exit(EXIT_FAILURE);
   }
 
   g_option_context_free(context);
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index 25755d4..b7e7892 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -913,7 +913,7 @@ gnac_ui_init_unique(void)
 
     g_object_unref(app);
 
-    exit(response == UNIQUE_RESPONSE_OK);
+    gnac_exit(response == UNIQUE_RESPONSE_OK);
   }
 #endif /* HAVE_LIBUNIQUE */
 }
diff --git a/src/profiles/formats/gnac-profiles-unknown.c b/src/profiles/formats/gnac-profiles-unknown.c
index 9dd24be..3766ff9 100644
--- a/src/profiles/formats/gnac-profiles-unknown.c
+++ b/src/profiles/formats/gnac-profiles-unknown.c
@@ -27,6 +27,7 @@
 #include <glib/gstdio.h>
 #include <stdlib.h>
 
+#include "gnac-main.h"
 #include "gnac-profiles-unknown.h"
 
 
@@ -94,7 +95,7 @@ gnac_profiles_unknown_init(UpdateTextBufferFunc call_back)
   {
     g_printerr("%s\n", error->message);
     g_error_free(error);
-    exit(EXIT_FAILURE);
+    gnac_exit(EXIT_FAILURE);
   }
 
   widget = GTK_WIDGET(gtk_builder_get_object(unknown_bfi.builder,
diff --git a/src/profiles/gnac-profiles-default.c b/src/profiles/gnac-profiles-default.c
index 044affb..5475247 100755
--- a/src/profiles/gnac-profiles-default.c
+++ b/src/profiles/gnac-profiles-default.c
@@ -26,6 +26,7 @@
 #include <glib/gstdio.h>
 #include <stdlib.h>
 
+#include "gnac-main.h"
 #include "gnac-profiles-default.h"
 #include "libgnac-debug.h"
 
@@ -46,7 +47,7 @@ gnac_profiles_default_init(BasicFormatInfo *bfi,
   {
     libgnac_critical("%s\n", error->message);
     g_clear_error(&error);
-    exit(EXIT_FAILURE);
+    gnac_exit(EXIT_FAILURE);
   }
 
   widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
@@ -57,7 +58,7 @@ gnac_profiles_default_init(BasicFormatInfo *bfi,
   {
     libgnac_critical("%s\n", error->message);
     g_error_free(error);
-    exit(EXIT_FAILURE);
+    gnac_exit(EXIT_FAILURE);
   }
 
   profile_advanced_base_widget = GTK_WIDGET(gtk_builder_get_object(
diff --git a/src/profiles/gnac-profiles-manager.c b/src/profiles/gnac-profiles-manager.c
index 3991e9e..6e15bc3 100644
--- a/src/profiles/gnac-profiles-manager.c
+++ b/src/profiles/gnac-profiles-manager.c
@@ -32,6 +32,7 @@
 #include <glib/gi18n.h>
 #include <stdlib.h>
 
+#include "gnac-main.h"
 #include "gnac-profiles-manager.h"
 #include "libgnac-debug.h"
 
@@ -163,7 +164,7 @@ gnac_profiles_mgr_init(StandardCallBack call_back)
   if (error) {
     libgnac_critical("%s\n", error->message);
     g_error_free(error);
-    exit(EXIT_FAILURE);
+    gnac_exit(EXIT_FAILURE);
   }
 
   view = GTK_TREE_VIEW(gtk_builder_get_object(profiles_mgr_builder,
diff --git a/src/profiles/gnac-profiles-properties.c b/src/profiles/gnac-profiles-properties.c
index 946bc9d..a792e52 100644
--- a/src/profiles/gnac-profiles-properties.c
+++ b/src/profiles/gnac-profiles-properties.c
@@ -30,7 +30,6 @@
 #include <gdk/gdkkeysyms.h>
 #include <gio/gio.h>
 #include <glib/gi18n.h>
-//#include <gmodule.h>
 #include <stdlib.h>
 
 #include "formats/gnac-profiles-aac.h"
@@ -42,6 +41,7 @@
 #include "formats/gnac-profiles-wav.h"
 #include "formats/gnac-profiles-wavpack.h"
 
+#include "gnac-main.h"
 #include "gnac-profiles-default.h"
 #include "gnac-profiles-properties.h"
 
@@ -146,7 +146,7 @@ gnac_profiles_properties_init(void)
   {
     libgnac_critical("%s\n",error->message);
     g_error_free(error);
-    exit(EXIT_FAILURE);
+    gnac_exit(EXIT_FAILURE);
   }
   
   hbox_properties = GTK_WIDGET(gtk_builder_get_object(



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