Mercurial > audlegacy
annotate audacious/util.c @ 2270:50dea14e2fa3 trunk
[svn] Serbian language upadated
author | kustodian |
---|---|
date | Thu, 04 Jan 2007 14:55:34 -0800 |
parents | 329fb2453c87 |
children |
rev | line source |
---|---|
2253 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team | |
3 * | |
4 * Based on BMP: | |
0 | 5 * Copyright (C) 2003-2004 BMP development team. |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
2105
f18a5b617c34
[svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents:
2087
diff
changeset
|
12 * the Free Software Foundation; under version 2 of the License. |
0 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
1459 | 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
0 | 22 */ |
23 | |
245
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
24 #define WEIRD_UTF_16_PLAYLIST_ENCODING |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
25 |
0 | 26 #ifdef HAVE_CONFIG_H |
27 # include "config.h" | |
28 #endif | |
29 | |
30 #define NEED_GLADE | |
31 #include "util.h" | |
32 | |
33 #include <glib.h> | |
34 #include <glib/gi18n.h> | |
35 #include <glade/glade.h> | |
36 #include <gtk/gtk.h> | |
37 #include <stdio.h> | |
38 #include <stdlib.h> | |
39 #include <string.h> | |
40 #include <ctype.h> | |
41 | |
1640 | 42 #include "platform/smartinclude.h" |
0 | 43 #include <gdk/gdkkeysyms.h> |
44 #include <X11/Xlib.h> | |
287
2d919c756941
[svn] - attach -Iaudacious to libaudcore build crap.
nenolod
parents:
284
diff
changeset
|
45 //#include <sys/ipc.h> |
0 | 46 #include <unistd.h> |
47 #include <errno.h> | |
48 | |
49 #ifdef HAVE_FTS_H | |
50 # include <fts.h> | |
51 #endif | |
52 | |
53 #include "glade.h" | |
54 #include "input.h" | |
55 #include "main.h" | |
538
e4e897d20791
[svn] remove libaudcore, we never did anything with it
nenolod
parents:
383
diff
changeset
|
56 #include "playback.h" |
0 | 57 #include "playlist.h" |
1653 | 58 #include "ui_playlist.h" |
0 | 59 |
1105
4be4d74db123
[svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents:
1067
diff
changeset
|
60 #ifdef USE_CHARDET |
1106 | 61 #include "../libguess/libguess.h" |
1613
9becbe564217
[svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents:
1459
diff
changeset
|
62 #include "../librcd/librcd.h" |
1106 | 63 #ifdef HAVE_UDET |
1105
4be4d74db123
[svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents:
1067
diff
changeset
|
64 #include <libudet_c.h> |
4be4d74db123
[svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents:
1067
diff
changeset
|
65 #endif |
1106 | 66 #endif |
0 | 67 |
68 static GQuark quark_popup_data; | |
69 | |
70 | |
71 /* | |
72 * find <file> in directory <dirname> or subdirectories. return | |
73 * pointer to complete filename which has to be freed by calling | |
74 * "g_free()" after use. Returns NULL if file could not be found. | |
75 */ | |
76 | |
77 typedef struct { | |
78 const gchar *to_match; | |
79 gchar *match; | |
80 gboolean found; | |
81 } FindFileContext; | |
82 | |
83 static gboolean | |
84 find_file_func(const gchar * path, const gchar * basename, gpointer data) | |
85 { | |
86 FindFileContext *context = data; | |
87 | |
88 if (strlen(path) > FILENAME_MAX) { | |
89 g_warning("Ignoring path: name too long (%s)", path); | |
90 return TRUE; | |
91 } | |
92 | |
93 if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) { | |
94 if (!strcasecmp(basename, context->to_match)) { | |
95 context->match = g_strdup(path); | |
96 context->found = TRUE; | |
97 return TRUE; | |
98 } | |
99 } | |
100 else if (g_file_test(path, G_FILE_TEST_IS_DIR)) { | |
101 dir_foreach(path, find_file_func, context, NULL); | |
102 if (context->found) | |
103 return TRUE; | |
104 } | |
105 | |
106 return FALSE; | |
107 } | |
108 | |
109 gchar * | |
110 find_file_recursively(const gchar * path, const gchar * filename) | |
111 { | |
112 FindFileContext context; | |
113 | |
114 context.to_match = filename; | |
115 context.match = NULL; | |
116 context.found = FALSE; | |
117 | |
118 dir_foreach(path, find_file_func, &context, NULL); | |
119 return context.match; | |
120 } | |
121 | |
122 | |
123 typedef enum { | |
124 ARCHIVE_UNKNOWN = 0, | |
125 ARCHIVE_DIR, | |
126 ARCHIVE_TAR, | |
127 ARCHIVE_TGZ, | |
128 ARCHIVE_ZIP, | |
129 ARCHIVE_TBZ2 | |
130 } ArchiveType; | |
131 | |
132 typedef gchar *(*ArchiveExtractFunc) (const gchar *, const gchar *); | |
133 | |
134 typedef struct { | |
135 ArchiveType type; | |
136 const gchar *ext; | |
137 } ArchiveExtensionType; | |
138 | |
139 static ArchiveExtensionType archive_extensions[] = { | |
140 {ARCHIVE_TAR, ".tar"}, | |
141 {ARCHIVE_ZIP, ".wsz"}, | |
142 {ARCHIVE_ZIP, ".zip"}, | |
143 {ARCHIVE_TGZ, ".tar.gz"}, | |
144 {ARCHIVE_TGZ, ".tgz"}, | |
145 {ARCHIVE_TBZ2, ".tar.bz2"}, | |
146 {ARCHIVE_TBZ2, ".bz2"}, | |
147 {ARCHIVE_UNKNOWN, NULL} | |
148 }; | |
149 | |
150 static gchar *archive_extract_tar(const gchar * archive, const gchar * dest); | |
151 static gchar *archive_extract_zip(const gchar * archive, const gchar * dest); | |
152 static gchar *archive_extract_tgz(const gchar * archive, const gchar * dest); | |
153 static gchar *archive_extract_tbz2(const gchar * archive, const gchar * dest); | |
154 | |
155 static ArchiveExtractFunc archive_extract_funcs[] = { | |
156 NULL, | |
157 NULL, | |
158 archive_extract_tar, | |
159 archive_extract_tgz, | |
160 archive_extract_zip, | |
161 archive_extract_tbz2 | |
162 }; | |
163 | |
164 | |
165 /* FIXME: these functions can be generalised into a function using a | |
166 * command lookup table */ | |
167 | |
168 static const gchar * | |
169 get_tar_command(void) | |
170 { | |
171 static const gchar *command = NULL; | |
172 | |
173 if (!command) { | |
174 if (!(command = getenv("TARCMD"))) | |
175 command = "tar"; | |
176 } | |
177 | |
178 return command; | |
179 } | |
180 | |
181 static const gchar * | |
182 get_unzip_command(void) | |
183 { | |
184 static const gchar *command = NULL; | |
185 | |
186 if (!command) { | |
187 if (!(command = getenv("UNZIPCMD"))) | |
188 command = "unzip"; | |
189 } | |
190 | |
191 return command; | |
192 } | |
193 | |
194 | |
195 static gchar * | |
196 archive_extract_tar(const gchar * archive, const gchar * dest) | |
197 { | |
198 return g_strdup_printf("%s >/dev/null xf \"%s\" -C %s", | |
199 get_tar_command(), archive, dest); | |
200 } | |
201 | |
202 static gchar * | |
203 archive_extract_zip(const gchar * archive, const gchar * dest) | |
204 { | |
205 return g_strdup_printf("%s >/dev/null -o -j \"%s\" -d %s", | |
206 get_unzip_command(), archive, dest); | |
207 } | |
208 | |
209 static gchar * | |
210 archive_extract_tgz(const gchar * archive, const gchar * dest) | |
211 { | |
212 return g_strdup_printf("%s >/dev/null xzf \"%s\" -C %s", | |
213 get_tar_command(), archive, dest); | |
214 } | |
215 | |
216 static gchar * | |
217 archive_extract_tbz2(const gchar * archive, const gchar * dest) | |
218 { | |
219 return g_strdup_printf("bzip2 -dc \"%s\" | %s >/dev/null xf - -C %s", | |
220 archive, get_tar_command(), dest); | |
221 } | |
222 | |
223 | |
224 ArchiveType | |
225 archive_get_type(const gchar * filename) | |
226 { | |
227 gint i = 0; | |
228 | |
229 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) | |
230 return ARCHIVE_DIR; | |
231 | |
232 while (archive_extensions[i].ext) { | |
233 if (g_str_has_suffix(filename, archive_extensions[i].ext)) { | |
234 return archive_extensions[i].type; | |
235 } | |
236 i++; | |
237 } | |
238 | |
239 return ARCHIVE_UNKNOWN; | |
240 } | |
241 | |
242 gboolean | |
243 file_is_archive(const gchar * filename) | |
244 { | |
245 return (archive_get_type(filename) > ARCHIVE_DIR); | |
246 } | |
247 | |
248 gchar * | |
249 archive_basename(const gchar * str) | |
250 { | |
251 gint i = 0; | |
252 | |
253 while (archive_extensions[i].ext) { | |
254 if (str_has_suffix_nocase(str, archive_extensions[i].ext)) { | |
255 const gchar *end = g_strrstr(str, archive_extensions[i].ext); | |
256 if (end) { | |
257 return g_strndup(str, end - str); | |
258 } | |
259 break; | |
260 } | |
261 i++; | |
262 } | |
263 | |
264 return NULL; | |
265 } | |
266 | |
267 /* | |
268 decompress_archive | |
269 | |
270 Decompresses the archive "filename" to a temporary directory, | |
271 returns the path to the temp dir, or NULL if failed, | |
272 watch out tho, doesn't actually check if the system command succeeds :-| | |
273 */ | |
274 | |
275 gchar * | |
276 archive_decompress(const gchar * filename) | |
277 { | |
278 gchar *tmpdir, *cmd, *escaped_filename; | |
279 ArchiveType type; | |
1890 | 280 mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
0 | 281 |
282 if ((type = archive_get_type(filename)) <= ARCHIVE_DIR) | |
283 return NULL; | |
284 | |
1890 | 285 #ifdef HAVE_MKDTEMP |
286 tmpdir = g_build_filename(g_get_tmp_dir(), "audacious.XXXXXXXX", NULL); | |
0 | 287 if (!mkdtemp(tmpdir)) { |
288 g_free(tmpdir); | |
289 g_message("Unable to load skin: Failed to create temporary " | |
290 "directory: %s", g_strerror(errno)); | |
291 return NULL; | |
292 } | |
1890 | 293 #else |
1891 | 294 tmpdir = g_strdup_printf("%s/audacious.%ld", g_get_tmp_dir(), rand()); |
1890 | 295 make_directory(tmpdir, mode755); |
296 #endif | |
0 | 297 |
298 escaped_filename = escape_shell_chars(filename); | |
299 cmd = archive_extract_funcs[type] (escaped_filename, tmpdir); | |
300 g_free(escaped_filename); | |
301 | |
302 if (!cmd) { | |
303 g_message("extraction function is NULL!"); | |
304 g_free(tmpdir); | |
305 return NULL; | |
306 } | |
307 | |
308 system(cmd); | |
309 g_free(cmd); | |
310 | |
311 return tmpdir; | |
312 } | |
313 | |
314 | |
315 #ifdef HAVE_FTS_H | |
316 | |
317 void | |
318 del_directory(const gchar * dirname) | |
319 { | |
320 gchar *const argv[2] = { (gchar *) dirname, NULL }; | |
321 FTS *fts; | |
322 FTSENT *p; | |
323 | |
324 fts = fts_open(argv, FTS_PHYSICAL, (gint(*)())NULL); | |
325 while ((p = fts_read(fts))) { | |
326 switch (p->fts_info) { | |
327 case FTS_D: | |
328 break; | |
329 case FTS_DNR: | |
330 case FTS_ERR: | |
331 break; | |
332 case FTS_DP: | |
333 rmdir(p->fts_accpath); | |
334 break; | |
335 default: | |
336 unlink(p->fts_accpath); | |
337 break; | |
338 } | |
339 } | |
340 fts_close(fts); | |
341 } | |
342 | |
343 #else /* !HAVE_FTS */ | |
344 | |
345 gboolean | |
346 del_directory_func(const gchar * path, const gchar * basename, | |
347 gpointer params) | |
348 { | |
349 if (!strcmp(basename, ".") || !strcmp(path, "..")) | |
350 return FALSE; | |
351 | |
352 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { | |
353 dir_foreach(path, del_directory_func, NULL, NULL); | |
354 rmdir(path); | |
355 return FALSE; | |
356 } | |
357 | |
358 unlink(path); | |
359 | |
360 return FALSE; | |
361 } | |
362 | |
363 void | |
364 del_directory(const gchar * path) | |
365 { | |
366 dir_foreach(path, del_directory_func, NULL, NULL); | |
367 rmdir(path); | |
368 } | |
369 | |
370 #endif /* ifdef HAVE_FTS */ | |
371 | |
372 gchar * | |
373 read_ini_string(const gchar * filename, const gchar * section, | |
374 const gchar * key) | |
375 { | |
1166
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
376 static gchar *buffer = NULL; |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
377 static gchar *open_buffer = NULL; |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
378 gchar *ret_buffer = NULL; |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
538
diff
changeset
|
379 gint found_section = 0, len = 0; |
1193
03414b9d2507
[svn] filesize must be cached, otherwise lookup loop will crash.
yaz
parents:
1166
diff
changeset
|
380 static gsize filesize = 0; |
03414b9d2507
[svn] filesize must be cached, otherwise lookup loop will crash.
yaz
parents:
1166
diff
changeset
|
381 gsize off = 0; |
245
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
382 gchar *outbuf; |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
383 unsigned char x[] = { 0xff, 0xfe, 0x00 }; |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
538
diff
changeset
|
384 guint counter; |
0 | 385 |
386 if (!filename) | |
387 return NULL; | |
388 | |
1166
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
389 /* |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
390 * We optimise for the condition that we may be reading from the |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
391 * same ini-file multiple times. This is fairly common; it happens |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
392 * on .pls playlist loads. To do otherwise would take entirely too |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
393 * long, as fstat() can be very slow when done 21,000 times too many. |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
394 * |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
395 * Therefore, we optimise by keeping the last ini file in memory. |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
396 * Yes, this is a memory leak, but it is not too bad, hopefully. |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
397 * - nenolod |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
398 */ |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
399 if (open_buffer == NULL || strcasecmp(filename, open_buffer)) |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
400 { |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
401 if (buffer != NULL) |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
402 { |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
403 g_free(buffer); |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
404 buffer = NULL; |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
405 } |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
406 |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
407 if (open_buffer != NULL) |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
408 { |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
409 g_free(open_buffer); |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
410 open_buffer = NULL; |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
411 } |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
412 |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
413 if (!g_file_get_contents(filename, &buffer, &filesize, NULL)) |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
414 return NULL; |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
415 |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
416 open_buffer = g_strdup(filename); |
36e8431d8e19
[svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents:
1123
diff
changeset
|
417 } |
0 | 418 |
245
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
419 /* |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
420 * Convert UTF-16 into something useful. Original implementation |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
421 * by incomp@#audacious. Cleanups \nenolod |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
422 */ |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
423 if (!memcmp(&buffer[0],&x,2)) { |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
424 outbuf = g_malloc (filesize); /* it's safe to waste memory. */ |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
425 |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
426 for (counter = 2; counter < filesize; counter += 2) |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
427 if (!memcmp(&buffer[counter+1], &x[2], 1)) |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
428 outbuf[(counter-2)/2] = buffer[counter]; |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
429 else |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
430 return NULL; |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
431 |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
432 outbuf[(counter-2)/2] = '\0'; |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
433 |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
434 if ((filesize - 2) / 2 == (counter - 2) / 2) { |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
435 g_free(buffer); |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
436 buffer = outbuf; |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
437 } else { |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
438 g_free(outbuf); |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
439 return NULL; /* XXX wrong encoding */ |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
440 } |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
441 } |
1d8012046612
[svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents:
86
diff
changeset
|
442 |
0 | 443 while (!ret_buffer && off < filesize) { |
444 while (off < filesize && | |
445 (buffer[off] == '\r' || buffer[off] == '\n' || | |
446 buffer[off] == ' ' || buffer[off] == '\t')) | |
447 off++; | |
448 if (off >= filesize) | |
449 break; | |
450 if (buffer[off] == '[') { | |
451 gint slen = strlen(section); | |
452 off++; | |
453 found_section = 0; | |
454 if (off + slen + 1 < filesize && | |
455 !strncasecmp(section, &buffer[off], slen)) { | |
456 off += slen; | |
457 if (buffer[off] == ']') { | |
458 off++; | |
459 found_section = 1; | |
460 } | |
461 } | |
462 } | |
463 else if (found_section && off + strlen(key) < filesize && | |
464 !strncasecmp(key, &buffer[off], strlen(key))) { | |
465 off += strlen(key); | |
466 while (off < filesize && | |
467 (buffer[off] == ' ' || buffer[off] == '\t')) | |
468 off++; | |
469 if (off >= filesize) | |
470 break; | |
471 if (buffer[off] == '=') { | |
472 off++; | |
473 while (off < filesize && | |
474 (buffer[off] == ' ' || buffer[off] == '\t')) | |
475 off++; | |
476 if (off >= filesize) | |
477 break; | |
478 len = 0; | |
479 while (off + len < filesize && | |
480 buffer[off + len] != '\r' && | |
481 buffer[off + len] != '\n' && buffer[off + len] != ';') | |
482 len++; | |
483 ret_buffer = g_strndup(&buffer[off], len); | |
484 off += len; | |
485 } | |
486 } | |
487 while (off < filesize && buffer[off] != '\r' && buffer[off] != '\n') | |
488 off++; | |
489 } | |
490 | |
491 return ret_buffer; | |
492 } | |
493 | |
494 GArray * | |
495 string_to_garray(const gchar * str) | |
496 { | |
497 GArray *array; | |
498 gint temp; | |
499 const gchar *ptr = str; | |
500 gchar *endptr; | |
501 | |
502 array = g_array_new(FALSE, TRUE, sizeof(gint)); | |
503 for (;;) { | |
504 temp = strtol(ptr, &endptr, 10); | |
505 if (ptr == endptr) | |
506 break; | |
507 g_array_append_val(array, temp); | |
508 ptr = endptr; | |
1717
837983bac90f
[svn] Fixed a lot of warnings that only showed up on *BSD.
js
parents:
1653
diff
changeset
|
509 while (!isdigit((int) *ptr) && (*ptr) != '\0') |
0 | 510 ptr++; |
511 if (*ptr == '\0') | |
512 break; | |
513 } | |
514 return (array); | |
515 } | |
516 | |
517 GArray * | |
518 read_ini_array(const gchar * filename, const gchar * section, | |
519 const gchar * key) | |
520 { | |
521 gchar *temp; | |
522 GArray *a; | |
523 | |
524 if ((temp = read_ini_string(filename, section, key)) == NULL) { | |
525 g_free(temp); | |
526 return NULL; | |
527 } | |
528 a = string_to_garray(temp); | |
529 g_free(temp); | |
530 return a; | |
531 } | |
532 | |
533 void | |
534 glist_movedown(GList * list) | |
535 { | |
536 gpointer temp; | |
537 | |
538 if (g_list_next(list)) { | |
539 temp = list->data; | |
540 list->data = list->next->data; | |
541 list->next->data = temp; | |
542 } | |
543 } | |
544 | |
545 void | |
546 glist_moveup(GList * list) | |
547 { | |
548 gpointer temp; | |
549 | |
550 if (g_list_previous(list)) { | |
551 temp = list->data; | |
552 list->data = list->prev->data; | |
553 list->prev->data = temp; | |
554 } | |
555 } | |
556 | |
557 | |
558 void | |
559 util_menu_position(GtkMenu * menu, gint * x, gint * y, | |
560 gboolean * push_in, gpointer data) | |
561 { | |
562 GtkRequisition requisition; | |
563 gint screen_width; | |
564 gint screen_height; | |
565 MenuPos *pos = data; | |
566 | |
567 gtk_widget_size_request(GTK_WIDGET(menu), &requisition); | |
568 | |
569 screen_width = gdk_screen_width(); | |
570 screen_height = gdk_screen_height(); | |
571 | |
572 *x = CLAMP(pos->x - 2, 0, MAX(0, screen_width - requisition.width)); | |
573 *y = CLAMP(pos->y - 2, 0, MAX(0, screen_height - requisition.height)); | |
574 } | |
575 | |
576 #define URL_HISTORY_MAX_SIZE 30 | |
577 | |
578 static void | |
579 util_add_url_callback(GtkWidget * widget, | |
580 GtkEntry * entry) | |
581 { | |
582 const gchar *text; | |
583 | |
584 text = gtk_entry_get_text(entry); | |
585 if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp)) | |
586 return; | |
587 | |
588 cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text)); | |
589 | |
590 while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) { | |
591 GList *node = g_list_last(cfg.url_history); | |
592 g_free(node->data); | |
593 cfg.url_history = g_list_delete_link(cfg.url_history, node); | |
594 } | |
595 } | |
596 | |
597 GtkWidget * | |
86 | 598 util_add_url_dialog_new(const gchar * caption, GCallback ok_func, |
599 GCallback enqueue_func) | |
0 | 600 { |
2210
165a62fdb49e
[svn] - improve the presentation of the URL entry dialog
nenolod
parents:
2184
diff
changeset
|
601 GtkWidget *win, *vbox, *bbox, *enqueue, *ok, *cancel, *combo, *entry, |
165a62fdb49e
[svn] - improve the presentation of the URL entry dialog
nenolod
parents:
2184
diff
changeset
|
602 *label; |
0 | 603 GList *url; |
604 | |
605 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
2227
649e3418aac2
[svn] - mark several tooltips in Preferences as translatable.
nenolod
parents:
2210
diff
changeset
|
606 gtk_window_set_title(GTK_WINDOW(win), _("Add/Open URL Dialog")); |
0 | 607 gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG); |
608 gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER); | |
609 gtk_window_set_default_size(GTK_WINDOW(win), 400, -1); | |
610 gtk_container_set_border_width(GTK_CONTAINER(win), 12); | |
611 | |
612 vbox = gtk_vbox_new(FALSE, 10); | |
613 gtk_container_add(GTK_CONTAINER(win), vbox); | |
614 | |
2210
165a62fdb49e
[svn] - improve the presentation of the URL entry dialog
nenolod
parents:
2184
diff
changeset
|
615 label = gtk_label_new(caption); |
165a62fdb49e
[svn] - improve the presentation of the URL entry dialog
nenolod
parents:
2184
diff
changeset
|
616 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
165a62fdb49e
[svn] - improve the presentation of the URL entry dialog
nenolod
parents:
2184
diff
changeset
|
617 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
165a62fdb49e
[svn] - improve the presentation of the URL entry dialog
nenolod
parents:
2184
diff
changeset
|
618 |
0 | 619 combo = gtk_combo_box_entry_new_text(); |
620 gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0); | |
621 | |
622 entry = gtk_bin_get_child(GTK_BIN(combo)); | |
623 gtk_window_set_focus(GTK_WINDOW(win), entry); | |
624 gtk_entry_set_text(GTK_ENTRY(entry), ""); | |
625 | |
626 for (url = cfg.url_history; url; url = g_list_next(url)) | |
627 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), (const gchar *) url->data); | |
628 | |
629 g_signal_connect(entry, "activate", | |
630 G_CALLBACK(util_add_url_callback), | |
631 entry); | |
632 g_signal_connect(entry, "activate", | |
86 | 633 G_CALLBACK(ok_func), |
0 | 634 entry); |
635 g_signal_connect_swapped(entry, "activate", | |
636 G_CALLBACK(gtk_widget_destroy), | |
637 win); | |
638 | |
639 bbox = gtk_hbutton_box_new(); | |
640 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
641 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
642 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
643 | |
86 | 644 ok = gtk_button_new_from_stock(GTK_STOCK_OPEN); |
645 g_signal_connect(ok, "clicked", | |
646 G_CALLBACK(util_add_url_callback), entry); | |
647 g_signal_connect(ok, "clicked", | |
648 G_CALLBACK(ok_func), entry); | |
649 g_signal_connect_swapped(ok, "clicked", | |
650 G_CALLBACK(gtk_widget_destroy), | |
651 win); | |
652 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0); | |
653 | |
0 | 654 enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD); |
655 gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0); | |
656 | |
657 g_signal_connect(enqueue, "clicked", | |
658 G_CALLBACK(util_add_url_callback), | |
659 entry); | |
660 g_signal_connect(enqueue, "clicked", | |
661 G_CALLBACK(enqueue_func), | |
662 entry); | |
663 g_signal_connect_swapped(enqueue, "clicked", | |
664 G_CALLBACK(gtk_widget_destroy), | |
665 win); | |
666 | |
667 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
668 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
669 | |
670 g_signal_connect_swapped(cancel, "clicked", | |
671 G_CALLBACK(gtk_widget_destroy), | |
672 win); | |
673 | |
674 gtk_widget_show_all(vbox); | |
675 | |
676 return win; | |
677 } | |
678 | |
679 static void | |
680 filebrowser_add_files(GtkFileChooser * browser, | |
681 GSList * files) | |
682 { | |
683 GSList *cur; | |
684 gchar *ptr; | |
685 guint ctr = 0; | |
2087 | 686 Playlist *playlist = playlist_get_active(); |
0 | 687 |
688 if (GTK_IS_WIDGET(mainwin_jtf)) | |
689 gtk_widget_set_sensitive(mainwin_jtf, FALSE); | |
690 | |
691 for (cur = files; cur; cur = g_slist_next(cur)) { | |
692 | |
693 if (g_file_test(cur->data,G_FILE_TEST_IS_DIR)) { | |
2087 | 694 playlist_add_dir(playlist, (const gchar *) cur->data); |
0 | 695 } else { |
2087 | 696 playlist_add(playlist, (const gchar *) cur->data); |
0 | 697 } |
698 | |
699 if (++ctr == 20) { | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2105
diff
changeset
|
700 playlistwin_update_list(playlist); |
0 | 701 ctr = 0; |
702 while (gtk_events_pending() ) gtk_main_iteration(); | |
703 } | |
704 } | |
705 | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2105
diff
changeset
|
706 playlistwin_update_list(playlist); |
0 | 707 |
708 if (GTK_IS_WIDGET(mainwin_jtf)) | |
709 gtk_widget_set_sensitive(mainwin_jtf, TRUE); | |
710 | |
711 ptr = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(browser)); | |
712 | |
713 g_free(cfg.filesel_path); | |
714 cfg.filesel_path = ptr; | |
715 } | |
716 | |
717 static void | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
718 filebrowser_add(GtkFileChooser *browser) |
0 | 719 { |
720 GSList *files; | |
721 | |
722 files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(browser)); | |
723 | |
724 if (!files) { | |
725 return; | |
726 } | |
727 | |
728 filebrowser_add_files(browser, files); | |
729 g_slist_foreach(files, (GFunc) g_free, NULL); | |
730 g_slist_free(files); | |
731 } | |
732 | |
733 static void | |
734 filebrowser_play(GtkFileChooser * browser) | |
735 { | |
736 GSList *files; | |
737 | |
738 files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(browser)); | |
739 | |
740 if (!files) return; | |
741 | |
2087 | 742 playlist_clear(playlist_get_active()); |
0 | 743 |
744 filebrowser_add_files(browser, files); | |
745 g_slist_foreach(files, (GFunc) g_free, NULL); | |
746 g_slist_free(files); | |
747 | |
2228
894f7aa46f83
[svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents:
2227
diff
changeset
|
748 playback_initiate(); |
0 | 749 } |
750 | |
751 | |
752 static void | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
753 _filebrowser_add_gtk2(GtkWidget *widget, |
0 | 754 gpointer data) |
755 { | |
756 filebrowser_add(data); | |
757 gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(data)); | |
758 } | |
759 | |
760 static void | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
761 _filebrowser_play_gtk2(GtkWidget *widget, gpointer data) |
0 | 762 { |
763 filebrowser_play(data); | |
764 gtk_file_chooser_unselect_all(data); | |
765 } | |
766 | |
767 #if 0 | |
768 static void | |
769 filebrowser_on_response(GtkFileChooser * browser, | |
770 gint response, | |
771 gpointer data) | |
772 { | |
773 gtk_widget_hide(GTK_WIDGET(browser)); | |
774 switch (response) { | |
775 case GTK_RESPONSE_OK: | |
776 break; | |
777 case GTK_RESPONSE_ACCEPT: | |
778 break; | |
779 case GTK_RESPONSE_CLOSE: | |
780 break; | |
781 } | |
782 gtk_widget_destroy(GTK_WIDGET(browser)); | |
783 | |
784 } | |
785 | |
786 #endif | |
787 | |
788 static void | |
789 _filebrowser_check_hide_add(GtkWidget * widget, | |
790 gpointer data) | |
791 { | |
792 cfg.close_dialog_add = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
793 } | |
794 | |
795 static void | |
796 _filebrowser_check_hide_open(GtkWidget * widget, | |
797 gpointer data) | |
798 { | |
799 cfg.close_dialog_open = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
800 } | |
801 | |
802 | |
803 | |
804 static gboolean | |
805 filebrowser_on_keypress(GtkWidget * browser, | |
806 GdkEventKey * event, | |
807 gpointer data) | |
808 { | |
809 if (event->keyval == GDK_Escape) { | |
810 /* FIXME: this crashes BMP for some reason */ | |
811 /* g_signal_emit_by_name(browser, "delete-event"); */ | |
812 gtk_widget_hide(browser); | |
813 return TRUE; | |
814 } | |
815 | |
816 return FALSE; | |
817 } | |
818 | |
819 static void | |
820 _filebrowser_do_hide_add(GtkWidget *widget, | |
821 gpointer data) | |
822 { | |
823 if (cfg.close_dialog_add) | |
824 gtk_widget_hide(data); | |
825 } | |
826 | |
827 static void | |
828 _filebrowser_do_hide_open(GtkWidget *widget, | |
829 gpointer data) | |
830 { | |
831 if (cfg.close_dialog_open) | |
832 gtk_widget_hide(data); | |
833 } | |
834 | |
835 void | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
836 util_run_filebrowser_gtk2style(gboolean play_button) |
0 | 837 { |
838 static GladeXML *xml = NULL; | |
839 static GtkWidget *dialog = NULL; | |
840 static GtkWidget *chooser = NULL; | |
841 | |
842 static GtkWidget *button_add; | |
843 static GtkWidget *button_select_all, *button_deselect_all; | |
844 static GtkWidget *toggle; | |
845 | |
846 static gulong handlerid, handlerid_check, handlerid_do; | |
847 static gulong handlerid_activate, handlerid_do_activate; | |
848 | |
849 if (!xml) { | |
850 /* FIXME: Creating a file chooser dialog manually using | |
851 libglade because there's no way to stop | |
852 GtkFileChooserDialog from resizing the buttons to the same | |
853 size. The long toggle button title causes the buttons to | |
854 turn unnecessarily elongated and fugly. */ | |
855 | |
856 GtkWidget *alignment; | |
857 | |
858 xml = glade_xml_new_or_die(_("Add/Open Files dialog"), | |
859 DATA_DIR "/glade/addfiles.glade", | |
860 NULL, NULL); | |
861 glade_xml_signal_autoconnect(xml); | |
862 | |
863 dialog = glade_xml_get_widget(xml, "add_files_dialog"); | |
864 | |
865 /* FIXME: Creating file chooser widget here because libglade <= 2.4.0 does | |
866 not support GtkFileChooserWidget */ | |
867 | |
868 chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN); | |
869 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), TRUE); | |
870 | |
871 if (cfg.filesel_path) | |
872 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), | |
873 cfg.filesel_path); | |
874 | |
875 alignment = glade_xml_get_widget(xml, "alignment2"); | |
876 gtk_container_add(GTK_CONTAINER(alignment), chooser); | |
877 | |
878 toggle = glade_xml_get_widget(xml, "close_on_action"); | |
879 button_select_all = glade_xml_get_widget(xml, "select_all"); | |
880 button_deselect_all = glade_xml_get_widget(xml, "deselect_all"); | |
881 button_add = glade_xml_get_widget(xml, "action"); | |
882 | |
883 g_signal_connect_swapped(button_select_all, "clicked", | |
884 G_CALLBACK(gtk_file_chooser_select_all), | |
885 chooser); | |
886 g_signal_connect_swapped(button_deselect_all, "clicked", | |
887 G_CALLBACK(gtk_file_chooser_unselect_all), | |
888 chooser); | |
889 | |
890 g_signal_connect(dialog, "key_press_event", | |
891 G_CALLBACK(filebrowser_on_keypress), | |
892 NULL); | |
893 | |
894 gtk_widget_show_all(dialog); | |
895 } /* !xml */ | |
896 else { | |
897 g_signal_handler_disconnect(button_add, handlerid); | |
898 g_signal_handler_disconnect(toggle, handlerid_check); | |
899 g_signal_handler_disconnect(chooser, handlerid_activate); | |
900 g_signal_handler_disconnect(button_add, handlerid_do); | |
901 g_signal_handler_disconnect(chooser, handlerid_do_activate); | |
1752
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
902 |
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
903 if (cfg.refresh_file_list) |
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
904 { |
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
905 gchar *tmp = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(chooser)); |
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
906 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), tmp); |
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
907 |
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
908 g_free(tmp); |
be1c5774f675
[svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents:
1717
diff
changeset
|
909 } |
0 | 910 } |
911 | |
912 if (play_button) { | |
913 gtk_window_set_title(GTK_WINDOW(dialog), _("Open Files")); | |
914 | |
915 gtk_button_set_label(GTK_BUTTON(button_add), GTK_STOCK_OPEN); | |
916 | |
917 gtk_button_set_label(GTK_BUTTON(toggle), _("Close dialog on Open")); | |
918 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), cfg.close_dialog_open); | |
919 | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
920 handlerid = g_signal_connect(button_add, "clicked", G_CALLBACK(_filebrowser_play_gtk2), chooser); |
0 | 921 handlerid_check = g_signal_connect(toggle, "toggled", G_CALLBACK(_filebrowser_check_hide_open), NULL); |
922 handlerid_do = g_signal_connect_after(button_add, "clicked", G_CALLBACK(_filebrowser_do_hide_open), dialog); | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
923 handlerid_activate = g_signal_connect(chooser, "file-activated", G_CALLBACK(_filebrowser_play_gtk2), chooser); |
0 | 924 handlerid_do_activate = g_signal_connect_after(chooser,"file_activated", G_CALLBACK(_filebrowser_do_hide_open), dialog); |
925 } | |
926 else { | |
927 gtk_window_set_title(GTK_WINDOW(dialog), _("Add Files")); | |
928 | |
929 gtk_button_set_label(GTK_BUTTON(button_add), GTK_STOCK_ADD); | |
930 | |
931 gtk_button_set_label(GTK_BUTTON(toggle), _("Close dialog on Add")); | |
932 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), cfg.close_dialog_add); | |
933 | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
934 handlerid = g_signal_connect(button_add, "clicked", G_CALLBACK(_filebrowser_add_gtk2), chooser); |
0 | 935 handlerid_check = g_signal_connect(toggle, "toggled", G_CALLBACK(_filebrowser_check_hide_add), NULL); |
936 handlerid_do = g_signal_connect_after(button_add, "clicked", G_CALLBACK(_filebrowser_do_hide_add), dialog); | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
937 handlerid_activate = g_signal_connect(chooser, "file-activated", G_CALLBACK(_filebrowser_add_gtk2), chooser); |
0 | 938 handlerid_do_activate = g_signal_connect_after(chooser,"file_activated", G_CALLBACK(_filebrowser_do_hide_add), dialog); |
939 } | |
940 | |
941 gtk_window_present(GTK_WINDOW(dialog)); | |
942 } | |
943 | |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
944 /* |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
945 * Derived from Beep Media Player 0.9.6.1. |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
946 * Which is (C) 2003 - 2006 Milosz Derezynski &c |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
947 * |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
948 * Although I changed it quite a bit. -nenolod |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
949 */ |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
950 static void filebrowser_changed_classic(GtkFileSelection * filesel) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
951 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
952 GList *list; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
953 GList *node; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
954 char *filename = (char *) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
955 gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
956 GtkListStore *store; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
957 GtkTreeIter iter; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
958 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
959 if ((list = input_scan_dir(filename)) != NULL) { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
960 /* |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
961 * We enter a directory that has been "hijacked" by an |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
962 * input-plugin. This is used by the CDDA plugin |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
963 */ |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
964 store = |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
965 GTK_LIST_STORE(gtk_tree_view_get_model |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
966 (GTK_TREE_VIEW(filesel->file_list))); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
967 gtk_list_store_clear(store); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
968 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
969 node = list; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
970 while (node) { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
971 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
972 gtk_list_store_append(store, &iter); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
973 gtk_list_store_set(store, &iter, 0, node->data, -1); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
974 g_free(node->data); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
975 node = g_list_next(node); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
976 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
977 g_list_free(list); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
978 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
979 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
980 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
981 static void filebrowser_entry_changed_classic(GtkEditable * entry, gpointer data) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
982 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
983 filebrowser_changed_classic(GTK_FILE_SELECTION(data)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
984 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
985 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
986 gboolean util_filebrowser_is_dir_classic(GtkFileSelection * filesel) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
987 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
988 char *text; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
989 struct stat buf; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
990 gboolean retv = FALSE; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
991 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
992 text = g_strdup(gtk_file_selection_get_filename(filesel)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
993 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
994 if (stat(text, &buf) == 0 && S_ISDIR(buf.st_mode)) { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
995 /* Selected directory */ |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
996 int len = strlen(text); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
997 if (len > 3 && !strcmp(text + len - 4, "/../")) { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
998 if (len == 4) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
999 /* At the root already */ |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1000 *(text + len - 3) = '\0'; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1001 else { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1002 char *ptr; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1003 *(text + len - 4) = '\0'; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1004 ptr = strrchr(text, '/'); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1005 *(ptr + 1) = '\0'; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1006 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1007 } else if (len > 2 && !strcmp(text + len - 3, "/./")) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1008 *(text + len - 2) = '\0'; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1009 gtk_file_selection_set_filename(filesel, text); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1010 retv = TRUE; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1011 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1012 g_free(text); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1013 return retv; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1014 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1015 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1016 static void filebrowser_add_files_classic(gchar ** files, |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1017 GtkFileSelection * filesel) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1018 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1019 int ctr = 0; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1020 char *ptr; |
2087 | 1021 Playlist *playlist = playlist_get_active(); |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1022 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1023 if (GTK_IS_WIDGET(mainwin_jtf)) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1024 gtk_widget_set_sensitive(mainwin_jtf, FALSE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1025 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1026 while (files[ctr] != NULL) { |
2087 | 1027 playlist_add(playlist, files[ctr++]); |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1028 } |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2105
diff
changeset
|
1029 playlistwin_update_list(playlist); |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1030 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1031 if (GTK_IS_WIDGET(mainwin_jtf)) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1032 gtk_widget_set_sensitive(mainwin_jtf, TRUE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1033 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1034 gtk_label_get(GTK_LABEL(GTK_BIN(filesel->history_pulldown)->child), |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1035 &ptr); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1036 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1037 /* This will give an extra slash if the current dir is the root. */ |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1038 cfg.filesel_path = g_strconcat(ptr, "/", NULL); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1039 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1040 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1041 static void filebrowser_ok_classic(GtkWidget * w, GtkWidget * filesel) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1042 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1043 gchar **files; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1044 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1045 if (util_filebrowser_is_dir_classic(GTK_FILE_SELECTION(filesel))) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1046 return; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1047 files = gtk_file_selection_get_selections(GTK_FILE_SELECTION(filesel)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1048 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1049 gtk_widget_destroy(filesel); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1050 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1051 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1052 static void filebrowser_play_classic(GtkWidget * w, GtkWidget * filesel) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1053 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1054 gchar **files; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1055 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1056 if (util_filebrowser_is_dir_classic |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1057 (GTK_FILE_SELECTION(GTK_FILE_SELECTION(filesel)))) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1058 return; |
2087 | 1059 playlist_clear(playlist_get_active()); |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1060 files = gtk_file_selection_get_selections(GTK_FILE_SELECTION(filesel)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1061 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1062 gtk_widget_destroy(filesel); |
2228
894f7aa46f83
[svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents:
2227
diff
changeset
|
1063 playback_initiate(); |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1064 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1065 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1066 static void filebrowser_add_selected_files_classic(GtkWidget * w, gpointer data) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1067 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1068 gchar **files; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1069 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1070 GtkFileSelection *filesel = GTK_FILE_SELECTION(data); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1071 files = gtk_file_selection_get_selections(filesel); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1072 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1073 filebrowser_add_files_classic(files, filesel); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1074 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1075 (GTK_TREE_VIEW(filesel->file_list))); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1076 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1077 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), ""); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1078 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1079 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1080 static void filebrowser_add_all_files_classic(GtkWidget * w, gpointer data) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1081 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1082 gchar **files; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1083 GtkFileSelection *filesel; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1084 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1085 filesel = data; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1086 gtk_tree_selection_select_all(gtk_tree_view_get_selection |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1087 (GTK_TREE_VIEW(filesel->file_list))); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1088 files = gtk_file_selection_get_selections(filesel); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1089 filebrowser_add_files_classic(files, filesel); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1090 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1091 (GTK_TREE_VIEW(filesel->file_list))); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1092 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), ""); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1093 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1094 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1095 void |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1096 util_run_filebrowser_classic(gboolean play_button) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1097 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1098 static GtkWidget *dialog; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1099 GtkWidget *button_add_selected, *button_add_all, *button_close, |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1100 *button_add; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1101 char *title; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1102 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1103 if (dialog != NULL) { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1104 gtk_window_present(GTK_WINDOW(dialog)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1105 return; |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1106 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1107 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1108 if (play_button) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1109 title = _("Play files"); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1110 else |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1111 title = _("Load files"); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1112 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1113 dialog = gtk_file_selection_new(title); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1114 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1115 gtk_file_selection_set_select_multiple |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1116 (GTK_FILE_SELECTION(dialog), TRUE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1117 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1118 if (cfg.filesel_path) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1119 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog), |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1120 cfg.filesel_path); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1121 |
1907
d7301ba54f70
[svn] - remove useless fileop buttons from the GTK1-like dialog.
nenolod
parents:
1905
diff
changeset
|
1122 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dialog)); |
d7301ba54f70
[svn] - remove useless fileop buttons from the GTK1-like dialog.
nenolod
parents:
1905
diff
changeset
|
1123 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); |
d7301ba54f70
[svn] - remove useless fileop buttons from the GTK1-like dialog.
nenolod
parents:
1905
diff
changeset
|
1124 |
1905
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1125 gtk_widget_hide(GTK_FILE_SELECTION(dialog)->ok_button); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1126 gtk_widget_destroy(GTK_FILE_SELECTION(dialog)->cancel_button); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1127 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1128 /* |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1129 * The mnemonics are quite unorthodox, but that should guarantee they're unique in any locale |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1130 * plus kinda easy to use |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1131 */ |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1132 button_add_selected = |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1133 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add selected", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1134 GTK_RESPONSE_NONE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1135 gtk_button_set_use_underline(GTK_BUTTON(button_add_selected), TRUE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1136 g_signal_connect(G_OBJECT(button_add_selected), "clicked", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1137 G_CALLBACK(filebrowser_add_selected_files_classic), dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1138 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1139 button_add_all = |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1140 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add all", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1141 GTK_RESPONSE_NONE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1142 gtk_button_set_use_underline(GTK_BUTTON(button_add_all), TRUE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1143 g_signal_connect(G_OBJECT(button_add_all), "clicked", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1144 G_CALLBACK(filebrowser_add_all_files_classic), dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1145 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1146 if (play_button) { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1147 button_add = |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1148 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_MEDIA_PLAY, |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1149 GTK_RESPONSE_NONE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1150 gtk_button_set_use_stock(GTK_BUTTON(button_add), TRUE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1151 g_signal_connect(G_OBJECT(button_add), "clicked", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1152 G_CALLBACK(filebrowser_play_classic), dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1153 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button), |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1154 "clicked", G_CALLBACK(filebrowser_play_classic), dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1155 } else { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1156 button_add = |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1157 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_ADD, |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1158 GTK_RESPONSE_NONE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1159 gtk_button_set_use_stock(GTK_BUTTON(button_add), TRUE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1160 g_signal_connect(G_OBJECT(button_add), "clicked", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1161 G_CALLBACK(filebrowser_ok_classic), dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1162 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button), |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1163 "clicked", G_CALLBACK(filebrowser_ok_classic), dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1164 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1165 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1166 button_close = |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1167 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1168 GTK_RESPONSE_NONE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1169 gtk_button_set_use_stock(GTK_BUTTON(button_close), TRUE); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1170 g_signal_connect_swapped(G_OBJECT(button_close), "clicked", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1171 G_CALLBACK(gtk_widget_destroy), |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1172 G_OBJECT(dialog)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1173 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1174 gtk_widget_set_size_request(dialog, 600, 450); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1175 gtk_widget_realize(dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1176 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1177 g_signal_connect(G_OBJECT |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1178 (GTK_FILE_SELECTION(dialog)->history_pulldown), |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1179 "changed", G_CALLBACK(filebrowser_entry_changed_classic), |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1180 dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1181 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1182 g_signal_connect(G_OBJECT(dialog), "destroy", |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1183 G_CALLBACK(gtk_widget_destroyed), &dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1184 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1185 filebrowser_changed_classic(GTK_FILE_SELECTION(dialog)); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1186 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1187 gtk_widget_show(dialog); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1188 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1189 |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1190 /* |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1191 * util_run_filebrowser(gboolean play_button) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1192 * |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1193 * Inputs: |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1194 * - whether or not a play button should be used |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1195 * |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1196 * Outputs: |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1197 * - none |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1198 * |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1199 * Side Effects: |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1200 * - either a GTK1 or a GTK2 fileselector is launched |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1201 */ |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1202 void |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1203 util_run_filebrowser(gboolean play_button) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1204 { |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1205 if (!cfg.use_xmms_style_fileselector) |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1206 util_run_filebrowser_gtk2style(play_button); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1207 else |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1208 util_run_filebrowser_classic(play_button); |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1209 } |
6b4116c34489
[svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents:
1891
diff
changeset
|
1210 |
0 | 1211 GdkFont * |
1212 util_font_load(const gchar * name) | |
1213 { | |
1214 GdkFont *font; | |
1215 PangoFontDescription *desc; | |
1216 | |
1217 desc = pango_font_description_from_string(name); | |
1218 font = gdk_font_from_description(desc); | |
1219 | |
1220 return font; | |
1221 } | |
1222 | |
1223 #ifdef ENABLE_NLS | |
1224 gchar * | |
1225 bmp_menu_translate(const gchar * path, gpointer func_data) | |
1226 { | |
1227 gchar *translation = gettext(path); | |
1228 | |
1229 if (!translation || *translation != '/') { | |
1230 g_warning("Bad translation for menupath: %s", path); | |
1231 translation = (gchar *) path; | |
1232 } | |
1233 | |
1234 return translation; | |
1235 } | |
1236 #endif | |
1237 | |
1238 void | |
1239 util_set_cursor(GtkWidget * window) | |
1240 { | |
1241 static GdkCursor *cursor = NULL; | |
1242 | |
1243 if (!window) { | |
1244 if (cursor) { | |
813
c8cf439179b8
[svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents:
625
diff
changeset
|
1245 gdk_cursor_unref(cursor); |
0 | 1246 cursor = NULL; |
1247 } | |
813
c8cf439179b8
[svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents:
625
diff
changeset
|
1248 |
0 | 1249 return; |
1250 } | |
1251 | |
1252 if (!cursor) | |
1253 cursor = gdk_cursor_new(GDK_LEFT_PTR); | |
1254 | |
1255 gdk_window_set_cursor(window->window, cursor); | |
1256 } | |
1257 | |
1653 | 1258 /* text_get_extents() taken from The GIMP (C) Spencer Kimball, Peter |
1259 * Mattis et al */ | |
1260 gboolean | |
1261 text_get_extents(const gchar * fontname, | |
1262 const gchar * text, | |
1263 gint * width, gint * height, gint * ascent, gint * descent) | |
1264 { | |
1265 PangoFontDescription *font_desc; | |
1266 PangoLayout *layout; | |
1267 PangoRectangle rect; | |
1268 | |
1269 g_return_val_if_fail(fontname != NULL, FALSE); | |
1270 g_return_val_if_fail(text != NULL, FALSE); | |
1271 | |
1272 /* FIXME: resolution */ | |
1273 layout = gtk_widget_create_pango_layout(GTK_WIDGET(mainwin), text); | |
1274 | |
1275 font_desc = pango_font_description_from_string(fontname); | |
1276 pango_layout_set_font_description(layout, font_desc); | |
1277 pango_font_description_free(font_desc); | |
1278 pango_layout_get_pixel_extents(layout, NULL, &rect); | |
1279 | |
1280 if (width) | |
1281 *width = rect.width; | |
1282 if (height) | |
1283 *height = rect.height; | |
1284 | |
1285 if (ascent || descent) { | |
1286 PangoLayoutIter *iter; | |
1287 PangoLayoutLine *line; | |
1288 | |
1289 iter = pango_layout_get_iter(layout); | |
1290 line = pango_layout_iter_get_line(iter); | |
1291 pango_layout_iter_free(iter); | |
1292 | |
1293 pango_layout_line_get_pixel_extents(line, NULL, &rect); | |
1294 | |
1295 if (ascent) | |
1296 *ascent = PANGO_ASCENT(rect); | |
1297 if (descent) | |
1298 *descent = -PANGO_DESCENT(rect); | |
1299 } | |
1300 | |
1301 g_object_unref(layout); | |
1302 | |
1303 return TRUE; | |
1304 } | |
1305 | |
0 | 1306 /* counts number of digits in a gint */ |
1307 guint | |
1308 gint_count_digits(gint n) | |
1309 { | |
1310 guint count = 0; | |
1311 | |
1312 n = ABS(n); | |
1313 do { | |
1314 count++; | |
1315 n /= 10; | |
1316 } while (n > 0); | |
1317 | |
1318 return count; | |
1319 } | |
1320 | |
1321 gboolean | |
1322 dir_foreach(const gchar * path, DirForeachFunc function, | |
1323 gpointer user_data, GError ** error) | |
1324 { | |
1325 GError *error_out = NULL; | |
1326 GDir *dir; | |
1327 const gchar *entry; | |
1328 gchar *entry_fullpath; | |
1329 | |
1330 if (!(dir = g_dir_open(path, 0, &error_out))) { | |
1331 g_propagate_error(error, error_out); | |
1332 return FALSE; | |
1333 } | |
1334 | |
1335 while ((entry = g_dir_read_name(dir))) { | |
1336 entry_fullpath = g_build_filename(path, entry, NULL); | |
1337 | |
1338 if ((*function) (entry_fullpath, entry, user_data)) { | |
1339 g_free(entry_fullpath); | |
1340 break; | |
1341 } | |
1342 | |
1343 g_free(entry_fullpath); | |
1344 } | |
1345 | |
1346 g_dir_close(dir); | |
1347 | |
1348 return TRUE; | |
1349 } | |
1350 | |
1653 | 1351 GtkWidget * |
1352 make_filebrowser(const gchar * title, | |
1353 gboolean save) | |
1354 { | |
1355 GtkWidget *dialog; | |
1356 GtkWidget *button; | |
1357 GtkWidget *button_close; | |
1358 | |
1359 g_return_val_if_fail(title != NULL, NULL); | |
1360 | |
1361 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), | |
1362 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); | |
1363 if (save) | |
1364 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog), | |
1365 GTK_FILE_CHOOSER_ACTION_SAVE); | |
1366 | |
1367 if (!save) | |
1368 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); | |
1369 | |
1370 g_signal_connect(dialog, "destroy", | |
1371 G_CALLBACK(gtk_widget_destroyed), &dialog); | |
1372 | |
1373 button_close = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, | |
1374 GTK_RESPONSE_REJECT); | |
1375 gtk_button_set_use_stock(GTK_BUTTON(button_close), TRUE); | |
1376 GTK_WIDGET_SET_FLAGS(button_close, GTK_CAN_DEFAULT); | |
1377 g_signal_connect_swapped(button_close, "clicked", | |
1378 G_CALLBACK(gtk_widget_destroy), dialog); | |
1379 | |
1380 button = gtk_dialog_add_button(GTK_DIALOG(dialog), save ? | |
1381 GTK_STOCK_SAVE : GTK_STOCK_OPEN, | |
1382 GTK_RESPONSE_ACCEPT); | |
1383 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
1384 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
1385 gtk_window_set_default(GTK_WINDOW(dialog), button); | |
1386 | |
1387 gtk_widget_show(dialog); | |
1388 | |
1389 return dialog; | |
1390 } | |
1391 | |
1851
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1392 /* |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1393 * Resizes a GDK pixmap. |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1394 */ |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1395 GdkPixmap *audacious_pixmap_resize(GdkWindow *src, GdkGC *src_gc, GdkPixmap *in, gint width, gint height) |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1396 { |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1397 GdkPixmap *out; |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1398 gint owidth, oheight; |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1399 |
1887 | 1400 g_return_val_if_fail(src != NULL, NULL); |
1401 g_return_val_if_fail(src_gc != NULL, NULL); | |
1402 g_return_val_if_fail(in != NULL, NULL); | |
1403 g_return_val_if_fail(width > 0 && height > 0, NULL); | |
1851
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1404 |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1405 gdk_drawable_get_size(in, &owidth, &oheight); |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1406 |
1852 | 1407 if (oheight == height && owidth == width) |
1887 | 1408 return NULL; |
1852 | 1409 |
1851
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1410 out = gdk_pixmap_new(src, width, height, -1); |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1411 |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1412 gdk_draw_rectangle(out, src_gc, TRUE, 0, 0, width, height); |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1413 |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1414 gdk_window_copy_area(out, src_gc, 0, 0, in, 0, 0, owidth, oheight); |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1415 g_object_unref(src); |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1416 |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1417 return out; |
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1752
diff
changeset
|
1418 } |
1938 | 1419 |
1420 GdkImage *create_dblsize_image(GdkImage * img) | |
1421 { | |
1422 GdkImage *dblimg; | |
1423 register guint x, y; | |
1424 | |
1425 /* | |
1426 * This needs to be optimized | |
1427 */ | |
1428 | |
1429 dblimg = | |
1972
edc01e85648d
[svn] - in particular X environment, double size caused a bad match X error.
yaz
parents:
1938
diff
changeset
|
1430 gdk_image_new(GDK_IMAGE_NORMAL, gdk_visual_get_system(), |
1938 | 1431 img->width << 1, img->height << 1); |
1432 if (dblimg->bpp == 1) { | |
1433 register guint8 *srcptr, *ptr, *ptr2, pix; | |
1434 | |
1435 srcptr = GDK_IMAGE_XIMAGE(img)->data; | |
1436 ptr = GDK_IMAGE_XIMAGE(dblimg)->data; | |
1437 ptr2 = ptr + dblimg->bpl; | |
1438 | |
1439 for (y = 0; y < img->height; y++) { | |
1440 for (x = 0; x < img->width; x++) { | |
1441 pix = *srcptr++; | |
1442 *ptr++ = pix; | |
1443 *ptr++ = pix; | |
1444 *ptr2++ = pix; | |
1445 *ptr2++ = pix; | |
1446 } | |
1447 srcptr += img->bpl - img->width; | |
1448 ptr += (dblimg->bpl << 1) - dblimg->width; | |
1449 ptr2 += (dblimg->bpl << 1) - dblimg->width; | |
1450 } | |
1451 } | |
1452 if (dblimg->bpp == 2) { | |
1453 guint16 *srcptr, *ptr, *ptr2, pix; | |
1454 | |
1455 srcptr = (guint16 *) GDK_IMAGE_XIMAGE(img)->data; | |
1456 ptr = (guint16 *) GDK_IMAGE_XIMAGE(dblimg)->data; | |
1457 ptr2 = ptr + (dblimg->bpl >> 1); | |
1458 | |
1459 for (y = 0; y < img->height; y++) { | |
1460 for (x = 0; x < img->width; x++) { | |
1461 pix = *srcptr++; | |
1462 *ptr++ = pix; | |
1463 *ptr++ = pix; | |
1464 *ptr2++ = pix; | |
1465 *ptr2++ = pix; | |
1466 } | |
1467 srcptr += (img->bpl >> 1) - img->width; | |
1468 ptr += (dblimg->bpl) - dblimg->width; | |
1469 ptr2 += (dblimg->bpl) - dblimg->width; | |
1470 } | |
1471 } | |
1472 if (dblimg->bpp == 3) { | |
1473 register guint8 *srcptr, *ptr, *ptr2, pix1, pix2, pix3; | |
1474 | |
1475 srcptr = GDK_IMAGE_XIMAGE(img)->data; | |
1476 ptr = GDK_IMAGE_XIMAGE(dblimg)->data; | |
1477 ptr2 = ptr + dblimg->bpl; | |
1478 | |
1479 for (y = 0; y < img->height; y++) { | |
1480 for (x = 0; x < img->width; x++) { | |
1481 pix1 = *srcptr++; | |
1482 pix2 = *srcptr++; | |
1483 pix3 = *srcptr++; | |
1484 *ptr++ = pix1; | |
1485 *ptr++ = pix2; | |
1486 *ptr++ = pix3; | |
1487 *ptr++ = pix1; | |
1488 *ptr++ = pix2; | |
1489 *ptr++ = pix3; | |
1490 *ptr2++ = pix1; | |
1491 *ptr2++ = pix2; | |
1492 *ptr2++ = pix3; | |
1493 *ptr2++ = pix1; | |
1494 *ptr2++ = pix2; | |
1495 *ptr2++ = pix3; | |
1496 | |
1497 } | |
1498 srcptr += img->bpl - (img->width * 3); | |
1499 ptr += (dblimg->bpl << 1) - (dblimg->width * 3); | |
1500 ptr2 += (dblimg->bpl << 1) - (dblimg->width * 3); | |
1501 } | |
1502 } | |
1503 if (dblimg->bpp == 4) { | |
1504 register guint32 *srcptr, *ptr, *ptr2, pix; | |
1505 | |
1506 srcptr = (guint32 *) GDK_IMAGE_XIMAGE(img)->data; | |
1507 ptr = (guint32 *) GDK_IMAGE_XIMAGE(dblimg)->data; | |
1508 ptr2 = ptr + (dblimg->bpl >> 2); | |
1509 | |
1510 for (y = 0; y < img->height; y++) { | |
1511 for (x = 0; x < img->width; x++) { | |
1512 pix = *srcptr++; | |
1513 *ptr++ = pix; | |
1514 *ptr++ = pix; | |
1515 *ptr2++ = pix; | |
1516 *ptr2++ = pix; | |
1517 } | |
1518 srcptr += (img->bpl >> 2) - img->width; | |
1519 ptr += (dblimg->bpl >> 1) - dblimg->width; | |
1520 ptr2 += (dblimg->bpl >> 1) - dblimg->width; | |
1521 } | |
1522 } | |
1523 return dblimg; | |
1524 } | |
2074
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1525 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1526 /* URL-decode a file: URL path, return NULL if it's not what we expect */ |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1527 gchar * |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1528 xmms_urldecode_path(const gchar * encoded_path) |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1529 { |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1530 const gchar *cur, *ext; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1531 gchar *path, *tmp; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1532 gint realchar; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1533 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1534 if (!encoded_path) |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1535 return NULL; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1536 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1537 if (!str_has_prefix_nocase(encoded_path, "file:")) |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1538 return NULL; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1539 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1540 cur = encoded_path + 5; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1541 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1542 if (str_has_prefix_nocase(cur, "//localhost")) |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1543 cur += 11; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1544 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1545 if (*cur == '/') |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1546 while (cur[1] == '/') |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1547 cur++; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1548 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1549 tmp = g_malloc0(strlen(cur) + 1); |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1550 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1551 while ((ext = strchr(cur, '%')) != NULL) { |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1552 strncat(tmp, cur, ext - cur); |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1553 ext++; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1554 cur = ext + 2; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1555 if (!sscanf(ext, "%2x", &realchar)) { |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1556 /* Assume it is a literal '%'. Several file |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1557 * managers send unencoded file: urls on drag |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1558 * and drop. */ |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1559 realchar = '%'; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1560 cur -= 2; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1561 } |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1562 tmp[strlen(tmp)] = realchar; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1563 } |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1564 |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1565 path = g_strconcat(tmp, cur, NULL); |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1566 g_free(tmp); |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1567 return path; |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1568 } |
c725daec3849
[svn] - move xmms_urldecode_path() back into main binary
nenolod
parents:
2019
diff
changeset
|
1569 |