# HG changeset patch # User Calin Crisan ccrisan@gmail.com # Date 1214936002 -10800 # Node ID 4ec0e13208dea286cec7352b0ab7581c83c86a9e # Parent 4d9540bcd7e2b9358a7c5d301e2a6a34636e1109 added shoutcast icon; fixed some small bugs diff -r 4d9540bcd7e2 -r 4ec0e13208de src/streambrowser/Makefile --- a/src/streambrowser/Makefile Tue Jul 01 02:06:01 2008 +0300 +++ b/src/streambrowser/Makefile Tue Jul 01 21:13:22 2008 +0300 @@ -6,11 +6,16 @@ gui/about_win.c \ gui/streambrowser_win.c +DATA = images/shoutcast.png + include ../../buildsys.mk include ../../extra.mk +PACKAGE = audacious + plugindir := ${plugindir}/${INPUT_PLUGIN_DIR} -CFLAGS += ${PLUGIN_CFLAGS} +CFLAGS += ${PLUGIN_CFLAGS} ${BEEP_DEFINES} CPPFLAGS += ${PLUGIN_CPPFLAGS} ${MOWGLI_CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} ${XML_CPPFLAGS} ${ARCH_DEFINES} -I../.. LIBS += ${GTK_LIBS} ${GLIB_LIBS} ${MOWGLI_LIBS} ${XML_LIBS} + diff -r 4d9540bcd7e2 -r 4ec0e13208de src/streambrowser/gui/streambrowser_win.c --- a/src/streambrowser/gui/streambrowser_win.c Tue Jul 01 02:06:01 2008 +0300 +++ b/src/streambrowser/gui/streambrowser_win.c Tue Jul 01 21:13:22 2008 +0300 @@ -202,20 +202,20 @@ static GtkWidget *gtk_streamdir_tree_view_new() { GtkWidget *tree_view = gtk_tree_view_new(); - + GtkTreeStore *store = gtk_tree_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(store)); // todo: why doesn't the tree view allow to be resized? - //gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), FALSE); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), TRUE); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree_view), TRUE); - //gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tree_view), TRUE); + gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tree_view), TRUE); gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(tree_view), FALSE); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, "", cell_renderer_pixbuf, "pixbuf", 0, NULL); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, "Stream name", cell_renderer_text, "text", 1, NULL); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, "Now playing", cell_renderer_text, "text", 2, NULL); - + g_signal_connect(G_OBJECT(tree_view), "cursor-changed", G_CALLBACK(on_tree_view_cursor_changed), NULL); return tree_view; @@ -238,8 +238,14 @@ return FALSE; /* update the current selected stream */ + + /* streamdir_gui_t *streamdir_gui = g_list_nth_data(streamdir_gui_list, page_num); update_function(streamdir_gui->streamdir, NULL, NULL); + */ + + /* clear the search box */ + gtk_entry_set_text(GTK_ENTRY(search_entry), ""); return TRUE; } @@ -249,11 +255,12 @@ GtkTreePath *path; GtkTreeViewColumn *focus_column; + /* obtain the current category */ gtk_tree_view_get_cursor(tree_view, &path, &focus_column); if (path == NULL) return TRUE; - + gint *indices = gtk_tree_path_get_indices(path); if (gtk_tree_path_get_depth(path) != 1) { gtk_tree_path_free(path); @@ -267,8 +274,12 @@ streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_tree_view(tree_view); if (streamdir_gui == NULL) return TRUE; - + + /* issue an update on the current category */ update_function(streamdir_gui->streamdir, category_get_by_index(streamdir_gui->streamdir, category_index), NULL); + + /* clear the search box */ + gtk_entry_set_text(GTK_ENTRY(search_entry), ""); return TRUE; } diff -r 4d9540bcd7e2 -r 4ec0e13208de src/streambrowser/images/shoutcast.png Binary file src/streambrowser/images/shoutcast.png has changed diff -r 4d9540bcd7e2 -r 4ec0e13208de src/streambrowser/shoutcast.h --- a/src/streambrowser/shoutcast.h Tue Jul 01 02:06:01 2008 +0300 +++ b/src/streambrowser/shoutcast.h Tue Jul 01 21:13:22 2008 +0300 @@ -5,10 +5,8 @@ #include "streambrowser.h" #include "streamdir.h" -// todo: replace hardcoded image paths with DATA_DIR G_DIR_SEPARATOR_S "images" G_DIR_SEPARATOR_S "whatever.png" - #define SHOUTCAST_NAME "Shoutcast" -#define SHOUTCAST_ICON "/usr/share/audacious/images/menu_playlist.png" +#define SHOUTCAST_ICON DATA_DIR G_DIR_SEPARATOR_S "images" G_DIR_SEPARATOR_S "shoutcast.png" #define SHOUTCAST_STREAMDIR_URL "http://www.shoutcast.com/sbin/newxml.phtml" #define SHOUTCAST_CATEGORY_URL "http://www.shoutcast.com/sbin/newxml.phtml?genre=%s" #define SHOUTCAST_STREAMINFO_URL "http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=%s&file=filename.pls" diff -r 4d9540bcd7e2 -r 4ec0e13208de src/streambrowser/streambrowser.c --- a/src/streambrowser/streambrowser.c Tue Jul 01 02:06:01 2008 +0300 +++ b/src/streambrowser/streambrowser.c Tue Jul 01 21:13:22 2008 +0300 @@ -37,7 +37,7 @@ static GtkWidget* playlist_menu_item; static GtkWidget* main_menu_item; -static update_thread_data_t update_thread_data_queue[MAX_UPDATE_THREADS]; +static GQueue* update_thread_data_queue; static gint update_thread_count = 0; static GMutex* update_thread_mutex; @@ -172,7 +172,10 @@ /* main streambrowser window */ streambrowser_win_init(); streambrowser_win_set_update_function(streamdir_update); + + /* others */ update_thread_mutex = g_mutex_new(); + update_thread_data_queue = g_queue_new(); debug("gui initialized\n"); } @@ -186,6 +189,10 @@ /* main streambrowser window */ streambrowser_win_hide(); streambrowser_win_done(); + + /* others */ + g_mutex_free(update_thread_mutex); + g_queue_free(update_thread_data_queue); debug("gui destroied\n"); } @@ -238,11 +245,16 @@ debug("another %d streamdir updates are pending, this request will be queued\n", update_thread_count); g_mutex_lock(update_thread_mutex); - update_thread_data_queue[update_thread_count].streamdir = streamdir; - update_thread_data_queue[update_thread_count].category = category; - update_thread_data_queue[update_thread_count].streaminfo = streaminfo; + + update_thread_data_t *update_thread_data = g_malloc(sizeof(update_thread_data_t)); + + update_thread_data->streamdir = streamdir; + update_thread_data->category = category; + update_thread_data->streaminfo = streaminfo; + g_queue_push_tail(update_thread_data_queue, update_thread_data); update_thread_count++; + g_mutex_unlock(update_thread_mutex); } else { @@ -258,6 +270,10 @@ static gpointer update_thread_core(update_thread_data_t *data) { + g_mutex_lock(update_thread_mutex); + update_thread_count++; + g_mutex_unlock(update_thread_mutex); + /* update a streaminfo - that is - add this streaminfo to playlist */ if (data->streaminfo != NULL) { streaminfo_add_to_playlist(data->streaminfo); @@ -302,18 +318,10 @@ data = NULL; g_mutex_lock(update_thread_mutex); - if (update_thread_count > 0) { - data = g_malloc(sizeof(update_thread_data_t)); - data->streamdir = update_thread_data_queue[0].streamdir; - data->category = update_thread_data_queue[0].category; - data->streaminfo = update_thread_data_queue[0].streaminfo; + update_thread_count--; - int i; - for (i = 0; i < update_thread_count; i++) { - update_thread_data_queue[i].streamdir = update_thread_data_queue[i + 1].streamdir; - update_thread_data_queue[i].category = update_thread_data_queue[i + 1].category; - update_thread_data_queue[i].streaminfo = update_thread_data_queue[i + 1].streaminfo; - } + if (update_thread_count > 0) { + data = g_queue_pop_head(update_thread_data_queue); update_thread_count--; }