comparison gui/mplayer/gtk/fs.c @ 23445:226957a512ca

Factor out some duplicated gui code
author reimar
date Mon, 04 Jun 2007 13:15:35 +0000
parents 4a9e6efb8200
children 23729eb4df91
comparison
equal deleted inserted replaced
23444:4a9e6efb8200 23445:226957a512ca
145 } 145 }
146 tmp[c]=0; 146 tmp[c]=0;
147 return tmp; 147 return tmp;
148 } 148 }
149 149
150 static void clist_append_fname(GtkWidget * list, char *fname,
151 GdkPixmap *pixmap, GdkPixmap *mask) {
152 gint pos;
153 gchar *str[2];
154 str[0] = NULL;
155 str[1] = fname;
156 pos = gtk_clist_append(GTK_CLIST(list), str);
157 gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask);
158 }
159
150 void CheckDir( GtkWidget * list,char * directory ) 160 void CheckDir( GtkWidget * list,char * directory )
151 { 161 {
152 struct stat fs; 162 struct stat fs;
153 int i,c=2; 163 int i;
154 gchar * str[1][2];
155 GdkPixmap * pixmap; 164 GdkPixmap * pixmap;
156 GdkBitmap * mask; 165 GdkBitmap * mask;
157 glob_t gg; 166 glob_t gg;
158 167
159 if ( !fsFilter[0] ) return; 168 if ( !fsFilter[0] ) return;
160 169
161 gtk_widget_hide( list ); 170 gtk_widget_hide( list );
162 gtk_clist_clear( GTK_CLIST( list ) ); 171 gtk_clist_clear( GTK_CLIST( list ) );
163 str[0][0]=NULL; 172
164 173 clist_append_fname(list, ".", dpixmap, dmask);
165 pixmap=dpixmap; mask=dmask; 174 clist_append_fname(list, "..", dpixmap, dmask);
166 str[0][1]="."; gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),0,0,pixmap,mask );
167 str[0][1]=".."; gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),1,0,pixmap,mask );
168 175
169 glob( "*",0,NULL,&gg ); 176 glob( "*",0,NULL,&gg );
170 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); 177 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg );
171 for( i=0;(unsigned)i<gg.gl_pathc;i++ ) 178 for( i=0;(unsigned)i<gg.gl_pathc;i++ )
172 { 179 {
173 stat( gg.gl_pathv[i],&fs ); 180 stat( gg.gl_pathv[i],&fs );
174 if( !S_ISDIR( fs.st_mode ) ) continue; 181 if( !S_ISDIR( fs.st_mode ) ) continue;
175 182 clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask);
176 str[0][1]=gg.gl_pathv[i];
177 gtk_clist_append( GTK_CLIST( list ),str[0] );
178 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask );
179 } 183 }
180 globfree( &gg ); 184 globfree( &gg );
181 185
182 if ( strchr( fsFilter,',' ) ) 186 if ( strchr( fsFilter,',' ) )
183 { 187 {
212 free( f ); 216 free( f );
213 } 217 }
214 #endif 218 #endif
215 219
216 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); 220 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg );
217 pixmap=fpixmap; mask=fmask;
218 for( i=0;(unsigned)i<gg.gl_pathc;i++ ) 221 for( i=0;(unsigned)i<gg.gl_pathc;i++ )
219 { 222 {
220 stat( gg.gl_pathv[i],&fs ); 223 stat( gg.gl_pathv[i],&fs );
221 if( S_ISDIR( fs.st_mode ) ) continue; 224 if( S_ISDIR( fs.st_mode ) ) continue;
222 225 clist_append_fname(list, gg.gl_pathv[i], fpixmap, fmask);
223 str[0][1]=gg.gl_pathv[i];
224 gtk_clist_append( GTK_CLIST( list ),str[0] );
225 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask );
226 } 226 }
227 globfree( &gg ); 227 globfree( &gg );
228 228
229 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 ); 229 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 );
230 gtk_clist_select_row( GTK_CLIST( list ),0,1 ); 230 gtk_clist_select_row( GTK_CLIST( list ),0,1 );