Mercurial > audlegacy
comparison src/audacious/ui_fileinfo.c @ 4162:0b00f1d21270
Prettify theme-icon util functions.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Thu, 10 Jan 2008 04:53:01 -0600 |
parents | 450581e58761 |
children | a12876b41f01 |
comparison
equal
deleted
inserted
replaced
4161:e1e675e7d737 | 4162:0b00f1d21270 |
---|---|
1 /* | 1 /* |
2 * Audacious: A cross-platform multimedia player | 2 * Audacious: A cross-platform multimedia player |
3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill, | 3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill, |
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. | 4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. |
5 * Copyright (c) 2008 Eugene Zagidullin | |
5 * | 6 * |
6 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | 8 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; under version 3 of the License. | 9 * the Free Software Foundation; under version 3 of the License. |
9 * | 10 * |
58 #include "ui_playlist.h" | 59 #include "ui_playlist.h" |
59 #include "build_stamp.h" | 60 #include "build_stamp.h" |
60 #include "ui_fileinfo.h" | 61 #include "ui_fileinfo.h" |
61 #include "ui_playlist.h" | 62 #include "ui_playlist.h" |
62 | 63 |
63 #define G_FREE_CLEAR(a) { if(a != NULL) { g_free(a); a = NULL; } } | 64 #define G_FREE_CLEAR(a) if(a != NULL) { g_free(a); a = NULL; } |
64 #define STATUS_TIMEOUT 3*1000 | 65 #define STATUS_TIMEOUT 3*1000 |
65 | 66 |
66 GtkWidget *fileinfo_win; | 67 GtkWidget *fileinfo_win; |
67 | 68 |
68 GtkWidget *entry_location; | 69 GtkWidget *entry_location; |
315 | 316 |
316 mowgli_object_unref(tuple); | 317 mowgli_object_unref(tuple); |
317 } | 318 } |
318 } | 319 } |
319 | 320 |
320 | 321 /** |
322 * Looks up an icon from a NULL-terminated list of icon names. | |
323 * | |
324 * size: the requested size | |
325 * name: the default name | |
326 * ... : a NULL-terminated list of alternates | |
327 */ | |
321 GdkPixbuf * | 328 GdkPixbuf * |
322 themed_icon_lookup(gint size, const gchar *name, ...) /* NULL-terminated list of icon names */ | 329 themed_icon_lookup(gint size, const gchar *name, ...) |
323 { | 330 { |
324 GtkIconTheme *icon_theme; | 331 GtkIconTheme *icon_theme; |
325 GdkPixbuf *pixbuf; | 332 GdkPixbuf *pixbuf; |
326 GError *error = NULL; | 333 GError *error = NULL; |
327 gchar *n; | 334 gchar *n; |
328 va_list par; | 335 va_list par; |
329 | 336 |
330 icon_theme = gtk_icon_theme_get_default (); | 337 icon_theme = gtk_icon_theme_get_default (); |
331 //fprintf(stderr, "looking for %s\n", name); | |
332 pixbuf = gtk_icon_theme_load_icon (icon_theme, name, size, 0, &error); | 338 pixbuf = gtk_icon_theme_load_icon (icon_theme, name, size, 0, &error); |
333 if(pixbuf) return pixbuf; | 339 if(pixbuf) return pixbuf; |
334 | 340 |
335 if(error != NULL) g_error_free(error); | 341 if(error != NULL) g_error_free(error); |
336 | 342 |
337 /* fallback */ | 343 /* fallback */ |
338 va_start(par, name); | 344 va_start(par, name); |
339 while((n = (gchar*)va_arg(par, gchar *)) != NULL) { | 345 while((n = (gchar*)va_arg(par, gchar *)) != NULL) { |
340 //fprintf(stderr, "looking for %s\n", n); | |
341 error = NULL; | 346 error = NULL; |
342 pixbuf = gtk_icon_theme_load_icon (icon_theme, n, size, 0, &error); | 347 pixbuf = gtk_icon_theme_load_icon (icon_theme, n, size, 0, &error); |
343 if(pixbuf) { | 348 |
344 //fprintf(stderr, "%s is ok\n", n); | 349 if (pixbuf) { |
345 va_end(par); | 350 va_end(par); |
346 return pixbuf; | 351 return pixbuf; |
347 } | 352 } |
348 if(error != NULL) g_error_free(error); | 353 |
354 if (error != NULL) | |
355 g_error_free(error); | |
349 } | 356 } |
350 | 357 |
351 return NULL; | 358 return NULL; |
352 } | 359 } |
353 | 360 |
361 /** | |
362 * Intelligently looks up an icon for a mimetype. Supports | |
363 * HIDEOUSLY BROKEN gnome icon naming scheme too. | |
364 * | |
365 * size : the requested size | |
366 * mime_type: the mime type. | |
367 */ | |
354 GdkPixbuf * | 368 GdkPixbuf * |
355 mime_icon_lookup(gint size, const gchar *mime_type) /* smart icon resolving routine :) */ | 369 mime_icon_lookup(gint size, const gchar *mime_type) /* smart icon resolving routine :) */ |
356 { | 370 { |
357 gchar *mime_as_is; /* audio-x-mp3 */ | 371 gchar *mime_as_is; /* audio-x-mp3 */ |
358 gchar *mime_gnome; /* gnome-mime-audio-x-mp3 */ | 372 gchar *mime_gnome; /* gnome-mime-audio-x-mp3 */ |
365 if(s[1] != NULL) { | 379 if(s[1] != NULL) { |
366 mime_as_is = g_strdup_printf("%s-%s", s[0], s[1]); | 380 mime_as_is = g_strdup_printf("%s-%s", s[0], s[1]); |
367 mime_gnome = g_strdup_printf("gnome-mime-%s-%s", s[0], s[1]); | 381 mime_gnome = g_strdup_printf("gnome-mime-%s-%s", s[0], s[1]); |
368 mime_generic = g_strdup_printf("%s-x-generic", s[0]); | 382 mime_generic = g_strdup_printf("%s-x-generic", s[0]); |
369 mime_gnome_generic = g_strdup_printf("gnome-mime-%s", s[0]); | 383 mime_gnome_generic = g_strdup_printf("gnome-mime-%s", s[0]); |
370 //fprintf(stderr, "will look for %s, %s, %s, %s, %s\n", mime_as_is, mime_gnome, mime_generic, mime_gnome_generic, s[0]); | |
371 icon = themed_icon_lookup(size, mime_as_is, mime_gnome, mime_generic, mime_gnome_generic, s[0], NULL); /* s[0] is category */ | 384 icon = themed_icon_lookup(size, mime_as_is, mime_gnome, mime_generic, mime_gnome_generic, s[0], NULL); /* s[0] is category */ |
372 g_free(mime_gnome_generic); | 385 g_free(mime_gnome_generic); |
373 g_free(mime_generic); | 386 g_free(mime_generic); |
374 g_free(mime_gnome); | 387 g_free(mime_gnome); |
375 g_free(mime_as_is); | 388 g_free(mime_as_is); |