changeset 4449:19e3f3c5fe7f

introduce function aud_quit(), which is basically mainwin_quit_cb(), but is in main.c now because it is quite much the opposite of main() and should feel at home there.
author mf0102 <0102@gmx.at>
date Sat, 12 Apr 2008 19:24:55 +0200
parents 3dd13b275b4e
children 413d80f7b011
files src/audacious/auddrct.c src/audacious/dbus.c src/audacious/main.c src/audacious/main.h src/audacious/signals.c src/audacious/ui_main.c src/audacious/ui_main.h
diffstat 7 files changed, 51 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/auddrct.c	Sat Apr 12 16:42:16 2008 +0200
+++ b/src/audacious/auddrct.c	Sat Apr 12 19:24:55 2008 +0200
@@ -38,8 +38,7 @@
 void
 drct_quit ( void )
 {
-  mainwin_quit_cb();
-  return;
+  aud_quit();
 }
 
 void
--- a/src/audacious/dbus.c	Sat Apr 12 16:42:16 2008 +0200
+++ b/src/audacious/dbus.c	Sat Apr 12 19:24:55 2008 +0200
@@ -302,7 +302,7 @@
     return TRUE;
 }
 gboolean mpris_player_quit(MprisPlayer *obj, GError **error) {
-    mainwin_quit_cb();
+    aud_quit();
     return TRUE;
 }
 gboolean mpris_player_get_status(MprisPlayer *obj, gint *status,
@@ -518,7 +518,7 @@
 }
 
 gboolean audacious_rc_quit(RemoteObject *obj, GError **error) {
-    mainwin_quit_cb();
+    aud_quit();
     return TRUE;
 }
 
--- a/src/audacious/main.c	Sat Apr 12 16:42:16 2008 +0200
+++ b/src/audacious/main.c	Sat Apr 12 19:24:55 2008 +0200
@@ -698,6 +698,45 @@
         g_warning("Could not load extra playlists\n");
 }
 
+void
+aud_quit(void)
+{
+    GList *playlists = NULL, *playlists_top = NULL;
+
+    playlist_stop_get_info_thread();
+
+    if (options.headless == FALSE)
+    {
+        gtk_widget_hide(equalizerwin);
+        gtk_widget_hide(playlistwin);
+        gtk_widget_hide(mainwin);
+
+        gtk_accel_map_save(aud_paths[BMP_PATH_ACCEL_FILE]);
+        gtk_main_quit();
+
+        cleanup_skins();
+    }
+
+    aud_config_save();
+    plugin_system_cleanup();
+
+    /* free and clear each playlist */
+    playlists = playlist_get_playlists();
+    playlists_top = playlists;
+    while ( playlists != NULL )
+    {
+        playlist_clear((Playlist*)playlists->data);
+        playlist_free((Playlist*)playlists->data);
+        playlists = g_list_next(playlists);
+    }
+    g_list_free( playlists_top );
+
+    g_cond_free(cond_scan);
+    g_mutex_free(mutex_scan);
+
+    exit(EXIT_SUCCESS);
+}
+
 gint
 main(gint argc, gchar ** argv)
 {
@@ -846,8 +885,6 @@
         g_main_loop_run(loop);
     }
 
-    g_cond_free(cond_scan);
-    g_mutex_free(mutex_scan);
-
+    aud_quit();
     return EXIT_SUCCESS;
 }
--- a/src/audacious/main.h	Sat Apr 12 16:42:16 2008 +0200
+++ b/src/audacious/main.h	Sat Apr 12 19:24:55 2008 +0200
@@ -92,6 +92,8 @@
 extern MprisPlayer *mpris;
 #endif
 
+void aud_quit(void);
+
 G_END_DECLS
 
 #endif /* __AUDACIOUS_MAIN_H__ */
--- a/src/audacious/signals.c	Sat Apr 12 16:42:16 2008 +0200
+++ b/src/audacious/signals.c	Sat Apr 12 19:24:55 2008 +0200
@@ -111,12 +111,12 @@
 
         case SIGINT:
             g_print("Audacious has received SIGINT and is shutting down.\n");
-            mainwin_quit_cb();
+            aud_quit();
             break;
 
         case SIGTERM:
             g_print("Audacious has received SIGTERM and is shutting down.\n");
-            mainwin_quit_cb();
+            aud_quit();
             break;
         }
     }
@@ -150,12 +150,12 @@
 
         case SIGINT:
             g_print("Audacious has received SIGINT and is shutting down.\n");
-            mainwin_quit_cb();
+            aud_quit();
             break;
 
         case SIGTERM:
             g_print("Audacious has received SIGTERM and is shutting down.\n");
-            mainwin_quit_cb();
+            aud_quit();
             break;
         }
     }
@@ -255,7 +255,7 @@
 signal_session_quit_cb(EggSMClient *client, gpointer user_data)
 {
     g_print("Session quit requested. Saving state and shutting down.\n");    
-    mainwin_quit_cb();
+    aud_quit();
 }
 
 static void
--- a/src/audacious/ui_main.c	Sat Apr 12 16:42:16 2008 +0200
+++ b/src/audacious/ui_main.c	Sat Apr 12 19:24:55 2008 +0200
@@ -368,39 +368,10 @@
 void
 mainwin_quit_cb(void)
 {
-    GList *playlists = NULL, *playlists_top = NULL;
-
-    playlist_stop_get_info_thread();
-
-    gtk_widget_hide(equalizerwin);
-    gtk_widget_hide(playlistwin);
-    gtk_widget_hide(mainwin);
-
     if (mainwin_timeout_id)
         g_source_remove(mainwin_timeout_id);
 
-    aud_config_save();
-    gtk_accel_map_save(aud_paths[BMP_PATH_ACCEL_FILE]);
-
-    plugin_system_cleanup();
-
-
-    /* free and clear each playlist */
-    playlists = playlist_get_playlists();
-    playlists_top = playlists;
-    while ( playlists != NULL )
-    {
-        playlist_clear((Playlist*)playlists->data);
-        playlist_free((Playlist*)playlists->data);
-        playlists = g_list_next(playlists);
-    }
-    g_list_free( playlists_top );
-
-    gtk_main_quit();
-
-    cleanup_skins();
-
-    exit(EXIT_SUCCESS);
+    aud_quit();
 }
 
 gboolean
--- a/src/audacious/ui_main.h	Sat Apr 12 16:42:16 2008 +0200
+++ b/src/audacious/ui_main.h	Sat Apr 12 19:24:55 2008 +0200
@@ -117,7 +117,6 @@
 void mainwin_create(void);
 void ui_main_set_initial_volume(void);
 
-void mainwin_quit_cb(void);
 void mainwin_lock_info_text(const gchar * text);
 void mainwin_release_info_text(void);
 void mainwin_play_pushed(void);