Mercurial > mplayer.hg
annotate gui/ui/gtk/fileselect.c @ 33943:de065d751a8c
Change ESC key behavior in fullscreen state.
The ESC key shall only switch to normal video window size
if there is a video window and during playback.
It shall have its default meaning else.
author | ib |
---|---|
date | Thu, 01 Sep 2011 16:55:14 +0000 |
parents | e0d211c62cf7 |
children | 8a7056729022 |
rev | line source |
---|---|
33572 | 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 */ | |
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 | |
26 #include "config.h" | |
27 #include "gui/ui/gmplayer.h" | |
28 | |
29 #include "gui/ui/pixmaps/up.xpm" | |
30 #include "gui/ui/pixmaps/dir.xpm" | |
31 #include "gui/ui/pixmaps/file.xpm" | |
32 | |
33 #include "gui/app.h" | |
34 #include "gui/interface.h" | |
33739 | 35 #include "gui/util/mem.h" |
33737 | 36 #include "gui/util/string.h" |
33572 | 37 #include "help_mp.h" |
38 #include "mpcommon.h" | |
39 #include "stream/stream.h" | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
40 #include "libavutil/common.h" |
33572 | 41 |
42 #include "gui/ui/widgets.h" | |
43 #include "fileselect.h" | |
44 #include "preferences.h" | |
45 #include "tools.h" | |
46 | |
47 #ifndef __linux__ | |
48 #define get_current_dir_name() getcwd(NULL, PATH_MAX) | |
49 #else | |
50 char * get_current_dir_name( void ); | |
51 #endif | |
52 | |
53 gchar * fsSelectedFile = NULL; | |
54 gchar * fsSelectedFileUtf8 = NULL; | |
55 gchar * fsSelectedDirectory = NULL; | |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
56 gchar * fsSelectedDirectoryUtf8 = NULL; |
33572 | 57 unsigned char * fsThatDir = "."; |
58 const gchar * fsFilter = "*"; | |
59 | |
60 int fsType = 0; | |
61 | |
62 char * fsVideoFilterNames[][2] = | |
63 { | |
64 { "ASF files (*.asf)", "*.asf" }, | |
65 { "AVI files (*.avi)", "*.avi" }, | |
66 { "Autodesk animations (*.fli,*.flc)", "*.fli,*.flc" }, | |
67 { "DGStation Cuberevo recordings (*.trp)", "*.trp" }, | |
68 { "DiVX files (*.divx)", "*.divx" }, | |
69 { "MP3 files (*.mp3,*.mp2)", "*.mp3,*.mp2" }, | |
70 { "MPEG files (*.mpg,*.mpeg,*.m1v)", "*.mpg,*.mpeg,*.m1v" }, | |
71 { "Macromedia Flash Video (*.flv)", "*.flv" }, | |
72 { "Matroska Audio files (*.mka)", "*.mka" }, | |
73 { "Matroska Media files (*.mkv)", "*.mkv" }, | |
74 { "NuppelVideo files (*.nuv)", "*.nuv" }, | |
75 { "OGG Vorbis files (*.ogg)", "*.ogg" }, | |
76 { "OGG Media files (*.ogm)", "*.ogm" }, | |
77 { "QuickTime files (*.mov,*.qt,*.mp4)", "*.mov,*.qt,*.mp4" }, | |
78 { "RealVideo files (*.rm,*.rmvb)", "*.rm,*.rmvb" }, | |
79 { "Tivo files (*.ty)", "*.ty" }, | |
80 { "VCD/SVCD Images (*.bin)", "*.bin" }, | |
81 { "VIVO files (*.viv)", "*.viv" }, | |
82 { "VOB files (*.vob)", "*.vob" }, | |
83 { "Wave files (*.wav)", "*.wav" }, | |
84 { "Windows Media Audio (*.wma)", "*.wma" }, | |
85 { "Windows Media Video (*.wmv)", "*.wmv" }, | |
86 { "Audio files", "*.mp2,*.mp3,*.mka,*.ogg,*.wav,*.wma" }, | |
87 { "Video files", "*.asf,*.avi,*.fli,*.flc,*.trp,*.divx,*.mpg,*.mpeg,*.m1v,*.flv,*.mkv,*.nuv,*.ogm,*.mov,*.qt,*.mp4,*.rm,*.rmvb,*.ty,*.bin,*.viv,*.vob,*.wmv" }, | |
88 { "All files", "*" }, | |
89 { NULL,NULL } | |
90 }; | |
91 int fsLastVideoFilterSelected = -1; | |
92 | |
93 char * fsSubtitleFilterNames[][2] = | |
94 { | |
95 { "AQT (*.aqt)", "*.aqt" }, | |
96 { "ASS (*.ass)", "*.ass" }, | |
97 { "RT (*.rt) ", "*.rt" }, | |
98 { "SMI (*.smi)", "*.smi" }, | |
99 { "SRT (*.srt)", "*.srt" }, | |
100 { "SSA (*.ssa)", "*.ssa" }, | |
101 { "SUB (*.sub)", "*.sub" }, | |
102 { "TXT (*.txt)", "*.txt" }, | |
103 { "UTF (*.utf)", "*.utf" }, | |
104 { "Subtitles", "*.aqt,*.ass,*.rt,*.smi,*.srt,*.ssa,*.sub,*.txt,*.utf" }, | |
105 { "All files", "*" }, | |
106 { NULL,NULL } | |
107 }; | |
108 int fsLastSubtitleFilterSelected = -1; | |
109 | |
110 char * fsOtherFilterNames[][2] = | |
111 { | |
112 { "All files", "*" }, | |
113 { NULL,NULL } | |
114 }; | |
115 | |
116 char * fsAudioFileNames[][2] = | |
117 { | |
118 { "MP3 files (*.mp2, *.mp3)", "*.mp2,*.mp3" }, | |
119 { "Matroska Audio files (*.mka)", "*.mka" }, | |
120 { "OGG Vorbis files (*.ogg)", "*.ogg" }, | |
121 { "WAV files (*.wav)", "*.wav" }, | |
122 { "WMA files (*.wma)", "*.wma" }, | |
123 { "Audio files", "*.mp2,*.mp3,*.mka,*.ogg,*.wav,*.wma" }, | |
124 { "All files", "*" }, | |
125 { NULL, NULL } | |
126 }; | |
127 int fsLastAudioFilterSelected = -1; | |
128 | |
129 char * fsFontFileNames[][2] = | |
130 { | |
131 #ifdef CONFIG_FREETYPE | |
132 { "True Type fonts (*.ttf)", "*.ttf" }, | |
133 { "Type1 fonts (*.pfb)", "*.pfb" }, | |
134 { "All fonts", "*.ttf,*.pfb" }, | |
135 #else | |
136 { "Font files (*.desc)", "*.desc" }, | |
137 #endif | |
138 { "All files", "*" }, | |
139 { NULL,NULL } | |
140 }; | |
141 int fsLastFontFilterSelected = -1; | |
142 | |
143 GtkWidget * fsFileNamesList; | |
144 GtkWidget * fsFNameList; | |
145 GtkWidget * fsFileSelect = NULL; | |
146 GdkColormap * fsColorMap; | |
147 GtkWidget * fsOk; | |
148 GtkWidget * fsUp; | |
149 GtkWidget * fsCancel; | |
150 GtkWidget * fsCombo4; | |
151 GtkWidget * fsPathCombo; | |
152 GList * fsList_items = NULL; | |
153 GList * fsTopList_items = NULL; | |
154 GtkWidget * List; | |
155 GtkWidget * fsFilterCombo; | |
156 | |
157 GtkStyle * style; | |
158 GdkPixmap * dpixmap; | |
159 GdkPixmap * fpixmap; | |
160 GdkBitmap * dmask; | |
161 GdkBitmap * fmask; | |
162 | |
163 static char * get_current_dir_name_utf8( void ) | |
164 { | |
165 char * dir, * utf8dir; | |
166 dir = get_current_dir_name(); | |
167 utf8dir = g_filename_to_utf8( dir, -1, NULL, NULL, NULL ); | |
168 if ( !utf8dir ) utf8dir = g_strdup( dir ); | |
169 free( dir ); | |
170 return utf8dir; | |
171 } | |
172 | |
173 static char * Filter( const char * name ) | |
174 { | |
175 static char tmp[32]; | |
33755
90a5fdb500db
Use unsigned index variable for comparison with string length.
ib
parents:
33751
diff
changeset
|
176 unsigned int i,c; |
33572 | 177 for ( i=0,c=0;i < strlen( name );i++ ) |
178 { | |
179 if ( ( name[i] >='a' )&&( name[i] <= 'z' ) ) { tmp[c++]='['; tmp[c++]=name[i]; tmp[c++]=name[i] - 32; tmp[c++]=']'; } | |
180 else tmp[c++]=name[i]; | |
181 } | |
182 tmp[c]=0; | |
183 return tmp; | |
184 } | |
185 | |
186 static void clist_append_fname(GtkWidget * list, char *fname, | |
187 GdkPixmap *pixmap, GdkPixmap *mask) { | |
188 gint pos; | |
189 gchar *filename, *str[2]; | |
190 filename = g_filename_to_utf8(fname, -1, NULL, NULL, NULL); | |
191 str[0] = NULL; | |
192 str[1] = filename ? filename : fname; | |
193 pos = gtk_clist_append(GTK_CLIST(list), str); | |
194 gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask); | |
195 g_free(filename); | |
196 } | |
197 | |
198 static void CheckDir( GtkWidget * list ) | |
199 { | |
200 struct stat fs; | |
201 int i; | |
202 glob_t gg; | |
203 | |
204 if ( !fsFilter[0] ) return; | |
205 | |
206 gtk_widget_hide( list ); | |
207 gtk_clist_clear( GTK_CLIST( list ) ); | |
208 | |
209 clist_append_fname(list, ".", dpixmap, dmask); | |
210 clist_append_fname(list, "..", dpixmap, dmask); | |
211 | |
212 glob( "*",0,NULL,&gg ); | |
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; | |
217 clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask); | |
218 } | |
219 globfree( &gg ); | |
220 | |
221 if ( strchr( fsFilter,',' ) ) | |
222 { | |
223 char tmp[8]; | |
224 int i,c,glob_param = 0; | |
225 for ( i=0,c=0;i<(int)strlen( fsFilter ) + 1;i++,c++ ) | |
226 { | |
227 tmp[c]=fsFilter[i]; | |
228 if ( ( tmp[c] == ',' )||( tmp[c] == '\0' ) ) | |
229 { | |
230 tmp[c]=0; c=-1; | |
231 glob( Filter( tmp ),glob_param,NULL,&gg ); | |
232 glob_param=GLOB_APPEND; | |
233 } | |
234 } | |
235 } else glob( Filter( fsFilter ),0,NULL,&gg ); | |
236 | |
237 for( i=0;(unsigned)i<gg.gl_pathc;i++ ) | |
238 { | |
239 stat( gg.gl_pathv[i],&fs ); | |
240 if( S_ISDIR( fs.st_mode ) ) continue; | |
241 clist_append_fname(list, gg.gl_pathv[i], fpixmap, fmask); | |
242 } | |
243 globfree( &gg ); | |
244 | |
245 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 ); | |
246 gtk_clist_select_row( GTK_CLIST( list ),0,1 ); | |
247 gtk_widget_show( list ); | |
248 } | |
249 | |
250 void ShowFileSelect( int type,int modal ) | |
251 { | |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
252 int i, k, fsMedium; |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
253 char * tmp = NULL, * dir = NULL; |
33572 | 254 |
255 if ( fsFileSelect ) gtkActive( fsFileSelect ); | |
256 else fsFileSelect=create_FileSelect(); | |
257 | |
258 fsType=type; | |
259 switch ( type ) | |
260 { | |
261 case fsVideoSelector: | |
262 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
263 fsList_items=NULL; | |
264 for( i=0;fsVideoFilterNames[i][0];i++ ) | |
265 fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] ); | |
266 k = fsLastVideoFilterSelected; | |
267 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
268 g_list_free( fsList_items ); | |
269 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[k >= 0 ? k : i-2][0] ); | |
270 tmp=guiInfo.Filename; | |
271 break; | |
272 case fsSubtitleSelector: | |
273 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_SubtitleSelect ); | |
274 fsList_items=NULL; | |
275 for( i=0;fsSubtitleFilterNames[i][0];i++ ) | |
276 fsList_items=g_list_append( fsList_items,fsSubtitleFilterNames[i][0] ); | |
277 k = fsLastSubtitleFilterSelected; | |
278 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
279 g_list_free( fsList_items ); | |
280 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsSubtitleFilterNames[k >= 0 ? k : i-2][0] ); | |
33897 | 281 tmp=guiInfo.SubtitleFilename; |
33572 | 282 break; |
33776 | 283 /* case fsOtherSelector: |
33572 | 284 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_OtherSelect ); |
285 fsList_items=NULL; | |
286 for( i=0;fsOtherFilterNames[i][0];i++ ) | |
287 fsList_items=g_list_append( fsList_items,fsOtherFilterNames[i][0] ); | |
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 ),fsOtherFilterNames[0][0] ); | |
291 tmp=guiInfo.Othername; | |
33776 | 292 break;*/ |
33572 | 293 case fsAudioSelector: |
294 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_AudioFileSelect ); | |
295 fsList_items=NULL; | |
296 for( i=0;fsAudioFileNames[i][0];i++ ) | |
297 fsList_items=g_list_append( fsList_items,fsAudioFileNames[i][0] ); | |
298 k = fsLastAudioFilterSelected; | |
299 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
300 g_list_free( fsList_items ); | |
301 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsAudioFileNames[k >= 0 ? k : i-2][0] ); | |
33897 | 302 tmp=guiInfo.AudioFilename; |
33572 | 303 break; |
304 case fsFontSelector: | |
305 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FontSelect ); | |
306 fsList_items=NULL; | |
307 for( i=0;fsFontFileNames[i][0];i++ ) | |
308 fsList_items=g_list_append( fsList_items,fsFontFileNames[i][0] ); | |
309 k = fsLastFontFilterSelected; | |
310 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
311 g_list_free( fsList_items ); | |
312 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsFontFileNames[k >= 0 ? k : i-2][0] ); | |
313 tmp=font_name; | |
314 break; | |
315 } | |
316 | |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
317 fsMedium=(fsType == fsVideoSelector || fsType == fsSubtitleSelector || fsType == fsAudioSelector); |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
318 |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
319 if ( !tmp && fsMedium ) tmp=guiInfo.Filename; |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
320 |
33572 | 321 if ( tmp && tmp[0] ) |
322 { | |
323 struct stat f; | |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
324 dir = strdup( tmp ); |
33572 | 325 |
326 do | |
327 { | |
328 char * c = strrchr( dir,'/' ); | |
329 stat( dir,&f ); | |
330 if ( S_ISDIR( f.st_mode ) ) break; | |
331 if ( c ) *c=0; | |
332 } while ( strrchr( dir,'/' ) ); | |
333 | |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
334 if ( !dir[0] ) nfree( dir ); |
33572 | 335 } |
336 | |
337 if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; | |
338 { | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
339 unsigned int i, c = 1; |
33572 | 340 |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
341 |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
342 if ( fsMedium ) |
33572 | 343 { |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
344 for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ ) |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
345 if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); if ( c ) c=gstrcmp( dir,fsHistory[i] ); } |
33572 | 346 } |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
347 if ( c && dir ) |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
348 { |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
349 g_free( fsSelectedDirectoryUtf8 ); |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
350 fsSelectedDirectoryUtf8=g_filename_to_utf8( dir, -1, NULL, NULL, NULL ); |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
351 fsTopList_items=g_list_prepend( fsTopList_items,fsSelectedDirectoryUtf8 ); |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
352 } |
33572 | 353 } |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
354 free( dir ); |
33572 | 355 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); |
356 fsTopList_items=g_list_append( fsTopList_items,"/home" ); | |
357 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); | |
358 fsTopList_items=g_list_append( fsTopList_items,"/" ); | |
359 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); | |
360 | |
361 gtk_window_set_modal( GTK_WINDOW( fsFileSelect ),modal ); | |
362 | |
363 gtk_widget_show( fsFileSelect ); | |
364 } | |
365 | |
366 void HideFileSelect( void ) | |
367 { | |
368 if ( !fsFileSelect ) return; | |
369 gtk_widget_hide( fsFileSelect ); | |
370 gtk_widget_destroy( fsFileSelect ); | |
371 fsFileSelect=NULL; | |
372 } | |
373 | |
374 static void fs_PersistantHistory( char * subject ) | |
375 { | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
376 unsigned int i; |
33572 | 377 |
378 if ( fsType != fsVideoSelector ) return; | |
379 | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
380 for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ ) |
33572 | 381 if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) ) |
382 { | |
383 char * tmp = fsHistory[i]; fsHistory[i]=fsHistory[0]; fsHistory[0]=tmp; | |
384 return; | |
385 } | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
386 nfree( fsHistory[FF_ARRAY_ELEMS(fsHistory) - 1] ); |
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
387 for ( i=FF_ARRAY_ELEMS(fsHistory) - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1]; |
33572 | 388 fsHistory[0]=gstrdup( subject ); |
389 } | |
390 //----------------------------------------------- | |
391 | |
392 static void fs_fsFilterCombo_activate( GtkEditable * editable, | |
393 gpointer user_data ) | |
394 { | |
395 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
396 CheckDir( fsFNameList ); | |
397 } | |
398 | |
399 static void fs_fsFilterCombo_changed( GtkEditable * editable, | |
400 gpointer user_data ) | |
401 { | |
402 const char * str; | |
403 int i; | |
404 | |
405 str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); | |
406 | |
407 switch ( fsType ) | |
408 { | |
409 case fsVideoSelector: | |
410 for( i=0;fsVideoFilterNames[i][0];i++ ) | |
411 if( !strcmp( str,fsVideoFilterNames[i][0] ) ) | |
412 { fsFilter=fsVideoFilterNames[i][1]; fsLastVideoFilterSelected = i; break; } | |
413 break; | |
414 case fsSubtitleSelector: | |
415 for( i=0;fsSubtitleFilterNames[i][0];i++ ) | |
416 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) | |
417 { fsFilter=fsSubtitleFilterNames[i][1]; fsLastSubtitleFilterSelected = i; break; } | |
418 break; | |
33776 | 419 /* case fsOtherSelector: |
33572 | 420 for( i=0;fsOtherFilterNames[i][0];i++ ) |
421 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) | |
422 { fsFilter=fsOtherFilterNames[i][1]; break; } | |
33776 | 423 break;*/ |
33572 | 424 case fsAudioSelector: |
425 for( i=0;fsAudioFileNames[i][0];i++ ) | |
426 if( !strcmp( str,fsAudioFileNames[i][0] ) ) | |
427 { fsFilter=fsAudioFileNames[i][1]; fsLastAudioFilterSelected = i; break; } | |
428 break; | |
429 case fsFontSelector: | |
430 for( i=0;fsFontFileNames[i][0];i++ ) | |
431 if( !strcmp( str,fsFontFileNames[i][0] ) ) | |
432 { fsFilter=fsFontFileNames[i][1]; fsLastFontFilterSelected = i; break; } | |
433 break; | |
434 default: return; | |
435 } | |
436 CheckDir( fsFNameList ); | |
437 } | |
438 | |
439 static void fs_fsPathCombo_activate( GtkEditable * editable, | |
440 gpointer user_data ) | |
441 { | |
442 const unsigned char * str; | |
443 gchar * dirname; | |
444 | |
445 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
446 dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL ); | |
447 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); | |
448 g_free( dirname ); | |
449 } | |
450 | |
451 static void fs_fsPathCombo_changed( GtkEditable * editable, | |
452 gpointer user_data ) | |
453 { | |
454 const unsigned char * str; | |
455 gchar * dirname; | |
456 | |
457 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
458 dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL ); | |
459 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); | |
460 g_free( dirname ); | |
461 } | |
462 | |
463 static void fs_Up_released( GtkButton * button, gpointer user_data ) | |
464 { | |
465 chdir( ".." ); | |
466 fsSelectedFile=fsThatDir; | |
467 CheckDir( fsFNameList ); | |
468 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() ); | |
469 return; | |
470 } | |
471 | |
472 static void fs_Ok_released( GtkButton * button, gpointer user_data ) | |
473 { | |
474 GList * item; | |
475 int i = 1; | |
476 struct stat fs; | |
477 | |
478 stat( fsSelectedFile,&fs ); | |
479 if( S_ISDIR(fs.st_mode ) ) | |
480 { | |
481 chdir( fsSelectedFile ); | |
482 fsSelectedFile=fsThatDir; | |
483 CheckDir( fsFNameList ); | |
484 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() ); | |
485 return; | |
486 } | |
487 | |
488 fsSelectedDirectory=(unsigned char *)get_current_dir_name(); | |
489 switch ( fsType ) | |
490 { | |
491 case fsVideoSelector: | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
492 setddup( &guiInfo.Filename,fsSelectedDirectory,fsSelectedFile ); |
33572 | 493 guiInfo.StreamType=STREAMTYPE_FILE; |
33894 | 494 guiInfo.NewPlay=GUI_FILE_NEW; sub_fps=0; |
33897 | 495 nfree( guiInfo.AudioFilename ); |
496 nfree( guiInfo.SubtitleFilename ); | |
33572 | 497 fs_PersistantHistory( get_current_dir_name_utf8() ); //totem, write into history |
498 break; | |
499 case fsSubtitleSelector: | |
33897 | 500 setddup( &guiInfo.SubtitleFilename,fsSelectedDirectory,fsSelectedFile ); |
501 mplayerLoadSubtitle( guiInfo.SubtitleFilename ); | |
33572 | 502 break; |
33776 | 503 /* case fsOtherSelector: |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
504 setddup( &guiInfo.Othername,fsSelectedDirectory,fsSelectedFile ); |
33776 | 505 break;*/ |
33572 | 506 case fsAudioSelector: |
33897 | 507 setddup( &guiInfo.AudioFilename,fsSelectedDirectory,fsSelectedFile ); |
33572 | 508 break; |
509 case fsFontSelector: | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
510 setddup( &font_name,fsSelectedDirectory,fsSelectedFile ); |
33763 | 511 mplayerLoadFont(); |
33572 | 512 if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name ); |
513 break; | |
514 } | |
515 | |
516 HideFileSelect(); | |
517 | |
518 item=fsTopList_items; | |
519 while( item ) | |
520 { | |
521 if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0; | |
522 item=item->next; | |
523 } | |
524 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name_utf8() ); | |
525 if ( uiMainAutoPlay ) { uiMainAutoPlay=0; uiEventHandling( evPlay,0 ); } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
526 else gui( GUI_SET_STATE,(void *) GUI_STOP ); |
33572 | 527 } |
528 | |
529 static void fs_Cancel_released( GtkButton * button,gpointer user_data ) | |
530 { | |
531 HideFileSelect(); | |
532 fs_PersistantHistory( get_current_dir_name_utf8() ); //totem, write into history file | |
533 } | |
534 | |
535 static void fs_fsFNameList_select_row( GtkWidget * widget, gint row, gint column, | |
536 GdkEventButton *bevent, gpointer user_data) | |
537 { | |
538 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); | |
539 g_free( fsSelectedFileUtf8 ); | |
540 fsSelectedFileUtf8 = g_filename_from_utf8( fsSelectedFile, -1, NULL, NULL, NULL ); | |
541 if ( fsSelectedFileUtf8 ) fsSelectedFile = fsSelectedFileUtf8; | |
542 if( bevent && bevent->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); | |
543 } | |
544 | |
545 static gboolean on_FileSelect_key_release_event( GtkWidget * widget, | |
546 GdkEventKey * event, | |
547 gpointer user_data ) | |
548 { | |
549 switch ( event->keyval ) | |
550 { | |
551 case GDK_Escape: | |
552 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
553 break; | |
554 case GDK_Return: | |
555 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
556 break; | |
557 case GDK_BackSpace: | |
558 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
559 break; | |
560 } | |
561 return FALSE; | |
562 } | |
563 | |
564 static gboolean fs_fsFNameList_event( GtkWidget * widget, | |
565 GdkEvent * event, | |
566 gpointer user_data ) | |
567 { | |
568 GdkEventButton *bevent; | |
569 gint row, col; | |
570 | |
571 (void) user_data; | |
572 | |
573 bevent = (GdkEventButton *) event; | |
574 | |
575 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
576 { | |
577 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
578 { | |
579 gtk_clist_get_text( GTK_CLIST( widget ), row, 1, &fsSelectedFile ); | |
580 g_free( fsSelectedFileUtf8 ); | |
581 fsSelectedFileUtf8 = g_filename_from_utf8( fsSelectedFile, -1, NULL, NULL, NULL ); | |
582 if ( fsSelectedFileUtf8 ) fsSelectedFile = fsSelectedFileUtf8; | |
583 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
584 return TRUE; | |
585 } | |
586 } | |
587 | |
588 return FALSE; | |
589 } | |
590 | |
591 static void fs_Destroy( void ) | |
592 { | |
593 g_free( fsSelectedFileUtf8 ); | |
594 fsSelectedFileUtf8 = NULL; | |
33787
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
595 g_free( fsSelectedDirectoryUtf8 ); |
42feff0f8a7b
Start all file dialogs always in last active directory.
ib
parents:
33776
diff
changeset
|
596 fsSelectedDirectoryUtf8 = NULL; |
33572 | 597 WidgetDestroy( fsFileSelect, &fsFileSelect ); |
598 } | |
599 | |
600 GtkWidget * create_FileSelect( void ) | |
601 { | |
602 GtkWidget * vbox4; | |
603 GtkWidget * hbox4; | |
604 GtkWidget * vseparator1; | |
605 GtkWidget * hbox6; | |
606 GtkWidget * fsFNameListWindow; | |
607 GtkWidget * hbuttonbox3; | |
608 | |
609 GtkWidget * uppixmapwid; | |
610 GdkPixmap * uppixmap; | |
611 GdkBitmap * upmask; | |
612 GtkStyle * upstyle; | |
613 | |
614 | |
615 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
616 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); | |
617 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | |
618 gtk_widget_set_usize( fsFileSelect,512,300 ); | |
619 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); | |
620 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 ); | |
621 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
622 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER ); | |
623 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE ); | |
624 gtk_window_set_wmclass( GTK_WINDOW( fsFileSelect ),"FileSelect","MPlayer" ); | |
625 fsColorMap=gdk_colormap_get_system(); | |
626 | |
627 gtk_widget_realize( fsFileSelect ); | |
628 gtkAddIcon( fsFileSelect ); | |
629 | |
630 style=gtk_widget_get_style( fsFileSelect ); | |
631 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
632 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
633 | |
634 vbox4=AddVBox( AddDialogFrame( fsFileSelect ),0 ); | |
635 hbox4=AddHBox( vbox4,1 ); | |
636 | |
637 fsCombo4=gtk_combo_new(); | |
638 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
639 gtk_widget_show( fsCombo4 ); | |
640 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
641 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
642 | |
643 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; | |
644 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
645 gtk_widget_show( fsPathCombo ); | |
646 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
647 | |
648 vseparator1=gtk_vseparator_new(); | |
649 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
650 gtk_widget_show( vseparator1 ); | |
651 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
652 gtk_widget_set_usize( vseparator1,7,20 ); | |
653 | |
654 upstyle=gtk_widget_get_style( fsFileSelect ); | |
655 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
656 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); | |
657 gtk_widget_show( uppixmapwid ); | |
658 | |
659 fsUp=gtk_button_new(); | |
660 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
661 gtk_widget_show( fsUp ); | |
662 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
663 gtk_widget_set_usize( fsUp,65,15 ); | |
664 | |
665 AddHSeparator( vbox4 ); | |
666 | |
667 hbox6=AddHBox( NULL,0 ); | |
668 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
669 | |
670 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
671 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
672 gtk_widget_show( fsFNameListWindow ); | |
673 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
674 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
675 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
676 | |
677 fsFNameList=gtk_clist_new( 2 ); | |
678 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
679 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); | |
680 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
681 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
682 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
683 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
684 | |
685 AddHSeparator( vbox4 ); | |
686 | |
687 List=gtk_combo_new(); | |
688 gtk_widget_set_name( List,"List" ); | |
689 gtk_widget_ref( List ); | |
690 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); | |
691 gtk_widget_show( List ); | |
692 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
693 gtk_widget_set_usize( List,-2,20 ); | |
694 | |
695 fsFilterCombo=GTK_COMBO( List )->entry; | |
696 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
697 gtk_widget_show( fsFilterCombo ); | |
698 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
699 | |
700 AddHSeparator( vbox4 ); | |
701 | |
702 hbuttonbox3=AddHButtonBox( vbox4 ); | |
703 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
704 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
705 | |
706 fsOk=AddButton( MSGTR_Ok,hbuttonbox3 ); | |
707 fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 ); | |
708 | |
709 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( fs_Destroy ), NULL ); | |
710 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
711 | |
712 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); | |
713 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
714 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
715 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
716 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
717 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); | |
718 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); | |
719 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); | |
720 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"event", (GtkSignalFunc)fs_fsFNameList_event,NULL ); | |
721 | |
722 gtk_widget_grab_focus( fsFNameList ); | |
723 | |
724 return fsFileSelect; | |
725 } |