Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/fs.c @ 9363:6398c11b1bef
sync
author | nicolas |
---|---|
date | Sun, 09 Feb 2003 11:41:33 +0000 |
parents | c2f31ca14a92 |
children | 27f8546f53c4 |
rev | line source |
---|---|
2901 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 #include <string.h> | |
5 #include <sys/stat.h> | |
6 #include <glob.h> | |
7 #include <unistd.h> | |
8 | |
6625 | 9 #include "../mplayer.h" |
2901 | 10 |
6625 | 11 #include "mplayer/pixmaps/up.xpm" |
12 #include "mplayer/pixmaps/dir.xpm" | |
13 #include "mplayer/pixmaps/file.xpm" | |
2901 | 14 |
8043 | 15 #include "../../app.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
16 #include "../../interface.h" |
2901 | 17 #include "../../../config.h" |
18 #include "../../../help_mp.h" | |
4846 | 19 #include "../../../libmpdemux/stream.h" |
2901 | 20 |
21 #include "../widgets.h" | |
22 #include "fs.h" | |
6794 | 23 #include "opts.h" |
8299 | 24 #include "common.h" |
2901 | 25 |
26 #ifndef __linux__ | |
27 #define get_current_dir_name() getcwd(NULL, PATH_MAX) | |
28 #endif | |
29 | |
30 #ifndef get_current_dir_name | |
31 extern char * get_current_dir_name( void ); | |
32 #endif | |
33 | |
34 gchar * fsSelectedFile = NULL; | |
35 gchar * fsSelectedDirectory = NULL; | |
36 unsigned char * fsThatDir = "."; | |
7540 | 37 gchar * fsFilter = "*"; |
2901 | 38 |
39 int fsPressed = 0; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
40 int fsType = 0; |
3054 | 41 |
7203 | 42 char * fsVideoFilterNames[][2] = |
7531 | 43 { { "MPEG files (*.mpg,*.mpeg,*.m1v)", "*.mpg,*.mpeg,*.m1v" }, |
5786 | 44 { "VOB files (*.vob)", "*.vob" }, |
45 { "AVI files (*.avi)", "*.avi" }, | |
7203 | 46 { "DiVX files (*.divx)", "*.divx" }, |
7531 | 47 { "QuickTime files (*.mov,*.qt)", "*.mov,*.qt" }, |
5786 | 48 { "ASF files (*.asf)", "*.asf" }, |
49 { "VIVO files (*.viv)", "*.viv" }, | |
7217 | 50 { "RealVideo files (*.rm)", "*.rm" }, |
5786 | 51 { "Windows Media Video (*.wmv)", "*.wmv" }, |
7531 | 52 { "OGG Media files (*.ogm)", "*.ogm" }, |
53 { "Autodesk animations (*.fli,*.flc)", "*.fli,*.flc" }, | |
54 { "NuppelVideo files (*.nuv)", "*.nuv" }, | |
7203 | 55 { "MP3 files (*.mp3,mp2)", "*.mp3,*.mp2" }, |
56 { "Wave files (*.wav)", "*.wav" }, | |
57 { "WMA files (*.wma)", "*.wma" }, | |
8299 | 58 { "Audio files", "*.wav,*.ogg,*.mp2,*.mp3,*.wma" }, |
59 { "Video files", "*.asf,*.avi,*.divx,*.fli,*.flc,*.ogm,*.mpg,*.mpeg,*.m1v,*.mov,*.nuv,*.qt,*.rm,*.vob,*.viv,*.wmv" }, | |
60 { "All files", "*" }, | |
7203 | 61 { NULL,NULL } |
62 }; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
63 |
7203 | 64 char * fsSubtitleFilterNames[][2] = |
5786 | 65 { { "UTF (*.utf)", "*.utf" }, |
66 { "SUB (*.sub)", "*.sub" }, | |
67 { "SRT (*.srt)", "*.str" }, | |
68 { "SMI (*.smi)", "*.smi" }, | |
69 { "RT (*.rt) ", "*.rt" }, | |
70 { "TXT (*.txt)", "*.txt" }, | |
71 { "SSA (*.ssa)", "*.ssa" }, | |
72 { "AQT (*.aqt)", "*.aqt" }, | |
8299 | 73 { "Subtitles", "*.utf,*.sub,*.srt,*.smi,*.rt,*.txt,*.ssa,*.aqt" }, |
74 { "All files", "*" }, | |
7203 | 75 { NULL,NULL } |
76 }; | |
3499 | 77 |
7203 | 78 char * fsOtherFilterNames[][2] = |
79 { | |
8299 | 80 { "All files", "*" }, |
7203 | 81 { NULL,NULL } |
82 }; | |
6623 | 83 |
7203 | 84 char * fsAudioFileNames[][2] = |
85 { | |
86 { "WAV files (*.wav)", "*.wav" }, | |
6623 | 87 { "MP3 files (*.mp2, *.mp3)", "*.mp2,*.mp3" }, |
7531 | 88 { "OGG Vorbis files (*.ogg)", "*.ogg" }, |
8299 | 89 { "Audio files", "*.ogg,*.mp2,*.mp3,*.wav" }, |
90 { "All files", "*" }, | |
7203 | 91 { NULL, NULL } |
92 }; | |
2901 | 93 |
7203 | 94 char * fsFontFileNames[][2] = |
95 { | |
7139 | 96 #ifdef HAVE_FREETYPE |
9195 | 97 { "True Type fonts (*.ttf)", "*.ttf" }, |
98 { "Type1 fonts (*.pfb)", "*.pfb" }, | |
99 { "All fonts", "*.ttf,*.pfb" }, | |
7139 | 100 #else |
7203 | 101 { "font files (*.desc)", "*.desc" }, |
7139 | 102 #endif |
8299 | 103 { "All files", "*" }, |
7203 | 104 { NULL,NULL } |
105 }; | |
6794 | 106 |
2901 | 107 GtkWidget * fsFileNamesList; |
108 GtkWidget * fsFNameList; | |
8299 | 109 GtkWidget * fsFileSelect = NULL; |
2901 | 110 GdkColormap * fsColorMap; |
111 GtkWidget * fsOk; | |
112 GtkWidget * fsUp; | |
113 GtkWidget * fsCancel; | |
114 GtkWidget * fsCombo4; | |
3499 | 115 GtkWidget * fsPathCombo; |
2901 | 116 GList * fsList_items = NULL; |
117 GList * fsTopList_items = NULL; | |
3499 | 118 GtkWidget * List; |
119 GtkWidget * fsFilterCombo; | |
2901 | 120 |
3499 | 121 GtkStyle * style; |
122 GdkPixmap * dpixmap; | |
123 GdkPixmap * fpixmap; | |
124 GdkBitmap * dmask; | |
125 GdkBitmap * fmask; | |
126 | |
7203 | 127 static char * Filter( char * name ) |
128 { | |
7387
072a85aa31c6
Can't return pointer to automatic C array, gmplayer file selector box does
jkeil
parents:
7237
diff
changeset
|
129 static char tmp[32]; |
7203 | 130 int i,c; |
131 for ( i=0,c=0;i < strlen( name );i++ ) | |
132 { | |
133 if ( ( name[i] >='a' )&&( name[i] <= 'z' ) ) { tmp[c++]='['; tmp[c++]=name[i]; tmp[c++]=name[i] - 32; tmp[c++]=']'; } | |
134 else tmp[c++]=name[i]; | |
135 } | |
136 tmp[c]=0; | |
137 return tmp; | |
138 } | |
139 | |
3499 | 140 void CheckDir( GtkWidget * list,char * directory ) |
2901 | 141 { |
142 struct stat fs; | |
143 int i,c=2; | |
144 gchar * str[1][2]; | |
3499 | 145 GdkPixmap * pixmap; |
146 GdkBitmap * mask; | |
2901 | 147 glob_t gg; |
148 | |
3499 | 149 if ( !fsFilter[0] ) return; |
150 | |
2901 | 151 gtk_widget_hide( list ); |
3499 | 152 gtk_clist_clear( GTK_CLIST( list ) ); |
2901 | 153 str[0][0]=NULL; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
154 |
2901 | 155 pixmap=dpixmap; mask=dmask; |
8980 | 156 str[0][0]=NULL; |
157 str[0][1]="."; gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),0,0,pixmap,mask ); | |
158 str[0][1]=".."; gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),1,0,pixmap,mask ); | |
2901 | 159 |
3499 | 160 glob( "*",0,NULL,&gg ); |
2901 | 161 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); |
6794 | 162 for( i=0;(unsigned)i<gg.gl_pathc;i++ ) |
2901 | 163 { |
164 stat( gg.gl_pathv[i],&fs ); | |
3499 | 165 if( !S_ISDIR( fs.st_mode ) ) continue; |
166 | |
8980 | 167 str[0][1]=gg.gl_pathv[i]; |
3499 | 168 pixmap=dpixmap; mask=dmask; |
169 gtk_clist_append( GTK_CLIST( list ),str[0] ); | |
170 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask ); | |
2901 | 171 } |
172 globfree( &gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
173 |
5786 | 174 if ( strchr( fsFilter,',' ) ) |
175 { | |
176 char tmp[8]; | |
177 int i,c,glob_param = 0; | |
178 //printf( "sub item detected.\n" ); | |
179 for ( i=0,c=0;i<(int)strlen( fsFilter ) + 1;i++,c++ ) | |
180 { | |
181 tmp[c]=fsFilter[i]; | |
182 if ( ( tmp[c] == ',' )||( tmp[c] == '\0' ) ) | |
183 { | |
184 tmp[c]=0; c=-1; | |
185 // printf( "substr: %s\n",tmp ); | |
7203 | 186 glob( Filter( tmp ),glob_param,NULL,&gg ); |
5786 | 187 glob_param=GLOB_APPEND; |
188 } | |
189 } | |
7203 | 190 } else glob( Filter( fsFilter ),0,NULL,&gg ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
191 |
3499 | 192 #if 0 |
193 if ( !strcmp( fsFilter,"*" ) ) | |
194 { | |
195 char * f = strdup( fsFilter ); | |
196 int i; | |
197 for( i=0;i<strlen( f );i++ ) | |
198 if ( ( f[i] >= 'A' )&&( f[i] <= 'Z' ) ) f[i]+=32; | |
199 glob( f,GLOB_APPEND,NULL,&gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
200 |
3499 | 201 for( i=0;i<strlen( f );i++ ) |
202 if ( ( f[i] >= 'a' )&&( f[i] <= 'z' ) ) f[i]-=32; | |
203 glob( f,GLOB_APPEND,NULL,&gg ); | |
204 free( f ); | |
205 } | |
206 #endif | |
207 | |
2901 | 208 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); |
209 pixmap=fpixmap; mask=fmask; | |
6794 | 210 for( i=0;(unsigned)i<gg.gl_pathc;i++ ) |
2901 | 211 { |
212 stat( gg.gl_pathv[i],&fs ); | |
213 if( S_ISDIR( fs.st_mode ) ) continue; | |
3499 | 214 |
8980 | 215 str[0][1]=gg.gl_pathv[i]; |
2901 | 216 gtk_clist_append( GTK_CLIST( list ),str[0] ); |
3499 | 217 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask ); |
2901 | 218 } |
219 globfree( &gg ); | |
220 | |
221 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 ); | |
222 gtk_clist_select_row( GTK_CLIST( list ),0,1 ); | |
223 gtk_widget_show( list ); | |
224 } | |
225 | |
9192 | 226 void fs_PersistantHistory( char *subject ); /* forward declaration */ |
9190 | 227 |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
228 void ShowFileSelect( int type,int modal ) |
3499 | 229 { |
230 int i; | |
6794 | 231 char * tmp = NULL; |
6146 | 232 |
8299 | 233 if ( fsFileSelect ) gtkActive( fsFileSelect ); |
6146 | 234 else fsFileSelect=create_FileSelect(); |
6044 | 235 |
3499 | 236 fsType=type; |
237 switch ( type ) | |
238 { | |
239 case fsVideoSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
240 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); |
3499 | 241 fsList_items=NULL; |
7203 | 242 for( i=0;fsVideoFilterNames[i][0];i++ ) |
3499 | 243 fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] ); |
244 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
245 g_list_free( fsList_items ); | |
7203 | 246 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[i-2][0] ); |
6794 | 247 tmp=guiIntfStruct.Filename; |
3499 | 248 break; |
249 case fsSubtitleSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
250 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_SubtitleSelect ); |
3499 | 251 fsList_items=NULL; |
7203 | 252 for( i=0;fsSubtitleFilterNames[i][0];i++ ) |
3499 | 253 fsList_items=g_list_append( fsList_items,fsSubtitleFilterNames[i][0] ); |
254 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
255 g_list_free( fsList_items ); | |
7203 | 256 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsSubtitleFilterNames[i-2][0] ); |
6794 | 257 tmp=guiIntfStruct.Subtitlename; |
3499 | 258 break; |
259 case fsOtherSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
260 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_OtherSelect ); |
3499 | 261 fsList_items=NULL; |
7203 | 262 for( i=0;fsOtherFilterNames[i][0];i++ ) |
3499 | 263 fsList_items=g_list_append( fsList_items,fsOtherFilterNames[i][0] ); |
264 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
265 g_list_free( fsList_items ); | |
7203 | 266 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsOtherFilterNames[0][0] ); |
6794 | 267 tmp=guiIntfStruct.Othername; |
3499 | 268 break; |
6623 | 269 case fsAudioSelector: |
270 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_AudioFileSelect ); | |
271 fsList_items=NULL; | |
7203 | 272 for( i=0;fsAudioFileNames[i][0];i++ ) |
6623 | 273 fsList_items=g_list_append( fsList_items,fsAudioFileNames[i][0] ); |
274 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
275 g_list_free( fsList_items ); | |
7203 | 276 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsAudioFileNames[i-2][0] ); |
6794 | 277 tmp=guiIntfStruct.AudioFile; |
278 break; | |
279 case fsFontSelector: | |
280 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FontSelect ); | |
281 fsList_items=NULL; | |
7203 | 282 for( i=0;fsFontFileNames[i][0];i++ ) |
6794 | 283 fsList_items=g_list_append( fsList_items,fsFontFileNames[i][0] ); |
284 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
285 g_list_free( fsList_items ); | |
7203 | 286 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsFontFileNames[i-2][0] ); |
7019 | 287 tmp=font_name; |
6623 | 288 break; |
3499 | 289 } |
6794 | 290 |
291 if ( tmp && tmp[0] ) | |
292 { | |
293 struct stat f; | |
294 char * dir = strdup( tmp ); | |
295 | |
296 do | |
297 { | |
298 char * c = strrchr( dir,'/' ); | |
299 stat( dir,&f ); | |
300 if ( S_ISDIR( f.st_mode ) ) break; | |
301 if ( c ) *c=0; | |
302 } while ( strrchr( dir,'/' ) ); | |
303 | |
304 if ( dir[0] ) chdir( dir ); | |
305 | |
306 free( dir ); | |
307 } | |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
308 |
6794 | 309 if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
310 { |
9055 | 311 char * hist; |
312 int i, c = 1; | |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
313 |
9195 | 314 if ( fsType == fsVideoSelector ) |
315 { | |
316 for ( i=0;i < fsPersistant_MaxPos;i++ ) | |
317 if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); c=0; } | |
318 } | |
9055 | 319 if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
320 } |
6794 | 321 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); |
322 fsTopList_items=g_list_append( fsTopList_items,"/home" ); | |
323 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); | |
324 fsTopList_items=g_list_append( fsTopList_items,"/" ); | |
325 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); | |
326 | |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
327 gtk_window_set_modal( GTK_WINDOW( fsFileSelect ),modal ); |
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
328 |
6903 | 329 gtk_widget_show( fsFileSelect ); |
3499 | 330 } |
331 | |
2901 | 332 void HideFileSelect( void ) |
6146 | 333 { |
8299 | 334 if ( !fsFileSelect ) return; |
6146 | 335 gtk_widget_hide( fsFileSelect ); |
336 gtk_widget_destroy( fsFileSelect ); | |
8299 | 337 fsFileSelect=NULL; |
6146 | 338 } |
2901 | 339 |
9192 | 340 void fs_PersistantHistory( char * subject ) |
9055 | 341 { |
342 int i; | |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
343 |
9192 | 344 if ( fsType != fsVideoSelector ) return; |
345 | |
9056 | 346 for ( i=0;i < fsPersistant_MaxPos;i++ ) |
347 if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) ) | |
348 { | |
349 char * tmp = fsHistory[i]; fsHistory[i]=fsHistory[0]; fsHistory[0]=tmp; | |
9192 | 350 return; |
9056 | 351 } |
9055 | 352 gfree( (void **)&fsHistory[fsPersistant_MaxPos - 1] ); |
353 for ( i=fsPersistant_MaxPos - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1]; | |
354 fsHistory[0]=gstrdup( subject ); | |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
355 } |
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
356 //----------------------------------------------- |
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
357 |
3499 | 358 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) |
2901 | 359 { |
7540 | 360 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); |
3499 | 361 CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 362 } |
363 | |
3499 | 364 void fs_fsFilterCombo_changed( GtkEditable * editable,gpointer user_data ) |
2901 | 365 { |
3499 | 366 char * str; |
367 int i; | |
2901 | 368 |
369 str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
370 |
3499 | 371 switch ( fsType ) |
2901 | 372 { |
3499 | 373 case fsVideoSelector: |
7203 | 374 for( i=0;fsVideoFilterNames[i][0];i++ ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
375 if( !strcmp( str,fsVideoFilterNames[i][0] ) ) |
7540 | 376 { fsFilter=fsVideoFilterNames[i][1]; break; } |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
377 break; |
3499 | 378 case fsSubtitleSelector: |
7203 | 379 for( i=0;fsSubtitleFilterNames[i][0];i++ ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
380 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) |
7540 | 381 { fsFilter=fsSubtitleFilterNames[i][1]; break; } |
3499 | 382 break; |
383 case fsOtherSelector: | |
7203 | 384 for( i=0;fsOtherFilterNames[i][0];i++ ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
385 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) |
7540 | 386 { fsFilter=fsOtherFilterNames[i][1]; break; } |
3499 | 387 break; |
6623 | 388 case fsAudioSelector: |
7203 | 389 for( i=0;fsAudioFileNames[i][0];i++ ) |
6623 | 390 if( !strcmp( str,fsAudioFileNames[i][0] ) ) |
7540 | 391 { fsFilter=fsAudioFileNames[i][1]; break; } |
6623 | 392 break; |
6794 | 393 case fsFontSelector: |
7203 | 394 for( i=0;fsFontFileNames[i][0];i++ ) |
6794 | 395 if( !strcmp( str,fsFontFileNames[i][0] ) ) |
7556 | 396 { fsFilter=fsFontFileNames[i][1]; break; } |
6794 | 397 break; |
6623 | 398 default: return; |
2901 | 399 } |
6623 | 400 CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 401 } |
402 | |
3499 | 403 void fs_fsPathCombo_activate( GtkEditable * editable,gpointer user_data ) |
2901 | 404 { |
405 unsigned char * str; | |
406 | |
407 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
3499 | 408 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 409 } |
410 | |
3499 | 411 void fs_fsPathCombo_changed( GtkEditable * editable,gpointer user_data ) |
2901 | 412 { |
413 unsigned char * str; | |
414 | |
415 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
416 fsPressed=2; | |
3499 | 417 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 418 } |
419 | |
420 void fs_Up_released( GtkButton * button,gpointer user_data ) | |
421 { | |
422 chdir( ".." ); | |
423 fsSelectedFile=fsThatDir; | |
3499 | 424 CheckDir( fsFNameList,get_current_dir_name() ); |
425 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
2901 | 426 return; |
427 } | |
428 | |
429 int fsFileExist( unsigned char * fname ) | |
430 { | |
431 FILE * f = fopen( fname,"r" ); | |
432 if ( f == NULL ) return 0; | |
433 fclose( f ); | |
434 return 1; | |
435 } | |
436 | |
437 void fs_Ok_released( GtkButton * button,gpointer user_data ) | |
438 { | |
439 unsigned char * str; | |
440 GList * item; | |
441 int size,j,i = 1; | |
442 struct stat fs; | |
443 | |
444 stat( fsSelectedFile,&fs ); | |
445 if( S_ISDIR(fs.st_mode ) ) | |
446 { | |
447 chdir( fsSelectedFile ); | |
448 fsSelectedFile=fsThatDir; | |
3499 | 449 CheckDir( fsFNameList,get_current_dir_name() ); |
450 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
2901 | 451 return; |
452 } | |
453 | |
454 switch( fsPressed ) | |
455 { | |
456 case 1: | |
457 fsSelectedDirectory=(unsigned char *)get_current_dir_name(); | |
458 break; | |
459 case 2: | |
3499 | 460 str=gtk_entry_get_text( GTK_ENTRY( fsPathCombo ) ); |
2901 | 461 fsSelectedFile=str; |
6146 | 462 if ( !fsFileExist( fsSelectedFile ) ) { HideFileSelect(); return; } |
2901 | 463 fsSelectedDirectory=fsSelectedFile; |
464 size=strlen( fsSelectedDirectory ); | |
465 for ( j=0;j<size;j++ ) | |
466 { | |
467 if ( fsSelectedDirectory[ size - j ] == '/' ) | |
468 { | |
469 fsSelectedFile+=size - j + 1; | |
470 fsSelectedDirectory[ size - j ]=0; | |
471 break; | |
472 } | |
473 } | |
474 break; | |
475 } | |
3499 | 476 switch ( fsType ) |
477 { | |
478 case fsVideoSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
479 guiSetDF( guiIntfStruct.Filename,fsSelectedDirectory,fsSelectedFile ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
480 guiIntfStruct.StreamType=STREAMTYPE_FILE; |
9088 | 481 guiIntfStruct.FilenameChanged=1; sub_fps=0; |
6840 | 482 gfree( (void **)&guiIntfStruct.AudioFile ); |
483 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
9055 | 484 fs_PersistantHistory( fsSelectedDirectory ); //totem, write into history |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
485 break; |
7150 | 486 #ifdef USE_SUB |
3499 | 487 case fsSubtitleSelector: |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
488 guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile ); |
7150 | 489 guiLoadSubtitle( guiIntfStruct.Subtitlename ); |
3499 | 490 break; |
7150 | 491 #endif |
3499 | 492 case fsOtherSelector: |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
493 guiSetDF( guiIntfStruct.Othername,fsSelectedDirectory,fsSelectedFile ); |
3499 | 494 break; |
6623 | 495 case fsAudioSelector: |
496 guiSetDF( guiIntfStruct.AudioFile,fsSelectedDirectory,fsSelectedFile ); | |
497 break; | |
6794 | 498 case fsFontSelector: |
7019 | 499 guiSetDF( font_name,fsSelectedDirectory,fsSelectedFile ); |
6794 | 500 #if defined( USE_OSD ) || defined( USE_SUB ) |
501 guiLoadFont(); | |
502 #endif | |
8299 | 503 if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name ); |
6794 | 504 break; |
3499 | 505 } |
6146 | 506 |
507 HideFileSelect(); | |
508 | |
2901 | 509 item=fsTopList_items; |
510 while( item ) | |
511 { | |
512 if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0; | |
513 item=item->next; | |
514 } | |
6044 | 515 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() ); |
6912 | 516 if ( mplMainAutoPlay ) { mplMainAutoPlay=0; mplEventHandling( evPlay,0 ); } |
9202 | 517 else guiGetEvent( guiCEvent,guiSetStop ); |
2901 | 518 } |
519 | |
520 void fs_Cancel_released( GtkButton * button,gpointer user_data ) | |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
521 { |
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
522 HideFileSelect(); |
9055 | 523 fs_PersistantHistory( get_current_dir_name() ); //totem, write into history file |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
524 } |
2901 | 525 |
526 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) | |
527 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
528 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); |
2901 | 529 fsPressed=1; |
8299 | 530 if( bevent && bevent->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); |
2901 | 531 } |
532 | |
533 gboolean on_FileSelect_key_release_event( GtkWidget * widget,GdkEventKey * event,gpointer user_data ) | |
534 { | |
535 switch ( event->keyval ) | |
536 { | |
537 case GDK_Escape: | |
538 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
539 break; | |
540 case GDK_Return: | |
541 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
542 break; | |
543 case GDK_BackSpace: | |
544 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
545 break; | |
546 } | |
547 return FALSE; | |
548 } | |
549 | |
550 GtkWidget * create_FileSelect( void ) | |
551 { | |
552 GtkWidget * FSFrame; | |
553 GtkWidget * frame2; | |
554 GtkWidget * frame3; | |
555 GtkWidget * frame4; | |
556 GtkWidget * vbox4; | |
557 GtkWidget * hbox4; | |
558 GtkWidget * vseparator1; | |
559 GtkWidget * hseparator1; | |
560 GtkWidget * hbox6; | |
561 GtkWidget * fsFNameListWindow; | |
562 GtkWidget * label1; | |
563 GtkWidget * hseparator2; | |
564 GtkWidget * hseparator3; | |
565 GtkWidget * hbuttonbox3; | |
566 | |
567 GtkWidget * uppixmapwid; | |
568 GdkPixmap * uppixmap; | |
569 GdkBitmap * upmask; | |
570 GtkStyle * upstyle; | |
571 | |
8713
d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
pontscho
parents:
8299
diff
changeset
|
572 |
4779 | 573 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
2901 | 574 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); |
575 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | |
4779 | 576 gtk_widget_set_usize( fsFileSelect,512,300 ); |
2901 | 577 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); |
578 gtk_widget_set_events( fsFileSelect,GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK ); | |
579 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
580 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER ); | |
4779 | 581 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE ); |
8299 | 582 gtk_window_set_wmclass( GTK_WINDOW( fsFileSelect ),"FileSelect","MPlayer" ); |
2901 | 583 fsColorMap=gdk_colormap_get_system(); |
6651 | 584 |
585 gtk_widget_realize( fsFileSelect ); | |
586 gtkAddIcon( fsFileSelect ); | |
2901 | 587 |
3499 | 588 style=gtk_widget_get_style( fsFileSelect ); |
589 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
590 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
591 | |
8299 | 592 vbox4=AddVBox( AddDialogFrame( fsFileSelect ),0 ); |
593 hbox4=AddHBox( vbox4,1 ); | |
2901 | 594 |
595 fsCombo4=gtk_combo_new(); | |
596 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
597 gtk_widget_show( fsCombo4 ); | |
598 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
599 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
600 | |
3499 | 601 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; |
602 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
603 gtk_widget_show( fsPathCombo ); | |
604 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
2901 | 605 |
606 vseparator1=gtk_vseparator_new(); | |
607 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
608 gtk_widget_show( vseparator1 ); | |
609 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
610 gtk_widget_set_usize( vseparator1,7,20 ); | |
611 | |
612 upstyle=gtk_widget_get_style( fsFileSelect ); | |
613 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
614 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); | |
615 gtk_widget_show( uppixmapwid ); | |
616 | |
617 fsUp=gtk_button_new(); | |
618 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
619 gtk_widget_show( fsUp ); | |
620 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
621 gtk_widget_set_usize( fsUp,65,15 ); | |
622 | |
8299 | 623 AddHSeparator( vbox4 ); |
2901 | 624 |
8299 | 625 hbox6=AddHBox( NULL,0 ); |
626 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
2901 | 627 |
628 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
629 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
630 gtk_widget_show( fsFNameListWindow ); | |
631 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
632 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
633 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
634 | |
635 fsFNameList=gtk_clist_new( 2 ); | |
636 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
637 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); | |
638 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
639 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
640 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
641 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
642 | |
8299 | 643 AddHSeparator( vbox4 ); |
2901 | 644 |
645 List=gtk_combo_new(); | |
646 gtk_widget_set_name( List,"List" ); | |
647 gtk_widget_ref( List ); | |
6044 | 648 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 649 gtk_widget_show( List ); |
650 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
651 gtk_widget_set_usize( List,-2,20 ); | |
652 | |
3499 | 653 fsFilterCombo=GTK_COMBO( List )->entry; |
654 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
655 gtk_widget_show( fsFilterCombo ); | |
656 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
2901 | 657 |
8299 | 658 AddHSeparator( vbox4 ); |
2901 | 659 |
8299 | 660 hbuttonbox3=AddHButtonBox( vbox4 ); |
661 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
662 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
2901 | 663 |
8299 | 664 fsOk=AddButton( MSGTR_Ok,hbuttonbox3 ); |
665 fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 ); | |
2901 | 666 |
8719
dc27303ae528
correct widget destroy event handler (thank for D J Hawkey Jr <hawkeyd@visi.com>)
pontscho
parents:
8713
diff
changeset
|
667 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&fsFileSelect ); |
6044 | 668 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); |
6146 | 669 |
6044 | 670 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); |
671 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
672 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
673 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
674 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
675 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); | |
676 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); | |
677 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); | |
2901 | 678 |
679 gtk_widget_grab_focus( fsFNameList ); | |
680 | |
681 return fsFileSelect; | |
682 } | |
683 |