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