Mercurial > audlegacy
changeset 4514:0fe46317167f
renamed playlist_fileinfo* to ui_fileinfo_show* and reworked those
functions (CODE DUPLICATION IS BAD!)
author | mf0102 <0102@gmx.at> |
---|---|
date | Wed, 23 Apr 2008 14:36:00 +0200 |
parents | 867d7caeb95b |
children | 212790dd92ba |
files | src/audacious/playlist.c src/audacious/playlist.h src/audacious/pluginenum.c src/audacious/ui_fileinfo.c src/audacious/ui_fileinfo.h src/audacious/ui_main.c src/audacious/ui_playlist.c |
diffstat | 7 files changed, 94 insertions(+), 154 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/playlist.c Tue Apr 22 18:27:57 2008 +0200 +++ b/src/audacious/playlist.c Wed Apr 23 14:36:00 2008 +0200 @@ -61,7 +61,6 @@ #include "playlist_evmessages.h" #include "pluginenum.h" #include "strings.h" -#include "ui_fileinfo.h" #include "ui_main.h" #include "ui_playlist_manager.h" #include "ui_playlist.h" @@ -2394,140 +2393,6 @@ } } -void -playlist_fileinfo(Playlist *playlist, guint pos) -{ - gchar *path = NULL; - GList *node; - PlaylistEntry *entry = NULL; - Tuple *tuple = NULL; - ProbeResult *pr = NULL; - time_t mtime; - - PLAYLIST_LOCK(playlist); - - if ((node = g_list_nth(playlist->entries, pos))) - { - entry = node->data; - tuple = entry->tuple; - path = g_strdup(entry->filename); - } - - PLAYLIST_UNLOCK(playlist); - - if (entry->decoder == NULL) - { - pr = input_check_file(entry->filename, FALSE); /* try to find a decoder */ - entry->decoder = pr ? pr->ip : NULL; - - g_free(pr); - } - - /* plugin is capable to update tags. we need to bypass tuple cache. --eugene */ - /* maybe code cleanup required... */ - if (entry->decoder != NULL && entry->decoder->update_song_tuple != NULL && - entry->decoder->file_info_box == NULL && path != NULL && !vfs_is_remote(path)) { - - fileinfo_show_editor_for_path(path, entry->decoder); - g_free(path); - - } else { - - if (entry->tuple) - mtime = tuple_get_int(entry->tuple, FIELD_MTIME, NULL); - else - mtime = 0; - - /* No tuple? Try to set this entry up properly. --nenolod */ - if (entry->tuple == NULL || mtime == -1 || - mtime == 0 || mtime != playlist_get_mtime(entry->filename)) - { - playlist_entry_get_info(entry); - tuple = entry->tuple; - } - - if (tuple != NULL) - { - if (entry->decoder != NULL && entry->decoder->file_info_box == NULL) - fileinfo_show_for_tuple(tuple, FALSE); - else if (entry->decoder != NULL && entry->decoder->file_info_box != NULL) - { - plugin_set_current((Plugin *)(entry->decoder)); - entry->decoder->file_info_box(path); - } - else - fileinfo_show_for_path(path); - g_free(path); - } - else if (path != NULL) - { - if (entry != NULL && entry->decoder != NULL && entry->decoder->file_info_box != NULL) - { - plugin_set_current((Plugin *)(entry->decoder)); - entry->decoder->file_info_box(path); - } - else - fileinfo_show_for_path(path); - g_free(path); - } - } -} - -void -playlist_fileinfo_current(Playlist *playlist) -{ - gchar *path = NULL; - Tuple *tuple = NULL; - - PLAYLIST_LOCK(playlist); - - if (playlist->entries && playlist->position) - { - path = g_strdup(playlist->position->filename); - if (( playlist->position->tuple == NULL ) || ( playlist->position->decoder == NULL )) - playlist_entry_get_info(playlist->position); - tuple = playlist->position->tuple; - } - - PLAYLIST_UNLOCK(playlist); - - if (playlist->position != NULL && playlist->position->decoder != NULL && - playlist->position->decoder->update_song_tuple != NULL && - playlist->position->decoder->file_info_box == NULL && path != NULL && - !vfs_is_remote(path)) { - - fileinfo_show_editor_for_path(path, playlist->position->decoder); - g_free(path); - - } else { - - if (tuple != NULL) - { - if (playlist->position->decoder != NULL && playlist->position->decoder->file_info_box == NULL) - fileinfo_show_for_tuple(tuple, FALSE); - else if (playlist->position->decoder != NULL && playlist->position->decoder->file_info_box != NULL) - { - plugin_set_current((Plugin *)(playlist->position->decoder)); - playlist->position->decoder->file_info_box(path); - } - else - fileinfo_show_for_path(path); - g_free(path); - } - else if (path != NULL) - { - if (playlist->position != NULL && playlist->position->decoder != NULL && playlist->position->decoder->file_info_box != NULL) - { - plugin_set_current((Plugin *)(playlist->position->decoder)); - playlist->position->decoder->file_info_box(path); - } - else - fileinfo_show_for_path(path); - g_free(path); - } - } -} - static gboolean playlist_get_info_is_going(void)
--- a/src/audacious/playlist.h Tue Apr 22 18:27:57 2008 +0200 +++ b/src/audacious/playlist.h Wed Apr 23 14:36:00 2008 +0200 @@ -176,9 +176,6 @@ void playlist_remove_duplicates(Playlist *playlist, PlaylistDupsType); void playlist_remove_dead_files(Playlist *playlist); -void playlist_fileinfo_current(Playlist *playlist); -void playlist_fileinfo(Playlist *playlist, guint pos); - void playlist_delete_index(Playlist *playlist, guint pos); PlaylistEntry *playlist_get_entry_to_play(Playlist *playlist);
--- a/src/audacious/pluginenum.c Tue Apr 22 18:27:57 2008 +0200 +++ b/src/audacious/pluginenum.c Wed Apr 23 14:36:00 2008 +0200 @@ -57,6 +57,7 @@ #include "vfs_buffered_file.h" #include "ui_preferences.h" +#include "ui_fileinfo.h" #include "ui_fileinfopopup.h" #include "effect.h" @@ -230,8 +231,8 @@ .playlist_remove_duplicates = playlist_remove_duplicates, .playlist_remove_dead_files = playlist_remove_dead_files, - .playlist_fileinfo_current = playlist_fileinfo_current, - .playlist_fileinfo = playlist_fileinfo, + .playlist_fileinfo_current = ui_fileinfo_show_current, + .playlist_fileinfo = ui_fileinfo_show, .playlist_delete_index = playlist_delete_index, .playlist_delete_filenames = NULL, /* remove eventually --mf0102 */
--- a/src/audacious/ui_fileinfo.c Tue Apr 22 18:27:57 2008 +0200 +++ b/src/audacious/ui_fileinfo.c Wed Apr 23 14:36:00 2008 +0200 @@ -264,7 +264,8 @@ g_object_unref(G_OBJECT(pixbuf)); } -void fileinfo_hide(gpointer unused) +static void +fileinfo_hide(gpointer unused) { if(GTK_WIDGET_VISIBLE(fileinfo_win)) gtk_widget_hide(fileinfo_win); @@ -296,7 +297,8 @@ fileinfo_entry_set_image(image_artwork, DATA_DIR "/images/audio.png"); } -static void entry_changed (GtkEditable *editable, gpointer user_data) +static void +entry_changed (GtkEditable *editable, gpointer user_data) { if(current_file != NULL && current_ip != NULL && current_ip->update_song_tuple != NULL) { something_changed = TRUE; @@ -773,7 +775,7 @@ gtk_widget_show_all (vbox0); } -void +static void fileinfo_show_for_tuple(Tuple *tuple, gboolean updating_enabled) { gchar *tmp, *tmp_utf = NULL; @@ -907,7 +909,7 @@ gtk_widget_show(fileinfo_win); } -void +static void fileinfo_show_for_path(gchar *path) { Tuple *tuple = input_get_song_tuple(path); @@ -922,7 +924,7 @@ mowgli_object_unref(tuple); } -void +static void fileinfo_show_editor_for_path(gchar *path, InputPlugin *ip) { G_FREE_CLEAR(current_file); @@ -940,3 +942,76 @@ mowgli_object_unref(tuple); } + +static void +ui_fileinfo_show_entry(Playlist *playlist, PlaylistEntry *entry) +{ + gchar *path = g_strdup(entry->filename); + Tuple *tuple = entry->tuple; + + PLAYLIST_UNLOCK(playlist); + + /* plugin is capable of updating tags. we need to bypass tuple cache. --eugene */ + /* maybe code cleanup required... */ + if (entry != NULL && + entry->decoder != NULL && + entry->decoder->update_song_tuple != NULL && + entry->decoder->file_info_box == NULL && + path != NULL && !vfs_is_remote(path)) + { + fileinfo_show_editor_for_path(path, entry->decoder); + g_free(path); + } + else + { + if (tuple != NULL) + { + if (entry->decoder != NULL) + { + if (entry->decoder->file_info_box == NULL) + fileinfo_show_for_tuple(tuple, FALSE); + else + { + plugin_set_current((Plugin *)(entry->decoder)); + entry->decoder->file_info_box(path); + } + } + else + fileinfo_show_for_path(path); + g_free(path); + } + else if (path != NULL) + { + if (entry != NULL && + entry->decoder != NULL && + entry->decoder->file_info_box != NULL) + { + plugin_set_current((Plugin *)(entry->decoder)); + entry->decoder->file_info_box(path); + } + else + fileinfo_show_for_path(path); + g_free(path); + } + } +} + +void +ui_fileinfo_show(Playlist *playlist, guint pos) +{ + GList *node = NULL; + + PLAYLIST_LOCK(playlist); + + if ((node = g_list_nth(playlist->entries, pos))) + ui_fileinfo_show_entry(playlist, node->data); +} + +void +ui_fileinfo_show_current(Playlist *playlist) +{ + PLAYLIST_LOCK(playlist); + + if (playlist->entries && playlist->position) + ui_fileinfo_show_entry(playlist, playlist->position); +}
--- a/src/audacious/ui_fileinfo.h Tue Apr 22 18:27:57 2008 +0200 +++ b/src/audacious/ui_fileinfo.h Wed Apr 23 14:36:00 2008 +0200 @@ -24,9 +24,9 @@ #include <glib.h> void create_fileinfo_window(void); -void fileinfo_show_for_tuple(Tuple *tuple, gboolean updating_enabled); gchar* fileinfo_recursive_get_image(const gchar* path, const gchar* file_name, gint depth); -void fileinfo_show_for_path(gchar *path); -void fileinfo_show_editor_for_path(gchar *path, InputPlugin *ip); + +void ui_fileinfo_show(Playlist *playlist, guint pos); +void ui_fileinfo_show_current(Playlist *playlist); #endif
--- a/src/audacious/ui_main.c Tue Apr 22 18:27:57 2008 +0200 +++ b/src/audacious/ui_main.c Wed Apr 23 14:36:00 2008 +0200 @@ -63,6 +63,7 @@ #include "strings.h" #include "ui_credits.h" #include "ui_equalizer.h" +#include "ui_fileinfo.h" #include "ui_fileopener.h" #include "ui_hints.h" #include "ui_jumptotrack.h" @@ -1768,7 +1769,7 @@ mainwin_show_add_url_window(); break; case MAINWIN_GENERAL_FILEINFO: - playlist_fileinfo_current(playlist); + ui_fileinfo_show_current(playlist); break; case MAINWIN_GENERAL_FOCUSPLWIN: gtk_window_present(GTK_WINDOW(playlistwin)); @@ -1911,7 +1912,7 @@ UI_SKINNED_MENUROW(mainwin_menurow)->always_selected ); break; case MENUROW_FILEINFOBOX: - playlist_fileinfo_current(playlist_get_active()); + ui_fileinfo_show_current(playlist_get_active()); break; case MENUROW_SCALE: gtk_toggle_action_set_active( @@ -2193,7 +2194,7 @@ } static void mainwin_info_double_clicked_cb(void) { - playlist_fileinfo_current(playlist_get_active()); + ui_fileinfo_show_current(playlist_get_active()); } static void @@ -2801,7 +2802,7 @@ void action_current_track_info( void ) { - playlist_fileinfo_current(playlist_get_active()); + ui_fileinfo_show_current(playlist_get_active()); } void
--- a/src/audacious/ui_playlist.c Tue Apr 22 18:27:57 2008 +0200 +++ b/src/audacious/ui_playlist.c Wed Apr 23 14:36:00 2008 +0200 @@ -49,6 +49,7 @@ #include "playlist_container.h" #include "strings.h" #include "ui_equalizer.h" +#include "ui_fileinfo.h" #include "ui_fileopener.h" #include "ui_main.h" #include "ui_manager.h" @@ -705,11 +706,11 @@ * selected */ GList *list = playlist_get_selected(playlist); if (list) { - playlist_fileinfo(playlist, GPOINTER_TO_INT(list->data)); + ui_fileinfo_show(playlist, GPOINTER_TO_INT(list->data)); g_list_free(list); } else - playlist_fileinfo_current(playlist); + ui_fileinfo_show_current(playlist); } static void