static void skinlist_update(void) { gchar *skinsdir; skinlist_clear(); if (g_file_test (skins_paths[SKINS_PATH_USER_SKIN_DIR], G_FILE_TEST_EXISTS)) scan_skindir (skins_paths[SKINS_PATH_USER_SKIN_DIR]); gchar * path = g_strdup_printf ("%s/Skins", aud_get_path (AUD_PATH_DATA_DIR)); scan_skindir (path); g_free (path); skinsdir = getenv("SKINSDIR"); if (skinsdir) { gchar **dir_list = g_strsplit(skinsdir, ":", 0); gchar **dir; for (dir = dir_list; *dir; dir++) scan_skindir(*dir); g_strfreev(dir_list); } skinlist = g_list_sort(skinlist, skinlist_compare_func); g_assert(skinlist != NULL); }
static gboolean queue_track_to_scrobble (gpointer data) { AUDDBG("The playing track is going to be ENQUEUED!\n."); gchar *tab_remover; char *queuepath = g_strconcat(aud_get_path(AUD_PATH_USER_DIR),"/scrobbler.log", NULL); char *artist = tuple_get_str(playing_track, FIELD_ARTIST); char *title = tuple_get_str(playing_track, FIELD_TITLE); char *album = tuple_get_str(playing_track, FIELD_ALBUM); tab_remover = remove_tabs(artist); str_unref(artist); artist = tab_remover; tab_remover = remove_tabs(title); str_unref(title); title = tab_remover; tab_remover = remove_tabs(album); str_unref(album); album = tab_remover; tab_remover = NULL; int number = tuple_get_int(playing_track, FIELD_TRACK_NUMBER); int length = tuple_get_int(playing_track, FIELD_LENGTH) / 1000; //artist, title and timestamp are required for a successful scrobble if ( artist != NULL && strlen(artist) > 0 && title != NULL && strlen(title) > 0) { pthread_mutex_lock(&log_access_mutex); FILE *f = fopen(queuepath, "a"); if (f == NULL) { perror("fopen"); } else { //This isn't exactly the scrobbler.log format because the header //is missing, but we're sticking to it anyway... //See http://www.audioscrobbler.net/wiki/Portable_Player_Logging if (fprintf(f, "%s\t%s\t%s\t%i\t%i\t%s\t%"G_GINT64_FORMAT"\n", artist, (album == NULL ? "" : album), title, number, length, "L", timestamp ) < 0) { perror("fprintf"); } else { pthread_mutex_lock(&communication_mutex); pthread_cond_signal(&communication_signal); pthread_mutex_unlock(&communication_mutex); } fclose(f); } pthread_mutex_unlock(&log_access_mutex); } g_free(queuepath); g_free(artist); g_free(title); g_free(album); cleanup_current_track(); return FALSE; }
EXPORT GdkPixbuf * audgui_pixbuf_fallback (void) { static GdkPixbuf * fallback = NULL; if (! fallback) { SPRINTF (path, "%s/images/album.png", aud_get_path (AUD_PATH_DATA_DIR)); fallback = gdk_pixbuf_new_from_file (path, NULL); } if (fallback) g_object_ref ((GObject *) fallback); return fallback; }
EXPORT GdkPixbuf * audgui_pixbuf_fallback (void) { static GdkPixbuf * fallback = NULL; if (! fallback) { const char * data_dir = aud_get_path (AUD_PATH_DATA_DIR); SCONCAT2 (path, data_dir, "/images/album.png"); fallback = gdk_pixbuf_new_from_file (path, NULL); } if (fallback) g_object_ref ((GObject *) fallback); return fallback; }
static void load_stock_icon (char * id, char * filename, GtkIconFactory * iconfactory) { char * path = g_strdup_printf ("%s/images/%s", aud_get_path (AUD_PATH_DATA_DIR), filename); GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file (path, NULL); if (pixbuf == NULL) goto ERR; GtkIconSet * iconset = gtk_icon_set_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); gtk_icon_factory_add(iconfactory, id, iconset); ERR: g_free (path); }
void audgui_show_about_window (void) { if (about_window) { gtk_window_present ((GtkWindow *) about_window); return; } const char * brief, * const * credits, * const * translators; aud_get_audacious_credits (& brief, & credits, & translators); about_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title ((GtkWindow *) about_window, _("About Audacious")); gtk_window_set_resizable ((GtkWindow *) about_window, FALSE); gtk_container_set_border_width ((GtkContainer *) about_window, 3); audgui_destroy_on_escape (about_window); g_signal_connect (about_window, "destroy", (GCallback) gtk_widget_destroyed, & about_window); GtkWidget * vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add ((GtkContainer *) about_window, vbox); char * name = g_strdup_printf ("%s/images/about-logo.png", aud_get_path (AUD_PATH_DATA_DIR)); GtkWidget * image = gtk_image_new_from_file (name); gtk_box_pack_start ((GtkBox *) vbox, image, FALSE, FALSE, 0); g_free (name); char * markup = g_strdup_printf (brief, VERSION); GtkWidget * label = gtk_label_new (NULL); gtk_label_set_markup ((GtkLabel *) label, markup); gtk_label_set_justify ((GtkLabel *) label, GTK_JUSTIFY_CENTER); gtk_box_pack_start ((GtkBox *) vbox, label, FALSE, FALSE, 0); g_free (markup); GtkWidget * exp = gtk_expander_new (_("Credits")); GtkWidget * notebook = create_credits_notebook (credits, translators); gtk_container_add ((GtkContainer *) exp, notebook); gtk_box_pack_start ((GtkBox *) vbox, exp, TRUE, TRUE, 0); gtk_widget_show_all (about_window); }
static GtkStatusIcon *si_create(void) { GtkStatusIcon *icon; GtkIconTheme *theme; theme = gtk_icon_theme_get_default(); if (gtk_icon_theme_has_icon(theme, "audacious-panel")) icon = gtk_status_icon_new_from_icon_name("audacious-panel"); else if (gtk_icon_theme_has_icon(theme, "audacious")) icon = gtk_status_icon_new_from_icon_name("audacious"); else { gchar * path = g_strdup_printf ("%s/images/audacious.png", aud_get_path (AUD_PATH_DATA_DIR)); icon = gtk_status_icon_new_from_file (path); g_free (path); } return icon; }
EXPORT GdkPixbuf * audgui_pixbuf_for_entry (int list, int entry) { char * name = aud_playlist_entry_get_filename (list, entry); g_return_val_if_fail (name, NULL); const void * data; int64_t size; aud_art_get_data (name, & data, & size); if (data) { GdkPixbuf * p = audgui_pixbuf_from_data (data, size); aud_art_unref (name); if (p) { str_unref (name); return p; } } str_unref (name); AUDDBG ("Using fallback pixbuf.\n"); static GdkPixbuf * fallback = NULL; if (! fallback) { char * path = g_strdup_printf ("%s/images/album.png", aud_get_path (AUD_PATH_DATA_DIR)); fallback = gdk_pixbuf_new_from_file (path, NULL); g_free (path); } if (fallback) g_object_ref ((GObject *) fallback); return fallback; }
gchar * i_configure_cfg_get_file( void ) { return g_build_filename (aud_get_path (AUD_PATH_USER_DIR), "amidi-plug.conf", NULL); }
static void scrobble_cached_queue() { gchar *queuepath = g_build_filename(aud_get_path(AUD_PATH_USER_DIR),"scrobbler.log", NULL); gchar *contents = NULL; gboolean success; gchar **lines = NULL; gchar **line; gchar *scrobblemsg; GSList *lines_to_remove = NULL; gchar *error_code = NULL; gchar *error_detail = NULL; pthread_mutex_lock(&log_access_mutex); success = g_file_get_contents(queuepath, &contents, NULL, NULL); pthread_mutex_unlock(&log_access_mutex); if (!success) { AUDDBG("Couldn't access the queue file.\n"); } else { lines = g_strsplit(contents, "\n", 0); for (int i = 0; lines[i] != NULL && strlen(lines[i]) > 0 && scrobbling_enabled; i++) { line = g_strsplit(lines[i], "\t", 0); //line[0] line[1] line[2] line[3] line[4] line[5] line[6] line[7] //artist album title number length "L" timestamp NULL if (line[0] && line[2] && (strcmp(line[5], "L") == 0) && line[6] && (line[7] == NULL)) { scrobblemsg = create_message_to_lastfm("track.scrobble", 8, "artist", line[0], "album", line[1], "track", line[2], "trackNumber", line[3], "duration", line[4], "timestamp", line[6], "api_key", SCROBBLER_API_KEY, "sk", session_key); if (send_message_to_lastfm(scrobblemsg) == TRUE) { error_code = NULL; error_detail = NULL; if (read_scrobble_result(&error_code, &error_detail) == TRUE) { //TODO: a track might not be scrobbled due to "daily scrobble limit exeeded". //This message comes on the ignoredMessage attribute, inside the XML of the response. //We are not dealing with this case currently and are losing that scrobble. AUDDBG("SCROBBLE OK.\n"); save_line_to_remove(&lines_to_remove, i); } else { AUDDBG("SCROBBLE NOT OK. Error code: %s. Error detail: %s.\n", error_code, error_detail); if (error_code == NULL) { //net error(?) or the answer from last.fm was not well read //scrobble to be retried } else if (g_strcmp0(error_code, "11") == 0 || g_strcmp0(error_code, "16") == 0){ //error code 11: Service Offline - This service is temporarily offline. Try again later. //error code 16: The service is temporarily unavailable, please try again. //scrobble to be retried } else if (g_strcmp0(error_code, "9") == 0) { //Bad Session. Reauth. scrobbling_enabled = FALSE; g_free(session_key); session_key = NULL; aud_set_string("scrobbler", "session_key", ""); } else { save_line_to_remove(&lines_to_remove, i); } } g_free(error_code); g_free(error_detail); } else { AUDDBG("Could not scrobble a track on the queue. Network problem?\n"); //scrobble to be retried scrobbling_enabled = FALSE; } g_free(scrobblemsg); } else { AUDDBG("Unscrobbable line.\n"); //leave entry on the cache file } g_strfreev(line); }//for if (lines_to_remove != NULL) { delete_lines_from_scrobble_log(&lines_to_remove, queuepath); g_slist_free_full(lines_to_remove, g_free); } g_strfreev(lines); } g_free(contents); g_free(queuepath); }