* @include: gio/gio.h
*
* A content type is a platform specific string that defines the type
- * of a file. On UNIX it is a <ulink url="http://www.wikipedia.org/wiki/Internet_media_type">mime type</ulink> like "text/plain" or "image/png".
+ * of a file. On UNIX it is a
+ * [mime type](http://www.wikipedia.org/wiki/Internet_media_type)
+ * like "text/plain" or "image/png".
* On Win32 it is an extension string like ".doc", ".txt" or a perceived
* string like "audio". Such strings can be looked up in the registry at
* HKEY_CLASSES_ROOT.
*
* Gets the mime type for the content type, if one is registered.
*
- * Returns: (allow-none): the registered mime type for the given @type,
+ * Returns: (nullable): the registered mime type for the given @type,
* or %NULL if unknown.
*/
char *
return g_strdup (type);
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-
static GIcon *
g_content_type_get_icon_internal (const gchar *type,
gboolean symbolic)
char *mimetype_icon;
char *generic_mimetype_icon = NULL;
char *q;
- char *xdg_mimetype_icon = NULL;
- char *xdg_mimetype_generic_icon;
- char *icon_names[3];
+ char *icon_names[6];
int n = 0;
GIcon *themed_icon;
const char *xdg_icon;
- const char *suffix;
+ int i;
g_return_val_if_fail (type != NULL, NULL);
- if (symbolic)
- suffix = "-symbolic";
- else
- suffix = "";
-
G_LOCK (gio_xdgmime);
xdg_icon = xdg_mime_get_icon (type);
G_UNLOCK (gio_xdgmime);
- if (xdg_icon != NULL)
- xdg_mimetype_icon = g_strconcat (xdg_icon, suffix, NULL);
- if (xdg_mimetype_icon)
- icon_names[n++] = xdg_mimetype_icon;
+ if (xdg_icon)
+ icon_names[n++] = g_strdup (xdg_icon);
- mimetype_icon = g_strconcat (type, suffix, NULL);
+ mimetype_icon = g_strdup (type);
while ((q = strchr (mimetype_icon, '/')) != NULL)
*q = '-';
icon_names[n++] = mimetype_icon;
- xdg_mimetype_generic_icon = g_content_type_get_generic_icon_name (type);
- if (xdg_mimetype_generic_icon)
- generic_mimetype_icon = g_strconcat (xdg_mimetype_generic_icon, suffix, NULL);
+ generic_mimetype_icon = g_content_type_get_generic_icon_name (type);
if (generic_mimetype_icon)
icon_names[n++] = generic_mimetype_icon;
+ if (symbolic)
+ {
+ for (i = 0; i < n; i++)
+ {
+ icon_names[n + i] = icon_names[i];
+ icon_names[i] = g_strconcat (icon_names[i], "-symbolic", NULL);
+ }
+
+ n += n;
+ }
+
themed_icon = g_themed_icon_new_from_names (icon_names, n);
- g_free (xdg_mimetype_icon);
- g_free (xdg_mimetype_generic_icon);
- g_free (mimetype_icon);
- g_free (generic_mimetype_icon);
+ for (i = 0; i < n; i++)
+ g_free (icon_names[i]);
return themed_icon;
}
-#pragma GCC diagnostic pop
/**
* g_content_type_get_icon:
*
* Gets the generic icon name for a content type.
*
- * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
+ * See the
+ * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
* specification for more on the generic icon name.
*
* Returns: (allow-none): the registered generic icon name for the given @type,
*
* Tries to find a content type based on the mime type name.
*
- * Returns: (allow-none): Newly allocated string with content type
- * or %NULL. Free with g_free()
+ * Returns: (nullable): Newly allocated string with content type or
+ * %NULL. Free with g_free()
*
* Since: 2.18
**/
*
* The types returned all have the form x-content/foo, e.g.
* x-content/audio-cdda (for audio CDs) or x-content/image-dcf
- * (for a camera memory card). See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
+ * (for a camera memory card). See the
+ * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
* specification for more on x-content types.
*
* This function is useful in the implementation of