mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-10-01 03:27:36 +00:00
Use GIO for this.
* gtk/gtkrecentmanager.c (get_icon_for_mime_type): Use GIO for this. svn path=/trunk/; revision=20472
This commit is contained in:
parent
2a5a00646d
commit
e1c47e2ee0
@ -1,3 +1,8 @@
|
||||
2008-06-19 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkrecentmanager.c (get_icon_for_mime_type): Use GIO
|
||||
for this.
|
||||
|
||||
2008-06-19 Johan Dahlin <jdahlin@async.com.br>
|
||||
|
||||
* gtk/gtkprintbackend.c: Fix a typo in a comment
|
||||
|
@ -1881,52 +1881,24 @@ get_icon_for_mime_type (const char *mime_type,
|
||||
gint pixel_size)
|
||||
{
|
||||
GtkIconTheme *icon_theme;
|
||||
const char *separator;
|
||||
GString *icon_name;
|
||||
char *content_type;
|
||||
GIcon *icon;
|
||||
GtkIconInfo *info;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
separator = strchr (mime_type, '/');
|
||||
if (!separator)
|
||||
return NULL;
|
||||
|
||||
icon_theme = gtk_icon_theme_get_default ();
|
||||
|
||||
/* try with the three icon name variants for MIME types */
|
||||
content_type = g_content_type_from_mime_type (mime_type);
|
||||
icon = g_content_type_get_icon (content_type);
|
||||
info = gtk_icon_theme_lookup_by_gicon (icon_theme,
|
||||
icon,
|
||||
pixel_size,
|
||||
GTK_ICON_LOOKUP_USE_BUILTIN);
|
||||
pixbuf = gtk_icon_info_load_icon (info, NULL);
|
||||
|
||||
/* canonicalize MIME type: foo/x-bar -> foo-x-bar */
|
||||
icon_name = g_string_new (NULL);
|
||||
g_string_append_len (icon_name, mime_type, separator - mime_type);
|
||||
g_string_append_c (icon_name, '-');
|
||||
g_string_append (icon_name, separator + 1);
|
||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
||||
pixel_size,
|
||||
0,
|
||||
NULL);
|
||||
g_string_free (icon_name, TRUE);
|
||||
if (pixbuf)
|
||||
return pixbuf;
|
||||
|
||||
/* canonicalize MIME type, and prepend "gnome-mime-" */
|
||||
icon_name = g_string_new ("gnome-mime-");
|
||||
g_string_append_len (icon_name, mime_type, separator - mime_type);
|
||||
g_string_append_c (icon_name, '-');
|
||||
g_string_append (icon_name, separator + 1);
|
||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
||||
pixel_size,
|
||||
0,
|
||||
NULL);
|
||||
g_string_free (icon_name, TRUE);
|
||||
if (pixbuf)
|
||||
return pixbuf;
|
||||
|
||||
/* try the MIME family icon */
|
||||
icon_name = g_string_new ("gnome-mime-");
|
||||
g_string_append_len (icon_name, mime_type, separator - mime_type);
|
||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
||||
pixel_size,
|
||||
0,
|
||||
NULL);
|
||||
g_string_free (icon_name, TRUE);
|
||||
g_free (content_type);
|
||||
g_object_unref (icon);
|
||||
gtk_icon_info_free (info);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user