diff options
author | David Zeuthen <davidz@redhat.com> | 2008-02-21 12:35:05 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2008-02-21 12:35:05 +0000 |
commit | bfda430eff9778c8b2b01c7af8fda19e491c9a7d (patch) | |
tree | ce9b6cc114e68d56705842a2ee1d934c08c36f45 /gio/gcontenttype.c | |
parent | bed0b3654617aff714876dfbca553c40e67986d5 (diff) | |
download | glib-bfda430eff9778c8b2b01c7af8fda19e491c9a7d.tar.gz |
Implement this function by moving bits from glocalfileinfo.c
2008-02-21 David Zeuthen <davidz@redhat.com>
* glocalfileinfo.c: (_g_local_file_info_get):
* gcontenttype.c:
(g_content_type_get_icon): Implement this function by
moving bits from glocalfileinfo.c
(g_content_type_get_description): Unalias before getting
description (#517687)
* gfile.c: (g_file_class_init),
(g_file_query_filesystem_info_async),
(g_file_query_filesystem_info_finish),
(query_filesystem_info_data_free),
(query_filesystem_info_async_thread),
(g_file_real_query_filesystem_info_async),
(g_file_real_query_filesystem_info_finish):
* gfile.h: Implement async version of
g_file_query_filesystem_info()
* gfileinfo.h: Add new attributes for filesystem::use-preview
* gio.symbols: Update
* gthemedicon.c: (g_themed_icon_append_name):
* gthemedicon.h: Add new new convenience function.
* gunionvolumemonitor.c: (g_union_volume_monitor_dispose),
(get_mounts), (get_volumes), (get_connected_drives),
(get_volume_for_uuid), (get_mount_for_uuid),
(g_union_volume_monitor_init), (populate_union_monitor),
(g_volume_monitor_get), (_g_mount_get_for_mount_path),
(g_volume_monitor_adopt_orphan_mount):
* gvolumemonitor.c:
* gvolumemonitor.h: Use recursive locks so it's safe for volume
monitor implementations to call into the main volume monitor. Also
separate object initialization and volume monitor initialization
such that non-native volume monitors can properly adopt their
mounts away.
svn path=/trunk/; revision=6550
Diffstat (limited to 'gio/gcontenttype.c')
-rw-r--r-- | gio/gcontenttype.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c index 2b0f9d0b1..bd63d65a7 100644 --- a/gio/gcontenttype.c +++ b/gio/gcontenttype.c @@ -1,3 +1,5 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + /* GIO - GLib Input, Output and Streaming Library * * Copyright (C) 2006-2007 Red Hat, Inc. @@ -25,6 +27,7 @@ #include <string.h> #include <stdio.h> #include "gcontenttypeprivate.h" +#include "gthemedicon.h" #include "glibintl.h" #include "gioalias.h" @@ -591,6 +594,8 @@ g_content_type_get_description (const char *type) g_return_val_if_fail (type != NULL, NULL); G_LOCK (gio_xdgmime); + type = xdg_mime_unalias_mime_type (type); + if (type_comment_cache == NULL) type_comment_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -639,10 +644,35 @@ g_content_type_get_mime_type (const char *type) GIcon * g_content_type_get_icon (const char *type) { + char *mimetype_icon, *generic_mimetype_icon, *p; + char *icon_names[2]; + GThemedIcon *themed_icon; + g_return_val_if_fail (type != NULL, NULL); - - /* TODO: Implement */ - return NULL; + + mimetype_icon = g_strdup (type); + + while ((p = strchr (mimetype_icon, '/')) != NULL) + *p = '-'; + + p = strchr (type, '/'); + if (p == NULL) + p = type + strlen (type); + + generic_mimetype_icon = g_malloc (p - type + strlen ("-x-generic") + 1); + memcpy (generic_mimetype_icon, type, p - type); + memcpy (generic_mimetype_icon + (p - type), "-x-generic", strlen ("-x-generic")); + generic_mimetype_icon[(p - type) + strlen ("-x-generic")] = 0; + + icon_names[0] = mimetype_icon; + icon_names[1] = generic_mimetype_icon; + + themed_icon = g_themed_icon_new_from_names (icon_names, 2); + + g_free (mimetype_icon); + g_free (generic_mimetype_icon); + + return G_ICON (themed_icon); } /** |