Mercurial > mplayer.hg
annotate gui/dialog/fileselect.c @ 36011:277882d42938
Remove pointless replacement lists.
Remove pointless #undefs.
author | ib |
---|---|
date | Sun, 31 Mar 2013 01:20:18 +0000 |
parents | 5c720c434d56 |
children | 72b526dc27a8 |
rev | line source |
---|---|
33572 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
18 | |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
21 #include <string.h> | |
35903 | 22 #include <strings.h> |
33572 | 23 #include <sys/stat.h> |
24 #include <glob.h> | |
25 #include <unistd.h> | |
26 | |
27 #include "config.h" | |
35772 | 28 #include "gui/ui/actions.h" |
33572 | 29 |
35526 | 30 #include "pixmaps/up.xpm" |
31 #include "pixmaps/dir.xpm" | |
32 #include "pixmaps/file.xpm" | |
33572 | 33 |
35525 | 34 #include "gui/app/app.h" |
35 #include "gui/app/gui.h" | |
33572 | 36 #include "gui/interface.h" |
35350 | 37 #include "gui/util/list.h" |
33739 | 38 #include "gui/util/mem.h" |
33737 | 39 #include "gui/util/string.h" |
33572 | 40 #include "help_mp.h" |
41 #include "mpcommon.h" | |
42 #include "stream/stream.h" | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
43 #include "libavutil/common.h" |
33572 | 44 |
35529 | 45 #include "dialog.h" |
33572 | 46 #include "fileselect.h" |
47 #include "preferences.h" | |
48 #include "tools.h" | |
49 | |
36011 | 50 #define CFG_OLD_FILESELECT |
35926 | 51 #include "gui/app/cfg-old.c" |
52 | |
33572 | 53 #ifndef __linux__ |
54 #define get_current_dir_name() getcwd(NULL, PATH_MAX) | |
55 #else | |
56 char * get_current_dir_name( void ); | |
57 #endif | |
58 | |
35969 | 59 const char * fsSelectedFile = NULL; |
60 const char * fsThisDir = "."; | |
33572 | 61 const gchar * fsFilter = "*"; |
62 | |
63 int fsType = 0; | |
64 | |
34364 | 65 static gint fsCurrFNameListSelected, fsLastFNameListSelected; |
66 | |
35985 | 67 char * fsVideoAudioFilterNames[][2] = |
33572 | 68 { |
34857
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
69 { MSGTR_Filter_AVIFiles, "*.avi" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
70 { MSGTR_Filter_DivXFiles, "*.divx" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
71 { MSGTR_Filter_FlashVideo, "*.flv" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
72 { MSGTR_Filter_MP3Files, "*.mp3" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
73 { MSGTR_Filter_MP4Files, "*.aac,*.f4a,*.f4b,*.f4v,*.m4a,*.m4b,*.m4v,*.mp4" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
74 { MSGTR_Filter_MPEGFiles, "*.m1v,*.m2v,*.mp2,*.mpe,*.mpeg,*.mpg,*.mpga,*.vdr,*.vob" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
75 { MSGTR_Filter_MP2TS, "*.bdm,*.bdmv,*.clpi,*.cpi,*.m2t,*.m2ts,*.mpl,*.mpls,*.mts,*.rec,*.trp,*.ts,*.ty" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
76 { MSGTR_Filter_MatroskaMedia, "*.mka,*.mkv" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
77 { MSGTR_Filter_OGGMedia, "*.oga,*.ogg,*.ogm,*.ogv,*.ogx,*.spx" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
78 { MSGTR_Filter_QTMedia, "*.moov,*.mov,*.qt,*.qtvr" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
79 { MSGTR_Filter_RNMedia, "*.ra,*.rm,*.rmvb,*.rv" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
80 { MSGTR_Filter_VideoCDImages, "*.bin" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
81 { MSGTR_Filter_WAVFiles, "*.wav" }, |
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
82 { MSGTR_Filter_WindowsMedia, "*.asf,*.wma,*.wmv" }, |
34869
30fad98fad6e
Add Windows Media Station file (application/x-netshow-channel) support.
ib
parents:
34868
diff
changeset
|
83 { MSGTR_Filter_Playlists, "*.asx,*.m3u,*.m3u8,*.nsc,*.pls,*.ram,*.smi,*.smil,*.sml,*.vlc,*.wax,*.wmx,*.wvx" }, |
35142
1accad685563
Add TAK file extension to the audio file filter of the file selector.
ib
parents:
34892
diff
changeset
|
84 { MSGTR_Filter_AllAudioFiles, "*.aac,*.ac3,*.aif,*.aifc,*.aiff,*.amr,*.ape,*.au,*.awb,*.cdg,*.f4a,*.f4b,*.flac,*.m4a,*.m4b,*.mka,*.mp+,*.mp2,*.mp3,*.mpc,*.mpga,*.mpp,*.nsa,*.oga,*.ogg,*.pcm,*.qcp,*.ra,*.snd,*.spx,*.tak,*.voc,*.vqf,*.w64,*.wav,*.wma,*.wv,*.wvp" }, |
34892
b538985dfaac
Add some file extensions to the video file filter of the file selector.
ib
parents:
34871
diff
changeset
|
85 { MSGTR_Filter_AllVideoFiles, "*.264,*.3g2,*.3ga,*.3gp,*.3gp2,*.3gpp,*.3gpp2,*.asf,*.avi,*.bdm,*.bdmv,*.bin,*.clpi,*.cpi,*.cpk,*.divx,*.dv,*.f4v,*.flc,*.fli,*.flv,*.m1v,*.m2t,*.m2ts,*.m2v,*.m4v,*.mjpg,*.mkv,*.moov,*.mov,*.mp2,*.mp4,*.mpe,*.mpeg,*.mpg,*.mpl,*.mpls,*.mts,*.mxf,*.nsv,*.nuv,*.ogg,*.ogm,*.ogv,*.ogx,*.pva,*.qt,*.qtvr,*.rec,*.rm,*.rmvb,*.roq,*.rv,*.spl,*.str,*.swf,*.trp,*.ts,*.ty,*.vdr,*.viv,*.vivo,*.vob,*.webm,*.wmv,*.y4m" }, |
34857
cceef8552b0c
Enable translation of video and audio file filter items.
ib
parents:
34856
diff
changeset
|
86 { MSGTR_Filter_AllFiles, "*" }, |
33572 | 87 { NULL,NULL } |
88 }; | |
35985 | 89 int fsLastVideoAudioFilterSelected = -1; |
33572 | 90 |
91 char * fsSubtitleFilterNames[][2] = | |
92 { | |
34849 | 93 { "AQTitle (*.aqt)", "*.aqt" }, |
94 { "Advanced SubStation Alpha (*.ass)", "*.ass" }, | |
95 { "JACOSub (*.jss) ", "*.jss" }, | |
96 { "RealText (*.rt) ", "*.rt" }, | |
97 { "SAMI (*.smi)", "*.smi" }, | |
98 { "SubRip (*.srt)", "*.srt" }, | |
99 { "SubStation Alpha (*.ssa)", "*.ssa" }, | |
100 { "MicroDVD (*.sub)", "*.sub" }, | |
101 { "Text (*.txt)", "*.txt" }, | |
34868
1a07230149a0
Revise UTF-8 encoded subtitle file filter for file selector.
ib
parents:
34867
diff
changeset
|
102 { MSGTR_Filter_UTF8Subtitles, "*.utf,*.utf-8,*.utf8" }, |
34850 | 103 { MSGTR_Filter_AllSubtitles, "*.aqt,*.ass,*.jss,*.rt,*.smi,*.srt,*.ssa,*.sub,*.txt,*.utf" }, |
104 { MSGTR_Filter_AllFiles, "*" }, | |
33572 | 105 { NULL,NULL } |
106 }; | |
107 int fsLastSubtitleFilterSelected = -1; | |
108 | |
109 char * fsOtherFilterNames[][2] = | |
110 { | |
34854 | 111 { MSGTR_Filter_AllFiles, "*" }, |
33572 | 112 { NULL,NULL } |
113 }; | |
114 | |
115 char * fsAudioFileNames[][2] = | |
116 { | |
34853
f6f1cfdaaccf
Enable translation of external audio file filter items.
ib
parents:
34852
diff
changeset
|
117 { MSGTR_Filter_DDRawAudio, "*.ac3,*.pcm" }, |
34856 | 118 { MSGTR_Filter_MPEGAudio, "*.aac,*.f4a,*.m4a,*.mp2,*.mp3,*.mpga" }, |
34853
f6f1cfdaaccf
Enable translation of external audio file filter items.
ib
parents:
34852
diff
changeset
|
119 { MSGTR_Filter_MatroskaAudio, "*.mka" }, |
f6f1cfdaaccf
Enable translation of external audio file filter items.
ib
parents:
34852
diff
changeset
|
120 { MSGTR_Filter_OGGAudio, "*.oga,*.ogg,*.spx" }, |
f6f1cfdaaccf
Enable translation of external audio file filter items.
ib
parents:
34852
diff
changeset
|
121 { MSGTR_Filter_WAVAudio, "*.wav" }, |
f6f1cfdaaccf
Enable translation of external audio file filter items.
ib
parents:
34852
diff
changeset
|
122 { MSGTR_Filter_WMAAudio, "*.wma" }, |
34856 | 123 { MSGTR_Filter_AllAudioFiles, "*.aac,*.ac3,*.f4a,*.m4a,*.mka,*.mp2,*.mp3,*.mpga,*.oga,*.ogg,*.pcm,*.spx,*.wav,*.wma" }, |
34853
f6f1cfdaaccf
Enable translation of external audio file filter items.
ib
parents:
34852
diff
changeset
|
124 { MSGTR_Filter_AllFiles, "*" }, |
33572 | 125 { NULL, NULL } |
126 }; | |
127 int fsLastAudioFilterSelected = -1; | |
128 | |
129 char * fsFontFileNames[][2] = | |
130 { | |
131 #ifdef CONFIG_FREETYPE | |
34851 | 132 { MSGTR_Filter_TTF, "*.ttf" }, |
133 { MSGTR_Filter_Type1, "*.pfb" }, | |
34856 | 134 { MSGTR_Filter_AllFonts, "*.pfb,*.ttf" }, |
33572 | 135 #else |
34851 | 136 { MSGTR_Filter_FontFiles, "*.desc" }, |
33572 | 137 #endif |
34851 | 138 { MSGTR_Filter_AllFiles, "*" }, |
33572 | 139 { NULL,NULL } |
140 }; | |
141 int fsLastFontFilterSelected = -1; | |
142 | |
143 GtkWidget * fsFileNamesList; | |
144 GtkWidget * fsFNameList; | |
35975 | 145 GtkWidget * FileSelector = NULL; |
33572 | 146 GdkColormap * fsColorMap; |
147 GtkWidget * fsOk; | |
148 GtkWidget * fsUp; | |
149 GtkWidget * fsCancel; | |
150 GtkWidget * fsCombo4; | |
151 GtkWidget * fsPathCombo; | |
152 GList * fsList_items = NULL; | |
153 GList * fsTopList_items = NULL; | |
35926 | 154 GHashTable * fsPathTable; |
33572 | 155 GtkWidget * List; |
156 GtkWidget * fsFilterCombo; | |
157 | |
158 GtkStyle * style; | |
159 GdkPixmap * dpixmap; | |
160 GdkPixmap * fpixmap; | |
161 GdkBitmap * dmask; | |
162 GdkBitmap * fmask; | |
163 | |
35960 | 164 static gchar * get_current_dir_name_utf8( void ) |
33572 | 165 { |
35960 | 166 char * dir; |
167 gchar * utf8dir; | |
33572 | 168 dir = get_current_dir_name(); |
35926 | 169 utf8dir = g_filename_display_name( dir ); |
33572 | 170 free( dir ); |
171 return utf8dir; | |
172 } | |
173 | |
174 static void clist_append_fname(GtkWidget * list, char *fname, | |
175 GdkPixmap *pixmap, GdkPixmap *mask) { | |
176 gint pos; | |
35925 | 177 gchar *str[2]; |
33572 | 178 str[0] = NULL; |
35925 | 179 str[1] = g_filename_display_name(fname); |
33572 | 180 pos = gtk_clist_append(GTK_CLIST(list), str); |
35925 | 181 gtk_clist_set_row_data_full(GTK_CLIST(list), pos, strdup(fname), free); |
33572 | 182 gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask); |
35925 | 183 g_free(str[1]); |
33572 | 184 } |
185 | |
186 static void CheckDir( GtkWidget * list ) | |
187 { | |
188 struct stat fs; | |
34838 | 189 unsigned int i, j, fn; |
33572 | 190 glob_t gg; |
34836 | 191 gchar *filter, **fext; |
33572 | 192 |
193 if ( !fsFilter[0] ) return; | |
194 | |
195 gtk_widget_hide( list ); | |
196 gtk_clist_clear( GTK_CLIST( list ) ); | |
197 | |
198 clist_append_fname(list, ".", dpixmap, dmask); | |
199 clist_append_fname(list, "..", dpixmap, dmask); | |
200 | |
201 glob( "*",0,NULL,&gg ); | |
34838 | 202 for( i=0;i<gg.gl_pathc;i++ ) |
33572 | 203 { |
35399
4d7adee0a7ba
Check stat() return value before utilizing its information.
ib
parents:
35353
diff
changeset
|
204 if( ( stat( gg.gl_pathv[i],&fs ) != 0 ) || !S_ISDIR( fs.st_mode ) ) continue; |
33572 | 205 clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask); |
206 } | |
34836 | 207 |
208 for (fn = 1, i = 0; fsFilter[i]; i++) | |
209 if (fsFilter[i] == ',') fn++; | |
210 | |
211 filter = g_strdup(fsFilter); | |
212 fext = calloc(fn, sizeof(gchar *)); | |
33572 | 213 |
34836 | 214 if (filter && fext) |
215 { | |
216 for (j = 0, i = 0; filter[i]; i++) | |
217 { | |
218 if (filter[i] == '.') fext[j] = filter + i; | |
219 | |
220 if (filter[i] == ',') | |
221 { | |
222 filter[i] = 0; | |
223 j++; | |
224 } | |
225 } | |
33572 | 226 |
34838 | 227 for( i=0;i<gg.gl_pathc;i++ ) |
34837 | 228 { |
34836 | 229 char *ext; |
230 | |
35399
4d7adee0a7ba
Check stat() return value before utilizing its information.
ib
parents:
35353
diff
changeset
|
231 if( ( stat( gg.gl_pathv[i],&fs ) != 0 ) || S_ISDIR( fs.st_mode ) ) continue; |
34836 | 232 |
233 ext = strrchr(gg.gl_pathv[i], '.'); | |
234 | |
235 if (ext || !fext[0]) | |
236 { | |
237 for (j = 0; j < fn; j++) | |
238 { | |
239 if (fext[j] == NULL || strcasecmp(fext[j], ext) == 0) | |
240 { | |
34837 | 241 clist_append_fname(list, gg.gl_pathv[i], fpixmap, fmask); |
34836 | 242 break; |
243 } | |
244 } | |
245 } | |
34837 | 246 } |
34836 | 247 } |
248 | |
249 free(fext); | |
250 g_free(filter); | |
33572 | 251 globfree( &gg ); |
252 | |
253 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 ); | |
254 gtk_widget_show( list ); | |
255 } | |
256 | |
35971 | 257 static GList *fs_AddPath (GList *list, gpointer data, GtkPositionType pos) |
35970
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
258 { |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
259 if (!g_list_find_custom(list, data, (GCompareFunc) strcmp)) |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
260 { |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
261 if (pos == GTK_POS_TOP) list = g_list_prepend(list, data); |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
262 else list = g_list_append(list, data); |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
263 } |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
264 |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
265 return list; |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
266 } |
90b6cc0747fb
Avoid duplicate entries in the file selector path list.
ib
parents:
35969
diff
changeset
|
267 |
35940 | 268 static void fs_AddPathUtf8 (const char *name, GtkPositionType pos) |
269 { | |
270 gchar *utf8name; | |
271 | |
272 utf8name = g_filename_display_name(name); | |
35971 | 273 fsTopList_items = fs_AddPath(fsTopList_items, utf8name, pos); |
35940 | 274 g_hash_table_insert(fsPathTable, strdup(utf8name), strdup(name)); |
275 } | |
276 | |
33572 | 277 static void fs_PersistantHistory( char * subject ) |
278 { | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
279 unsigned int i; |
35847 | 280 char * entry; |
33572 | 281 |
35848 | 282 if ( !subject ) return; |
33572 | 283 |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33740
diff
changeset
|
284 for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ ) |
35849 | 285 if ( gstrcmp( fsHistory[i],subject ) == 0 ) |
33572 | 286 { |
35847 | 287 entry=fsHistory[i]; |
288 break; | |
33572 | 289 } |
35850 | 290 if ( i == FF_ARRAY_ELEMS(fsHistory) ) |
35847 | 291 { |
35848 | 292 entry=strdup( subject ); |
35852 | 293 free( fsHistory[--i] ); |
35847 | 294 } |
295 for ( ;i;i-- ) fsHistory[i]=fsHistory[i - 1]; | |
296 fsHistory[0]=entry; | |
33572 | 297 } |
34684 | 298 /* ----------------------------------------------- */ |
33572 | 299 |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
300 static void fs_fsFilterCombo_activate( GtkEntry * entry, |
33572 | 301 gpointer user_data ) |
302 { | |
36010 | 303 (void) entry; |
304 | |
33572 | 305 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); |
306 CheckDir( fsFNameList ); | |
307 } | |
308 | |
309 static void fs_fsFilterCombo_changed( GtkEditable * editable, | |
310 gpointer user_data ) | |
311 { | |
312 const char * str; | |
313 int i; | |
314 | |
36010 | 315 (void) editable; |
316 | |
33572 | 317 str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); |
318 | |
319 switch ( fsType ) | |
320 { | |
35974 | 321 case FILESELECT_VIDEO_AUDIO: |
35985 | 322 for( i=0;fsVideoAudioFilterNames[i][0];i++ ) |
323 if( !strcmp( str,fsVideoAudioFilterNames[i][0] ) ) | |
324 { fsFilter=fsVideoAudioFilterNames[i][1]; fsLastVideoAudioFilterSelected = i; break; } | |
33572 | 325 break; |
35974 | 326 case FILESELECT_SUBTITLE: |
33572 | 327 for( i=0;fsSubtitleFilterNames[i][0];i++ ) |
328 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) | |
329 { fsFilter=fsSubtitleFilterNames[i][1]; fsLastSubtitleFilterSelected = i; break; } | |
330 break; | |
33776 | 331 /* case fsOtherSelector: |
33572 | 332 for( i=0;fsOtherFilterNames[i][0];i++ ) |
333 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) | |
334 { fsFilter=fsOtherFilterNames[i][1]; break; } | |
33776 | 335 break;*/ |
35974 | 336 case FILESELECT_AUDIO: |
33572 | 337 for( i=0;fsAudioFileNames[i][0];i++ ) |
338 if( !strcmp( str,fsAudioFileNames[i][0] ) ) | |
339 { fsFilter=fsAudioFileNames[i][1]; fsLastAudioFilterSelected = i; break; } | |
340 break; | |
35974 | 341 case FILESELECT_FONT: |
33572 | 342 for( i=0;fsFontFileNames[i][0];i++ ) |
343 if( !strcmp( str,fsFontFileNames[i][0] ) ) | |
344 { fsFilter=fsFontFileNames[i][1]; fsLastFontFilterSelected = i; break; } | |
345 break; | |
346 default: return; | |
347 } | |
348 CheckDir( fsFNameList ); | |
349 } | |
350 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
351 static void fs_fsPathCombo_activate( GtkEntry * entry, |
33572 | 352 gpointer user_data ) |
353 { | |
354 const unsigned char * str; | |
355 gchar * dirname; | |
356 | |
36010 | 357 (void) entry; |
358 | |
33572 | 359 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); |
35926 | 360 dirname=g_hash_table_lookup(fsPathTable, str); |
33572 | 361 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); |
362 } | |
363 | |
364 static void fs_fsPathCombo_changed( GtkEditable * editable, | |
365 gpointer user_data ) | |
366 { | |
367 const unsigned char * str; | |
368 gchar * dirname; | |
369 | |
36010 | 370 (void) editable; |
371 | |
33572 | 372 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); |
35926 | 373 dirname=g_hash_table_lookup(fsPathTable, str); |
33572 | 374 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); |
375 } | |
376 | |
377 static void fs_Up_released( GtkButton * button, gpointer user_data ) | |
378 { | |
35960 | 379 gchar *utf8dir; |
35934 | 380 |
36010 | 381 (void) button; |
382 (void) user_data; | |
383 | |
33572 | 384 chdir( ".." ); |
385 CheckDir( fsFNameList ); | |
35934 | 386 utf8dir = get_current_dir_name_utf8(); |
35961 | 387 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),utf8dir ); |
35934 | 388 g_free(utf8dir); |
35969 | 389 fsSelectedFile=fsThisDir; |
33572 | 390 return; |
391 } | |
392 | |
36001 | 393 static void fs_Cancel_released( GtkButton * button,gpointer user_data ) |
394 { | |
36010 | 395 (void) button; |
396 (void) user_data; | |
397 | |
36001 | 398 gtk_widget_destroy( FileSelector ); |
399 fsLastFNameListSelected = fsCurrFNameListSelected; | |
400 } | |
401 | |
33572 | 402 static void fs_Ok_released( GtkButton * button, gpointer user_data ) |
403 { | |
35931 | 404 char * fsSelectedDirectory; |
35935 | 405 int l; |
33572 | 406 struct stat fs; |
35348 | 407 gchar * selected; |
33572 | 408 |
36010 | 409 (void) button; |
410 (void) user_data; | |
411 | |
35399
4d7adee0a7ba
Check stat() return value before utilizing its information.
ib
parents:
35353
diff
changeset
|
412 if( ( stat( fsSelectedFile,&fs ) == 0 ) && S_ISDIR( fs.st_mode ) ) |
33572 | 413 { |
35960 | 414 gchar *utf8dir; |
35401 | 415 if ( chdir( fsSelectedFile ) != 0 ) return; |
33572 | 416 CheckDir( fsFNameList ); |
35934 | 417 utf8dir = get_current_dir_name_utf8(); |
35961 | 418 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),utf8dir ); |
35934 | 419 g_free(utf8dir); |
34364 | 420 gtk_widget_grab_focus( fsFNameList ); |
35969 | 421 fsSelectedFile=fsThisDir; |
33572 | 422 return; |
423 } | |
424 | |
35961 | 425 fsSelectedDirectory=get_current_dir_name(); |
33572 | 426 switch ( fsType ) |
427 { | |
35974 | 428 case FILESELECT_VIDEO_AUDIO: |
35985 | 429 for (l = 0; fsVideoAudioFilterNames[l][0]; l++) |
430 if (strcmp(fsVideoAudioFilterNames[l][0], MSGTR_Filter_Playlists) == 0) break; | |
431 uiSetFile( fsSelectedDirectory,fsSelectedFile, fsLastVideoAudioFilterSelected == l ? STREAMTYPE_PLAYLIST : STREAMTYPE_FILE ); | |
35348 | 432 selected = g_strconcat(fsSelectedDirectory, "/", fsSelectedFile, NULL); |
433 if (selected) | |
434 { | |
35352 | 435 listMgr(PLAYLIST_DELETE, 0); |
35350 | 436 add_to_gui_playlist(selected, PLAYLIST_ITEM_APPEND); |
35348 | 437 g_free(selected); |
438 } | |
33894 | 439 guiInfo.NewPlay=GUI_FILE_NEW; sub_fps=0; |
35931 | 440 fs_PersistantHistory( fsSelectedDirectory ); |
33572 | 441 break; |
35974 | 442 case FILESELECT_SUBTITLE: |
33897 | 443 setddup( &guiInfo.SubtitleFilename,fsSelectedDirectory,fsSelectedFile ); |
444 mplayerLoadSubtitle( guiInfo.SubtitleFilename ); | |
33572 | 445 break; |
33776 | 446 /* case fsOtherSelector: |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
447 setddup( &guiInfo.Othername,fsSelectedDirectory,fsSelectedFile ); |
33776 | 448 break;*/ |
35974 | 449 case FILESELECT_AUDIO: |
33897 | 450 setddup( &guiInfo.AudioFilename,fsSelectedDirectory,fsSelectedFile ); |
33572 | 451 break; |
35974 | 452 case FILESELECT_FONT: |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
453 setddup( &font_name,fsSelectedDirectory,fsSelectedFile ); |
33763 | 454 mplayerLoadFont(); |
33572 | 455 if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name ); |
456 break; | |
457 } | |
458 | |
35937 | 459 free(fsSelectedDirectory); |
33572 | 460 |
36001 | 461 fs_Cancel_released(NULL, NULL); |
35931 | 462 |
35773 | 463 if ( uiLoadPlay ) { uiLoadPlay=False; uiEvent( evPlay,0 ); } |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
464 else gui( GUI_SET_STATE,(void *) GUI_STOP ); |
33572 | 465 } |
466 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
467 static void fs_fsFNameList_select_row( GtkCList * clist, gint row, gint column, |
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
468 GdkEvent * event, gpointer user_data) |
33572 | 469 { |
36010 | 470 (void) column; |
471 (void) user_data; | |
472 | |
34364 | 473 fsCurrFNameListSelected = row; |
35925 | 474 fsSelectedFile = gtk_clist_get_row_data(clist, row); |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
475 if( event && event->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); |
33572 | 476 } |
477 | |
478 static gboolean on_FileSelect_key_release_event( GtkWidget * widget, | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
479 GdkEvent * event, |
33572 | 480 gpointer user_data ) |
481 { | |
36010 | 482 (void) user_data; |
483 | |
34344 | 484 if ( GTK_WIDGET_TYPE( widget ) == GTK_TYPE_BUTTON ) |
485 { | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
486 if (event->key.keyval == GDK_Return) gtk_button_released( GTK_BUTTON( widget ) ); |
34344 | 487 } |
488 else | |
489 { | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34368
diff
changeset
|
490 switch ( event->key.keyval ) |
34345 | 491 { |
492 case GDK_Escape: | |
493 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
494 break; | |
495 case GDK_Return: | |
496 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
497 break; | |
498 case GDK_BackSpace: | |
499 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
34351
52a18f850c28
Leave the focus in fsFNameList after key event in file selector.
ib
parents:
34346
diff
changeset
|
500 gtk_widget_grab_focus( fsFNameList ); |
34345 | 501 break; |
502 } | |
34344 | 503 } |
33572 | 504 return FALSE; |
505 } | |
506 | |
507 static gboolean fs_fsFNameList_event( GtkWidget * widget, | |
508 GdkEvent * event, | |
509 gpointer user_data ) | |
510 { | |
511 GdkEventButton *bevent; | |
512 gint row, col; | |
513 | |
36010 | 514 (void) user_data; |
515 | |
33572 | 516 bevent = (GdkEventButton *) event; |
517 | |
518 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
519 { | |
520 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
521 { | |
35925 | 522 fsSelectedFile = gtk_clist_get_row_data(GTK_CLIST(widget), row); |
33572 | 523 gtk_button_released( GTK_BUTTON( fsOk ) ); |
524 return TRUE; | |
525 } | |
526 } | |
527 | |
528 return FALSE; | |
529 } | |
530 | |
531 static void fs_Destroy( void ) | |
532 { | |
36008 | 533 gtk_widget_destroyed( FileSelector, &FileSelector ); |
35959 | 534 |
535 g_hash_table_destroy( fsPathTable ); | |
536 | |
537 g_list_foreach(fsTopList_items, (GFunc) g_free, NULL); | |
538 g_list_free(fsTopList_items); | |
539 fsTopList_items = NULL; | |
33572 | 540 } |
541 | |
35996 | 542 static GtkWidget * CreateFileSelect( void ) |
33572 | 543 { |
544 GtkWidget * vbox4; | |
545 GtkWidget * hbox4; | |
546 GtkWidget * vseparator1; | |
547 GtkWidget * hbox6; | |
548 GtkWidget * fsFNameListWindow; | |
549 GtkWidget * hbuttonbox3; | |
550 | |
551 GtkWidget * uppixmapwid; | |
552 GdkPixmap * uppixmap; | |
553 GdkBitmap * upmask; | |
554 GtkStyle * upstyle; | |
555 | |
556 | |
35975 | 557 FileSelector=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
558 gtk_widget_set_name( FileSelector,"FileSelector" ); | |
559 gtk_object_set_data( GTK_OBJECT( FileSelector ),"FileSelector",FileSelector ); | |
560 gtk_widget_set_usize( FileSelector,512,300 ); | |
561 GTK_WIDGET_SET_FLAGS( FileSelector,GTK_CAN_DEFAULT ); | |
562 gtk_widget_set_events( FileSelector,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 ); | |
563 gtk_window_set_title( GTK_WINDOW( FileSelector ),MSGTR_FileSelect ); | |
564 gtk_window_set_position( GTK_WINDOW( FileSelector ),GTK_WIN_POS_CENTER ); | |
565 gtk_window_set_policy( GTK_WINDOW( FileSelector ),TRUE,TRUE,TRUE ); | |
566 gtk_window_set_wmclass( GTK_WINDOW( FileSelector ),"FileSelect","MPlayer" ); | |
33572 | 567 fsColorMap=gdk_colormap_get_system(); |
568 | |
35975 | 569 gtk_widget_realize( FileSelector ); |
570 gtkAddIcon( FileSelector ); | |
33572 | 571 |
35975 | 572 style=gtk_widget_get_style( FileSelector ); |
573 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( FileSelector->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
574 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( FileSelector->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
33572 | 575 |
35975 | 576 vbox4=AddVBox( AddDialogFrame( FileSelector ),0 ); |
33572 | 577 hbox4=AddHBox( vbox4,1 ); |
578 | |
579 fsCombo4=gtk_combo_new(); | |
580 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
581 gtk_widget_show( fsCombo4 ); | |
582 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
583 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
584 | |
585 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; | |
586 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
587 gtk_widget_show( fsPathCombo ); | |
588 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
589 | |
590 vseparator1=gtk_vseparator_new(); | |
591 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
592 gtk_widget_show( vseparator1 ); | |
593 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
594 gtk_widget_set_usize( vseparator1,7,20 ); | |
595 | |
35975 | 596 upstyle=gtk_widget_get_style( FileSelector ); |
597 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( FileSelector->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
33572 | 598 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); |
599 gtk_widget_show( uppixmapwid ); | |
600 | |
601 fsUp=gtk_button_new(); | |
602 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
603 gtk_widget_show( fsUp ); | |
604 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
605 gtk_widget_set_usize( fsUp,65,15 ); | |
606 | |
607 AddHSeparator( vbox4 ); | |
608 | |
609 hbox6=AddHBox( NULL,0 ); | |
610 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
611 | |
612 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
613 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
614 gtk_widget_show( fsFNameListWindow ); | |
615 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
616 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
617 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
618 | |
619 fsFNameList=gtk_clist_new( 2 ); | |
620 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
621 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); | |
622 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
623 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
624 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
625 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
626 | |
627 AddHSeparator( vbox4 ); | |
628 | |
629 List=gtk_combo_new(); | |
630 gtk_widget_set_name( List,"List" ); | |
631 gtk_widget_ref( List ); | |
35975 | 632 gtk_object_set_data_full( GTK_OBJECT( FileSelector ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); |
33572 | 633 gtk_widget_show( List ); |
634 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
635 gtk_widget_set_usize( List,-2,20 ); | |
636 | |
637 fsFilterCombo=GTK_COMBO( List )->entry; | |
638 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
639 gtk_widget_show( fsFilterCombo ); | |
640 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
34871 | 641 gtk_widget_set_usize( fsFilterCombo,-2,20 ); |
33572 | 642 |
643 AddHSeparator( vbox4 ); | |
644 | |
645 hbuttonbox3=AddHButtonBox( vbox4 ); | |
646 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
647 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
648 | |
649 fsOk=AddButton( MSGTR_Ok,hbuttonbox3 ); | |
650 fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 ); | |
651 | |
35975 | 652 gtk_signal_connect( GTK_OBJECT( FileSelector ),"destroy",GTK_SIGNAL_FUNC( fs_Destroy ), NULL ); |
653 gtk_signal_connect( GTK_OBJECT( FileSelector ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
33572 | 654 |
655 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); | |
656 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
657 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
658 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
659 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
34344 | 660 gtk_signal_connect( GTK_OBJECT( fsUp ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); |
33572 | 661 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); |
34344 | 662 gtk_signal_connect( GTK_OBJECT( fsOk ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); |
33572 | 663 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); |
34344 | 664 gtk_signal_connect( GTK_OBJECT( fsCancel ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); |
33572 | 665 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); |
666 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"event", (GtkSignalFunc)fs_fsFNameList_event,NULL ); | |
667 | |
35975 | 668 return FileSelector; |
33572 | 669 } |
35958 | 670 |
35976 | 671 void ShowFileSelector( int type ) |
35958 | 672 { |
673 int i, k, fsMedium; | |
674 char * tmp = NULL, * dir = NULL; | |
675 const gchar *fname; | |
676 struct stat f; | |
677 | |
35975 | 678 if ( FileSelector ) gtkActive( FileSelector ); |
35996 | 679 else FileSelector=CreateFileSelect(); |
35958 | 680 |
681 fsType=type; | |
682 switch ( type ) | |
683 { | |
35974 | 684 case FILESELECT_VIDEO_AUDIO: |
35975 | 685 gtk_window_set_title( GTK_WINDOW( FileSelector ),MSGTR_FileSelect ); |
35958 | 686 fsList_items=NULL; |
35985 | 687 for( i=0;fsVideoAudioFilterNames[i][0];i++ ) |
688 fsList_items=g_list_append( fsList_items,fsVideoAudioFilterNames[i][0] ); | |
689 k = fsLastVideoAudioFilterSelected; | |
35958 | 690 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); |
691 g_list_free( fsList_items ); | |
35985 | 692 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoAudioFilterNames[k >= 0 ? k : i-2][0] ); |
35964
3ebf8c880e07
Don't set path information for fsVideoSelector on ShowFileSelect().
ib
parents:
35961
diff
changeset
|
693 //tmp=guiInfo.Filename; |
35958 | 694 break; |
35974 | 695 case FILESELECT_SUBTITLE: |
35975 | 696 gtk_window_set_title( GTK_WINDOW( FileSelector ),MSGTR_SubtitleSelect ); |
35958 | 697 fsList_items=NULL; |
698 for( i=0;fsSubtitleFilterNames[i][0];i++ ) | |
699 fsList_items=g_list_append( fsList_items,fsSubtitleFilterNames[i][0] ); | |
700 k = fsLastSubtitleFilterSelected; | |
701 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
702 g_list_free( fsList_items ); | |
703 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsSubtitleFilterNames[k >= 0 ? k : i-2][0] ); | |
704 tmp=guiInfo.SubtitleFilename; | |
705 break; | |
706 /* case fsOtherSelector: | |
35975 | 707 gtk_window_set_title( GTK_WINDOW( FileSelector ),MSGTR_OtherSelect ); |
35958 | 708 fsList_items=NULL; |
709 for( i=0;fsOtherFilterNames[i][0];i++ ) | |
710 fsList_items=g_list_append( fsList_items,fsOtherFilterNames[i][0] ); | |
711 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
712 g_list_free( fsList_items ); | |
713 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsOtherFilterNames[0][0] ); | |
714 tmp=guiInfo.Othername; | |
715 break;*/ | |
35974 | 716 case FILESELECT_AUDIO: |
35975 | 717 gtk_window_set_title( GTK_WINDOW( FileSelector ),MSGTR_AudioFileSelect ); |
35958 | 718 fsList_items=NULL; |
719 for( i=0;fsAudioFileNames[i][0];i++ ) | |
720 fsList_items=g_list_append( fsList_items,fsAudioFileNames[i][0] ); | |
721 k = fsLastAudioFilterSelected; | |
722 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
723 g_list_free( fsList_items ); | |
724 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsAudioFileNames[k >= 0 ? k : i-2][0] ); | |
725 tmp=guiInfo.AudioFilename; | |
726 break; | |
35974 | 727 case FILESELECT_FONT: |
35975 | 728 gtk_window_set_title( GTK_WINDOW( FileSelector ),MSGTR_FontSelect ); |
35958 | 729 fsList_items=NULL; |
730 for( i=0;fsFontFileNames[i][0];i++ ) | |
731 fsList_items=g_list_append( fsList_items,fsFontFileNames[i][0] ); | |
732 k = fsLastFontFilterSelected; | |
733 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
734 g_list_free( fsList_items ); | |
735 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsFontFileNames[k >= 0 ? k : i-2][0] ); | |
736 tmp=font_name; | |
737 break; | |
738 } | |
739 | |
35974 | 740 fsMedium=(fsType == FILESELECT_VIDEO_AUDIO || fsType == FILESELECT_SUBTITLE || fsType == FILESELECT_AUDIO); |
35958 | 741 |
742 if ( tmp && tmp[0] && !strstr( tmp,"://" ) ) | |
743 { | |
744 dir = strdup( tmp ); | |
745 | |
746 do | |
747 { | |
748 char * c = strrchr( dir,'/' ); | |
749 if ( ( stat( dir,&f ) == 0 ) && S_ISDIR( f.st_mode ) ) break; | |
750 if ( c ) *c=0; | |
751 } while ( strrchr( dir,'/' ) ); | |
752 | |
753 if ( !dir[0] ) nfree( dir ); | |
754 } | |
755 | |
35959 | 756 fsPathTable = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); |
757 | |
35958 | 758 { |
759 unsigned int i, c = 1; | |
760 | |
761 if ( fsMedium ) | |
762 { | |
763 for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ ) | |
764 if ( fsHistory[i] ) | |
765 { | |
766 fname = cfg_old_filename_from_utf8(fsHistory[i]); | |
767 fs_AddPathUtf8(fname, GTK_POS_BOTTOM); | |
768 if ( c ) c=gstrcmp( dir,fname ); | |
769 } | |
770 } | |
771 if ( c && dir ) fs_AddPathUtf8(dir, GTK_POS_TOP); | |
772 } | |
773 free( dir ); | |
774 fname = getenv( "HOME" ); | |
775 if ( fname ) fs_AddPathUtf8(fname, GTK_POS_BOTTOM); | |
35971 | 776 else fsTopList_items=fs_AddPath( fsTopList_items,g_strdup( "/home" ),GTK_POS_BOTTOM ); |
777 if (stat( "/media",&f ) == 0) fsTopList_items=fs_AddPath( fsTopList_items,g_strdup( "/media" ),GTK_POS_BOTTOM ); | |
778 if (stat( "/mnt",&f ) == 0) fsTopList_items=fs_AddPath( fsTopList_items,g_strdup( "/mnt" ),GTK_POS_BOTTOM ); | |
779 fsTopList_items=fs_AddPath( fsTopList_items,g_strdup( "/" ),GTK_POS_BOTTOM ); | |
35958 | 780 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); |
781 | |
782 gtk_widget_grab_focus( fsFNameList ); | |
783 if (fsLastFNameListSelected + 1 > ((GtkCList *)fsFNameList)->rows) fsLastFNameListSelected = 0; | |
784 ((GtkCList *)fsFNameList)->focus_row = fsLastFNameListSelected; | |
785 gtk_clist_select_row( GTK_CLIST( fsFNameList ),fsLastFNameListSelected,1 ); | |
786 fsLastFNameListSelected = 0; | |
787 | |
35975 | 788 gtk_widget_show( FileSelector ); |
35958 | 789 } |