# HG changeset patch # User William Pitcock # Date 1214719748 18000 # Node ID fdcbbfdd428e099c457a9f31befb9a767101e7f0 # Parent 2079f04c19e2ac6f4d014d08a837394e6d183a51 Split out a lot of stuff in main.c to ui_legacy.c. diff -r 2079f04c19e2 -r fdcbbfdd428e src/audacious/Makefile --- a/src/audacious/Makefile Sun Jun 29 00:45:55 2008 -0500 +++ b/src/audacious/Makefile Sun Jun 29 01:09:08 2008 -0500 @@ -49,6 +49,7 @@ ui_hints.c \ ui_jumptotrack.c \ ui_jumptotrack_cache.c \ + ui_legacy.c \ ui_main.c \ ui_main_evlisteners.c \ ui_manager.c \ diff -r 2079f04c19e2 -r fdcbbfdd428e src/audacious/main.c --- a/src/audacious/main.c Sun Jun 29 00:45:55 2008 -0500 +++ b/src/audacious/main.c Sun Jun 29 01:09:08 2008 -0500 @@ -89,9 +89,8 @@ #include "icons-stock.h" #include "images/audacious_player.xpm" - #include "ui_new.h" - +#include "ui_legacy.h" static const gchar *application_name = N_("Audacious"); @@ -107,11 +106,12 @@ gboolean enqueue_to_temp; gboolean version; gchar *previous_session_id; + gchar *interface; gboolean macpack; }; typedef struct _AudCmdLineOpt AudCmdLineOpt; -static AudCmdLineOpt options; +static AudCmdLineOpt options = {}; gchar *aud_paths[BMP_PATH_COUNT] = {}; @@ -280,6 +280,7 @@ {"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}, #ifdef GDK_WINDOWING_QUARTZ {"macpack", 'n', 0, G_OPTION_ARG_NONE, &options.macpack, N_("Used in macpacking"), NULL}, /* Make this hidden */ #endif @@ -339,6 +340,11 @@ exit(EXIT_SUCCESS); } + if (options.interface == NULL) + { + options.interface = g_strdup("default"); + } + #ifdef USE_DBUS if (is_running) { @@ -541,27 +547,6 @@ g_atexit(aud_logger_stop); } -static void -run_load_skin_error_dialog(const gchar * skin_path) -{ - const gchar *markup = - N_("Unable to load skin.\n" - "\n" - "Check that skin at '%s' is usable and default skin is properly " - "installed at '%s'\n"); - - GtkWidget *dialog = - gtk_message_dialog_new_with_markup(NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _(markup), - skin_path, - BMP_DEFAULT_SKIN_PATH); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); -} - static gboolean aud_headless_iteration(gpointer unused) { @@ -587,31 +572,6 @@ } static void -resume_playback_on_startup() -{ - gint i; - - if (!cfg.resume_playback_on_startup || - cfg.resume_playback_on_startup_time == -1 || - playlist_get_length(playlist_get_active()) <= 0) - return; - - while (gtk_events_pending()) gtk_main_iteration(); - - playback_initiate(); - - /* Busy wait; loop is fairly tight to minimize duration of - * "frozen" GUI. Feel free to tune. --chainsaw */ - for (i = 0; i < 20; i++) - { - g_usleep(1000); - if (!ip_data.playing) - break; - } - playback_seek(cfg.resume_playback_on_startup_time / 1000); -} - -static void playlist_system_init() { Playlist *playlist; @@ -763,70 +723,19 @@ output_set_volume((cfg.saved_volume & 0xff00) >> 8, (cfg.saved_volume & 0x00ff)); - ui_populate_default_interface(); - - if (options.headless == FALSE) - { - g_message("GUI and skin setup"); - aud_set_default_icon(); -#ifdef GDK_WINDOWING_QUARTZ - set_dock_icon(); -#endif - - gtk_accel_map_load(aud_paths[BMP_PATH_ACCEL_FILE]); - - if (!init_skins(cfg.skin)) { - run_load_skin_error_dialog(cfg.skin); - exit(EXIT_FAILURE); - } - - GDK_THREADS_ENTER(); - - /* this needs to be called after all 3 windows are created and - * input plugins are setup'ed - * but not if we're running headless --nenolod - */ - mainwin_setup_menus(); - - gint h_vol[2]; - input_get_volume(&h_vol[0], &h_vol[1]); - hook_call("volume set", h_vol); + g_message("Setting default icon"); + aud_set_default_icon(); - /* FIXME: delayed, because it deals directly with the plugin - * interface to set menu items */ - create_prefs_window(); - - create_fileinfo_window(); - - - if (cfg.player_visible) - mainwin_show(TRUE); - else if (!cfg.playlist_visible && !cfg.equalizer_visible) - { - /* all of the windows are hidden... warn user about this */ - mainwin_show_visibility_warning(); - } + g_message("Populating included interfaces"); + ui_populate_default_interface(); + ui_populate_legacy_interface(); - if (cfg.equalizer_visible) - equalizerwin_show(TRUE); - - if (cfg.playlist_visible) - playlistwin_show(); - - hint_set_always(cfg.always_on_top); - - resume_playback_on_startup(); - - g_message("Entering Gtk+ main loop!"); - gtk_main(); - - GDK_THREADS_LEAVE(); - } - // if we are running headless - else { /* temporarily headless operation is disabled in favour of testing the new UI */ - Interface *i = interface_get("default"); /* XXX */ + 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); #if 0 diff -r 2079f04c19e2 -r fdcbbfdd428e src/audacious/ui_legacy.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_legacy.c Sun Jun 29 01:09:08 2008 -0500 @@ -0,0 +1,205 @@ +/* Audacious - Cross-platform multimedia player + * Copyright (C) 2005-2007 Audacious development team. + * + * Based on BMP: + * Copyright (C) 2003-2004 BMP development team. + * + * Based on XMMS: + * Copyright (C) 1998-2003 XMMS 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 . + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "main.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef USE_SAMPLERATE +# include +#endif + +#include "platform/smartinclude.h" + +#include "configdb.h" +#include "vfs.h" + +#include "auddrct.h" +#include "build_stamp.h" +#include "dnd.h" +#include "input.h" +#include "logger.h" +#include "output.h" +#include "playback.h" +#include "playlist.h" +#include "pluginenum.h" +#include "signals.h" +#include "ui_skin.h" +#include "ui_equalizer.h" +#include "ui_fileinfo.h" +#include "ui_hints.h" +#include "ui_main.h" +#include "ui_manager.h" +#include "ui_playlist.h" +#include "ui_preferences.h" +#include "ui_skinselector.h" +#include "util.h" + +#include "libSAD.h" +#ifdef USE_EGGSM +#include "eggsmclient.h" +#include "eggdesktopfile.h" +#endif + +#include "icons-stock.h" + +#include "ui_new.h" + +static void +resume_playback_on_startup(void) +{ + gint i; + + if (!cfg.resume_playback_on_startup || + cfg.resume_playback_on_startup_time == -1 || + playlist_get_length(playlist_get_active()) <= 0) + return; + + while (gtk_events_pending()) gtk_main_iteration(); + + playback_initiate(); + + /* Busy wait; loop is fairly tight to minimize duration of + * "frozen" GUI. Feel free to tune. --chainsaw */ + for (i = 0; i < 20; i++) + { + g_usleep(1000); + if (!ip_data.playing) + break; + } + playback_seek(cfg.resume_playback_on_startup_time / 1000); +} + +static void +run_load_skin_error_dialog(const gchar * skin_path) +{ + const gchar *markup = + N_("Unable to load skin.\n" + "\n" + "Check that skin at '%s' is usable and default skin is properly " + "installed at '%s'\n"); + + GtkWidget *dialog = + gtk_message_dialog_new_with_markup(NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _(markup), + skin_path, + BMP_DEFAULT_SKIN_PATH); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); +} + +gboolean +_ui_initialize(void) +{ + g_message("GUI and skin setup"); +#ifdef GDK_WINDOWING_QUARTZ + set_dock_icon(); +#endif + + gtk_accel_map_load(aud_paths[BMP_PATH_ACCEL_FILE]); + + if (!init_skins(cfg.skin)) { + run_load_skin_error_dialog(cfg.skin); + exit(EXIT_FAILURE); + } + + GDK_THREADS_ENTER(); + + /* this needs to be called after all 3 windows are created and + * input plugins are setup'ed + * but not if we're running headless --nenolod + */ + mainwin_setup_menus(); + + gint h_vol[2]; + input_get_volume(&h_vol[0], &h_vol[1]); + hook_call("volume set", h_vol); + + /* FIXME: delayed, because it deals directly with the plugin + * interface to set menu items */ + create_prefs_window(); + + create_fileinfo_window(); + + + if (cfg.player_visible) + mainwin_show(TRUE); + else if (!cfg.playlist_visible && !cfg.equalizer_visible) + { + /* all of the windows are hidden... warn user about this */ + mainwin_show_visibility_warning(); + } + + if (cfg.equalizer_visible) + equalizerwin_show(TRUE); + + if (cfg.playlist_visible) + playlistwin_show(); + + hint_set_always(cfg.always_on_top); + + resume_playback_on_startup(); + + g_message("Entering Gtk+ main loop!"); + gtk_main(); + + GDK_THREADS_LEAVE(); + + return TRUE; +} + +static Interface legacy_interface = { + .id = "legacy", + .desc = N_("Legacy Interface"), + .init = _ui_initialize, +}; + +void +ui_populate_legacy_interface(void) +{ + interface_register(&legacy_interface); +} + diff -r 2079f04c19e2 -r fdcbbfdd428e src/audacious/ui_legacy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_legacy.h Sun Jun 29 01:09:08 2008 -0500 @@ -0,0 +1,31 @@ +/* Audacious - Cross-platform multimedia player + * Copyright (C) 2005-2007 Audacious development team. + * + * Based on BMP: + * Copyright (C) 2003-2004 BMP development team. + * + * Based on XMMS: + * Copyright (C) 1998-2003 XMMS 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 . + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +#ifndef __UI_LEGACY_H__ +#define __UI_LEGACY_H__ + +void ui_populate_legacy_interface(void); + +#endif