Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/fs.c @ 6089:39c2bfe5c267
small fixes
author | pontscho |
---|---|
date | Tue, 14 May 2002 11:41:02 +0000 |
parents | 153fc4ed86ad |
children | b9651eb9749e |
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 | |
9 #include "./mplayer.h" | |
10 | |
11 #include "pixmaps/up.xpm" | |
12 #include "pixmaps/dir.xpm" | |
13 #include "pixmaps/file.xpm" | |
14 | |
15 #include "../../events.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" | |
23 | |
24 #ifndef __linux__ | |
25 #define get_current_dir_name() getcwd(NULL, PATH_MAX) | |
26 #endif | |
27 | |
28 #ifndef get_current_dir_name | |
29 extern char * get_current_dir_name( void ); | |
30 #endif | |
31 | |
32 gchar * fsSelectedFile = NULL; | |
33 gchar * fsSelectedDirectory = NULL; | |
34 unsigned char * fsThatDir = "."; | |
5786 | 35 gchar fsFilter[64] = "*"; |
2901 | 36 |
37 int fsPressed = 0; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
38 int fsMessage = -1; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
39 int fsType = 0; |
3054 | 40 |
5786 | 41 #define fsNumberOfVideoFilterNames 9 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
42 char * fsVideoFilterNames[fsNumberOfVideoFilterNames+1][2] = |
6089 | 43 { { "MPEG files (*.mpg,*.mpeg)", "*.mpg,*.mpeg" }, |
5786 | 44 { "VOB files (*.vob)", "*.vob" }, |
45 { "AVI files (*.avi)", "*.avi" }, | |
46 { "QT files (*.mov)", "*.mov" }, | |
47 { "ASF files (*.asf)", "*.asf" }, | |
48 { "VIVO files (*.viv)", "*.viv" }, | |
49 { "Windows Media Video (*.wmv)", "*.wmv" }, | |
50 { "Audio files (*.mp2,*.mp3,*.wma)", "*.mp2,*.mp3,*.wma" }, | |
6089 | 51 { "Video files (*.mpg,*.mpeg,*.vob,*.avi,*.mov,*.asf,*.viv,*.wmv)", "*.mpg,*.mpeg,*.vob,*.avi,*.mov,*.asf,*.viv,*.wmv" }, |
5786 | 52 { "All files (*)", "*" } }; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
53 |
5786 | 54 #define fsNumberOfSubtitleFilterNames 9 |
3499 | 55 char * fsSubtitleFilterNames[fsNumberOfSubtitleFilterNames+1][2] = |
5786 | 56 { { "UTF (*.utf)", "*.utf" }, |
57 { "SUB (*.sub)", "*.sub" }, | |
58 { "SRT (*.srt)", "*.str" }, | |
59 { "SMI (*.smi)", "*.smi" }, | |
60 { "RT (*.rt) ", "*.rt" }, | |
61 { "TXT (*.txt)", "*.txt" }, | |
62 { "SSA (*.ssa)", "*.ssa" }, | |
63 { "AQT (*.aqt)", "*.aqt" }, | |
64 { "Subtitles (*.utf,*.sub,*.srt,*.smi,*.rt,*.txt,*.ssa,*.aqt)", "*.utf,*.sub,*.srt,*.smi,*.rt,*.txt,*.ssa,*.aqt" }, | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
65 { "All files ( * )", "*" } }; |
3499 | 66 |
67 #define fsNumberOfOtherFilterNames 0 | |
68 char * fsOtherFilterNames[fsNumberOfOtherFilterNames+1][2] = | |
3587 | 69 { { "All files ( * )", "*" } }; |
2901 | 70 |
71 GtkWidget * fsFileNamesList; | |
72 GtkWidget * fsFNameList; | |
73 GtkWidget * fsFileSelect; | |
74 GdkColormap * fsColorMap; | |
75 GtkWidget * fsOk; | |
76 GtkWidget * fsUp; | |
77 GtkWidget * fsCancel; | |
78 GtkWidget * fsCombo4; | |
3499 | 79 GtkWidget * fsPathCombo; |
2901 | 80 GList * fsList_items = NULL; |
81 GList * fsTopList_items = NULL; | |
3499 | 82 GtkWidget * List; |
83 GtkWidget * fsFilterCombo; | |
2901 | 84 |
3499 | 85 |
86 GtkStyle * style; | |
87 GdkPixmap * dpixmap; | |
88 GdkPixmap * fpixmap; | |
89 GdkBitmap * dmask; | |
90 GdkBitmap * fmask; | |
91 | |
92 void CheckDir( GtkWidget * list,char * directory ) | |
2901 | 93 { |
94 struct stat fs; | |
95 int i,c=2; | |
96 gchar * str[1][2]; | |
3499 | 97 GdkPixmap * pixmap; |
98 GdkBitmap * mask; | |
2901 | 99 glob_t gg; |
100 | |
3499 | 101 if ( !fsFilter[0] ) return; |
102 | |
2901 | 103 gtk_widget_hide( list ); |
3499 | 104 gtk_clist_clear( GTK_CLIST( list ) ); |
2901 | 105 str[0][0]=NULL; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
106 |
2901 | 107 pixmap=dpixmap; mask=dmask; |
108 str[0][0]=NULL; str[0][1]=(gchar *)malloc( 3 ); | |
3499 | 109 strcpy( str[0][1],"." ); gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),0,0,pixmap,mask ); |
110 strcpy( str[0][1],".." ); gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),1,0,pixmap,mask ); | |
2901 | 111 free( str[0][0] ); |
112 | |
3499 | 113 glob( "*",0,NULL,&gg ); |
2901 | 114 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); |
115 for( i=0;i<gg.gl_pathc;i++ ) | |
116 { | |
117 stat( gg.gl_pathv[i],&fs ); | |
3499 | 118 if( !S_ISDIR( fs.st_mode ) ) continue; |
119 | |
120 str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 1 ); | |
121 strcpy( str[0][1],gg.gl_pathv[i] ); | |
122 pixmap=dpixmap; mask=dmask; | |
123 gtk_clist_append( GTK_CLIST( list ),str[0] ); | |
124 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask ); | |
125 free( str[0][1] ); | |
2901 | 126 } |
127 globfree( &gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
128 |
5786 | 129 //printf( "fsFiler: '%s'\n",fsFilter ); |
130 if ( strchr( fsFilter,',' ) ) | |
131 { | |
132 char tmp[8]; | |
133 int i,c,glob_param = 0; | |
134 //printf( "sub item detected.\n" ); | |
135 for ( i=0,c=0;i<(int)strlen( fsFilter ) + 1;i++,c++ ) | |
136 { | |
137 tmp[c]=fsFilter[i]; | |
138 if ( ( tmp[c] == ',' )||( tmp[c] == '\0' ) ) | |
139 { | |
140 tmp[c]=0; c=-1; | |
141 // printf( "substr: %s\n",tmp ); | |
142 glob( tmp,glob_param,NULL,&gg ); | |
143 glob_param=GLOB_APPEND; | |
144 } | |
145 } | |
146 } else glob( fsFilter,0,NULL,&gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
147 |
3499 | 148 #if 0 |
149 if ( !strcmp( fsFilter,"*" ) ) | |
150 { | |
151 char * f = strdup( fsFilter ); | |
152 int i; | |
153 for( i=0;i<strlen( f );i++ ) | |
154 if ( ( f[i] >= 'A' )&&( f[i] <= 'Z' ) ) f[i]+=32; | |
155 glob( f,GLOB_APPEND,NULL,&gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
156 |
3499 | 157 for( i=0;i<strlen( f );i++ ) |
158 if ( ( f[i] >= 'a' )&&( f[i] <= 'z' ) ) f[i]-=32; | |
159 glob( f,GLOB_APPEND,NULL,&gg ); | |
160 free( f ); | |
161 } | |
162 #endif | |
163 | |
2901 | 164 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); |
165 pixmap=fpixmap; mask=fmask; | |
166 for( i=0;i<gg.gl_pathc;i++ ) | |
167 { | |
168 stat( gg.gl_pathv[i],&fs ); | |
169 if( S_ISDIR( fs.st_mode ) ) continue; | |
3499 | 170 |
171 str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 1 ); | |
172 strcpy( str[0][1],gg.gl_pathv[i] ); | |
2901 | 173 gtk_clist_append( GTK_CLIST( list ),str[0] ); |
3499 | 174 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask ); |
2901 | 175 free( str[0][1] ); |
176 } | |
177 globfree( &gg ); | |
178 | |
179 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 ); | |
180 gtk_clist_select_row( GTK_CLIST( list ),0,1 ); | |
181 gtk_widget_show( list ); | |
182 } | |
183 | |
6044 | 184 static int FirstInit = 1; |
185 | |
3499 | 186 void ShowFileSelect( int type ) |
187 { | |
188 int i; | |
6044 | 189 FileSelect=create_FileSelect(); |
190 | |
191 if ( FirstInit ) | |
192 { | |
193 fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); | |
194 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); | |
195 fsTopList_items=g_list_append( fsTopList_items,"/home" ); | |
196 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); | |
197 fsTopList_items=g_list_append( fsTopList_items,"/" ); | |
198 FirstInit=0; | |
199 } | |
200 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); | |
201 | |
3499 | 202 fsType=type; |
203 switch ( type ) | |
204 { | |
205 case fsVideoSelector: | |
206 fsMessage=evFileLoaded; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
207 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); |
3499 | 208 fsList_items=NULL; |
209 for( i=0;i<fsNumberOfVideoFilterNames + 1;i++ ) | |
210 fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] ); | |
211 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
212 g_list_free( fsList_items ); | |
5786 | 213 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[fsNumberOfVideoFilterNames - 1][0] ); |
3499 | 214 break; |
215 case fsSubtitleSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
216 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_SubtitleSelect ); |
3499 | 217 fsList_items=NULL; |
218 for( i=0;i<fsNumberOfSubtitleFilterNames + 1;i++ ) | |
219 fsList_items=g_list_append( fsList_items,fsSubtitleFilterNames[i][0] ); | |
220 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
221 g_list_free( fsList_items ); | |
5786 | 222 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsSubtitleFilterNames[fsNumberOfSubtitleFilterNames - 1][0] ); |
3499 | 223 break; |
224 case fsOtherSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
225 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_OtherSelect ); |
3499 | 226 fsList_items=NULL; |
227 for( i=0;i<fsNumberOfSubtitleFilterNames + 1;i++ ) | |
228 fsList_items=g_list_append( fsList_items,fsOtherFilterNames[i][0] ); | |
229 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
230 g_list_free( fsList_items ); | |
231 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsOtherFilterNames[fsNumberOfOtherFilterNames][0] ); | |
232 break; | |
233 } | |
234 gtk_widget_show( FileSelect ); | |
235 } | |
236 | |
2901 | 237 void HideFileSelect( void ) |
6044 | 238 { gtk_widget_destroy( fsFileSelect ); } |
2901 | 239 |
240 void fs_fsFileSelect_destroy( GtkObject * object,gpointer user_data ) | |
241 { HideFileSelect(); } | |
242 | |
3499 | 243 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) |
2901 | 244 { |
3499 | 245 strcpy( fsFilter,gtk_entry_get_text( GTK_ENTRY( user_data ) ) ); |
246 CheckDir( fsFNameList,get_current_dir_name() ); | |
2901 | 247 } |
248 | |
3499 | 249 void fs_fsFilterCombo_changed( GtkEditable * editable,gpointer user_data ) |
2901 | 250 { |
3499 | 251 char * str; |
252 int i; | |
2901 | 253 |
254 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
|
255 |
3499 | 256 switch ( fsType ) |
2901 | 257 { |
3499 | 258 case fsVideoSelector: |
259 for( i=0;i<fsNumberOfVideoFilterNames+1;i++ ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
260 if( !strcmp( str,fsVideoFilterNames[i][0] ) ) |
3499 | 261 { |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
262 strcpy( fsFilter,fsVideoFilterNames[i][1] ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
263 CheckDir( fsFNameList,get_current_dir_name() ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
264 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
265 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
266 break; |
3499 | 267 case fsSubtitleSelector: |
268 for( i=0;i<fsNumberOfSubtitleFilterNames+1;i++ ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
269 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) |
3499 | 270 { |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
271 strcpy( fsFilter,fsSubtitleFilterNames[i][1] ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
272 CheckDir( fsFNameList,get_current_dir_name() ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
273 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
274 } |
3499 | 275 break; |
276 case fsOtherSelector: | |
277 for( i=0;i<fsNumberOfOtherFilterNames+1;i++ ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
278 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) |
3499 | 279 { |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
280 strcpy( fsFilter,fsOtherFilterNames[i][1] ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
281 CheckDir( fsFNameList,get_current_dir_name() ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
282 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
283 } |
3499 | 284 break; |
2901 | 285 } |
286 } | |
287 | |
3499 | 288 void fs_fsPathCombo_activate( GtkEditable * editable,gpointer user_data ) |
2901 | 289 { |
290 unsigned char * str; | |
291 | |
292 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
3499 | 293 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 294 } |
295 | |
3499 | 296 void fs_fsPathCombo_changed( GtkEditable * editable,gpointer user_data ) |
2901 | 297 { |
298 unsigned char * str; | |
299 | |
300 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
301 fsPressed=2; | |
3499 | 302 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 303 } |
304 | |
305 void fs_Up_released( GtkButton * button,gpointer user_data ) | |
306 { | |
307 chdir( ".." ); | |
308 fsSelectedFile=fsThatDir; | |
3499 | 309 CheckDir( fsFNameList,get_current_dir_name() ); |
310 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
2901 | 311 return; |
312 } | |
313 | |
314 int fsFileExist( unsigned char * fname ) | |
315 { | |
316 FILE * f = fopen( fname,"r" ); | |
317 if ( f == NULL ) return 0; | |
318 fclose( f ); | |
319 return 1; | |
320 } | |
321 | |
322 void fs_Ok_released( GtkButton * button,gpointer user_data ) | |
323 { | |
324 unsigned char * str; | |
325 GList * item; | |
326 int size,j,i = 1; | |
327 struct stat fs; | |
328 | |
329 stat( fsSelectedFile,&fs ); | |
330 if( S_ISDIR(fs.st_mode ) ) | |
331 { | |
332 chdir( fsSelectedFile ); | |
333 fsSelectedFile=fsThatDir; | |
3499 | 334 CheckDir( fsFNameList,get_current_dir_name() ); |
335 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
2901 | 336 return; |
337 } | |
338 | |
339 HideFileSelect(); | |
340 | |
341 switch( fsPressed ) | |
342 { | |
343 case 1: | |
344 fsSelectedDirectory=(unsigned char *)get_current_dir_name(); | |
345 break; | |
346 case 2: | |
3499 | 347 str=gtk_entry_get_text( GTK_ENTRY( fsPathCombo ) ); |
2901 | 348 fsSelectedFile=str; |
349 if ( !fsFileExist( fsSelectedFile ) ) return; | |
350 fsSelectedDirectory=fsSelectedFile; | |
351 size=strlen( fsSelectedDirectory ); | |
352 for ( j=0;j<size;j++ ) | |
353 { | |
354 if ( fsSelectedDirectory[ size - j ] == '/' ) | |
355 { | |
356 fsSelectedFile+=size - j + 1; | |
357 fsSelectedDirectory[ size - j ]=0; | |
358 break; | |
359 } | |
360 } | |
361 break; | |
362 } | |
3499 | 363 switch ( fsType ) |
364 { | |
365 case fsVideoSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
366 guiSetDF( guiIntfStruct.Filename,fsSelectedDirectory,fsSelectedFile ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
367 guiIntfStruct.StreamType=STREAMTYPE_FILE; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
368 guiIntfStruct.FilenameChanged=1; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
369 break; |
3499 | 370 case fsSubtitleSelector: |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
371 guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
372 guiIntfStruct.SubtitleChanged=1; |
3499 | 373 break; |
374 case fsOtherSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
375 guiSetDF( guiIntfStruct.Othername,fsSelectedDirectory,fsSelectedFile ); |
3499 | 376 break; |
377 } | |
2901 | 378 item=fsTopList_items; |
379 while( item ) | |
380 { | |
381 if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0; | |
382 item=item->next; | |
383 } | |
6044 | 384 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
385 if ( mplMainAutoPlay ) mplEventHandling( evPlay,0 ); |
2901 | 386 } |
387 | |
388 void fs_Cancel_released( GtkButton * button,gpointer user_data ) | |
389 { HideFileSelect(); } | |
390 | |
391 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) | |
392 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
393 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); |
2901 | 394 fsPressed=1; |
395 if( !bevent ) return; | |
396 if( bevent->type == GDK_2BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); | |
397 } | |
398 | |
399 gboolean on_FileSelect_key_release_event( GtkWidget * widget,GdkEventKey * event,gpointer user_data ) | |
400 { | |
401 switch ( event->keyval ) | |
402 { | |
403 case GDK_Escape: | |
404 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
405 break; | |
406 case GDK_Return: | |
407 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
408 break; | |
409 case GDK_BackSpace: | |
410 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
411 break; | |
412 } | |
413 return FALSE; | |
414 } | |
415 | |
416 GtkWidget * create_FileSelect( void ) | |
417 { | |
418 GtkWidget * FSFrame; | |
419 GtkWidget * frame2; | |
420 GtkWidget * frame3; | |
421 GtkWidget * frame4; | |
422 GtkWidget * vbox4; | |
423 GtkWidget * hbox4; | |
424 GtkWidget * vseparator1; | |
425 GtkWidget * hseparator1; | |
426 GtkWidget * hbox6; | |
427 GtkWidget * fsFNameListWindow; | |
428 GtkWidget * label1; | |
429 GtkWidget * hseparator2; | |
430 GtkWidget * hseparator3; | |
431 GtkWidget * hbuttonbox3; | |
432 int i; | |
433 | |
434 GtkWidget * uppixmapwid; | |
435 GdkPixmap * uppixmap; | |
436 GdkBitmap * upmask; | |
437 GtkStyle * upstyle; | |
438 | |
4779 | 439 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
2901 | 440 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); |
441 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | |
4779 | 442 gtk_widget_set_usize( fsFileSelect,512,300 ); |
2901 | 443 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); |
444 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 ); | |
445 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
446 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER ); | |
4779 | 447 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE ); |
2901 | 448 fsColorMap=gdk_colormap_get_system(); |
449 | |
3499 | 450 style=gtk_widget_get_style( fsFileSelect ); |
451 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
452 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
453 | |
2901 | 454 FSFrame=gtk_frame_new( NULL ); |
455 gtk_widget_set_name( FSFrame,"FSFrame" ); | |
456 gtk_widget_ref( FSFrame ); | |
6044 | 457 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"FSFrame",FSFrame,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 458 gtk_widget_show( FSFrame ); |
459 gtk_container_add( GTK_CONTAINER( fsFileSelect ),FSFrame ); | |
460 gtk_container_set_border_width( GTK_CONTAINER( FSFrame ),1 ); | |
461 gtk_frame_set_shadow_type( GTK_FRAME( FSFrame ),GTK_SHADOW_IN ); | |
462 | |
463 frame2=gtk_frame_new( NULL ); | |
464 gtk_widget_set_name( frame2,"frame2" ); | |
465 gtk_widget_ref( frame2 ); | |
6044 | 466 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"frame2",frame2,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 467 gtk_widget_show( frame2 ); |
468 gtk_container_add( GTK_CONTAINER( FSFrame ),frame2 ); | |
469 gtk_frame_set_shadow_type( GTK_FRAME( frame2 ),GTK_SHADOW_NONE ); | |
470 | |
471 frame3=gtk_frame_new( NULL ); | |
472 gtk_widget_set_name( frame3,"frame3" ); | |
473 gtk_widget_ref( frame3 ); | |
6044 | 474 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"frame3",frame3,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 475 gtk_widget_show( frame3 ); |
476 gtk_container_add( GTK_CONTAINER( frame2 ),frame3 ); | |
477 gtk_frame_set_shadow_type( GTK_FRAME( frame3 ),GTK_SHADOW_ETCHED_OUT ); | |
478 | |
479 frame4=gtk_frame_new( NULL ); | |
480 gtk_widget_set_name( frame4,"frame4" ); | |
481 gtk_widget_ref( frame4 ); | |
6044 | 482 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"frame4",frame4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 483 gtk_widget_show( frame4 ); |
484 gtk_container_add( GTK_CONTAINER( frame3 ),frame4 ); | |
485 gtk_container_set_border_width( GTK_CONTAINER( frame4 ),1 ); | |
486 gtk_frame_set_shadow_type( GTK_FRAME( frame4 ),GTK_SHADOW_NONE ); | |
487 | |
488 vbox4=gtk_vbox_new( FALSE,0 ); | |
489 gtk_widget_set_name( vbox4,"vbox4" ); | |
490 gtk_widget_ref( vbox4 ); | |
6044 | 491 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"vbox4",vbox4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 492 gtk_widget_show( vbox4 ); |
493 gtk_container_add( GTK_CONTAINER( frame4 ),vbox4 ); | |
494 | |
495 hbox4=gtk_hbox_new( FALSE,0 ); | |
496 gtk_widget_set_name( hbox4,"hbox4" ); | |
497 gtk_widget_ref( hbox4 ); | |
6044 | 498 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hbox4",hbox4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 499 gtk_widget_show( hbox4 ); |
4779 | 500 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox4,FALSE,FALSE,0 ); |
2901 | 501 |
502 fsCombo4=gtk_combo_new(); | |
503 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
504 gtk_widget_ref( fsCombo4 ); | |
6044 | 505 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsCombo4",fsCombo4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 506 gtk_widget_show( fsCombo4 ); |
507 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
508 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
509 | |
3499 | 510 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; |
511 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
512 gtk_widget_ref( fsPathCombo ); | |
6044 | 513 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsPathCombo",fsPathCombo,(GtkDestroyNotify)gtk_widget_unref ); |
3499 | 514 gtk_widget_show( fsPathCombo ); |
515 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
2901 | 516 |
517 vseparator1=gtk_vseparator_new(); | |
518 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
519 gtk_widget_ref( vseparator1 ); | |
6044 | 520 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"vseparator1",vseparator1,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 521 gtk_widget_show( vseparator1 ); |
522 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
523 gtk_widget_set_usize( vseparator1,7,20 ); | |
524 | |
525 upstyle=gtk_widget_get_style( fsFileSelect ); | |
526 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
527 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); | |
528 gtk_widget_show( uppixmapwid ); | |
529 | |
530 fsUp=gtk_button_new(); | |
531 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
532 gtk_widget_show( fsUp ); | |
533 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
534 gtk_widget_set_usize( fsUp,65,15 ); | |
535 | |
536 hseparator1=gtk_hseparator_new(); | |
537 gtk_widget_set_name( hseparator1,"hseparator1" ); | |
538 gtk_widget_ref( hseparator1 ); | |
6044 | 539 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hseparator1",hseparator1,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 540 gtk_widget_show( hseparator1 ); |
541 gtk_box_pack_start( GTK_BOX( vbox4 ),hseparator1,FALSE,TRUE,0 ); | |
542 gtk_widget_set_usize( hseparator1,-2,8 ); | |
543 | |
544 hbox6=gtk_hbox_new( FALSE,0 ); | |
545 gtk_widget_set_name( hbox6,"hbox6" ); | |
546 gtk_widget_ref( hbox6 ); | |
6044 | 547 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hbox6",hbox6,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 548 gtk_widget_show( hbox6 ); |
549 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
550 | |
551 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
552 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
553 gtk_widget_ref( fsFNameListWindow ); | |
6044 | 554 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsFNameListWindow",fsFNameListWindow,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 555 gtk_widget_show( fsFNameListWindow ); |
556 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
557 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
558 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
559 | |
560 fsFNameList=gtk_clist_new( 2 ); | |
561 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
562 gtk_widget_ref( fsFNameList ); | |
6044 | 563 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsFNameList",fsFNameList,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 564 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); |
565 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
566 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
567 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
568 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
3499 | 569 CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 570 |
571 label1=gtk_label_new( "label1" ); | |
572 gtk_widget_set_name( label1,"label1" ); | |
573 gtk_widget_ref( label1 ); | |
6044 | 574 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"label1",label1,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 575 gtk_widget_show( label1 ); |
576 gtk_clist_set_column_widget( GTK_CLIST( fsFNameList ),0,label1 ); | |
577 | |
578 hseparator2=gtk_hseparator_new(); | |
579 gtk_widget_set_name( hseparator2,"hseparator2" ); | |
580 gtk_widget_ref( hseparator2 ); | |
6044 | 581 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hseparator2",hseparator2,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 582 gtk_widget_show( hseparator2 ); |
583 gtk_box_pack_start( GTK_BOX( vbox4 ),hseparator2,FALSE,TRUE,0 ); | |
584 gtk_widget_set_usize( hseparator2,-2,9 ); | |
585 | |
586 List=gtk_combo_new(); | |
587 gtk_widget_set_name( List,"List" ); | |
588 gtk_widget_ref( List ); | |
6044 | 589 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 590 gtk_widget_show( List ); |
591 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
592 gtk_widget_set_usize( List,-2,20 ); | |
593 fsList_items=NULL; | |
3499 | 594 for( i=0;i<fsNumberOfVideoFilterNames + 1;i++ ) |
595 fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] ); | |
2901 | 596 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); |
597 g_list_free( fsList_items ); | |
598 | |
3499 | 599 fsFilterCombo=GTK_COMBO( List )->entry; |
600 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
601 gtk_widget_ref( fsFilterCombo ); | |
6044 | 602 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsFilterCombo",fsFilterCombo,(GtkDestroyNotify)gtk_widget_unref ); |
3499 | 603 gtk_widget_show( fsFilterCombo ); |
604 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
5786 | 605 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[fsNumberOfVideoFilterNames - 1][0] ); |
2901 | 606 |
607 hseparator3=gtk_hseparator_new(); | |
608 gtk_widget_set_name( hseparator3,"hseparator3" ); | |
609 gtk_widget_ref( hseparator3 ); | |
6044 | 610 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hseparator3",hseparator3,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 611 gtk_widget_show( hseparator3 ); |
612 gtk_box_pack_start( GTK_BOX( vbox4 ),hseparator3,FALSE,TRUE,0 ); | |
613 gtk_widget_set_usize( hseparator3,-2,7 ); | |
614 | |
615 hbuttonbox3=gtk_hbutton_box_new(); | |
616 gtk_widget_set_name( hbuttonbox3,"hbuttonbox3" ); | |
617 gtk_widget_ref( hbuttonbox3 ); | |
6044 | 618 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hbuttonbox3",hbuttonbox3,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 619 gtk_widget_show( hbuttonbox3 ); |
620 gtk_box_pack_start( GTK_BOX( vbox4 ),hbuttonbox3,FALSE,TRUE,0 ); | |
621 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
622 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
623 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox3 ),85,20 ); | |
624 gtk_button_box_set_child_ipadding( GTK_BUTTON_BOX( hbuttonbox3 ),0,0 ); | |
625 | |
626 fsOk=gtk_button_new_with_label( MSGTR_Ok ); | |
627 gtk_widget_set_name( fsOk,MSGTR_Ok ); | |
628 gtk_widget_ref( fsOk ); | |
629 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),MSGTR_Ok,fsOk,( GtkDestroyNotify )gtk_widget_unref ); | |
630 gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsOk ); | |
631 gtk_widget_show( fsOk ); | |
632 | |
633 fsCancel=gtk_button_new_with_label( MSGTR_Cancel ); | |
634 gtk_widget_set_name( fsCancel,MSGTR_Cancel ); | |
635 gtk_widget_ref( fsCancel ); | |
636 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),MSGTR_Cancel,fsCancel,( GtkDestroyNotify )gtk_widget_unref ); | |
637 gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsCancel ); | |
638 gtk_widget_show( fsCancel ); | |
639 | |
6044 | 640 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( fs_fsFileSelect_destroy ),NULL ); |
641 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
642 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); | |
643 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
644 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
645 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
646 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
647 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); | |
648 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); | |
649 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); | |
2901 | 650 |
651 gtk_widget_grab_focus( fsFNameList ); | |
652 | |
653 return fsFileSelect; | |
654 } | |
655 |