comparison gui/dialog/playlist.c @ 35982:3fbbee95fc22

Make create_PlayList() static. It only has file scope. In order to do so, relocate some other static functions. Additionally, rename it create_Playlist().
author ib
date Thu, 28 Mar 2013 17:39:01 +0000
parents 1d11ed014a53
children 111a018fab28
comparison
equal deleted inserted replaced
35981:1d11ed014a53 35982:3fbbee95fc22
89 free( tmp ); 89 free( tmp );
90 return i; 90 return i;
91 } 91 }
92 92
93 static void scan_dir( char * path ); 93 static void scan_dir( char * path );
94
95 void ShowPlaylist( void )
96 {
97 plItem * next;
98
99 if ( Playlist ) gtkActive( Playlist );
100 else Playlist=create_PlayList();
101
102 if ( old_path && *old_path )
103 {
104 char * currentdir = strdup( old_path );
105 char * tpath,* pos;
106 GtkCTreeNode * node,* nextnode;
107 gboolean leaf;
108 tpath=strdup( "/" );
109 pos=strtok( currentdir,"/" );
110 node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func );
111 do
112 {
113 char * tpathnew = g_strconcat( tpath,pos,"/",NULL );
114 free( tpath ); tpath=tpathnew;
115 nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func );
116 if ( !nextnode ) break;
117 node=nextnode;
118 pos=strtok( NULL,"/" );
119 gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL );
120 if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node );
121 else
122 {
123 DirNodeType * DirNode;
124 gtk_ctree_select( GTK_CTREE( CTDirTree ),node );
125 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node );
126 current_path=DirNode->path;
127 scan_dir( DirNode->path );
128 free( CLFileSelected );
129 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
130 break;
131 }
132 } while( pos );
133 free( tpath );
134 free( currentdir );
135 }
136 else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent );
137
138 gtk_clist_freeze( GTK_CLIST( CLSelected ) );
139 gtk_clist_clear( GTK_CLIST( CLSelected ) );
140 next = listMgr( PLAYLIST_GET,0 );
141 if ( next )
142 {
143 while ( next || next->next )
144 {
145 char * text[1][5]; text[0][4]="";
146 text[0][0]=g_filename_display_name( next->name );
147 text[0][1]=g_filename_display_name( next->path );
148 text[0][2]=next->name;
149 text[0][3]=next->path;
150 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
151 g_free( text[0][0] );
152 g_free( text[0][1] );
153 NrOfSelected++;
154 if ( next->next ) next=next->next; else break;
155 }
156 CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) );
157 }
158 gtk_clist_thaw( GTK_CLIST( CLSelected ) );
159
160 gtk_widget_show( Playlist );
161 }
162 94
163 static void HidePlaylist( void ) 95 static void HidePlaylist( void )
164 { 96 {
165 if ( !Playlist ) return; 97 if ( !Playlist ) return;
166 NrOfSelected=NrOfEntrys=0; 98 NrOfSelected=NrOfEntrys=0;
483 scan_dir( DirNode->path ); 415 scan_dir( DirNode->path );
484 free( CLFileSelected ); 416 free( CLFileSelected );
485 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); 417 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
486 } 418 }
487 419
488 GtkWidget * create_PlayList( void ) 420 static GtkWidget * create_Playlist( void )
489 { 421 {
490 GtkWidget * vbox1; 422 GtkWidget * vbox1;
491 GtkWidget * hbox1; 423 GtkWidget * hbox1;
492 GtkWidget * scrolledwindow1; 424 GtkWidget * scrolledwindow1;
493 GtkWidget * vbox2; 425 GtkWidget * vbox2;
639 571
640 gtk_window_add_accel_group( GTK_WINDOW( Playlist ),accel_group ); 572 gtk_window_add_accel_group( GTK_WINDOW( Playlist ),accel_group );
641 573
642 return Playlist; 574 return Playlist;
643 } 575 }
576
577 void ShowPlaylist( void )
578 {
579 plItem * next;
580
581 if ( Playlist ) gtkActive( Playlist );
582 else Playlist=create_Playlist();
583
584 if ( old_path && *old_path )
585 {
586 char * currentdir = strdup( old_path );
587 char * tpath,* pos;
588 GtkCTreeNode * node,* nextnode;
589 gboolean leaf;
590 tpath=strdup( "/" );
591 pos=strtok( currentdir,"/" );
592 node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func );
593 do
594 {
595 char * tpathnew = g_strconcat( tpath,pos,"/",NULL );
596 free( tpath ); tpath=tpathnew;
597 nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func );
598 if ( !nextnode ) break;
599 node=nextnode;
600 pos=strtok( NULL,"/" );
601 gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL );
602 if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node );
603 else
604 {
605 DirNodeType * DirNode;
606 gtk_ctree_select( GTK_CTREE( CTDirTree ),node );
607 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node );
608 current_path=DirNode->path;
609 scan_dir( DirNode->path );
610 free( CLFileSelected );
611 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
612 break;
613 }
614 } while( pos );
615 free( tpath );
616 free( currentdir );
617 }
618 else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent );
619
620 gtk_clist_freeze( GTK_CLIST( CLSelected ) );
621 gtk_clist_clear( GTK_CLIST( CLSelected ) );
622 next = listMgr( PLAYLIST_GET,0 );
623 if ( next )
624 {
625 while ( next || next->next )
626 {
627 char * text[1][5]; text[0][4]="";
628 text[0][0]=g_filename_display_name( next->name );
629 text[0][1]=g_filename_display_name( next->path );
630 text[0][2]=next->name;
631 text[0][3]=next->path;
632 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
633 g_free( text[0][0] );
634 g_free( text[0][1] );
635 NrOfSelected++;
636 if ( next->next ) next=next->next; else break;
637 }
638 CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) );
639 }
640 gtk_clist_thaw( GTK_CLIST( CLSelected ) );
641
642 gtk_widget_show( Playlist );
643 }