/* $Id: explore.c,v 1.1.1.1 2000/01/30 16:39:18 benediktroth Exp $ */ #include #include #include #include #include #include #include #include #include "yamt.h" #include "explore.h" #include "clist_items.h" #include "menus.h" #define E_D_COL 0 /* dir */ #define E_F_COL 1 /* file */ #define E_T_COL 2 /* title */ #define E_A_COL 3 #define E_B_COL 4 #define E_Y_COL 5 #define E_G_COL 6 #define E_C_COL 7 #define E_N_COL 8 /* filename */ #define E_ITEMS 9 GtkWidget *explore_box_new( ) { GtkWidget *explore_box; GtkWidget *explore_notebook; GtkWidget *explore_main_box; GtkWidget *explore_main_scrolled_window; GtkWidget *explore_filter_box; GtkWidget *explore_filter_opts_frame; GtkWidget *explore_filter_opts_table; GtkWidget *explore_filter_tag_frame; GtkWidget *explore_filter_tag_table; GtkWidget *explore_filter_tag_title_label; GtkWidget *explore_filter_tag_artist_label; GtkWidget *explore_filter_tag_album_label; GtkWidget *explore_filter_tag_comment_label; GtkWidget *explore_filter_tag_year_label; GtkWidget *explore_filter_tag_genre_label; GtkWidget *explore_buttons_box; GtkWidget *explore_buttons_start; GtkWidget *explore_buttons_quit; GtkWidget *popup; GtkWidget *label; gint i; gchar *titles[E_ITEMS]; titles[E_D_COL]= _("Dir"); titles[E_F_COL]= _("File"); titles[E_T_COL]= _("Title"); titles[E_A_COL]= _("Artist"); titles[E_B_COL]= _("Album"); titles[E_C_COL]= _("Comment"); titles[E_Y_COL]= _("Year"); titles[E_G_COL]= _("Genre"); titles[E_N_COL]= _("File"); /* The box it which everything is put */ explore_box = gtk_vbox_new( FALSE, 0); explore_notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos( GTK_NOTEBOOK(explore_notebook), GTK_POS_LEFT ); gtk_box_pack_start( GTK_BOX(explore_box), explore_notebook, FALSE, FALSE, 0); gtk_widget_show(explore_notebook); /************************************** MAIN **************************************/ explore_main_box = gtk_vbox_new( FALSE, 0 ); gtk_widget_show(explore_main_box); label = gtk_label_new(_("Main")); gtk_notebook_append_page( GTK_NOTEBOOK(explore_notebook), explore_main_box, label ); explore_main_scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_usize( GTK_WIDGET(explore_main_scrolled_window), 200, 150); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (explore_main_scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start( GTK_BOX(explore_main_box), explore_main_scrolled_window, TRUE, TRUE, 0); gtk_widget_show(explore_main_scrolled_window); explore_main_clist = gtk_clist_new_with_titles( E_ITEMS, titles ); gtk_clist_set_sort_column( GTK_CLIST(explore_main_clist), E_F_COL ); gtk_clist_set_selection_mode( GTK_CLIST(explore_main_clist), GTK_SELECTION_EXTENDED ); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_D_COL, 120); gtk_clist_set_column_visibility( GTK_CLIST(explore_main_clist), E_D_COL, FALSE ); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_F_COL, 120); gtk_clist_set_column_visibility( GTK_CLIST(explore_main_clist), E_F_COL, FALSE ); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_T_COL, 120); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_A_COL, 100); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_B_COL, 80); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_Y_COL, 30); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_G_COL, 60); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_C_COL, 70); gtk_clist_set_column_width( GTK_CLIST(explore_main_clist), E_N_COL, 100); gtk_signal_connect( GTK_OBJECT(explore_main_clist), "click-column", GTK_SIGNAL_FUNC(clist_items_sort), explore_main_clist ); gtk_container_add( GTK_CONTAINER(explore_main_scrolled_window), explore_main_clist); gtk_widget_show(explore_main_clist); /* The popup menu */ popup = popup_menu_new( GTK_CLIST(explore_main_clist), ALL_ITEMS-MASS_ITEM ); /* Connect the popup menu to the browse list */ if( popup ) gtk_signal_connect_object ( GTK_OBJECT(explore_main_clist), "event", GTK_SIGNAL_FUNC(menu_popup), GTK_OBJECT(popup) ); /************************************** FILTER **************************************/ explore_filter_box = gtk_vbox_new( FALSE, 0 ); gtk_widget_show(explore_filter_box); label = gtk_label_new(_("Filter")); gtk_notebook_append_page( GTK_NOTEBOOK(explore_notebook), explore_filter_box, label ); /* Frame for the options */ explore_filter_opts_frame = gtk_frame_new( _("Options") ); gtk_box_pack_start( GTK_BOX(explore_filter_box), explore_filter_opts_frame, TRUE, FALSE, 5 ); gtk_widget_show(explore_filter_opts_frame); /* The table for the options*/ explore_filter_opts_table = gtk_table_new( 1, 1, TRUE); gtk_container_set_border_width( GTK_CONTAINER(explore_filter_opts_table), 10); gtk_container_add( GTK_CONTAINER(explore_filter_opts_frame), explore_filter_opts_table ); gtk_widget_show(explore_filter_opts_table); /* The exact macht button */ explore_filter_opts_exact_match = gtk_check_button_new_with_label( _("Exact Match") ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(explore_filter_opts_exact_match), FALSE ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_opts_table), explore_filter_opts_exact_match, 0, 1, 0, 1); gtk_widget_show( explore_filter_opts_exact_match ); /* The recursive button */ explore_filter_opts_recursive = gtk_check_button_new_with_label( _("Recurse Subdirs") ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(explore_filter_opts_recursive), FALSE ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_opts_table), explore_filter_opts_recursive, 1, 2, 0, 1); gtk_widget_show( explore_filter_opts_recursive ); /* The add button */ explore_filter_opts_add = gtk_check_button_new_with_label( _("Add") ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(explore_filter_opts_add), FALSE ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_opts_table), explore_filter_opts_add, 2, 3, 0, 1); gtk_widget_show( explore_filter_opts_add ); /* ----------------- */ /* Frame for the id3 tag */ explore_filter_tag_frame = gtk_frame_new( NULL ); gtk_frame_set_label( GTK_FRAME(explore_filter_tag_frame), _("ID3 TAG") ); gtk_box_pack_start( GTK_BOX(explore_filter_box), explore_filter_tag_frame, TRUE, FALSE, 5 ); gtk_widget_show( explore_filter_tag_frame ); /* Table for id3 tag */ explore_filter_tag_table = gtk_table_new( 6, 4, FALSE); gtk_container_set_border_width( GTK_CONTAINER(explore_filter_tag_table), 10); gtk_container_add( GTK_CONTAINER(explore_filter_tag_frame), explore_filter_tag_table); gtk_widget_show(explore_filter_tag_table); /* Title */ explore_filter_tag_title_label=gtk_label_new( _("Title: ") ); gtk_misc_set_alignment( GTK_MISC(explore_filter_tag_title_label), 1, 0.5 ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_title_label, 0, 1, 0, 1); gtk_widget_show( explore_filter_tag_title_label ); explore_filter_tag_title = gtk_entry_new_with_max_length(30); gtk_entry_set_editable( GTK_ENTRY (explore_filter_tag_title), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_title), FALSE); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_title, 1, 3, 0, 1); gtk_widget_show( explore_filter_tag_title ); explore_filter_tag_buttons_title = gtk_check_button_new_with_label( _("Use this field") ); gtk_signal_connect( GTK_OBJECT(explore_filter_tag_buttons_title), "clicked", GTK_SIGNAL_FUNC (explore_use_field_button_toggled), "t" ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_buttons_title, 3, 4, 0, 1); gtk_widget_show( explore_filter_tag_buttons_title ); /* Artist */ explore_filter_tag_artist_label=gtk_label_new( _("Artist: ")); gtk_misc_set_alignment( GTK_MISC(explore_filter_tag_artist_label), 1, 0.5 ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_artist_label, 0, 1, 1, 2); gtk_widget_show( explore_filter_tag_artist_label ); explore_filter_tag_artist = gtk_entry_new_with_max_length(30); gtk_entry_set_editable( GTK_ENTRY (explore_filter_tag_artist), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_artist), FALSE); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_artist, 1, 3, 1, 2); gtk_widget_show( explore_filter_tag_artist ); explore_filter_tag_buttons_artist = gtk_check_button_new_with_label( _("Use this field") ); gtk_signal_connect( GTK_OBJECT(explore_filter_tag_buttons_artist), "clicked", GTK_SIGNAL_FUNC (explore_use_field_button_toggled), "a" ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_buttons_artist, 3, 4, 1, 2); gtk_widget_show( explore_filter_tag_buttons_artist ); /* Album */ explore_filter_tag_album_label=gtk_label_new( _("Album: ") ); gtk_misc_set_alignment( GTK_MISC(explore_filter_tag_album_label), 1, 0.5 ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_album_label, 0, 1, 2, 3); gtk_widget_show( explore_filter_tag_album_label ); explore_filter_tag_album = gtk_entry_new_with_max_length(30); gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_album), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_album), FALSE); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_album, 1, 3, 2, 3); gtk_widget_show( explore_filter_tag_album ); explore_filter_tag_buttons_album = gtk_check_button_new_with_label( _("Use this field") ); gtk_signal_connect( GTK_OBJECT(explore_filter_tag_buttons_album), "clicked", GTK_SIGNAL_FUNC(explore_use_field_button_toggled), "b" ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_buttons_album, 3, 4, 2, 3); gtk_widget_show( explore_filter_tag_buttons_album ); /* Comment */ explore_filter_tag_comment_label=gtk_label_new( _("Comment: ") ); gtk_misc_set_alignment( GTK_MISC(explore_filter_tag_comment_label), 1, 0.5 ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_comment_label, 0, 1, 3, 4); gtk_widget_show( explore_filter_tag_comment_label ); explore_filter_tag_comment = gtk_entry_new_with_max_length(30); gtk_entry_set_editable( GTK_ENTRY (explore_filter_tag_comment), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_comment), FALSE); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_comment, 1, 3, 3, 4); gtk_widget_show( explore_filter_tag_comment ); explore_filter_tag_buttons_comment = gtk_check_button_new_with_label( _("Use this field") ); gtk_signal_connect( GTK_OBJECT(explore_filter_tag_buttons_comment), "clicked", GTK_SIGNAL_FUNC(explore_use_field_button_toggled), "c" ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_buttons_comment, 3, 4, 3, 4); gtk_widget_show( explore_filter_tag_buttons_comment ); /* Year */ explore_filter_tag_year_label=gtk_label_new( _("Year: ") ); gtk_misc_set_alignment( GTK_MISC(explore_filter_tag_year_label), 1, 0.5 ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_year_label, 0, 1, 4, 5); gtk_widget_show( explore_filter_tag_year_label ); explore_filter_tag_year = gtk_entry_new_with_max_length(4); gtk_entry_set_editable( GTK_ENTRY (explore_filter_tag_year), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_year), FALSE); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_year, 1, 3, 4, 5); gtk_widget_show( explore_filter_tag_year ); explore_filter_tag_buttons_year = gtk_check_button_new_with_label( _("Use this field") ); gtk_signal_connect( GTK_OBJECT(explore_filter_tag_buttons_year), "clicked", GTK_SIGNAL_FUNC (explore_use_field_button_toggled), "y" ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_buttons_year, 3, 4, 4, 5); gtk_widget_show( explore_filter_tag_buttons_year ); /* Genre */ explore_filter_tag_genre_label=gtk_label_new( _("Genre: ") ); gtk_misc_set_alignment( GTK_MISC(explore_filter_tag_genre_label), 1, 0.5 ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_genre_label, 0, 1, 5, 6); gtk_widget_show( explore_filter_tag_genre_label ); /* Create a new combo box */ explore_filter_tag_genre = gtk_combo_new(); gtk_entry_set_editable( GTK_ENTRY(GTK_COMBO(explore_filter_tag_genre)->entry), FALSE); /* Create the CList */ if (!explore_filter_tag_genre_list) { for (i = 0; i < GENRE_MAX; i++) explore_filter_tag_genre_list = g_list_append( explore_filter_tag_genre_list, (gchar *) id3tag_genres_sorted[i]); explore_filter_tag_genre_list = g_list_append(explore_filter_tag_genre_list, ""); } /* Connect the combo and the list */ gtk_combo_set_popdown_strings(GTK_COMBO(explore_filter_tag_genre), explore_filter_tag_genre_list); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_genre, 1, 2, 5, 6); gtk_entry_set_text( GTK_ENTRY(GTK_COMBO (explore_filter_tag_genre)->entry), " "); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_genre), FALSE); gtk_widget_show(explore_filter_tag_genre); explore_filter_tag_buttons_genre = gtk_check_button_new_with_label( _("Use this field") ); gtk_signal_connect( GTK_OBJECT(explore_filter_tag_buttons_genre), "clicked", GTK_SIGNAL_FUNC (explore_use_field_button_toggled), "g" ); gtk_table_attach_defaults( GTK_TABLE(explore_filter_tag_table), explore_filter_tag_buttons_genre, 3, 4, 5, 6); gtk_widget_show( explore_filter_tag_buttons_genre ); /************************************** BUTTONS **************************************/ /* The Box for the buttons */ explore_buttons_box = gtk_hbox_new( TRUE, 10 ); gtk_box_pack_start( GTK_BOX(explore_box), explore_buttons_box, TRUE, FALSE, 0 ); gtk_widget_show(explore_buttons_box); /* The buttons */ explore_buttons_start = gnome_stock_or_ordinary_button( GNOME_STOCK_PIXMAP_EXEC ); gtk_signal_connect( GTK_OBJECT(explore_buttons_start), "clicked", GTK_SIGNAL_FUNC(explore_start), NULL ); gtk_box_pack_start( GTK_BOX(explore_buttons_box), explore_buttons_start, TRUE, TRUE, 0 ); gtk_widget_show(explore_buttons_start); /* Quit */ explore_buttons_quit = gnome_stock_or_ordinary_button( GNOME_STOCK_PIXMAP_QUIT ); gtk_signal_connect( GTK_OBJECT(explore_buttons_quit), "clicked", GTK_SIGNAL_FUNC(yamt_exit), NULL ); gtk_box_pack_start( GTK_BOX(explore_buttons_box), explore_buttons_quit, TRUE, TRUE, 0 ); gtk_widget_show(explore_buttons_quit); return(explore_box); } void explore_load_properties( void ) { } void explore_use_field_button_toggled( GtkWidget *widget, gchar *data ) { gboolean state; switch( data[0] ) { case 't': /* Get the current state of the button */ state = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_title) ); /* If the button is active make the entry editable, if not then not */ if( state == TRUE ) gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_title), TRUE ); else gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_title), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_title), state*-1 ); break; case 'a': state = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_artist) ); if( state == TRUE ) gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_artist), TRUE); else gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_artist), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_artist), state*-1 ); break; case 'b': state = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_album) ); if( state == TRUE ) gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_album), TRUE ); else gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_album), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_album), state*-1 ); break; case 'c': state = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_comment) ); if( state == TRUE ) gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_comment), TRUE ); else gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_comment), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_comment), state*-1 ); break; case 'y': state = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_year) ); if( state == TRUE ) gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_year), TRUE ); else gtk_entry_set_editable( GTK_ENTRY(explore_filter_tag_year), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_year), state*-1 ); break; case 'g': state = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_genre) ); /* if( state == TRUE ) */ /* g_print("Genre TRUE\n"); */ /* else */ /* g_print("Genre FALSE\n"); */ gtk_widget_set_sensitive( GTK_WIDGET(explore_filter_tag_genre), state*-1 ); break; } } void explore_directory_load( gchar *dirname ) { /* gtk_label_set_text( GTK_LABEL (filter_directory),dirname); */ /* g_print("dir: %s\n", dirname ); */ } int explore_start( void ) { gchar *directory; gboolean active; gboolean exact_match; gboolean recursive; gboolean add; gchar *buffer; struct id3tag tag; /* gtk_label_get( GTK_LABEL(explore_directory), &directory ); */ directory = g_strdup(selected_directory); yamtlog("%s %s", _("Explore-Directory: "), directory ); exact_match = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_opts_exact_match) ); yamtlog("%s %s", _("Explore-Exact_match: "), exact_match ? "TRUE" : "FALSE" ); recursive = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_opts_recursive) ); yamtlog("%s %s", _("Explore-Recursive: "), recursive ? "TRUE" : "FALSE" ); add = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_opts_add) ); yamtlog("%s %s", _("Explore-Add: "), add ? "TRUE" : "FALSE" ); strcpy( tag.tag, "TAG" ); active = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_title) ); if( active ) { buffer = gtk_entry_get_text( GTK_ENTRY(explore_filter_tag_title) ); /* To get sure the tag will be deleted */ if( buffer[0] == '\0' ) { buffer[0]=' '; buffer[1]='\0'; } strcpy( tag.title, buffer ); } else tag.title[0]='\0'; active = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_artist) ); if( active ) { buffer = gtk_entry_get_text( GTK_ENTRY(explore_filter_tag_artist) ); if( buffer[0] == '\0' ) { buffer[0]=' '; buffer[1]='\0'; } strcpy( tag.artist, buffer ); } else tag.artist[0]='\0'; active = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_album) ); if( active ) { buffer = gtk_entry_get_text( GTK_ENTRY(explore_filter_tag_album) ); if( buffer[0] == '\0' ) { buffer[0]=' '; buffer[1]='\0'; } strcpy( tag.album, buffer ); } else tag.album[0]='\0'; active = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_comment) ); if( active ) { buffer = gtk_entry_get_text( GTK_ENTRY(explore_filter_tag_comment) ); if( buffer[0] == '\0' ) { buffer[0]=' '; buffer[1]='\0'; } strcpy( tag.comment, buffer ); } else tag.comment[0]='\0'; active = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_year) ); if( active ) { buffer = gtk_entry_get_text( GTK_ENTRY(explore_filter_tag_year) ); if( buffer[0] == '\0' ) { buffer[0]=' '; buffer[1]='\0'; } strcpy( tag.year, buffer ); } else tag.year[0]='\0'; active = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(explore_filter_tag_buttons_genre) ); if( active ) tag.genre = id3tag_lookup_genre(gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(explore_filter_tag_genre)->entry))); else tag.genre = 0xFF; /* id3tag_show(tag); */ /* If add is selected use the at last created clist */ if( add ) yamtlog("%s", _("Using existing list")); else gtk_clist_clear( GTK_CLIST(explore_main_clist) ); explore_go( directory, directory, 0 , recursive, exact_match, tag, NULL ); /* explore_results_calculate_statistics( ); */ gtk_clist_sort( GTK_CLIST(explore_main_clist) ); g_free(directory); return(1); } void explore_go( gchar *rootdir, gchar *dir, gint depth, gboolean recursive, gboolean exact_match, struct id3tag tag, FILE *file ) { DIR *dp; struct dirent *entry; struct stat statbuf; struct id3tag tag2; gchar *buffer[2][E_ITEMS]; if( (dp = opendir(dir))==NULL ) { yamtlog("%s %s", _("ERROR while opening "), dir); gnome_error_dialog( _("Could not open directory!") ); return; } while( (entry = readdir(dp)) != NULL ) { update_progress_bar(); chdir(dir); lstat( entry->d_name, &statbuf); if( S_ISDIR(statbuf.st_mode)) /* If it's a directory */ { /* Shall it be recursive ? */ if( recursive == 0 ) continue; /* ignore "." and ".." */ if( strcmp(".", entry->d_name) == 0 || strcmp("..", entry->d_name) == 0 ) continue; /* printf("%*s%s/\n", depth, " ", entry->d_name ); */ /* Recurse but increase the indent level */ explore_go( rootdir, g_concat_dir_and_file( dir, entry->d_name ), depth+4, recursive, exact_match, tag, file ); } else /* If it's not a directory */ { /* printf("%*s%s\n", depth, " ", entry->d_name ); */ tag2 = id3tag_get( entry->d_name); /* If the file has no valid tag */ if( strncmp( tag2.tag, "TAG", 3 ) != 0 ) { yamtlog("%s %s", entry->d_name, _(" skipped") ); continue; } /* Found a matching TAG, add the filename to the list */ if( id3tag_cmp( tag, tag2, exact_match ) == 0 ) { yamtlog("%s %s", _("Found: "), entry->d_name); /* Add it to the list */ /* if( strcmp( rootdir, dir) == 0 ) */ /* buffer[0][0] = dir; */ /* else */ /* buffer[0][0] = g_concat_dir_and_file( rootdir, dir ); */ buffer[0][E_D_COL] = dir; buffer[0][E_F_COL] = entry->d_name; buffer[0][E_T_COL] = tag2.title; buffer[0][E_A_COL] = tag2.artist; buffer[0][E_B_COL] = tag2.album; buffer[0][E_Y_COL] = tag2.year; buffer[0][E_C_COL] = tag2.comment; buffer[0][E_G_COL] = id3tag_get_genre(tag2.genre); buffer[0][E_N_COL] = entry->d_name; gtk_clist_append( GTK_CLIST(explore_main_clist), buffer[0] ); gtk_clist_sort( GTK_CLIST(explore_main_clist) ); } else yamtlog("%s %s", entry->d_name, _(" does not match given tag")); } } chdir(".."); closedir(dp); }