changeset 4669:ec88df86deef

Split out headless specific interface code (mostly).
author William Pitcock <nenolod@atheme.org>
date Sun, 29 Jun 2008 01:19:23 -0500
parents fdcbbfdd428e
children 1d7c8ecc353c
files src/audacious/Makefile src/audacious/main.c src/audacious/ui_headless.c src/audacious/ui_headless.h
diffstat 4 files changed, 91 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/Makefile	Sun Jun 29 01:09:08 2008 -0500
+++ b/src/audacious/Makefile	Sun Jun 29 01:19:23 2008 -0500
@@ -46,6 +46,7 @@
        ui_fileinfo.c					\
        ui_fileinfopopup.c				\
        ui_fileopener.c					\
+       ui_headless.c					\
        ui_hints.c						\
        ui_jumptotrack.c					\
        ui_jumptotrack_cache.c			\
--- a/src/audacious/main.c	Sun Jun 29 01:09:08 2008 -0500
+++ b/src/audacious/main.c	Sun Jun 29 01:19:23 2008 -0500
@@ -101,7 +101,6 @@
     gboolean play, stop, pause, fwd, rew, play_pause, show_jump_box;
     gboolean enqueue, mainwin, remote, activate;
     gboolean load_skins;
-    gboolean headless;
     gboolean no_log;
     gboolean enqueue_to_temp;
     gboolean version;
@@ -277,7 +276,6 @@
     {"enqueue-to-temp", 'E', 0, G_OPTION_ARG_NONE, &options.enqueue_to_temp, N_("Add new files to a temporary playlist"), NULL},
     {"show-main-window", 'm', 0, G_OPTION_ARG_NONE, &options.mainwin, N_("Display the main window"), NULL},
     {"activate", 'a', 0, G_OPTION_ARG_NONE, &options.activate, N_("Display all open Audacious windows"), NULL},
-    {"headless", 'H', 0, G_OPTION_ARG_NONE, &options.headless, N_("Enable headless operation"), NULL},
     {"no-log", 'N', 0, G_OPTION_ARG_NONE, &options.no_log, N_("Print all errors and warnings to stdout"), NULL},
     {"version", 'v', 0, G_OPTION_ARG_NONE, &options.version, N_("Show version"), NULL},
     {"interface", 'i', 0, G_OPTION_ARG_STRING, &options.interface, N_("Interface to use"), NULL},
@@ -548,13 +546,6 @@
 }
 
 static gboolean
-aud_headless_iteration(gpointer unused)
-{
-    free_vis_data();
-    return TRUE;
-}
-
-static gboolean
 load_extra_playlist(const gchar * path, const gchar * basename,
         gpointer def)
 {
@@ -596,6 +587,7 @@
 
     aud_config_save();
 
+#if 0
     if (options.headless == FALSE)
     {
         gtk_widget_hide(equalizerwin);
@@ -607,6 +599,7 @@
 
         cleanup_skins();
     }
+#endif
 
     plugin_system_cleanup();
 
@@ -630,6 +623,8 @@
 gint
 main(gint argc, gchar ** argv)
 {
+    Interface *i;
+
     /* glib-2.13.0 requires g_thread_init() to be called before all
        other GLib functions */
     g_thread_init(NULL);
@@ -665,7 +660,7 @@
         aud_setup_logger();
 
     g_message("Initializing Gtk+");
-    if (!gtk_init_check(&argc, &argv) && options.headless == FALSE) {
+    if (!gtk_init_check(&argc, &argv)) { /* XXX */
         /* GTK check failed, and no arguments passed to indicate
            that user is intending to only remote control a running
            session */
@@ -686,7 +681,7 @@
     g_message("Handling commandline options, part #1");
     handle_cmd_line_options(TRUE);
 
-    if (options.headless == FALSE)
+    if (g_ascii_strcasecmp(options.interface, "headless")) /* XXX */
     {
         g_message("Non-headless operation setup");
         ui_main_check_theme_engine();
@@ -729,23 +724,14 @@
     g_message("Populating included interfaces");
     ui_populate_default_interface();
     ui_populate_legacy_interface();
-
-    {
-        /* temporarily headless operation is disabled in favour of testing the new UI */
-        g_message("Selecting interface %s", options.interface);
-        Interface *i = interface_get(options.interface);
-
-        g_message("Running interface %s@%p", options.interface, i);
-        interface_run(i);
+    ui_populate_headless_interface();
 
-#if 0
-        g_print(_("Headless operation enabled\n"));
-        resume_playback_on_startup();
+    /* temporarily headless operation is disabled in favour of testing the new UI */
+    g_message("Selecting interface %s", options.interface);
+    i = interface_get(options.interface);
 
-        g_timeout_add(10, aud_headless_iteration, NULL);
-        g_main_loop_run(g_main_loop_new(NULL, TRUE));
-#endif
-    }
+    g_message("Running interface %s@%p", options.interface, i);
+    interface_run(i);
 
     aud_quit();
     return EXIT_SUCCESS;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_headless.c	Sun Jun 29 01:19:23 2008 -0500
@@ -0,0 +1,51 @@
+/*  Audacious - Cross-platform multimedia player
+ *  Copyright (C) 2005-2008  Audacious development team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses>.
+ *
+ *  The Audacious team does not consider modular code linking to
+ *  Audacious or using our public API to be a derived work.
+ */
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "interface.h"
+#include "playlist.h"
+#include "input.h"
+
+static gboolean
+aud_headless_iteration(gpointer unused)
+{
+    free_vis_data();
+    return TRUE;
+}
+
+static gboolean
+_ui_initialize(void)
+{
+    g_timeout_add(10, aud_headless_iteration, NULL);
+    g_main_loop_run(g_main_loop_new(NULL, TRUE));
+}
+
+static Interface headless_interface = {
+    .id = "headless",
+    .desc = N_("Headless Interface"),
+    .init = _ui_initialize,
+};
+
+void
+ui_populate_headless_interface(void)
+{
+    interface_register(&headless_interface);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_headless.h	Sun Jun 29 01:19:23 2008 -0500
@@ -0,0 +1,27 @@
+/*  Audacious - Cross-platform multimedia player
+ *  Copyright (C) 2005-2008  Audacious development team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses>.
+ *
+ *  The Audacious team does not consider modular code linking to
+ *  Audacious or using our public API to be a derived work.
+ */
+
+#include "interface.h"
+
+#ifndef UI_HEADLESS_H
+#define UI_HEADLESS_H
+
+void ui_populate_headless_interface();
+
+#endif