Mercurial > mplayer.hg
annotate gui/mplayer/gtk/fs.c @ 27414:031e294a414c
sync w/27407 + fixes
author | gpoirier |
---|---|
date | Sat, 09 Aug 2008 18:40:51 +0000 |
parents | 4876c89bafdd |
children | 9e739bdb049c |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
21 #include <string.h> | |
22 #include <sys/stat.h> | |
23 #include <glob.h> | |
24 #include <unistd.h> | |
25 | |
26203 | 26 #include "config.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
27 #include "gui/mplayer/gmplayer.h" |
23077 | 28 |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
29 #include "gui/mplayer/pixmaps/up.xpm" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
30 #include "gui/mplayer/pixmaps/dir.xpm" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
31 #include "gui/mplayer/pixmaps/file.xpm" |
23077 | 32 |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
33 #include "gui/app.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
34 #include "gui/interface.h" |
23077 | 35 #include "help_mp.h" |
36 #include "stream/stream.h" | |
37 | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "gui/mplayer/widgets.h" |
23077 | 39 #include "fs.h" |
40 #include "opts.h" | |
25601
8a0adeba5910
Rename common.[ch] to gtk_common.[ch], there are too many files by that name.
diego
parents:
25248
diff
changeset
|
41 #include "gtk_common.h" |
23077 | 42 |
43 #ifndef __linux__ | |
44 #define get_current_dir_name() getcwd(NULL, PATH_MAX) | |
25992
a9e86b2def64
Merge the two conditional definitions of get_current_dir_name.
diego
parents:
25601
diff
changeset
|
45 #else |
25993 | 46 extern char * get_current_dir_name( void ); |
23077 | 47 #endif |
48 | |
49 gchar * fsSelectedFile = NULL; | |
50 gchar * fsSelectedDirectory = NULL; | |
51 unsigned char * fsThatDir = "."; | |
25226 | 52 const gchar * fsFilter = "*"; |
23077 | 53 |
54 int fsType = 0; | |
55 | |
56 char * fsVideoFilterNames[][2] = | |
57 { { "MPEG files (*.mpg,*.mpeg,*.m1v)", "*.mpg,*.mpeg,*.m1v" }, | |
58 { "VCD/SVCD Images (*.bin)", "*.bin" }, | |
59 { "VOB files (*.vob)", "*.vob" }, | |
60 { "AVI files (*.avi)", "*.avi" }, | |
61 { "DiVX files (*.divx)", "*.divx" }, | |
62 { "QuickTime files (*.mov,*.qt,*.mp4)", "*.mov,*.qt,*.mp4" }, | |
63 { "ASF files (*.asf)", "*.asf" }, | |
64 { "VIVO files (*.viv)", "*.viv" }, | |
65 { "RealVideo files (*.rm)", "*.rm" }, | |
66 { "Windows Media Video (*.wmv)", "*.wmv" }, | |
67 { "OGG Media files (*.ogm)", "*.ogm" }, | |
68 { "Matroska Media files (*.mkv)", "*.mkv" }, | |
69 { "Autodesk animations (*.fli,*.flc)", "*.fli,*.flc" }, | |
70 { "NuppelVideo files (*.nuv)", "*.nuv" }, | |
71 { "MP3 files (*.mp3,*.mp2)", "*.mp3,*.mp2" }, | |
72 { "Wave files (*.wav)", "*.wav" }, | |
73 { "WMA files (*.wma)", "*.wma" }, | |
74 { "Matroska Audio files (*.mka)", "*.mka" }, | |
75 { "Audio files", "*.wav,*.ogg,*.mp2,*.mp3,*.wma,*.mka" }, | |
76 { "Video files", "*.asf,*.avi,*.divx,*.fli,*.flc,*.ogm,*.mpg,*.mpeg,*.m1v,*.mov,*.mp4,*.nuv,*.qt,*.rm,*.vob,*.viv,*.wmv,*.mkv,*.bin" }, | |
77 { "All files", "*" }, | |
78 { NULL,NULL } | |
79 }; | |
80 int fsLastVideoFilterSelected = -1; | |
81 | |
82 char * fsSubtitleFilterNames[][2] = | |
83 { { "UTF (*.utf)", "*.utf" }, | |
84 { "SUB (*.sub)", "*.sub" }, | |
85 { "SRT (*.srt)", "*.str" }, | |
86 { "SMI (*.smi)", "*.smi" }, | |
87 { "RT (*.rt) ", "*.rt" }, | |
88 { "TXT (*.txt)", "*.txt" }, | |
89 { "ASS (*.ass)", "*.ass" }, | |
90 { "SSA (*.ssa)", "*.ssa" }, | |
91 { "AQT (*.aqt)", "*.aqt" }, | |
92 { "Subtitles", "*.utf,*.sub,*.srt,*.smi,*.rt,*.txt,*.ass,*.ssa,*.aqt" }, | |
93 { "All files", "*" }, | |
94 { NULL,NULL } | |
95 }; | |
96 int fsLastSubtitleFilterSelected = -1; | |
97 | |
98 char * fsOtherFilterNames[][2] = | |
25993 | 99 { |
23077 | 100 { "All files", "*" }, |
101 { NULL,NULL } | |
102 }; | |
25993 | 103 |
23077 | 104 char * fsAudioFileNames[][2] = |
25993 | 105 { |
23077 | 106 { "WAV files (*.wav)", "*.wav" }, |
107 { "MP3 files (*.mp2, *.mp3)", "*.mp2,*.mp3" }, | |
108 { "OGG Vorbis files (*.ogg)", "*.ogg" }, | |
109 { "WMA files (*.wma)", "*.wma" }, | |
110 { "Matroska Audio files (*.mka)", "*.mka" }, | |
111 { "Audio files", "*.ogg,*.mp2,*.mp3,*.wav,*.wma,*.mka" }, | |
112 { "All files", "*" }, | |
113 { NULL, NULL } | |
114 }; | |
115 int fsLastAudioFilterSelected = -1; | |
116 | |
117 char * fsFontFileNames[][2] = | |
118 { | |
27393 | 119 #ifdef CONFIG_FREETYPE |
23077 | 120 { "True Type fonts (*.ttf)", "*.ttf" }, |
121 { "Type1 fonts (*.pfb)", "*.pfb" }, | |
122 { "All fonts", "*.ttf,*.pfb" }, | |
123 #else | |
124 { "font files (*.desc)", "*.desc" }, | |
125 #endif | |
126 { "All files", "*" }, | |
127 { NULL,NULL } | |
128 }; | |
129 int fsLastFontFilterSelected = -1; | |
130 | |
131 GtkWidget * fsFileNamesList; | |
132 GtkWidget * fsFNameList; | |
133 GtkWidget * fsFileSelect = NULL; | |
134 GdkColormap * fsColorMap; | |
135 GtkWidget * fsOk; | |
136 GtkWidget * fsUp; | |
137 GtkWidget * fsCancel; | |
138 GtkWidget * fsCombo4; | |
139 GtkWidget * fsPathCombo; | |
140 GList * fsList_items = NULL; | |
141 GList * fsTopList_items = NULL; | |
142 GtkWidget * List; | |
143 GtkWidget * fsFilterCombo; | |
144 | |
145 GtkStyle * style; | |
146 GdkPixmap * dpixmap; | |
147 GdkPixmap * fpixmap; | |
148 GdkBitmap * dmask; | |
149 GdkBitmap * fmask; | |
150 | |
25235
b444558c0b22
Parameter of Filter function can be const, removes the warning
reimar
parents:
25226
diff
changeset
|
151 static char * Filter( const char * name ) |
23077 | 152 { |
153 static char tmp[32]; | |
154 int i,c; | |
155 for ( i=0,c=0;i < strlen( name );i++ ) | |
156 { | |
157 if ( ( name[i] >='a' )&&( name[i] <= 'z' ) ) { tmp[c++]='['; tmp[c++]=name[i]; tmp[c++]=name[i] - 32; tmp[c++]=']'; } | |
158 else tmp[c++]=name[i]; | |
159 } | |
160 tmp[c]=0; | |
161 return tmp; | |
162 } | |
163 | |
23445 | 164 static void clist_append_fname(GtkWidget * list, char *fname, |
165 GdkPixmap *pixmap, GdkPixmap *mask) { | |
166 gint pos; | |
167 gchar *str[2]; | |
168 str[0] = NULL; | |
169 str[1] = fname; | |
170 pos = gtk_clist_append(GTK_CLIST(list), str); | |
171 gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask); | |
172 } | |
173 | |
23077 | 174 void CheckDir( GtkWidget * list,char * directory ) |
175 { | |
176 struct stat fs; | |
23445 | 177 int i; |
23077 | 178 glob_t gg; |
179 | |
180 if ( !fsFilter[0] ) return; | |
181 | |
182 gtk_widget_hide( list ); | |
183 gtk_clist_clear( GTK_CLIST( list ) ); | |
184 | |
23445 | 185 clist_append_fname(list, ".", dpixmap, dmask); |
186 clist_append_fname(list, "..", dpixmap, dmask); | |
23077 | 187 |
188 glob( "*",0,NULL,&gg ); | |
189 for( i=0;(unsigned)i<gg.gl_pathc;i++ ) | |
190 { | |
191 stat( gg.gl_pathv[i],&fs ); | |
192 if( !S_ISDIR( fs.st_mode ) ) continue; | |
23445 | 193 clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask); |
23077 | 194 } |
195 globfree( &gg ); | |
196 | |
197 if ( strchr( fsFilter,',' ) ) | |
198 { | |
199 char tmp[8]; | |
200 int i,c,glob_param = 0; | |
201 for ( i=0,c=0;i<(int)strlen( fsFilter ) + 1;i++,c++ ) | |
202 { | |
203 tmp[c]=fsFilter[i]; | |
204 if ( ( tmp[c] == ',' )||( tmp[c] == '\0' ) ) | |
205 { | |
206 tmp[c]=0; c=-1; | |
25993 | 207 glob( Filter( tmp ),glob_param,NULL,&gg ); |
23077 | 208 glob_param=GLOB_APPEND; |
209 } | |
210 } | |
211 } else glob( Filter( fsFilter ),0,NULL,&gg ); | |
212 | |
213 for( i=0;(unsigned)i<gg.gl_pathc;i++ ) | |
214 { | |
215 stat( gg.gl_pathv[i],&fs ); | |
216 if( S_ISDIR( fs.st_mode ) ) continue; | |
23445 | 217 clist_append_fname(list, gg.gl_pathv[i], fpixmap, fmask); |
23077 | 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 | |
226 void fs_PersistantHistory( char *subject ); /* forward declaration */ | |
227 | |
228 void ShowFileSelect( int type,int modal ) | |
229 { | |
230 int i, k; | |
231 char * tmp = NULL; | |
232 | |
233 if ( fsFileSelect ) gtkActive( fsFileSelect ); | |
234 else fsFileSelect=create_FileSelect(); | |
25993 | 235 |
23077 | 236 fsType=type; |
237 switch ( type ) | |
238 { | |
239 case fsVideoSelector: | |
240 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
241 fsList_items=NULL; | |
242 for( i=0;fsVideoFilterNames[i][0];i++ ) | |
243 fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] ); | |
244 k = fsLastVideoFilterSelected; | |
245 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
246 g_list_free( fsList_items ); | |
247 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[k >= 0 ? k : i-2][0] ); | |
248 tmp=guiIntfStruct.Filename; | |
249 break; | |
250 case fsSubtitleSelector: | |
251 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_SubtitleSelect ); | |
252 fsList_items=NULL; | |
253 for( i=0;fsSubtitleFilterNames[i][0];i++ ) | |
254 fsList_items=g_list_append( fsList_items,fsSubtitleFilterNames[i][0] ); | |
255 k = fsLastSubtitleFilterSelected; | |
256 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
257 g_list_free( fsList_items ); | |
258 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsSubtitleFilterNames[k >= 0 ? k : i-2][0] ); | |
259 tmp=guiIntfStruct.Subtitlename; | |
260 break; | |
261 case fsOtherSelector: | |
262 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_OtherSelect ); | |
263 fsList_items=NULL; | |
264 for( i=0;fsOtherFilterNames[i][0];i++ ) | |
265 fsList_items=g_list_append( fsList_items,fsOtherFilterNames[i][0] ); | |
266 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
267 g_list_free( fsList_items ); | |
268 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsOtherFilterNames[0][0] ); | |
269 tmp=guiIntfStruct.Othername; | |
270 break; | |
271 case fsAudioSelector: | |
272 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_AudioFileSelect ); | |
273 fsList_items=NULL; | |
274 for( i=0;fsAudioFileNames[i][0];i++ ) | |
275 fsList_items=g_list_append( fsList_items,fsAudioFileNames[i][0] ); | |
276 k = fsLastAudioFilterSelected; | |
277 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
278 g_list_free( fsList_items ); | |
279 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsAudioFileNames[k >= 0 ? k : i-2][0] ); | |
280 tmp=guiIntfStruct.AudioFile; | |
281 break; | |
282 case fsFontSelector: | |
283 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FontSelect ); | |
284 fsList_items=NULL; | |
285 for( i=0;fsFontFileNames[i][0];i++ ) | |
286 fsList_items=g_list_append( fsList_items,fsFontFileNames[i][0] ); | |
287 k = fsLastFontFilterSelected; | |
288 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
289 g_list_free( fsList_items ); | |
290 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsFontFileNames[k >= 0 ? k : i-2][0] ); | |
291 tmp=font_name; | |
292 break; | |
293 } | |
294 | |
295 if ( tmp && tmp[0] ) | |
296 { | |
297 struct stat f; | |
298 char * dir = strdup( tmp ); | |
299 | |
25993 | 300 do |
23077 | 301 { |
302 char * c = strrchr( dir,'/' ); | |
303 stat( dir,&f ); | |
304 if ( S_ISDIR( f.st_mode ) ) break; | |
305 if ( c ) *c=0; | |
306 } while ( strrchr( dir,'/' ) ); | |
307 | |
308 if ( dir[0] ) chdir( dir ); | |
25993 | 309 |
23077 | 310 free( dir ); |
311 } | |
25993 | 312 |
23077 | 313 if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; |
314 { | |
315 int i, c = 1; | |
25993 | 316 |
23077 | 317 if ( fsType == fsVideoSelector ) |
318 { | |
319 for ( i=0;i < fsPersistant_MaxPos;i++ ) | |
320 if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); c=0; } | |
321 } | |
322 if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); | |
323 } | |
324 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); | |
325 fsTopList_items=g_list_append( fsTopList_items,"/home" ); | |
326 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); | |
327 fsTopList_items=g_list_append( fsTopList_items,"/" ); | |
328 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); | |
25993 | 329 |
23077 | 330 gtk_window_set_modal( GTK_WINDOW( fsFileSelect ),modal ); |
331 | |
332 gtk_widget_show( fsFileSelect ); | |
333 } | |
334 | |
335 void HideFileSelect( void ) | |
336 { | |
337 if ( !fsFileSelect ) return; | |
338 gtk_widget_hide( fsFileSelect ); | |
339 gtk_widget_destroy( fsFileSelect ); | |
340 fsFileSelect=NULL; | |
341 } | |
342 | |
343 void fs_PersistantHistory( char * subject ) | |
344 { | |
345 int i; | |
346 | |
347 if ( fsType != fsVideoSelector ) return; | |
348 | |
349 for ( i=0;i < fsPersistant_MaxPos;i++ ) | |
350 if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) ) | |
351 { | |
352 char * tmp = fsHistory[i]; fsHistory[i]=fsHistory[0]; fsHistory[0]=tmp; | |
353 return; | |
354 } | |
355 gfree( (void **)&fsHistory[fsPersistant_MaxPos - 1] ); | |
356 for ( i=fsPersistant_MaxPos - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1]; | |
357 fsHistory[0]=gstrdup( subject ); | |
358 } | |
359 //----------------------------------------------- | |
360 | |
361 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) | |
362 { | |
363 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
364 CheckDir( fsFNameList,get_current_dir_name() ); | |
365 } | |
366 | |
367 void fs_fsFilterCombo_changed( GtkEditable * editable,gpointer user_data ) | |
368 { | |
25226 | 369 const char * str; |
23077 | 370 int i; |
371 | |
372 str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); | |
373 | |
374 switch ( fsType ) | |
375 { | |
376 case fsVideoSelector: | |
377 for( i=0;fsVideoFilterNames[i][0];i++ ) | |
378 if( !strcmp( str,fsVideoFilterNames[i][0] ) ) | |
379 { fsFilter=fsVideoFilterNames[i][1]; fsLastVideoFilterSelected = i; break; } | |
380 break; | |
381 case fsSubtitleSelector: | |
382 for( i=0;fsSubtitleFilterNames[i][0];i++ ) | |
383 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) | |
384 { fsFilter=fsSubtitleFilterNames[i][1]; fsLastSubtitleFilterSelected = i; break; } | |
385 break; | |
386 case fsOtherSelector: | |
387 for( i=0;fsOtherFilterNames[i][0];i++ ) | |
388 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) | |
389 { fsFilter=fsOtherFilterNames[i][1]; break; } | |
390 break; | |
391 case fsAudioSelector: | |
392 for( i=0;fsAudioFileNames[i][0];i++ ) | |
393 if( !strcmp( str,fsAudioFileNames[i][0] ) ) | |
394 { fsFilter=fsAudioFileNames[i][1]; fsLastAudioFilterSelected = i; break; } | |
395 break; | |
396 case fsFontSelector: | |
397 for( i=0;fsFontFileNames[i][0];i++ ) | |
398 if( !strcmp( str,fsFontFileNames[i][0] ) ) | |
399 { fsFilter=fsFontFileNames[i][1]; fsLastFontFilterSelected = i; break; } | |
400 break; | |
401 default: return; | |
402 } | |
403 CheckDir( fsFNameList,get_current_dir_name() ); | |
404 } | |
405 | |
406 void fs_fsPathCombo_activate( GtkEditable * editable,gpointer user_data ) | |
407 { | |
25226 | 408 const unsigned char * str; |
23077 | 409 |
410 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
411 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); | |
412 } | |
413 | |
414 void fs_fsPathCombo_changed( GtkEditable * editable,gpointer user_data ) | |
415 { | |
25226 | 416 const unsigned char * str; |
23077 | 417 |
418 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
419 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); | |
420 } | |
421 | |
422 void fs_Up_released( GtkButton * button,gpointer user_data ) | |
423 { | |
424 chdir( ".." ); | |
425 fsSelectedFile=fsThatDir; | |
426 CheckDir( fsFNameList,get_current_dir_name() ); | |
427 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
428 return; | |
429 } | |
430 | |
431 int fsFileExist( unsigned char * fname ) | |
432 { | |
433 FILE * f = fopen( fname,"r" ); | |
434 if ( f == NULL ) return 0; | |
435 fclose( f ); | |
436 return 1; | |
437 } | |
438 | |
439 void fs_Ok_released( GtkButton * button,gpointer user_data ) | |
440 { | |
441 GList * item; | |
25248 | 442 int i = 1; |
23077 | 443 struct stat fs; |
444 | |
445 stat( fsSelectedFile,&fs ); | |
446 if( S_ISDIR(fs.st_mode ) ) | |
447 { | |
448 chdir( fsSelectedFile ); | |
449 fsSelectedFile=fsThatDir; | |
450 CheckDir( fsFNameList,get_current_dir_name() ); | |
451 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
452 return; | |
453 } | |
454 | |
455 fsSelectedDirectory=(unsigned char *)get_current_dir_name(); | |
456 switch ( fsType ) | |
457 { | |
458 case fsVideoSelector: | |
459 guiSetDF( guiIntfStruct.Filename,fsSelectedDirectory,fsSelectedFile ); | |
460 guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
461 guiIntfStruct.FilenameChanged=1; sub_fps=0; | |
462 gfree( (void **)&guiIntfStruct.AudioFile ); | |
463 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
464 fs_PersistantHistory( fsSelectedDirectory ); //totem, write into history | |
465 break; | |
466 case fsSubtitleSelector: | |
467 guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile ); | |
468 guiLoadSubtitle( guiIntfStruct.Subtitlename ); | |
469 break; | |
470 case fsOtherSelector: | |
471 guiSetDF( guiIntfStruct.Othername,fsSelectedDirectory,fsSelectedFile ); | |
472 break; | |
473 case fsAudioSelector: | |
474 guiSetDF( guiIntfStruct.AudioFile,fsSelectedDirectory,fsSelectedFile ); | |
475 break; | |
476 case fsFontSelector: | |
477 guiSetDF( font_name,fsSelectedDirectory,fsSelectedFile ); | |
478 guiLoadFont(); | |
479 if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name ); | |
480 break; | |
481 } | |
482 | |
483 HideFileSelect(); | |
484 | |
485 item=fsTopList_items; | |
486 while( item ) | |
487 { | |
488 if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0; | |
489 item=item->next; | |
490 } | |
491 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() ); | |
492 if ( mplMainAutoPlay ) { mplMainAutoPlay=0; mplEventHandling( evPlay,0 ); } | |
493 else guiGetEvent( guiCEvent,guiSetStop ); | |
494 } | |
495 | |
496 void fs_Cancel_released( GtkButton * button,gpointer user_data ) | |
497 { | |
498 HideFileSelect(); | |
499 fs_PersistantHistory( get_current_dir_name() ); //totem, write into history file | |
500 } | |
501 | |
502 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) | |
503 { | |
504 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); | |
505 if( bevent && bevent->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); | |
506 } | |
507 | |
508 gboolean on_FileSelect_key_release_event( GtkWidget * widget,GdkEventKey * event,gpointer user_data ) | |
509 { | |
510 switch ( event->keyval ) | |
511 { | |
512 case GDK_Escape: | |
513 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
514 break; | |
515 case GDK_Return: | |
516 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
517 break; | |
518 case GDK_BackSpace: | |
519 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
520 break; | |
521 } | |
522 return FALSE; | |
523 } | |
524 | |
525 GtkWidget * create_FileSelect( void ) | |
526 { | |
527 GtkWidget * vbox4; | |
528 GtkWidget * hbox4; | |
529 GtkWidget * vseparator1; | |
530 GtkWidget * hbox6; | |
531 GtkWidget * fsFNameListWindow; | |
532 GtkWidget * hbuttonbox3; | |
533 | |
534 GtkWidget * uppixmapwid; | |
535 GdkPixmap * uppixmap; | |
536 GdkBitmap * upmask; | |
537 GtkStyle * upstyle; | |
538 | |
539 | |
540 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
541 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); | |
542 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | |
543 gtk_widget_set_usize( fsFileSelect,512,300 ); | |
544 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); | |
545 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 ); | |
546 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
547 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER ); | |
548 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE ); | |
549 gtk_window_set_wmclass( GTK_WINDOW( fsFileSelect ),"FileSelect","MPlayer" ); | |
550 fsColorMap=gdk_colormap_get_system(); | |
25993 | 551 |
23077 | 552 gtk_widget_realize( fsFileSelect ); |
553 gtkAddIcon( fsFileSelect ); | |
554 | |
555 style=gtk_widget_get_style( fsFileSelect ); | |
556 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
557 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
558 | |
559 vbox4=AddVBox( AddDialogFrame( fsFileSelect ),0 ); | |
560 hbox4=AddHBox( vbox4,1 ); | |
561 | |
562 fsCombo4=gtk_combo_new(); | |
563 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
564 gtk_widget_show( fsCombo4 ); | |
565 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
566 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
567 | |
568 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; | |
569 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
570 gtk_widget_show( fsPathCombo ); | |
571 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
572 | |
573 vseparator1=gtk_vseparator_new(); | |
574 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
575 gtk_widget_show( vseparator1 ); | |
576 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
577 gtk_widget_set_usize( vseparator1,7,20 ); | |
578 | |
579 upstyle=gtk_widget_get_style( fsFileSelect ); | |
580 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
581 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); | |
582 gtk_widget_show( uppixmapwid ); | |
583 | |
584 fsUp=gtk_button_new(); | |
585 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
586 gtk_widget_show( fsUp ); | |
587 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
588 gtk_widget_set_usize( fsUp,65,15 ); | |
589 | |
590 AddHSeparator( vbox4 ); | |
591 | |
592 hbox6=AddHBox( NULL,0 ); | |
593 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
594 | |
595 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
596 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
597 gtk_widget_show( fsFNameListWindow ); | |
598 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
599 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
600 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
601 | |
602 fsFNameList=gtk_clist_new( 2 ); | |
603 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
604 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); | |
605 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
606 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
607 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
608 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
609 | |
610 AddHSeparator( vbox4 ); | |
611 | |
612 List=gtk_combo_new(); | |
613 gtk_widget_set_name( List,"List" ); | |
614 gtk_widget_ref( List ); | |
615 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); | |
616 gtk_widget_show( List ); | |
617 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
618 gtk_widget_set_usize( List,-2,20 ); | |
619 | |
620 fsFilterCombo=GTK_COMBO( List )->entry; | |
621 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
622 gtk_widget_show( fsFilterCombo ); | |
623 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
624 | |
625 AddHSeparator( vbox4 ); | |
626 | |
627 hbuttonbox3=AddHButtonBox( vbox4 ); | |
628 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
629 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
630 | |
631 fsOk=AddButton( MSGTR_Ok,hbuttonbox3 ); | |
632 fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 ); | |
633 | |
634 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&fsFileSelect ); | |
635 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
636 | |
637 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); | |
638 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
639 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
640 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
641 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
642 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); | |
643 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); | |
644 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); | |
645 | |
646 gtk_widget_grab_focus( fsFNameList ); | |
647 | |
648 return fsFileSelect; | |
649 } | |
650 |