Mercurial > audlegacy
changeset 4678:66dea2610f1c
Automated merge with ssh://hg.atheme.org//hg/audacious
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sun, 29 Jun 2008 13:01:51 -0500 |
parents | 48cdebc174ef (diff) 04c53c9d261b (current diff) |
children | da0a9ed4f0ab |
files | |
diffstat | 5 files changed, 205 insertions(+), 240 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/interface.c Sun Jun 29 12:59:51 2008 -0500 +++ b/src/audacious/interface.c Sun Jun 29 13:01:51 2008 -0500 @@ -52,6 +52,13 @@ i->init(); } +void +interface_destroy(Interface *i) +{ + if (i->fini != NULL) + i->fini(); +} + Interface * interface_get(gchar *id) {
--- a/src/audacious/interface.h Sun Jun 29 12:59:51 2008 -0500 +++ b/src/audacious/interface.h Sun Jun 29 13:01:51 2008 -0500 @@ -38,6 +38,8 @@ void interface_register(Interface *i); void interface_deregister(Interface *i); void interface_run(Interface *i); +void interface_destroy(Interface *i); + Interface *interface_get(gchar *id); #endif
--- a/src/audacious/main.c Sun Jun 29 12:59:51 2008 -0500 +++ b/src/audacious/main.c Sun Jun 29 13:01:51 2008 -0500 @@ -27,41 +27,30 @@ # include "config.h" #endif +#include "platform/smartinclude.h" + #include "main.h" -#include <glib.h> -#include <glib/gi18n.h> #include <glib/gprintf.h> -#include <gdk/gdk.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <ctype.h> -#include <time.h> - -#include <unistd.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <signal.h> #ifdef USE_SAMPLERATE # include <samplerate.h> #endif -#include "platform/smartinclude.h" - -#include "configdb.h" -#include "vfs.h" - #ifdef USE_DBUS # include "dbus-service.h" # include "audctrl.h" #endif -#include "auddrct.h" +#ifdef USE_EGGSM +#include "eggsmclient.h" +#include "eggdesktopfile.h" +#endif + +#include "libSAD.h" + #include "build_stamp.h" -#include "dnd.h" +#include "configdb.h" #include "input.h" #include "logger.h" #include "output.h" @@ -69,22 +58,10 @@ #include "playlist.h" #include "pluginenum.h" #include "signals.h" +#include "ui_manager.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 "vfs.h" #include "icons-stock.h" #include "images/audacious_player.xpm" @@ -216,54 +193,6 @@ g_object_unref(icon); } -#ifdef GDK_WINDOWING_QUARTZ -static void -set_dock_icon(void) -{ - GdkPixbuf *icon, *pixbuf; - CGColorSpaceRef colorspace; - CGDataProviderRef data_provider; - CGImageRef image; - gpointer data; - gint rowstride, pixbuf_width, pixbuf_height; - gboolean has_alpha; - - icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); - pixbuf = gdk_pixbuf_scale_simple(icon, 128, 128, GDK_INTERP_BILINEAR); - - data = gdk_pixbuf_get_pixels(pixbuf); - pixbuf_width = gdk_pixbuf_get_width(pixbuf); - pixbuf_height = gdk_pixbuf_get_height(pixbuf); - rowstride = gdk_pixbuf_get_rowstride(pixbuf); - has_alpha = gdk_pixbuf_get_has_alpha(pixbuf); - - /* create the colourspace for the CGImage. */ - colorspace = CGColorSpaceCreateDeviceRGB(); - data_provider = CGDataProviderCreateWithData(NULL, data, - pixbuf_height * rowstride, - NULL); - image = CGImageCreate(pixbuf_width, pixbuf_height, 8, - has_alpha ? 32 : 24, rowstride, colorspace, - has_alpha ? kCGImageAlphaLast : 0, - data_provider, NULL, FALSE, - kCGRenderingIntentDefault); - - /* release the colourspace and data provider, we have what we want. */ - CGDataProviderRelease(data_provider); - CGColorSpaceRelease(colorspace); - - /* set the dock tile images */ - SetApplicationDockTileImage(image); - -#if 0 - /* and release */ - CGImageRelease(image); - g_object_unref(icon); - g_object_unref(pixbuf); -#endif -} -#endif - static GOptionEntry cmd_entries[] = { {"rew", 'r', 0, G_OPTION_ARG_NONE, &options.rew, N_("Skip backwards in playlist"), NULL}, {"play", 'p', 0, G_OPTION_ARG_NONE, &options.play, N_("Start playing current playlist"), NULL}, @@ -319,17 +248,117 @@ } static void -handle_cmd_line_options(gboolean skip) +handle_cmd_line_filenames(gboolean is_running) { gchar **filenames = options.filenames; #ifdef USE_DBUS DBusGProxy *session = audacious_get_dbus_proxy(); - gboolean is_running; +#endif + + if (filenames == NULL) + return; + + gint pos = 0; + gint i = 0; + GList *fns = NULL; + + for (i = 0; filenames[i] != NULL; i++) + { + gchar *filename; + gchar *current_dir = g_get_current_dir(); + + if (!strstr(filenames[i], "://")) + { + if (filenames[i][0] == '/') + filename = g_strdup_printf("file:///%s", filenames[i]); + else + filename = g_strdup_printf("file:///%s/%s", current_dir, + filenames[i]); + } + else + filename = g_strdup(filenames[i]); + + fns = g_list_prepend(fns, filename); + + g_free(current_dir); + } + + fns = g_list_reverse(fns); + +#ifdef USE_DBUS + if (is_running) + { + if (options.load_skins) + { + audacious_remote_set_skin(session, filenames[0]); + skin_install_skin(filenames[0]); + } + else + { + GList *i; + + if (options.enqueue_to_temp) + audacious_remote_playlist_enqueue_to_temp(session, filenames[0]); + + if (options.enqueue && options.play) + pos = audacious_remote_get_playlist_length(session); + + if (!options.enqueue) + { + audacious_remote_playlist_clear(session); + audacious_remote_stop(session); + } + + for (i = fns; i != NULL; i = i->next) + audacious_remote_playlist_add_url_string(session, i->data); + + if (options.enqueue && options.play && + audacious_remote_get_playlist_length(session) > pos) + audacious_remote_set_playlist_pos(session, pos); + + if (!options.enqueue) + audacious_remote_play(session); + } + } + else /* !is_running */ +#endif + { + if (options.enqueue_to_temp) + drct_pl_enqueue_to_temp(filenames[0]); + + if (options.enqueue && options.play) + pos = drct_pl_get_length(); + + if (!options.enqueue) + { + drct_pl_clear(); + drct_stop(); + } + + drct_pl_add(fns); + + if (options.enqueue && options.play && + drct_pl_get_length() > pos) + drct_pl_set_pos(pos); + + if (!options.enqueue) + g_idle_add(aud_start_playback, NULL); + } /* !is_running */ + + g_list_foreach(fns, (GFunc) g_free, NULL); + g_list_free(fns); +} + +static void +handle_cmd_line_options(gboolean skip) +{ + gboolean is_running = FALSE; + +#ifdef USE_DBUS + DBusGProxy *session = audacious_get_dbus_proxy(); if (skip) - is_running = audacious_remote_is_running(session); - else - is_running = FALSE; + is_running = audacious_remote_is_running(session); #endif if (options.version) @@ -339,80 +368,13 @@ } if (options.interface == NULL) - { options.interface = g_strdup("default"); - } + + handle_cmd_line_filenames(is_running); #ifdef USE_DBUS if (is_running) { - if (filenames != NULL) - { - gint pos = 0; - gint i = 0; - GList *fns = NULL; - - for (i = 0; filenames[i] != NULL; i++) - { - gchar *filename; - gchar *current_dir = g_get_current_dir(); - - if (!strstr(filenames[i], "://")) - { - if (filenames[i][0] == '/') - filename = g_strdup_printf("file:///%s", filenames[i]); - else - filename = g_strdup_printf("file:///%s/%s", current_dir, - filenames[i]); - } - else - filename = g_strdup(filenames[i]); - - fns = g_list_prepend(fns, filename); - - g_free(current_dir); - } - - fns = g_list_reverse(fns); - - if (options.load_skins) - { - audacious_remote_set_skin(session, filenames[0]); - skin_install_skin(filenames[0]); - } - else - { - GList *i; - - if (options.enqueue_to_temp) - audacious_remote_playlist_enqueue_to_temp(session, filenames[0]); - - if (options.enqueue && options.play) - pos = audacious_remote_get_playlist_length(session); - - if (!options.enqueue) - { - audacious_remote_playlist_clear(session); - audacious_remote_stop(session); - } - - for (i = fns; i != NULL; i = i->next) - audacious_remote_playlist_add_url_string(session, i->data); - - if (options.enqueue && options.play && - audacious_remote_get_playlist_length(session) > pos) - audacious_remote_set_playlist_pos(session, pos); - - if (!options.enqueue) - audacious_remote_play(session); - } - - g_list_foreach(fns, (GFunc) g_free, NULL); - g_list_free(fns); - - g_strfreev(filenames); - } /* filename */ - if (options.rew) audacious_remote_playlist_prev(session); @@ -444,65 +406,7 @@ } /* is_running */ else #endif - if (!skip) { /* !is_running */ - if (filenames != NULL) - { - gint pos = 0; - gint i = 0; - GList *fns = NULL; - - for (i = 0; filenames[i] != NULL; i++) - { - gchar *filename; - gchar *current_dir = g_get_current_dir(); - - if (!strstr(filenames[i], "://")) - { - if (filenames[i][0] == '/') - filename = g_strdup_printf("file:///%s", filenames[i]); - else - filename = g_strdup_printf("file:///%s/%s", current_dir, - filenames[i]); - } - else - filename = g_strdup(filenames[i]); - - fns = g_list_prepend(fns, filename); - - g_free(current_dir); - } - - fns = g_list_reverse(fns); - - { - if (options.enqueue_to_temp) - drct_pl_enqueue_to_temp(filenames[0]); - - if (options.enqueue && options.play) - pos = drct_pl_get_length(); - - if (!options.enqueue) - { - drct_pl_clear(); - drct_stop(); - } - - drct_pl_add(fns); - - if (options.enqueue && options.play && - drct_pl_get_length() > pos) - drct_pl_set_pos(pos); - - if (!options.enqueue) - g_idle_add(aud_start_playback, NULL); - } - - g_list_foreach(fns, (GFunc) g_free, NULL); - g_list_free(fns); - - g_strfreev(filenames); - } /* filename */ - + { if (options.rew) drct_pl_prev(); @@ -518,7 +422,8 @@ if (options.fwd) drct_pl_next(); - if (options.play_pause) { + if (options.play_pause) + { if (drct_get_paused()) drct_play(); else @@ -582,24 +487,13 @@ aud_quit(void) { GList *playlists = NULL, *playlists_top = NULL; + Interface *i = interface_get(options.interface); playlist_stop_get_info_thread(); aud_config_save(); -#if 0 - 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(); - } -#endif + interface_destroy(i); plugin_system_cleanup(); @@ -711,7 +605,6 @@ g_message("Handling commandline options, part #2"); handle_cmd_line_options(FALSE); - g_message("Playlist scanner thread startup"); playlist_start_get_info_thread(); @@ -726,7 +619,6 @@ ui_populate_legacy_interface(); ui_populate_headless_interface(); - /* temporarily headless operation is disabled in favour of testing the new UI */ g_message("Selecting interface %s", options.interface); i = interface_get(options.interface);
--- a/src/audacious/ui_legacy.c Sun Jun 29 12:59:51 2008 -0500 +++ b/src/audacious/ui_legacy.c Sun Jun 29 13:01:51 2008 -0500 @@ -131,6 +131,54 @@ gtk_widget_destroy(dialog); } +#ifdef GDK_WINDOWING_QUARTZ +static void +set_dock_icon(void) +{ + GdkPixbuf *icon, *pixbuf; + CGColorSpaceRef colorspace; + CGDataProviderRef data_provider; + CGImageRef image; + gpointer data; + gint rowstride, pixbuf_width, pixbuf_height; + gboolean has_alpha; + + icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); + pixbuf = gdk_pixbuf_scale_simple(icon, 128, 128, GDK_INTERP_BILINEAR); + + data = gdk_pixbuf_get_pixels(pixbuf); + pixbuf_width = gdk_pixbuf_get_width(pixbuf); + pixbuf_height = gdk_pixbuf_get_height(pixbuf); + rowstride = gdk_pixbuf_get_rowstride(pixbuf); + has_alpha = gdk_pixbuf_get_has_alpha(pixbuf); + + /* create the colourspace for the CGImage. */ + colorspace = CGColorSpaceCreateDeviceRGB(); + data_provider = CGDataProviderCreateWithData(NULL, data, + pixbuf_height * rowstride, + NULL); + image = CGImageCreate(pixbuf_width, pixbuf_height, 8, + has_alpha ? 32 : 24, rowstride, colorspace, + has_alpha ? kCGImageAlphaLast : 0, + data_provider, NULL, FALSE, + kCGRenderingIntentDefault); + + /* release the colourspace and data provider, we have what we want. */ + CGDataProviderRelease(data_provider); + CGColorSpaceRelease(colorspace); + + /* set the dock tile images */ + SetApplicationDockTileImage(image); + +#if 0 + /* and release */ + CGImageRelease(image); + g_object_unref(icon); + g_object_unref(pixbuf); +#endif +} +#endif + gboolean _ui_initialize(void) { @@ -191,10 +239,26 @@ return TRUE; } +static gboolean +_ui_finalize() +{ + 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(); + + return TRUE; +} + static Interface legacy_interface = { .id = "legacy", .desc = N_("Legacy Interface"), .init = _ui_initialize, + .fini = _ui_finalize }; void
--- a/src/audacious/ui_new.c Sun Jun 29 12:59:51 2008 -0500 +++ b/src/audacious/ui_new.c Sun Jun 29 13:01:51 2008 -0500 @@ -27,37 +27,37 @@ static GtkWidget *label_prev, *label_current, *label_next; -gboolean +static gboolean window_delete() { return FALSE; } -void +static void window_destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } -void +static void button_open_pressed() { run_filebrowser(TRUE); } -void +static void button_previous_pressed() { playlist_prev(playlist_get_active()); } -void +static void button_next_pressed() { playlist_next(playlist_get_active()); } -void +static void set_song_title(gpointer hook_data, gpointer user_data) { gchar *title = @@ -69,7 +69,7 @@ } -GtkWidget * +static GtkWidget * gtk_box_button_add(GtkWidget *box, void(*callback)(), const gchar *stock_id) { GtkWidget *button = gtk_button_new_from_stock(stock_id); @@ -79,7 +79,7 @@ return button; } -GtkWidget * +static GtkWidget * gtk_markup_label_new(const gchar *str) { GtkWidget *label = gtk_label_new(str);