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