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