# HG changeset patch # User reimar # Date 1180962935 0 # Node ID 226957a512ca12539de74f4919a53fb7fe0f2e92 # Parent 4a9e6efb82005c99a80c6c8c2ddd09f6394418d2 Factor out some duplicated gui code diff -r 4a9e6efb8200 -r 226957a512ca gui/mplayer/gtk/fs.c --- a/gui/mplayer/gtk/fs.c Mon Jun 04 13:05:26 2007 +0000 +++ b/gui/mplayer/gtk/fs.c Mon Jun 04 13:15:35 2007 +0000 @@ -147,11 +147,20 @@ return tmp; } +static void clist_append_fname(GtkWidget * list, char *fname, + GdkPixmap *pixmap, GdkPixmap *mask) { + gint pos; + gchar *str[2]; + str[0] = NULL; + str[1] = fname; + pos = gtk_clist_append(GTK_CLIST(list), str); + gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask); +} + void CheckDir( GtkWidget * list,char * directory ) { struct stat fs; - int i,c=2; - gchar * str[1][2]; + int i; GdkPixmap * pixmap; GdkBitmap * mask; glob_t gg; @@ -160,11 +169,9 @@ gtk_widget_hide( list ); gtk_clist_clear( GTK_CLIST( list ) ); - str[0][0]=NULL; - pixmap=dpixmap; mask=dmask; - str[0][1]="."; gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),0,0,pixmap,mask ); - str[0][1]=".."; gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),1,0,pixmap,mask ); + clist_append_fname(list, ".", dpixmap, dmask); + clist_append_fname(list, "..", dpixmap, dmask); glob( "*",0,NULL,&gg ); // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); @@ -172,10 +179,7 @@ { stat( gg.gl_pathv[i],&fs ); if( !S_ISDIR( fs.st_mode ) ) continue; - - str[0][1]=gg.gl_pathv[i]; - gtk_clist_append( GTK_CLIST( list ),str[0] ); - gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask ); + clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask); } globfree( &gg ); @@ -214,15 +218,11 @@ #endif // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); - pixmap=fpixmap; mask=fmask; for( i=0;(unsigned)i