Mercurial > audlegacy
annotate src/audacious/util.c @ 2448:ff135e2ba10e trunk
[svn] - mark some strings used by GOption as translatable
author | nenolod |
---|---|
date | Tue, 30 Jan 2007 14:21:06 -0800 |
parents | 5b1b26db3a37 |
children | 59661bd074b4 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; under version 2 of the License. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 #define NEED_GLADE | |
29 #include "util.h" | |
30 | |
31 #include <glib.h> | |
32 #include <glib/gi18n.h> | |
33 #include <glade/glade.h> | |
34 #include <gtk/gtk.h> | |
35 #include <stdlib.h> | |
36 #include <string.h> | |
37 #include <ctype.h> | |
38 | |
39 #include "platform/smartinclude.h" | |
40 #include <errno.h> | |
41 | |
42 #ifdef HAVE_FTS_H | |
43 # include <fts.h> | |
44 #endif | |
45 | |
46 #include "glade.h" | |
47 #include "input.h" | |
48 #include "main.h" | |
49 #include "playback.h" | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2365
diff
changeset
|
50 #include "strings.h" |
2313 | 51 #include "ui_playlist.h" |
52 | |
53 #ifdef USE_CHARDET | |
54 #include "../librcd/librcd.h" | |
55 #ifdef HAVE_UDET | |
56 #include <libudet_c.h> | |
57 #endif | |
58 #endif | |
59 | |
60 /* | |
61 * find <file> in directory <dirname> or subdirectories. return | |
62 * pointer to complete filename which has to be freed by calling | |
63 * "g_free()" after use. Returns NULL if file could not be found. | |
64 */ | |
65 | |
66 typedef struct { | |
67 const gchar *to_match; | |
68 gchar *match; | |
69 gboolean found; | |
70 } FindFileContext; | |
71 | |
72 static gboolean | |
73 find_file_func(const gchar * path, const gchar * basename, gpointer data) | |
74 { | |
75 FindFileContext *context = data; | |
76 | |
77 if (strlen(path) > FILENAME_MAX) { | |
78 g_warning("Ignoring path: name too long (%s)", path); | |
79 return TRUE; | |
80 } | |
81 | |
82 if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) { | |
83 if (!strcasecmp(basename, context->to_match)) { | |
84 context->match = g_strdup(path); | |
85 context->found = TRUE; | |
86 return TRUE; | |
87 } | |
88 } | |
89 else if (g_file_test(path, G_FILE_TEST_IS_DIR)) { | |
90 dir_foreach(path, find_file_func, context, NULL); | |
91 if (context->found) | |
92 return TRUE; | |
93 } | |
94 | |
95 return FALSE; | |
96 } | |
97 | |
98 gchar * | |
99 find_file_recursively(const gchar * path, const gchar * filename) | |
100 { | |
101 FindFileContext context; | |
102 | |
103 context.to_match = filename; | |
104 context.match = NULL; | |
105 context.found = FALSE; | |
106 | |
107 dir_foreach(path, find_file_func, &context, NULL); | |
108 return context.match; | |
109 } | |
110 | |
111 | |
112 typedef enum { | |
113 ARCHIVE_UNKNOWN = 0, | |
114 ARCHIVE_DIR, | |
115 ARCHIVE_TAR, | |
116 ARCHIVE_TGZ, | |
117 ARCHIVE_ZIP, | |
118 ARCHIVE_TBZ2 | |
119 } ArchiveType; | |
120 | |
121 typedef gchar *(*ArchiveExtractFunc) (const gchar *, const gchar *); | |
122 | |
123 typedef struct { | |
124 ArchiveType type; | |
125 const gchar *ext; | |
126 } ArchiveExtensionType; | |
127 | |
128 static ArchiveExtensionType archive_extensions[] = { | |
129 {ARCHIVE_TAR, ".tar"}, | |
130 {ARCHIVE_ZIP, ".wsz"}, | |
131 {ARCHIVE_ZIP, ".zip"}, | |
132 {ARCHIVE_TGZ, ".tar.gz"}, | |
133 {ARCHIVE_TGZ, ".tgz"}, | |
134 {ARCHIVE_TBZ2, ".tar.bz2"}, | |
135 {ARCHIVE_TBZ2, ".bz2"}, | |
136 {ARCHIVE_UNKNOWN, NULL} | |
137 }; | |
138 | |
139 static gchar *archive_extract_tar(const gchar * archive, const gchar * dest); | |
140 static gchar *archive_extract_zip(const gchar * archive, const gchar * dest); | |
141 static gchar *archive_extract_tgz(const gchar * archive, const gchar * dest); | |
142 static gchar *archive_extract_tbz2(const gchar * archive, const gchar * dest); | |
143 | |
144 static ArchiveExtractFunc archive_extract_funcs[] = { | |
145 NULL, | |
146 NULL, | |
147 archive_extract_tar, | |
148 archive_extract_tgz, | |
149 archive_extract_zip, | |
150 archive_extract_tbz2 | |
151 }; | |
152 | |
153 | |
154 /* FIXME: these functions can be generalised into a function using a | |
155 * command lookup table */ | |
156 | |
157 static const gchar * | |
158 get_tar_command(void) | |
159 { | |
160 static const gchar *command = NULL; | |
161 | |
162 if (!command) { | |
163 if (!(command = getenv("TARCMD"))) | |
164 command = "tar"; | |
165 } | |
166 | |
167 return command; | |
168 } | |
169 | |
170 static const gchar * | |
171 get_unzip_command(void) | |
172 { | |
173 static const gchar *command = NULL; | |
174 | |
175 if (!command) { | |
176 if (!(command = getenv("UNZIPCMD"))) | |
177 command = "unzip"; | |
178 } | |
179 | |
180 return command; | |
181 } | |
182 | |
183 | |
184 static gchar * | |
185 archive_extract_tar(const gchar * archive, const gchar * dest) | |
186 { | |
187 return g_strdup_printf("%s >/dev/null xf \"%s\" -C %s", | |
188 get_tar_command(), archive, dest); | |
189 } | |
190 | |
191 static gchar * | |
192 archive_extract_zip(const gchar * archive, const gchar * dest) | |
193 { | |
194 return g_strdup_printf("%s >/dev/null -o -j \"%s\" -d %s", | |
195 get_unzip_command(), archive, dest); | |
196 } | |
197 | |
198 static gchar * | |
199 archive_extract_tgz(const gchar * archive, const gchar * dest) | |
200 { | |
201 return g_strdup_printf("%s >/dev/null xzf \"%s\" -C %s", | |
202 get_tar_command(), archive, dest); | |
203 } | |
204 | |
205 static gchar * | |
206 archive_extract_tbz2(const gchar * archive, const gchar * dest) | |
207 { | |
208 return g_strdup_printf("bzip2 -dc \"%s\" | %s >/dev/null xf - -C %s", | |
209 archive, get_tar_command(), dest); | |
210 } | |
211 | |
212 | |
213 ArchiveType | |
214 archive_get_type(const gchar * filename) | |
215 { | |
216 gint i = 0; | |
217 | |
218 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) | |
219 return ARCHIVE_DIR; | |
220 | |
221 while (archive_extensions[i].ext) { | |
222 if (g_str_has_suffix(filename, archive_extensions[i].ext)) { | |
223 return archive_extensions[i].type; | |
224 } | |
225 i++; | |
226 } | |
227 | |
228 return ARCHIVE_UNKNOWN; | |
229 } | |
230 | |
231 gboolean | |
232 file_is_archive(const gchar * filename) | |
233 { | |
234 return (archive_get_type(filename) > ARCHIVE_DIR); | |
235 } | |
236 | |
237 gchar * | |
238 archive_basename(const gchar * str) | |
239 { | |
240 gint i = 0; | |
241 | |
242 while (archive_extensions[i].ext) { | |
243 if (str_has_suffix_nocase(str, archive_extensions[i].ext)) { | |
244 const gchar *end = g_strrstr(str, archive_extensions[i].ext); | |
245 if (end) { | |
246 return g_strndup(str, end - str); | |
247 } | |
248 break; | |
249 } | |
250 i++; | |
251 } | |
252 | |
253 return NULL; | |
254 } | |
255 | |
256 /* | |
257 decompress_archive | |
258 | |
259 Decompresses the archive "filename" to a temporary directory, | |
260 returns the path to the temp dir, or NULL if failed, | |
261 watch out tho, doesn't actually check if the system command succeeds :-| | |
262 */ | |
263 | |
264 gchar * | |
265 archive_decompress(const gchar * filename) | |
266 { | |
267 gchar *tmpdir, *cmd, *escaped_filename; | |
268 ArchiveType type; | |
2328 | 269 #ifndef HAVE_MKDTEMP |
2313 | 270 mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
2328 | 271 #endif |
2313 | 272 |
273 if ((type = archive_get_type(filename)) <= ARCHIVE_DIR) | |
274 return NULL; | |
275 | |
276 #ifdef HAVE_MKDTEMP | |
277 tmpdir = g_build_filename(g_get_tmp_dir(), "audacious.XXXXXXXX", NULL); | |
278 if (!mkdtemp(tmpdir)) { | |
279 g_free(tmpdir); | |
280 g_message("Unable to load skin: Failed to create temporary " | |
281 "directory: %s", g_strerror(errno)); | |
282 return NULL; | |
283 } | |
284 #else | |
285 tmpdir = g_strdup_printf("%s/audacious.%ld", g_get_tmp_dir(), rand()); | |
286 make_directory(tmpdir, mode755); | |
287 #endif | |
288 | |
289 escaped_filename = escape_shell_chars(filename); | |
290 cmd = archive_extract_funcs[type] (escaped_filename, tmpdir); | |
291 g_free(escaped_filename); | |
292 | |
293 if (!cmd) { | |
294 g_message("extraction function is NULL!"); | |
295 g_free(tmpdir); | |
296 return NULL; | |
297 } | |
298 | |
2361
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2332
diff
changeset
|
299 if(system(cmd) == -1) |
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2332
diff
changeset
|
300 { |
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2332
diff
changeset
|
301 g_message("could not execute cmd %s",cmd); |
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2332
diff
changeset
|
302 g_free(cmd); |
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2332
diff
changeset
|
303 return NULL; |
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2332
diff
changeset
|
304 } |
2313 | 305 g_free(cmd); |
306 | |
307 return tmpdir; | |
308 } | |
309 | |
310 | |
311 #ifdef HAVE_FTS_H | |
312 | |
313 void | |
314 del_directory(const gchar * dirname) | |
315 { | |
316 gchar *const argv[2] = { (gchar *) dirname, NULL }; | |
317 FTS *fts; | |
318 FTSENT *p; | |
319 | |
320 fts = fts_open(argv, FTS_PHYSICAL, (gint(*)())NULL); | |
321 while ((p = fts_read(fts))) { | |
322 switch (p->fts_info) { | |
323 case FTS_D: | |
324 break; | |
325 case FTS_DNR: | |
326 case FTS_ERR: | |
327 break; | |
328 case FTS_DP: | |
329 rmdir(p->fts_accpath); | |
330 break; | |
331 default: | |
332 unlink(p->fts_accpath); | |
333 break; | |
334 } | |
335 } | |
336 fts_close(fts); | |
337 } | |
338 | |
339 #else /* !HAVE_FTS */ | |
340 | |
341 gboolean | |
342 del_directory_func(const gchar * path, const gchar * basename, | |
343 gpointer params) | |
344 { | |
345 if (!strcmp(basename, ".") || !strcmp(path, "..")) | |
346 return FALSE; | |
347 | |
348 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { | |
349 dir_foreach(path, del_directory_func, NULL, NULL); | |
350 rmdir(path); | |
351 return FALSE; | |
352 } | |
353 | |
354 unlink(path); | |
355 | |
356 return FALSE; | |
357 } | |
358 | |
359 void | |
360 del_directory(const gchar * path) | |
361 { | |
362 dir_foreach(path, del_directory_func, NULL, NULL); | |
363 rmdir(path); | |
364 } | |
365 | |
366 #endif /* ifdef HAVE_FTS */ | |
367 | |
368 gchar * | |
369 read_ini_string(const gchar * filename, const gchar * section, | |
370 const gchar * key) | |
371 { | |
372 static gchar *buffer = NULL; | |
373 static gchar *open_buffer = NULL; | |
374 gchar *ret_buffer = NULL; | |
375 gint found_section = 0, len = 0; | |
376 static gsize filesize = 0; | |
377 gsize off = 0; | |
378 gchar *outbuf; | |
379 unsigned char x[] = { 0xff, 0xfe, 0x00 }; | |
380 guint counter; | |
381 | |
382 if (!filename) | |
383 return NULL; | |
384 | |
385 /* | |
386 * We optimise for the condition that we may be reading from the | |
387 * same ini-file multiple times. This is fairly common; it happens | |
388 * on .pls playlist loads. To do otherwise would take entirely too | |
389 * long, as fstat() can be very slow when done 21,000 times too many. | |
390 * | |
391 * Therefore, we optimise by keeping the last ini file in memory. | |
392 * Yes, this is a memory leak, but it is not too bad, hopefully. | |
393 * - nenolod | |
394 */ | |
395 if (open_buffer == NULL || strcasecmp(filename, open_buffer)) | |
396 { | |
397 if (buffer != NULL) | |
2423 | 398 { |
2313 | 399 g_free(buffer); |
400 buffer = NULL; | |
401 } | |
402 | |
2423 | 403 if (open_buffer != NULL) |
2313 | 404 { |
2423 | 405 g_free(open_buffer); |
2313 | 406 open_buffer = NULL; |
407 } | |
408 | |
2425 | 409 vfs_file_get_contents(filename, &buffer, &filesize); |
410 | |
411 if (buffer == NULL) | |
2313 | 412 return NULL; |
413 | |
414 open_buffer = g_strdup(filename); | |
415 } | |
416 | |
417 /* | |
418 * Convert UTF-16 into something useful. Original implementation | |
419 * by incomp@#audacious. Cleanups \nenolod | |
420 */ | |
421 if (!memcmp(&buffer[0],&x,2)) { | |
2402 | 422 outbuf = g_malloc (filesize); /* it's safe to waste memory. */ |
2313 | 423 |
424 for (counter = 2; counter < filesize; counter += 2) | |
425 if (!memcmp(&buffer[counter+1], &x[2], 1)) | |
426 outbuf[(counter-2)/2] = buffer[counter]; | |
427 else | |
2402 | 428 return NULL; |
2313 | 429 |
430 outbuf[(counter-2)/2] = '\0'; | |
431 | |
432 if ((filesize - 2) / 2 == (counter - 2) / 2) { | |
433 g_free(buffer); | |
434 buffer = outbuf; | |
435 } else { | |
436 g_free(outbuf); | |
2402 | 437 return NULL; /* XXX wrong encoding */ |
2313 | 438 } |
439 } | |
440 | |
441 while (!ret_buffer && off < filesize) { | |
442 while (off < filesize && | |
443 (buffer[off] == '\r' || buffer[off] == '\n' || | |
444 buffer[off] == ' ' || buffer[off] == '\t')) | |
445 off++; | |
446 if (off >= filesize) | |
447 break; | |
448 if (buffer[off] == '[') { | |
449 gint slen = strlen(section); | |
450 off++; | |
451 found_section = 0; | |
452 if (off + slen + 1 < filesize && | |
453 !strncasecmp(section, &buffer[off], slen)) { | |
454 off += slen; | |
455 if (buffer[off] == ']') { | |
456 off++; | |
457 found_section = 1; | |
458 } | |
459 } | |
460 } | |
461 else if (found_section && off + strlen(key) < filesize && | |
462 !strncasecmp(key, &buffer[off], strlen(key))) { | |
463 off += strlen(key); | |
464 while (off < filesize && | |
465 (buffer[off] == ' ' || buffer[off] == '\t')) | |
466 off++; | |
467 if (off >= filesize) | |
468 break; | |
469 if (buffer[off] == '=') { | |
470 off++; | |
471 while (off < filesize && | |
472 (buffer[off] == ' ' || buffer[off] == '\t')) | |
473 off++; | |
474 if (off >= filesize) | |
475 break; | |
476 len = 0; | |
477 while (off + len < filesize && | |
478 buffer[off + len] != '\r' && | |
479 buffer[off + len] != '\n' && buffer[off + len] != ';') | |
480 len++; | |
481 ret_buffer = g_strndup(&buffer[off], len); | |
482 off += len; | |
483 } | |
484 } | |
485 while (off < filesize && buffer[off] != '\r' && buffer[off] != '\n') | |
486 off++; | |
487 } | |
488 | |
489 return ret_buffer; | |
490 } | |
491 | |
492 GArray * | |
493 string_to_garray(const gchar * str) | |
494 { | |
495 GArray *array; | |
496 gint temp; | |
497 const gchar *ptr = str; | |
498 gchar *endptr; | |
499 | |
500 array = g_array_new(FALSE, TRUE, sizeof(gint)); | |
501 for (;;) { | |
502 temp = strtol(ptr, &endptr, 10); | |
503 if (ptr == endptr) | |
504 break; | |
505 g_array_append_val(array, temp); | |
506 ptr = endptr; | |
507 while (!isdigit((int) *ptr) && (*ptr) != '\0') | |
508 ptr++; | |
509 if (*ptr == '\0') | |
510 break; | |
511 } | |
512 return (array); | |
513 } | |
514 | |
515 GArray * | |
516 read_ini_array(const gchar * filename, const gchar * section, | |
517 const gchar * key) | |
518 { | |
519 gchar *temp; | |
520 GArray *a; | |
521 | |
522 if ((temp = read_ini_string(filename, section, key)) == NULL) { | |
523 g_free(temp); | |
524 return NULL; | |
525 } | |
526 a = string_to_garray(temp); | |
527 g_free(temp); | |
528 return a; | |
529 } | |
530 | |
531 void | |
532 glist_movedown(GList * list) | |
533 { | |
534 gpointer temp; | |
535 | |
536 if (g_list_next(list)) { | |
537 temp = list->data; | |
538 list->data = list->next->data; | |
539 list->next->data = temp; | |
540 } | |
541 } | |
542 | |
543 void | |
544 glist_moveup(GList * list) | |
545 { | |
546 gpointer temp; | |
547 | |
548 if (g_list_previous(list)) { | |
549 temp = list->data; | |
550 list->data = list->prev->data; | |
551 list->prev->data = temp; | |
552 } | |
553 } | |
554 | |
555 | |
556 void | |
557 util_menu_position(GtkMenu * menu, gint * x, gint * y, | |
558 gboolean * push_in, gpointer data) | |
559 { | |
560 GtkRequisition requisition; | |
561 gint screen_width; | |
562 gint screen_height; | |
563 MenuPos *pos = data; | |
564 | |
565 gtk_widget_size_request(GTK_WIDGET(menu), &requisition); | |
566 | |
567 screen_width = gdk_screen_width(); | |
568 screen_height = gdk_screen_height(); | |
569 | |
570 *x = CLAMP(pos->x - 2, 0, MAX(0, screen_width - requisition.width)); | |
571 *y = CLAMP(pos->y - 2, 0, MAX(0, screen_height - requisition.height)); | |
572 } | |
573 | |
574 GdkFont * | |
575 util_font_load(const gchar * name) | |
576 { | |
577 GdkFont *font; | |
578 PangoFontDescription *desc; | |
579 | |
580 desc = pango_font_description_from_string(name); | |
581 font = gdk_font_from_description(desc); | |
582 | |
583 return font; | |
584 } | |
585 | |
586 #ifdef ENABLE_NLS | |
587 gchar * | |
588 bmp_menu_translate(const gchar * path, gpointer func_data) | |
589 { | |
590 gchar *translation = gettext(path); | |
591 | |
592 if (!translation || *translation != '/') { | |
593 g_warning("Bad translation for menupath: %s", path); | |
594 translation = (gchar *) path; | |
595 } | |
596 | |
597 return translation; | |
598 } | |
599 #endif | |
600 | |
601 void | |
602 util_set_cursor(GtkWidget * window) | |
603 { | |
604 static GdkCursor *cursor = NULL; | |
605 | |
606 if (!window) { | |
607 if (cursor) { | |
608 gdk_cursor_unref(cursor); | |
609 cursor = NULL; | |
610 } | |
611 | |
612 return; | |
613 } | |
614 | |
615 if (!cursor) | |
616 cursor = gdk_cursor_new(GDK_LEFT_PTR); | |
617 | |
618 gdk_window_set_cursor(window->window, cursor); | |
619 } | |
620 | |
621 /* text_get_extents() taken from The GIMP (C) Spencer Kimball, Peter | |
622 * Mattis et al */ | |
623 gboolean | |
624 text_get_extents(const gchar * fontname, | |
625 const gchar * text, | |
626 gint * width, gint * height, gint * ascent, gint * descent) | |
627 { | |
628 PangoFontDescription *font_desc; | |
629 PangoLayout *layout; | |
630 PangoRectangle rect; | |
631 | |
632 g_return_val_if_fail(fontname != NULL, FALSE); | |
633 g_return_val_if_fail(text != NULL, FALSE); | |
634 | |
635 /* FIXME: resolution */ | |
636 layout = gtk_widget_create_pango_layout(GTK_WIDGET(mainwin), text); | |
637 | |
638 font_desc = pango_font_description_from_string(fontname); | |
639 pango_layout_set_font_description(layout, font_desc); | |
640 pango_font_description_free(font_desc); | |
641 pango_layout_get_pixel_extents(layout, NULL, &rect); | |
642 | |
643 if (width) | |
644 *width = rect.width; | |
645 if (height) | |
646 *height = rect.height; | |
647 | |
648 if (ascent || descent) { | |
649 PangoLayoutIter *iter; | |
650 PangoLayoutLine *line; | |
651 | |
652 iter = pango_layout_get_iter(layout); | |
653 line = pango_layout_iter_get_line(iter); | |
654 pango_layout_iter_free(iter); | |
655 | |
656 pango_layout_line_get_pixel_extents(line, NULL, &rect); | |
657 | |
658 if (ascent) | |
659 *ascent = PANGO_ASCENT(rect); | |
660 if (descent) | |
661 *descent = -PANGO_DESCENT(rect); | |
662 } | |
663 | |
664 g_object_unref(layout); | |
665 | |
666 return TRUE; | |
667 } | |
668 | |
669 /* counts number of digits in a gint */ | |
670 guint | |
671 gint_count_digits(gint n) | |
672 { | |
673 guint count = 0; | |
674 | |
675 n = ABS(n); | |
676 do { | |
677 count++; | |
678 n /= 10; | |
679 } while (n > 0); | |
680 | |
681 return count; | |
682 } | |
683 | |
684 gboolean | |
685 dir_foreach(const gchar * path, DirForeachFunc function, | |
686 gpointer user_data, GError ** error) | |
687 { | |
688 GError *error_out = NULL; | |
689 GDir *dir; | |
690 const gchar *entry; | |
691 gchar *entry_fullpath; | |
692 | |
693 if (!(dir = g_dir_open(path, 0, &error_out))) { | |
694 g_propagate_error(error, error_out); | |
695 return FALSE; | |
696 } | |
697 | |
698 while ((entry = g_dir_read_name(dir))) { | |
699 entry_fullpath = g_build_filename(path, entry, NULL); | |
700 | |
701 if ((*function) (entry_fullpath, entry, user_data)) { | |
702 g_free(entry_fullpath); | |
703 break; | |
704 } | |
705 | |
706 g_free(entry_fullpath); | |
707 } | |
708 | |
709 g_dir_close(dir); | |
710 | |
711 return TRUE; | |
712 } | |
713 | |
714 GtkWidget * | |
715 make_filebrowser(const gchar * title, | |
716 gboolean save) | |
717 { | |
718 GtkWidget *dialog; | |
719 GtkWidget *button; | |
720 GtkWidget *button_close; | |
721 | |
722 g_return_val_if_fail(title != NULL, NULL); | |
723 | |
724 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), | |
725 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); | |
726 if (save) | |
727 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog), | |
728 GTK_FILE_CHOOSER_ACTION_SAVE); | |
729 | |
730 if (!save) | |
731 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); | |
732 | |
733 g_signal_connect(dialog, "destroy", | |
734 G_CALLBACK(gtk_widget_destroyed), &dialog); | |
735 | |
736 button_close = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, | |
737 GTK_RESPONSE_REJECT); | |
738 gtk_button_set_use_stock(GTK_BUTTON(button_close), TRUE); | |
739 GTK_WIDGET_SET_FLAGS(button_close, GTK_CAN_DEFAULT); | |
740 g_signal_connect_swapped(button_close, "clicked", | |
741 G_CALLBACK(gtk_widget_destroy), dialog); | |
742 | |
743 button = gtk_dialog_add_button(GTK_DIALOG(dialog), save ? | |
744 GTK_STOCK_SAVE : GTK_STOCK_OPEN, | |
745 GTK_RESPONSE_ACCEPT); | |
746 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
747 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
748 gtk_window_set_default(GTK_WINDOW(dialog), button); | |
749 | |
750 gtk_widget_show(dialog); | |
751 | |
752 return dialog; | |
753 } | |
754 | |
755 /* | |
756 * Resizes a GDK pixmap. | |
757 */ | |
758 GdkPixmap *audacious_pixmap_resize(GdkWindow *src, GdkGC *src_gc, GdkPixmap *in, gint width, gint height) | |
759 { | |
2402 | 760 GdkPixmap *out; |
761 gint owidth, oheight; | |
2313 | 762 |
2402 | 763 g_return_val_if_fail(src != NULL, NULL); |
764 g_return_val_if_fail(src_gc != NULL, NULL); | |
765 g_return_val_if_fail(in != NULL, NULL); | |
766 g_return_val_if_fail(width > 0 && height > 0, NULL); | |
2313 | 767 |
2402 | 768 gdk_drawable_get_size(in, &owidth, &oheight); |
2313 | 769 |
2402 | 770 if (oheight == height && owidth == width) |
771 return NULL; | |
2313 | 772 |
2402 | 773 out = gdk_pixmap_new(src, width, height, -1); |
2313 | 774 |
2402 | 775 gdk_draw_rectangle(out, src_gc, TRUE, 0, 0, width, height); |
2313 | 776 |
2402 | 777 gdk_window_copy_area(out, src_gc, 0, 0, in, 0, 0, owidth, oheight); |
778 g_object_unref(src); | |
2313 | 779 |
2402 | 780 return out; |
2313 | 781 } |
782 | |
783 GdkImage *create_dblsize_image(GdkImage * img) | |
784 { | |
785 GdkImage *dblimg; | |
786 register guint x, y; | |
787 | |
788 /* | |
789 * This needs to be optimized | |
790 */ | |
791 | |
792 dblimg = | |
2402 | 793 gdk_image_new(GDK_IMAGE_NORMAL, gdk_visual_get_system(), |
794 img->width << 1, img->height << 1); | |
2313 | 795 if (dblimg->bpp == 1) { |
2402 | 796 register guint8 *srcptr, *ptr, *ptr2, pix; |
2313 | 797 |
2402 | 798 srcptr = GDK_IMAGE(img)->mem; |
799 ptr = GDK_IMAGE(dblimg)->mem; | |
800 ptr2 = ptr + dblimg->bpl; | |
2313 | 801 |
2402 | 802 for (y = 0; y < img->height; y++) { |
803 for (x = 0; x < img->width; x++) { | |
804 pix = *srcptr++; | |
805 *ptr++ = pix; | |
806 *ptr++ = pix; | |
807 *ptr2++ = pix; | |
808 *ptr2++ = pix; | |
809 } | |
810 srcptr += img->bpl - img->width; | |
811 ptr += (dblimg->bpl << 1) - dblimg->width; | |
812 ptr2 += (dblimg->bpl << 1) - dblimg->width; | |
813 } | |
2313 | 814 } |
815 if (dblimg->bpp == 2) { | |
2402 | 816 guint16 *srcptr, *ptr, *ptr2, pix; |
2313 | 817 |
2402 | 818 srcptr = (guint16 *) GDK_IMAGE_XIMAGE(img)->data; |
819 ptr = (guint16 *) GDK_IMAGE_XIMAGE(dblimg)->data; | |
820 ptr2 = ptr + (dblimg->bpl >> 1); | |
2313 | 821 |
2402 | 822 for (y = 0; y < img->height; y++) { |
823 for (x = 0; x < img->width; x++) { | |
824 pix = *srcptr++; | |
825 *ptr++ = pix; | |
826 *ptr++ = pix; | |
827 *ptr2++ = pix; | |
828 *ptr2++ = pix; | |
829 } | |
830 srcptr += (img->bpl >> 1) - img->width; | |
831 ptr += (dblimg->bpl) - dblimg->width; | |
832 ptr2 += (dblimg->bpl) - dblimg->width; | |
833 } | |
2313 | 834 } |
835 if (dblimg->bpp == 3) { | |
2402 | 836 register guint8 *srcptr, *ptr, *ptr2, pix1, pix2, pix3; |
2313 | 837 |
2402 | 838 srcptr = GDK_IMAGE(img)->mem; |
839 ptr = GDK_IMAGE(dblimg)->mem; | |
840 ptr2 = ptr + dblimg->bpl; | |
2313 | 841 |
2402 | 842 for (y = 0; y < img->height; y++) { |
843 for (x = 0; x < img->width; x++) { | |
844 pix1 = *srcptr++; | |
845 pix2 = *srcptr++; | |
846 pix3 = *srcptr++; | |
847 *ptr++ = pix1; | |
848 *ptr++ = pix2; | |
849 *ptr++ = pix3; | |
850 *ptr++ = pix1; | |
851 *ptr++ = pix2; | |
852 *ptr++ = pix3; | |
853 *ptr2++ = pix1; | |
854 *ptr2++ = pix2; | |
855 *ptr2++ = pix3; | |
856 *ptr2++ = pix1; | |
857 *ptr2++ = pix2; | |
858 *ptr2++ = pix3; | |
2313 | 859 |
2402 | 860 } |
861 srcptr += img->bpl - (img->width * 3); | |
862 ptr += (dblimg->bpl << 1) - (dblimg->width * 3); | |
863 ptr2 += (dblimg->bpl << 1) - (dblimg->width * 3); | |
864 } | |
2313 | 865 } |
866 if (dblimg->bpp == 4) { | |
2402 | 867 register guint32 *srcptr, *ptr, *ptr2, pix; |
2313 | 868 |
2402 | 869 srcptr = (guint32 *) GDK_IMAGE(img)->mem; |
870 ptr = (guint32 *) GDK_IMAGE(dblimg)->mem; | |
871 ptr2 = ptr + (dblimg->bpl >> 2); | |
2313 | 872 |
2402 | 873 for (y = 0; y < img->height; y++) { |
874 for (x = 0; x < img->width; x++) { | |
875 pix = *srcptr++; | |
876 *ptr++ = pix; | |
877 *ptr++ = pix; | |
878 *ptr2++ = pix; | |
879 *ptr2++ = pix; | |
880 } | |
881 srcptr += (img->bpl >> 2) - img->width; | |
882 ptr += (dblimg->bpl >> 1) - dblimg->width; | |
883 ptr2 += (dblimg->bpl >> 1) - dblimg->width; | |
884 } | |
2313 | 885 } |
886 return dblimg; | |
887 } | |
888 | |
889 /* URL-decode a file: URL path, return NULL if it's not what we expect */ | |
890 gchar * | |
891 xmms_urldecode_path(const gchar * encoded_path) | |
892 { | |
893 const gchar *cur, *ext; | |
894 gchar *path, *tmp; | |
895 gint realchar; | |
896 | |
897 if (!encoded_path) | |
898 return NULL; | |
899 | |
900 if (!str_has_prefix_nocase(encoded_path, "file:")) | |
901 return NULL; | |
902 | |
903 cur = encoded_path + 5; | |
904 | |
905 if (str_has_prefix_nocase(cur, "//localhost")) | |
906 cur += 11; | |
907 | |
908 if (*cur == '/') | |
909 while (cur[1] == '/') | |
910 cur++; | |
911 | |
912 tmp = g_malloc0(strlen(cur) + 1); | |
913 | |
914 while ((ext = strchr(cur, '%')) != NULL) { | |
915 strncat(tmp, cur, ext - cur); | |
916 ext++; | |
917 cur = ext + 2; | |
918 if (!sscanf(ext, "%2x", &realchar)) { | |
919 /* Assume it is a literal '%'. Several file | |
920 * managers send unencoded file: urls on drag | |
921 * and drop. */ | |
922 realchar = '%'; | |
923 cur -= 2; | |
924 } | |
925 tmp[strlen(tmp)] = realchar; | |
926 } | |
927 | |
928 path = g_strconcat(tmp, cur, NULL); | |
929 g_free(tmp); | |
930 return path; | |
931 } | |
932 | |
2421
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
933 /** |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
934 * xmms_show_message: |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
935 * @title: The title of the message to show. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
936 * @text: The text of the message to show. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
937 * @button_text: The text of the button which will close the messagebox. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
938 * @modal: Whether or not the messagebox should be modal. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
939 * @button_action: Code to execute on when the messagebox is closed, or %NULL. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
940 * @action_data: Optional opaque data to pass to @button_action. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
941 * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
942 * Displays a message box. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
943 * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
944 * Return value: A GTK widget handle for the message box. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
945 **/ |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
946 GtkWidget * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
947 xmms_show_message(const gchar * title, const gchar * text, |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
948 const gchar * button_text, gboolean modal, |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
949 GtkSignalFunc button_action, gpointer action_data) |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
950 { |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
951 GtkWidget *dialog; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
952 GtkWidget *dialog_vbox, *dialog_hbox, *dialog_bbox; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
953 GtkWidget *dialog_bbox_b1; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
954 GtkWidget *dialog_textlabel; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
955 GtkWidget *dialog_icon; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
956 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
957 dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
958 gtk_window_set_type_hint( GTK_WINDOW(dialog) , GDK_WINDOW_TYPE_HINT_DIALOG ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
959 gtk_window_set_modal( GTK_WINDOW(dialog) , modal ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
960 gtk_window_set_title( GTK_WINDOW(dialog) , title ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
961 gtk_container_set_border_width( GTK_CONTAINER(dialog) , 10 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
962 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
963 dialog_vbox = gtk_vbox_new( FALSE , 0 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
964 dialog_hbox = gtk_hbox_new( FALSE , 0 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
965 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
966 /* icon */ |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
967 dialog_icon = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO , GTK_ICON_SIZE_DIALOG ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
968 gtk_box_pack_start( GTK_BOX(dialog_hbox) , dialog_icon , FALSE , FALSE , 2 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
969 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
970 /* label */ |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
971 dialog_textlabel = gtk_label_new( text ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
972 /* gtk_label_set_selectable( GTK_LABEL(dialog_textlabel) , TRUE ); */ |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
973 gtk_box_pack_start( GTK_BOX(dialog_hbox) , dialog_textlabel , TRUE , TRUE , 2 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
974 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
975 gtk_box_pack_start( GTK_BOX(dialog_vbox) , dialog_hbox , FALSE , FALSE , 2 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
976 gtk_box_pack_start( GTK_BOX(dialog_vbox) , gtk_hseparator_new() , FALSE , FALSE , 4 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
977 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
978 dialog_bbox = gtk_hbutton_box_new(); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
979 gtk_button_box_set_layout( GTK_BUTTON_BOX(dialog_bbox) , GTK_BUTTONBOX_END ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
980 dialog_bbox_b1 = gtk_button_new_with_label( button_text ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
981 g_signal_connect_swapped( G_OBJECT(dialog_bbox_b1) , "clicked" , |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
982 G_CALLBACK(gtk_widget_destroy) , dialog ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
983 if ( button_action ) |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
984 g_signal_connect( G_OBJECT(dialog_bbox_b1) , "clicked" , |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
985 button_action , action_data ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
986 GTK_WIDGET_SET_FLAGS( dialog_bbox_b1 , GTK_CAN_DEFAULT); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
987 gtk_widget_grab_default( dialog_bbox_b1 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
988 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
989 gtk_container_add( GTK_CONTAINER(dialog_bbox) , dialog_bbox_b1 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
990 gtk_box_pack_start( GTK_BOX(dialog_vbox) , dialog_bbox , FALSE , FALSE , 0 ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
991 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
992 gtk_container_add( GTK_CONTAINER(dialog) , dialog_vbox ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
993 gtk_widget_show_all(dialog); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
994 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
995 return dialog; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
996 } |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
997 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
998 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
999 /** |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1000 * audacious_get_localdir: |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1001 * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1002 * Returns a string with the full path of Audacious local datadir (where config files are placed). |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1003 * It's useful in order to put in the right place custom config files for audacious plugins. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1004 * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1005 * Return value: a string with full path of Audacious local datadir (should be freed after use) |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1006 **/ |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1007 gchar* |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1008 audacious_get_localdir(void) |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1009 { |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1010 gchar *datadir; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1011 gchar *tmp; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1012 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1013 if ( (tmp = getenv("XDG_CONFIG_HOME")) == NULL ) |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1014 datadir = g_build_filename( g_get_home_dir() , ".config" , "audacious" , NULL ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1015 else |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1016 datadir = g_build_filename( tmp , "audacious" , NULL ); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1017 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1018 return datadir; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1019 } |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1020 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1021 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1022 /** |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1023 * xmms_check_realtime_priority: |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1024 * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1025 * Legacy function included for compatibility with XMMS. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1026 * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1027 * Return value: FALSE |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1028 **/ |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1029 gboolean |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1030 xmms_check_realtime_priority(void) |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1031 { |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1032 return FALSE; |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1033 } |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1034 |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1035 /** |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1036 * xmms_usleep: |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1037 * @usec: The amount of microseconds to sleep. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1038 * |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1039 * Legacy function included for compatibility with XMMS. |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1040 **/ |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1041 void |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1042 xmms_usleep(gint usec) |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1043 { |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1044 g_usleep(usec); |
74ec16ef847b
[svn] - fix accidental removal of xmms_show_message
nenolod
parents:
2416
diff
changeset
|
1045 } |