annotate gui/ui/gtk/fileselect.c @ 34518:d476fbab0a28

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