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
2008-02-21 13:35:05 +01:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
/* GIO - GLib Input, Output and Streaming Library
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006-2007 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General
|
|
|
|
* Public License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Author: Alexander Larsson <alexl@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2008-06-22 17:10:51 +02:00
|
|
|
#include "config.h"
|
2007-11-26 17:13:05 +01:00
|
|
|
#include <sys/types.h>
|
2008-07-18 17:33:22 +02:00
|
|
|
#include <stdlib.h>
|
2007-11-26 17:13:05 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "gcontenttypeprivate.h"
|
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
2008-02-21 13:35:05 +01:00
|
|
|
#include "gthemedicon.h"
|
2008-07-02 03:54:16 +02:00
|
|
|
#include "gicon.h"
|
2008-07-18 17:33:22 +02:00
|
|
|
#include "gfile.h"
|
|
|
|
#include "gfileenumerator.h"
|
|
|
|
#include "gfileinfo.h"
|
2007-11-26 17:13:05 +01:00
|
|
|
#include "glibintl.h"
|
|
|
|
|
2007-11-28 13:39:07 +01:00
|
|
|
#include "gioalias.h"
|
|
|
|
|
2007-11-27 15:00:13 +01:00
|
|
|
/**
|
|
|
|
* SECTION:gcontenttype
|
2007-12-01 05:38:29 +01:00
|
|
|
* @short_description: Platform-specific content typing
|
2008-02-21 19:20:17 +01:00
|
|
|
* @include: gio/gio.h
|
2007-11-27 15:00:13 +01:00
|
|
|
*
|
|
|
|
* A content type is a platform specific string that defines the type
|
|
|
|
* of a file. On unix it is a mime type, on win32 it is an extension string
|
|
|
|
* like ".doc", ".txt" or a percieved string like "audio". Such strings
|
|
|
|
* can be looked up in the registry at HKEY_CLASSES_ROOT.
|
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
static char *
|
2007-11-29 08:17:59 +01:00
|
|
|
get_registry_classes_key (const char *subdir,
|
2007-11-26 17:13:05 +01:00
|
|
|
const wchar_t *key_name)
|
|
|
|
{
|
|
|
|
wchar_t *wc_key;
|
|
|
|
HKEY reg_key = NULL;
|
|
|
|
DWORD key_type;
|
|
|
|
DWORD nbytes;
|
|
|
|
char *value_utf8;
|
|
|
|
|
|
|
|
value_utf8 = NULL;
|
|
|
|
|
|
|
|
nbytes = 0;
|
|
|
|
wc_key = g_utf8_to_utf16 (subdir, -1, NULL, NULL, NULL);
|
|
|
|
if (RegOpenKeyExW (HKEY_CLASSES_ROOT, wc_key, 0,
|
|
|
|
KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS &&
|
|
|
|
RegQueryValueExW (reg_key, key_name, 0,
|
|
|
|
&key_type, NULL, &nbytes) == ERROR_SUCCESS &&
|
2008-06-16 15:23:14 +02:00
|
|
|
(key_type == REG_SZ || key_type == REG_EXPAND_SZ))
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
wchar_t *wc_temp = g_new (wchar_t, (nbytes+1)/2 + 1);
|
|
|
|
RegQueryValueExW (reg_key, key_name, 0,
|
|
|
|
&key_type, (LPBYTE) wc_temp, &nbytes);
|
|
|
|
wc_temp[nbytes/2] = '\0';
|
2008-06-16 15:23:14 +02:00
|
|
|
if (key_type == REG_EXPAND_SZ)
|
|
|
|
{
|
|
|
|
wchar_t dummy[1];
|
|
|
|
int len = ExpandEnvironmentStringsW (wc_temp, dummy, 1);
|
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
wchar_t *wc_temp_expanded = g_new (wchar_t, len);
|
|
|
|
if (ExpandEnvironmentStringsW (wc_temp, wc_temp_expanded, len) == len)
|
|
|
|
value_utf8 = g_utf16_to_utf8 (wc_temp_expanded, -1, NULL, NULL, NULL);
|
|
|
|
g_free (wc_temp_expanded);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value_utf8 = g_utf16_to_utf8 (wc_temp, -1, NULL, NULL, NULL);
|
|
|
|
}
|
2007-11-26 17:13:05 +01:00
|
|
|
g_free (wc_temp);
|
2008-06-16 15:23:14 +02:00
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
}
|
|
|
|
g_free (wc_key);
|
|
|
|
|
|
|
|
if (reg_key != NULL)
|
|
|
|
RegCloseKey (reg_key);
|
|
|
|
|
|
|
|
return value_utf8;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
g_content_type_equals (const char *type1,
|
|
|
|
const char *type2)
|
|
|
|
{
|
|
|
|
char *progid1, *progid2;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (type1 != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (type2 != NULL, FALSE);
|
|
|
|
|
|
|
|
if (g_ascii_strcasecmp (type1, type2) == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
res = FALSE;
|
|
|
|
progid1 = get_registry_classes_key (type1, NULL);
|
|
|
|
progid2 = get_registry_classes_key (type2, NULL);
|
|
|
|
if (progid1 != NULL && progid2 != NULL &&
|
|
|
|
strcmp (progid1, progid2) == 0)
|
|
|
|
res = TRUE;
|
|
|
|
g_free (progid1);
|
|
|
|
g_free (progid2);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_is_a (const char *type,
|
|
|
|
const char *supertype)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
char *value_utf8;
|
|
|
|
|
|
|
|
g_return_val_if_fail (type != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (supertype != NULL, FALSE);
|
|
|
|
|
|
|
|
if (g_content_type_equals (type, supertype))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
res = FALSE;
|
|
|
|
value_utf8 = get_registry_classes_key (type, L"PerceivedType");
|
|
|
|
if (value_utf8 && strcmp (value_utf8, supertype) == 0)
|
|
|
|
res = TRUE;
|
|
|
|
g_free (value_utf8);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
g_content_type_is_unknown (const char *type)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (type != NULL, FALSE);
|
|
|
|
|
|
|
|
return strcmp ("*", type) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
g_content_type_get_description (const char *type)
|
|
|
|
{
|
|
|
|
char *progid;
|
|
|
|
char *description;
|
|
|
|
|
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
|
|
|
|
|
|
|
progid = get_registry_classes_key (type, NULL);
|
|
|
|
if (progid)
|
|
|
|
{
|
|
|
|
description = get_registry_classes_key (progid, NULL);
|
|
|
|
g_free (progid);
|
|
|
|
|
|
|
|
if (description)
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_content_type_is_unknown (type))
|
|
|
|
return g_strdup (_("Unknown type"));
|
|
|
|
return g_strdup_printf (_("%s filetype"), type);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_get_mime_type (const char *type)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
char *mime;
|
|
|
|
|
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
|
|
|
|
|
|
|
mime = get_registry_classes_key (type, L"Content Type");
|
|
|
|
if (mime)
|
|
|
|
return mime;
|
|
|
|
else if (g_content_type_is_unknown (type))
|
|
|
|
return g_strdup ("application/octet-stream");
|
|
|
|
else if (*type == '.')
|
|
|
|
return g_strdup_printf ("application/x-ext-%s", type+1);
|
|
|
|
/* TODO: Map "image" to "image/ *", etc? */
|
|
|
|
|
|
|
|
return g_strdup ("application/octet-stream");
|
|
|
|
}
|
|
|
|
|
2008-06-16 15:23:14 +02:00
|
|
|
G_LOCK_DEFINE_STATIC (_type_icons);
|
|
|
|
static GHashTable *_type_icons = NULL;
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
GIcon *
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_get_icon (const char *type)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
2008-06-16 15:23:14 +02:00
|
|
|
GIcon *themed_icon;
|
|
|
|
char *name = NULL;
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
|
|
|
|
2008-06-16 15:23:14 +02:00
|
|
|
/* In the Registry icons are the default value of
|
2007-11-26 17:13:05 +01:00
|
|
|
HKEY_CLASSES_ROOT\<progid>\DefaultIcon with typical values like:
|
|
|
|
<type>: <value>
|
|
|
|
REG_EXPAND_SZ: %SystemRoot%\System32\Wscript.exe,3
|
|
|
|
REG_SZ: shimgvw.dll,3
|
|
|
|
*/
|
2008-06-16 15:23:14 +02:00
|
|
|
G_LOCK (_type_icons);
|
|
|
|
if (!_type_icons)
|
|
|
|
_type_icons = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
name = g_hash_table_lookup (_type_icons, type);
|
|
|
|
if (!name && type[0] == '.')
|
|
|
|
{
|
|
|
|
/* double lookup by extension */
|
|
|
|
gchar *key = get_registry_classes_key (type, NULL);
|
|
|
|
if (!key)
|
|
|
|
key = g_strconcat (type+1, "file\\DefaultIcon", NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *key2 = g_strconcat (key, "\\DefaultIcon", NULL);
|
|
|
|
g_free (key);
|
|
|
|
key = key2;
|
|
|
|
}
|
|
|
|
name = get_registry_classes_key (key, NULL);
|
|
|
|
if (name && strcmp (name, "%1") == 0)
|
|
|
|
{
|
|
|
|
g_free (name);
|
|
|
|
name = NULL;
|
|
|
|
}
|
|
|
|
if (name)
|
|
|
|
g_hash_table_insert (_type_icons, g_strdup (type), g_strdup (name));
|
|
|
|
g_free (key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* icon-name similar to how it was with gtk-2-12 */
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
themed_icon = g_themed_icon_new (name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if not found an icon fall back to gtk-builtins */
|
|
|
|
name = strcmp (type, "inode/directory") == 0 ? "gtk-directory" :
|
|
|
|
g_content_type_can_be_executable (type) ? "gtk-execute" : "gtk-file";
|
|
|
|
g_hash_table_insert (_type_icons, g_strdup (type), g_strdup (name));
|
|
|
|
themed_icon = g_themed_icon_new_with_default_fallbacks (name);
|
|
|
|
}
|
|
|
|
G_UNLOCK (_type_icons);
|
|
|
|
|
|
|
|
return G_ICON (themed_icon);
|
2007-11-26 17:13:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_can_be_executable (const char *type)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (type != NULL, FALSE);
|
|
|
|
|
|
|
|
if (strcmp (type, ".exe") == 0 ||
|
|
|
|
strcmp (type, ".com") == 0 ||
|
|
|
|
strcmp (type, ".bat") == 0)
|
|
|
|
return TRUE;
|
2008-06-10 12:34:02 +02:00
|
|
|
|
|
|
|
/* TODO: Also look at PATHEXT, which lists the extensions for
|
|
|
|
* "scripts" in addition to those for true binary executables.
|
|
|
|
*
|
|
|
|
* (PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH for me
|
|
|
|
* right now, for instance). And in a sense, all associated file
|
|
|
|
* types are "executable" on Windows... You can just type foo.jpg as
|
|
|
|
* a command name in cmd.exe, and it will run the application
|
|
|
|
* associated with .jpg. Hard to say what this API actually means
|
|
|
|
* with "executable".
|
|
|
|
*/
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2007-11-29 08:17:59 +01:00
|
|
|
looks_like_text (const guchar *data,
|
|
|
|
gsize data_size)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
gsize i;
|
|
|
|
guchar c;
|
|
|
|
for (i = 0; i < data_size; i++)
|
|
|
|
{
|
|
|
|
c = data[i];
|
|
|
|
if (g_ascii_iscntrl (c) && !g_ascii_isspace (c))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-05-18 04:50:48 +02:00
|
|
|
char *
|
|
|
|
g_content_type_from_mime_type (const char *mime_type)
|
|
|
|
{
|
|
|
|
char *key, *content_type;
|
|
|
|
|
|
|
|
g_return_val_if_fail (mime_type != NULL, NULL);
|
|
|
|
|
|
|
|
key = g_strconcat ("MIME\\DataBase\\Content Type\\", mime_type, NULL);
|
|
|
|
content_type = get_registry_classes_key (key, L"Extension");
|
|
|
|
g_free (key);
|
|
|
|
|
|
|
|
return content_type;
|
|
|
|
}
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
char *
|
|
|
|
g_content_type_guess (const char *filename,
|
|
|
|
const guchar *data,
|
|
|
|
gsize data_size,
|
|
|
|
gboolean *result_uncertain)
|
|
|
|
{
|
|
|
|
char *basename;
|
|
|
|
char *type;
|
|
|
|
char *dot;
|
|
|
|
|
|
|
|
type = NULL;
|
|
|
|
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
basename = g_path_get_basename (filename);
|
|
|
|
dot = strrchr (basename, '.');
|
|
|
|
if (dot)
|
|
|
|
type = g_strdup (dot);
|
|
|
|
g_free (basename);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type)
|
|
|
|
return type;
|
|
|
|
|
|
|
|
if (data && looks_like_text (data, data_size))
|
|
|
|
return g_strdup (".txt");
|
|
|
|
|
|
|
|
return g_strdup ("*");
|
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
g_content_types_get_registered (void)
|
|
|
|
{
|
|
|
|
DWORD index;
|
|
|
|
wchar_t keyname[256];
|
|
|
|
DWORD key_len;
|
|
|
|
char *key_utf8;
|
|
|
|
GList *types;
|
|
|
|
|
|
|
|
types = NULL;
|
|
|
|
index = 0;
|
|
|
|
key_len = 256;
|
|
|
|
while (RegEnumKeyExW(HKEY_CLASSES_ROOT,
|
|
|
|
index,
|
|
|
|
keyname,
|
|
|
|
&key_len,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
key_utf8 = g_utf16_to_utf8 (keyname, -1, NULL, NULL, NULL);
|
|
|
|
if (key_utf8)
|
|
|
|
{
|
|
|
|
if (*key_utf8 == '.')
|
|
|
|
types = g_list_prepend (types, key_utf8);
|
|
|
|
else
|
|
|
|
g_free (key_utf8);
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
key_len = 256;
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_list_reverse (types);
|
|
|
|
}
|
|
|
|
|
2008-07-18 17:33:22 +02:00
|
|
|
char **
|
|
|
|
g_content_type_guess_for_tree (GFile *root)
|
|
|
|
{
|
|
|
|
/* FIXME: implement */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
#else /* !G_OS_WIN32 - Unix specific version */
|
|
|
|
|
2007-12-03 23:37:44 +01:00
|
|
|
#include <dirent.h>
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
#define XDG_PREFIX _gio_xdg
|
|
|
|
#include "xdgmime/xdgmime.h"
|
|
|
|
|
|
|
|
/* We lock this mutex whenever we modify global state in this module. */
|
|
|
|
G_LOCK_DEFINE_STATIC (gio_xdgmime);
|
|
|
|
|
|
|
|
gsize
|
|
|
|
_g_unix_content_type_get_sniff_len (void)
|
|
|
|
{
|
|
|
|
gsize size;
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
size = xdg_mime_get_max_buffer_extents ();
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
_g_unix_content_type_unalias (const char *type)
|
|
|
|
{
|
|
|
|
char *res;
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
res = g_strdup (xdg_mime_unalias_mime_type (type));
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
char **
|
|
|
|
_g_unix_content_type_get_parents (const char *type)
|
|
|
|
{
|
|
|
|
const char *umime;
|
2008-02-01 14:17:04 +01:00
|
|
|
char **parents;
|
2007-11-26 17:13:05 +01:00
|
|
|
GPtrArray *array;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
array = g_ptr_array_new ();
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
umime = xdg_mime_unalias_mime_type (type);
|
2008-01-29 11:20:49 +01:00
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
g_ptr_array_add (array, g_strdup (umime));
|
|
|
|
|
2008-01-29 11:20:49 +01:00
|
|
|
parents = xdg_mime_list_mime_parents (umime);
|
2007-11-26 17:13:05 +01:00
|
|
|
for (i = 0; parents && parents[i] != NULL; i++)
|
|
|
|
g_ptr_array_add (array, g_strdup (parents[i]));
|
|
|
|
|
2008-01-29 11:20:49 +01:00
|
|
|
free (parents);
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
g_ptr_array_add (array, NULL);
|
|
|
|
|
|
|
|
return (char **)g_ptr_array_free (array, FALSE);
|
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_type_equals:
|
|
|
|
* @type1: a content type string.
|
|
|
|
* @type2: a content type string.
|
|
|
|
*
|
|
|
|
* Compares two content types for equality.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the two strings are identical or equivalent,
|
|
|
|
* %FALSE otherwise.
|
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
gboolean
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_equals (const char *type1,
|
|
|
|
const char *type2)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (type1 != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (type2 != NULL, FALSE);
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
res = xdg_mime_mime_type_equal (type1, type2);
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_type_is_a:
|
|
|
|
* @type: a content type string.
|
|
|
|
* @supertype: a string.
|
|
|
|
*
|
|
|
|
* Determines if @type is a subset of @supertype.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @type is a kind of @supertype,
|
|
|
|
* %FALSE otherwise.
|
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
gboolean
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_is_a (const char *type,
|
|
|
|
const char *supertype)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (type != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (supertype != NULL, FALSE);
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
res = xdg_mime_mime_type_subclass (type, supertype);
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_type_is_unknown:
|
|
|
|
* @type: a content type string.
|
|
|
|
*
|
2007-12-12 13:19:02 +01:00
|
|
|
* Checks if the content type is the generic "unknown" type.
|
|
|
|
* On unix this is the "application/octet-stream" mimetype,
|
|
|
|
* while on win32 it is "*".
|
2007-11-28 07:01:13 +01:00
|
|
|
*
|
2007-12-12 13:19:02 +01:00
|
|
|
* Returns: %TRUE if the type is the unknown type.
|
2007-11-28 07:01:13 +01:00
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
gboolean
|
|
|
|
g_content_type_is_unknown (const char *type)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (type != NULL, FALSE);
|
|
|
|
|
|
|
|
return strcmp (XDG_MIME_TYPE_UNKNOWN, type) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
MIME_TAG_TYPE_OTHER,
|
|
|
|
MIME_TAG_TYPE_COMMENT
|
|
|
|
} MimeTagType;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int current_type;
|
|
|
|
int current_lang_level;
|
|
|
|
int comment_lang_level;
|
|
|
|
char *comment;
|
|
|
|
} MimeParser;
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
language_level (const char *lang)
|
|
|
|
{
|
|
|
|
const char * const *lang_list;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* The returned list is sorted from most desirable to least
|
|
|
|
desirable and always contains the default locale "C". */
|
|
|
|
lang_list = g_get_language_names ();
|
|
|
|
|
|
|
|
for (i = 0; lang_list[i]; i++)
|
|
|
|
if (strcmp (lang_list[i], lang) == 0)
|
|
|
|
return 1000-i;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-29 08:17:59 +01:00
|
|
|
mime_info_start_element (GMarkupParseContext *context,
|
|
|
|
const gchar *element_name,
|
|
|
|
const gchar **attribute_names,
|
|
|
|
const gchar **attribute_values,
|
|
|
|
gpointer user_data,
|
|
|
|
GError **error)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const char *lang;
|
|
|
|
MimeParser *parser = user_data;
|
|
|
|
|
|
|
|
if (strcmp (element_name, "comment") == 0)
|
|
|
|
{
|
|
|
|
lang = "C";
|
|
|
|
for (i = 0; attribute_names[i]; i++)
|
|
|
|
if (strcmp (attribute_names[i], "xml:lang") == 0)
|
|
|
|
{
|
|
|
|
lang = attribute_values[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
parser->current_lang_level = language_level (lang);
|
|
|
|
parser->current_type = MIME_TAG_TYPE_COMMENT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
parser->current_type = MIME_TAG_TYPE_OTHER;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-29 08:17:59 +01:00
|
|
|
mime_info_end_element (GMarkupParseContext *context,
|
|
|
|
const gchar *element_name,
|
|
|
|
gpointer user_data,
|
|
|
|
GError **error)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
MimeParser *parser = user_data;
|
|
|
|
|
|
|
|
parser->current_type = MIME_TAG_TYPE_OTHER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-29 08:17:59 +01:00
|
|
|
mime_info_text (GMarkupParseContext *context,
|
|
|
|
const gchar *text,
|
|
|
|
gsize text_len,
|
|
|
|
gpointer user_data,
|
|
|
|
GError **error)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
MimeParser *parser = user_data;
|
|
|
|
|
|
|
|
if (parser->current_type == MIME_TAG_TYPE_COMMENT &&
|
|
|
|
parser->current_lang_level > parser->comment_lang_level)
|
|
|
|
{
|
|
|
|
g_free (parser->comment);
|
|
|
|
parser->comment = g_strndup (text, text_len);
|
|
|
|
parser->comment_lang_level = parser->current_lang_level;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2007-11-29 08:17:59 +01:00
|
|
|
load_comment_for_mime_helper (const char *dir,
|
|
|
|
const char *basename)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
GMarkupParseContext *context;
|
|
|
|
char *filename, *data;
|
|
|
|
gsize len;
|
|
|
|
gboolean res;
|
|
|
|
MimeParser parse_data = {0};
|
|
|
|
GMarkupParser parser = {
|
|
|
|
mime_info_start_element,
|
|
|
|
mime_info_end_element,
|
|
|
|
mime_info_text
|
|
|
|
};
|
|
|
|
|
|
|
|
filename = g_build_filename (dir, "mime", basename, NULL);
|
|
|
|
|
|
|
|
res = g_file_get_contents (filename, &data, &len, NULL);
|
|
|
|
g_free (filename);
|
|
|
|
if (!res)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
context = g_markup_parse_context_new (&parser, 0, &parse_data, NULL);
|
|
|
|
res = g_markup_parse_context_parse (context, data, len, NULL);
|
|
|
|
g_free (data);
|
|
|
|
g_markup_parse_context_free (context);
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return parse_data.comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
load_comment_for_mime (const char *mimetype)
|
|
|
|
{
|
|
|
|
const char * const* dirs;
|
|
|
|
char *basename;
|
|
|
|
char *comment;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
basename = g_strdup_printf ("%s.xml", mimetype);
|
|
|
|
|
|
|
|
comment = load_comment_for_mime_helper (g_get_user_data_dir (), basename);
|
|
|
|
if (comment)
|
|
|
|
{
|
|
|
|
g_free (basename);
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
dirs = g_get_system_data_dirs ();
|
|
|
|
|
|
|
|
for (i = 0; dirs[i] != NULL; i++)
|
|
|
|
{
|
|
|
|
comment = load_comment_for_mime_helper (dirs[i], basename);
|
|
|
|
if (comment)
|
|
|
|
{
|
|
|
|
g_free (basename);
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free (basename);
|
|
|
|
|
|
|
|
return g_strdup_printf (_("%s type"), mimetype);
|
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_type_get_description:
|
|
|
|
* @type: a content type string.
|
|
|
|
*
|
|
|
|
* Gets the human readable description of the content type.
|
|
|
|
*
|
|
|
|
* Returns: a short description of the content type @type.
|
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
char *
|
|
|
|
g_content_type_get_description (const char *type)
|
|
|
|
{
|
|
|
|
static GHashTable *type_comment_cache = NULL;
|
|
|
|
char *comment;
|
|
|
|
|
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
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
2008-02-21 13:35:05 +01:00
|
|
|
type = xdg_mime_unalias_mime_type (type);
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
if (type_comment_cache == NULL)
|
|
|
|
type_comment_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
|
|
|
|
|
|
|
comment = g_hash_table_lookup (type_comment_cache, type);
|
|
|
|
comment = g_strdup (comment);
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
if (comment != NULL)
|
|
|
|
return comment;
|
|
|
|
|
|
|
|
comment = load_comment_for_mime (type);
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
g_hash_table_insert (type_comment_cache,
|
|
|
|
g_strdup (type),
|
|
|
|
g_strdup (comment));
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_type_get_mime_type:
|
|
|
|
* @type: a content type string.
|
|
|
|
*
|
2007-12-12 13:19:02 +01:00
|
|
|
* Gets the mime-type for the content type. If one is registered
|
2007-11-28 07:01:13 +01:00
|
|
|
*
|
2007-12-12 13:19:02 +01:00
|
|
|
* Returns: the registered mime-type for the given @type, or NULL if unknown.
|
2007-11-28 07:01:13 +01:00
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
char *
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_get_mime_type (const char *type)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
|
|
|
|
|
|
|
return g_strdup (type);
|
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_type_get_icon:
|
|
|
|
* @type: a content type string.
|
|
|
|
*
|
|
|
|
* Gets the icon for a content type.
|
|
|
|
*
|
|
|
|
* Returns: #GIcon corresponding to the content type.
|
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
GIcon *
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_get_icon (const char *type)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
2008-02-27 12:23:35 +01:00
|
|
|
char *mimetype_icon, *generic_mimetype_icon, *q;
|
2008-06-09 19:33:43 +02:00
|
|
|
char *xdg_mimetype_icon, *legacy_mimetype_icon;
|
2008-10-10 07:07:56 +02:00
|
|
|
char *xdg_mimetype_generic_icon;
|
2008-06-09 19:33:43 +02:00
|
|
|
char *icon_names[4];
|
2008-06-10 12:51:29 +02:00
|
|
|
int n = 0;
|
2008-02-27 12:23:35 +01:00
|
|
|
const char *p;
|
|
|
|
GIcon *themed_icon;
|
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
2008-02-21 13:35:05 +01:00
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
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
2008-02-21 13:35:05 +01:00
|
|
|
|
2008-06-09 19:33:43 +02:00
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
xdg_mimetype_icon = g_strdup (xdg_mime_get_icon (type));
|
2008-10-10 07:07:56 +02:00
|
|
|
xdg_mimetype_generic_icon = g_strdup (xdg_mime_get_generic_icon (type));
|
2008-06-09 19:33:43 +02:00
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
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
2008-02-21 13:35:05 +01:00
|
|
|
mimetype_icon = g_strdup (type);
|
|
|
|
|
2008-02-27 12:23:35 +01:00
|
|
|
while ((q = strchr (mimetype_icon, '/')) != NULL)
|
|
|
|
*q = '-';
|
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
2008-02-21 13:35:05 +01:00
|
|
|
|
|
|
|
p = strchr (type, '/');
|
|
|
|
if (p == NULL)
|
|
|
|
p = type + strlen (type);
|
2008-06-09 19:33:43 +02:00
|
|
|
|
|
|
|
/* Not all icons have migrated to the new icon theme spec, look for old names too */
|
|
|
|
legacy_mimetype_icon = g_strconcat ("gnome-mime-", mimetype_icon, NULL);
|
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
2008-02-21 13:35:05 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2008-06-09 19:33:43 +02:00
|
|
|
if (xdg_mimetype_icon)
|
|
|
|
icon_names[n++] = xdg_mimetype_icon;
|
|
|
|
|
|
|
|
icon_names[n++] = mimetype_icon;
|
|
|
|
icon_names[n++] = legacy_mimetype_icon;
|
2008-10-10 07:07:56 +02:00
|
|
|
|
|
|
|
if (xdg_mimetype_generic_icon)
|
|
|
|
icon_names[n++] = xdg_mimetype_generic_icon;
|
|
|
|
|
2008-06-09 19:33:43 +02:00
|
|
|
icon_names[n++] = generic_mimetype_icon;
|
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
2008-02-21 13:35:05 +01:00
|
|
|
|
2008-06-09 19:33:43 +02:00
|
|
|
themed_icon = g_themed_icon_new_from_names (icon_names, n);
|
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
2008-02-21 13:35:05 +01:00
|
|
|
|
2008-06-09 19:33:43 +02:00
|
|
|
g_free (xdg_mimetype_icon);
|
2008-11-21 00:58:39 +01:00
|
|
|
g_free (xdg_mimetype_generic_icon);
|
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
2008-02-21 13:35:05 +01:00
|
|
|
g_free (mimetype_icon);
|
2008-06-09 19:33:43 +02:00
|
|
|
g_free (legacy_mimetype_icon);
|
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
2008-02-21 13:35:05 +01:00
|
|
|
g_free (generic_mimetype_icon);
|
|
|
|
|
2008-02-27 12:23:35 +01:00
|
|
|
return themed_icon;
|
2007-11-26 17:13:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* g_content_type_can_be_executable:
|
|
|
|
* @type: a content type string.
|
|
|
|
*
|
2007-11-28 07:01:13 +01:00
|
|
|
* Checks if a content type can be executable. Note that for instance
|
|
|
|
* things like text files can be executables (i.e. scripts and batch files).
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the file type corresponds to a type that
|
|
|
|
* can be executable, %FALSE otherwise.
|
2007-11-26 17:13:05 +01:00
|
|
|
**/
|
|
|
|
gboolean
|
2007-11-29 08:17:59 +01:00
|
|
|
g_content_type_can_be_executable (const char *type)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (type != NULL, FALSE);
|
|
|
|
|
|
|
|
if (g_content_type_is_a (type, "application/x-executable") ||
|
|
|
|
g_content_type_is_a (type, "text/plain"))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
looks_like_text (const guchar *data, gsize data_size)
|
|
|
|
{
|
|
|
|
gsize i;
|
2008-01-29 15:19:46 +01:00
|
|
|
char c;
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
for (i = 0; i < data_size; i++)
|
|
|
|
{
|
2008-01-29 15:19:46 +01:00
|
|
|
c = data[i];
|
|
|
|
|
|
|
|
if (g_ascii_iscntrl (c) &&
|
|
|
|
!g_ascii_isspace (c))
|
2007-11-26 17:13:05 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-05-18 04:50:48 +02:00
|
|
|
/**
|
|
|
|
* g_content_type_from_mime_type:
|
|
|
|
* @mime_type: a mime type string.
|
|
|
|
*
|
|
|
|
* Tries to find a content type based on the mime type name.
|
|
|
|
*
|
|
|
|
* Returns: Newly allocated string with content type or NULL when does not know.
|
|
|
|
*
|
|
|
|
* Since: 2.18
|
|
|
|
**/
|
|
|
|
char *
|
|
|
|
g_content_type_from_mime_type (const char *mime_type)
|
|
|
|
{
|
2008-06-30 06:59:40 +02:00
|
|
|
char *umime;
|
|
|
|
|
2008-05-18 04:50:48 +02:00
|
|
|
g_return_val_if_fail (mime_type != NULL, NULL);
|
|
|
|
|
2008-06-30 06:59:40 +02:00
|
|
|
G_LOCK (gio_xdgmime);
|
2008-05-18 04:50:48 +02:00
|
|
|
/* mime type and content type are same on unixes */
|
2008-06-30 06:59:40 +02:00
|
|
|
umime = g_strdup (xdg_mime_unalias_mime_type (mime_type));
|
2008-07-02 21:06:08 +02:00
|
|
|
G_UNLOCK (gio_xdgmime);
|
2008-06-30 06:59:40 +02:00
|
|
|
|
|
|
|
return umime;
|
2008-05-18 04:50:48 +02:00
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_type_guess:
|
2008-07-18 17:33:22 +02:00
|
|
|
* @filename: a string, or %NULL
|
|
|
|
* @data: a stream of data, or %NULL
|
|
|
|
* @data_size: the size of @data
|
|
|
|
* @result_uncertain: a flag indicating the certainty of the result
|
2007-11-28 07:01:13 +01:00
|
|
|
*
|
|
|
|
* Guesses the content type based on example data. If the function is
|
2008-07-18 17:33:22 +02:00
|
|
|
* uncertain, @result_uncertain will be set to %TRUE. Either @filename
|
|
|
|
* or @data may be %NULL, in which case the guess will be based solely
|
|
|
|
* on the other argument.
|
2007-11-28 07:01:13 +01:00
|
|
|
*
|
|
|
|
* Returns: a string indicating a guessed content type for the
|
|
|
|
* given data.
|
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
char *
|
|
|
|
g_content_type_guess (const char *filename,
|
|
|
|
const guchar *data,
|
|
|
|
gsize data_size,
|
|
|
|
gboolean *result_uncertain)
|
|
|
|
{
|
|
|
|
char *basename;
|
|
|
|
const char *name_mimetypes[10], *sniffed_mimetype;
|
|
|
|
char *mimetype;
|
|
|
|
int i;
|
|
|
|
int n_name_mimetypes;
|
|
|
|
int sniffed_prio;
|
|
|
|
|
|
|
|
sniffed_prio = 0;
|
|
|
|
n_name_mimetypes = 0;
|
|
|
|
sniffed_mimetype = XDG_MIME_TYPE_UNKNOWN;
|
|
|
|
|
|
|
|
if (result_uncertain)
|
|
|
|
*result_uncertain = FALSE;
|
|
|
|
|
|
|
|
G_LOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
if (filename)
|
|
|
|
{
|
2008-09-15 18:06:05 +02:00
|
|
|
i = strlen (filename);
|
2008-09-16 13:36:52 +02:00
|
|
|
if (filename[i - 1] == '/')
|
|
|
|
{
|
|
|
|
name_mimetypes[0] = "inode/directory";
|
|
|
|
name_mimetypes[1] = NULL;
|
|
|
|
n_name_mimetypes = 1;
|
|
|
|
if (result_uncertain)
|
|
|
|
*result_uncertain = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
basename = g_path_get_basename (filename);
|
|
|
|
n_name_mimetypes = xdg_mime_get_mime_types_from_file_name (basename, name_mimetypes, 10);
|
|
|
|
g_free (basename);
|
|
|
|
}
|
2007-11-26 17:13:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Got an extension match, and no conflicts. This is it. */
|
|
|
|
if (n_name_mimetypes == 1)
|
|
|
|
{
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
return g_strdup (name_mimetypes[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
sniffed_mimetype = xdg_mime_get_mime_type_for_data (data, data_size, &sniffed_prio);
|
|
|
|
if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN &&
|
|
|
|
data &&
|
|
|
|
looks_like_text (data, data_size))
|
|
|
|
sniffed_mimetype = "text/plain";
|
2009-02-20 08:46:57 +01:00
|
|
|
|
|
|
|
/* For security reasons we don't ever want to sniff desktop files
|
|
|
|
* where we know the filename and it doesn't have a .desktop extension.
|
|
|
|
* This is because desktop files allow executing any application and
|
|
|
|
* we don't want to make it possible to hide them looking like something
|
|
|
|
* else.
|
|
|
|
*/
|
|
|
|
if (filename != NULL &&
|
|
|
|
strcmp (sniffed_mimetype, "application/x-desktop") == 0)
|
|
|
|
sniffed_mimetype = "text/plain";
|
2007-11-26 17:13:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (n_name_mimetypes == 0)
|
|
|
|
{
|
|
|
|
if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN &&
|
|
|
|
result_uncertain)
|
|
|
|
*result_uncertain = TRUE;
|
|
|
|
|
|
|
|
mimetype = g_strdup (sniffed_mimetype);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mimetype = NULL;
|
|
|
|
if (sniffed_mimetype != XDG_MIME_TYPE_UNKNOWN)
|
|
|
|
{
|
|
|
|
if (sniffed_prio >= 80) /* High priority sniffing match, use that */
|
|
|
|
mimetype = g_strdup (sniffed_mimetype);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* There are conflicts between the name matches and we have a sniffed
|
|
|
|
type, use that as a tie breaker. */
|
|
|
|
|
|
|
|
for (i = 0; i < n_name_mimetypes; i++)
|
|
|
|
{
|
|
|
|
if ( xdg_mime_mime_type_subclass (name_mimetypes[i], sniffed_mimetype))
|
|
|
|
{
|
|
|
|
/* This nametype match is derived from (or the same as) the sniffed type).
|
|
|
|
This is probably it. */
|
|
|
|
mimetype = g_strdup (name_mimetypes[i]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mimetype == NULL)
|
|
|
|
{
|
2008-06-09 19:33:43 +02:00
|
|
|
/* Conflicts, and sniffed type was no help or not there. Guess on the first one */
|
2007-11-26 17:13:05 +01:00
|
|
|
mimetype = g_strdup (name_mimetypes[0]);
|
|
|
|
if (result_uncertain)
|
|
|
|
*result_uncertain = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
G_UNLOCK (gio_xdgmime);
|
|
|
|
|
|
|
|
return mimetype;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-29 08:17:59 +01:00
|
|
|
enumerate_mimetypes_subdir (const char *dir,
|
|
|
|
const char *prefix,
|
|
|
|
GHashTable *mimetypes)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
DIR *d;
|
|
|
|
struct dirent *ent;
|
|
|
|
char *mimetype;
|
|
|
|
|
|
|
|
d = opendir (dir);
|
|
|
|
if (d)
|
|
|
|
{
|
|
|
|
while ((ent = readdir (d)) != NULL)
|
|
|
|
{
|
|
|
|
if (g_str_has_suffix (ent->d_name, ".xml"))
|
|
|
|
{
|
|
|
|
mimetype = g_strdup_printf ("%s/%.*s", prefix, (int) strlen (ent->d_name) - 4, ent->d_name);
|
2008-10-20 18:49:16 +02:00
|
|
|
g_hash_table_replace (mimetypes, mimetype, NULL);
|
2007-11-26 17:13:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir (d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-29 08:17:59 +01:00
|
|
|
enumerate_mimetypes_dir (const char *dir,
|
|
|
|
GHashTable *mimetypes)
|
2007-11-26 17:13:05 +01:00
|
|
|
{
|
|
|
|
DIR *d;
|
|
|
|
struct dirent *ent;
|
|
|
|
char *mimedir;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
mimedir = g_build_filename (dir, "mime", NULL);
|
|
|
|
|
|
|
|
d = opendir (mimedir);
|
|
|
|
if (d)
|
|
|
|
{
|
|
|
|
while ((ent = readdir (d)) != NULL)
|
|
|
|
{
|
|
|
|
if (strcmp (ent->d_name, "packages") != 0)
|
|
|
|
{
|
|
|
|
name = g_build_filename (mimedir, ent->d_name, NULL);
|
|
|
|
if (g_file_test (name, G_FILE_TEST_IS_DIR))
|
|
|
|
enumerate_mimetypes_subdir (name, ent->d_name, mimetypes);
|
|
|
|
g_free (name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir (d);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (mimedir);
|
|
|
|
}
|
|
|
|
|
2007-11-28 07:01:13 +01:00
|
|
|
/**
|
|
|
|
* g_content_types_get_registered:
|
|
|
|
*
|
2007-12-12 13:19:02 +01:00
|
|
|
* Gets a list of strings containing all the registered content types
|
2007-12-31 11:00:52 +01:00
|
|
|
* known to the system. The list and its data should be freed using
|
|
|
|
* @g_list_foreach(list, g_free, NULL) and @g_list_free(list)
|
2007-11-28 07:01:13 +01:00
|
|
|
* Returns: #GList of the registered content types.
|
|
|
|
**/
|
2007-11-26 17:13:05 +01:00
|
|
|
GList *
|
|
|
|
g_content_types_get_registered (void)
|
|
|
|
{
|
|
|
|
const char * const* dirs;
|
|
|
|
GHashTable *mimetypes;
|
2007-12-15 05:39:26 +01:00
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key;
|
2007-11-26 17:13:05 +01:00
|
|
|
int i;
|
|
|
|
GList *l;
|
|
|
|
|
2008-10-20 18:49:16 +02:00
|
|
|
mimetypes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
2007-11-26 17:13:05 +01:00
|
|
|
|
|
|
|
enumerate_mimetypes_dir (g_get_user_data_dir (), mimetypes);
|
|
|
|
dirs = g_get_system_data_dirs ();
|
|
|
|
|
|
|
|
for (i = 0; dirs[i] != NULL; i++)
|
|
|
|
enumerate_mimetypes_dir (dirs[i], mimetypes);
|
|
|
|
|
|
|
|
l = NULL;
|
2007-12-15 05:39:26 +01:00
|
|
|
g_hash_table_iter_init (&iter, mimetypes);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, NULL))
|
2008-10-20 18:49:16 +02:00
|
|
|
{
|
|
|
|
l = g_list_prepend (l, key);
|
|
|
|
g_hash_table_iter_steal (&iter);
|
|
|
|
}
|
2007-12-15 05:39:26 +01:00
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
g_hash_table_destroy (mimetypes);
|
|
|
|
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
2008-07-18 17:33:22 +02:00
|
|
|
|
|
|
|
/* tree magic data */
|
|
|
|
static GList *tree_matches = NULL;
|
|
|
|
static gboolean need_reload = FALSE;
|
|
|
|
|
|
|
|
G_LOCK_DEFINE_STATIC (gio_treemagic);
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gchar *path;
|
|
|
|
GFileType type;
|
|
|
|
guint match_case : 1;
|
|
|
|
guint executable : 1;
|
|
|
|
guint non_empty : 1;
|
|
|
|
guint on_disc : 1;
|
|
|
|
gchar *mimetype;
|
|
|
|
GList *matches;
|
|
|
|
} TreeMatchlet;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gchar *contenttype;
|
|
|
|
gint priority;
|
|
|
|
GList *matches;
|
|
|
|
} TreeMatch;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_matchlet_free (TreeMatchlet *matchlet)
|
|
|
|
{
|
|
|
|
g_list_foreach (matchlet->matches, (GFunc)tree_matchlet_free, NULL);
|
|
|
|
g_list_free (matchlet->matches);
|
|
|
|
g_free (matchlet->path);
|
|
|
|
g_free (matchlet->mimetype);
|
|
|
|
g_slice_free (TreeMatchlet, matchlet);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_match_free (TreeMatch *match)
|
|
|
|
{
|
|
|
|
g_list_foreach (match->matches, (GFunc)tree_matchlet_free, NULL);
|
|
|
|
g_list_free (match->matches);
|
|
|
|
g_free (match->contenttype);
|
|
|
|
g_slice_free (TreeMatch, match);
|
|
|
|
}
|
|
|
|
|
|
|
|
static TreeMatch *
|
|
|
|
parse_header (gchar *line)
|
|
|
|
{
|
|
|
|
gint len;
|
|
|
|
gchar *s;
|
|
|
|
TreeMatch *match;
|
|
|
|
|
|
|
|
len = strlen (line);
|
|
|
|
|
|
|
|
if (line[0] != '[' || line[len - 1] != ']')
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
line[len - 1] = 0;
|
|
|
|
s = strchr (line, ':');
|
|
|
|
|
|
|
|
match = g_slice_new0 (TreeMatch);
|
|
|
|
match->priority = atoi (line + 1);
|
|
|
|
match->contenttype = g_strdup (s + 1);
|
|
|
|
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
|
|
|
static TreeMatchlet *
|
|
|
|
parse_match_line (gchar *line,
|
|
|
|
gint *depth)
|
|
|
|
{
|
|
|
|
gchar *s, *p;
|
|
|
|
TreeMatchlet *matchlet;
|
|
|
|
gchar **parts;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
matchlet = g_slice_new0 (TreeMatchlet);
|
|
|
|
|
|
|
|
if (line[0] == '>')
|
|
|
|
{
|
|
|
|
*depth = 0;
|
|
|
|
s = line;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*depth = atoi (line);
|
|
|
|
s = strchr (line, '>');
|
|
|
|
}
|
|
|
|
s += 2;
|
|
|
|
p = strchr (s, '"');
|
|
|
|
*p = 0;
|
|
|
|
|
|
|
|
matchlet->path = g_strdup (s);
|
|
|
|
s = p + 1;
|
|
|
|
parts = g_strsplit (s, ",", 0);
|
|
|
|
if (strcmp (parts[0], "=file") == 0)
|
|
|
|
matchlet->type = G_FILE_TYPE_REGULAR;
|
|
|
|
else if (strcmp (parts[0], "=directory") == 0)
|
|
|
|
matchlet->type = G_FILE_TYPE_DIRECTORY;
|
|
|
|
else if (strcmp (parts[0], "=link") == 0)
|
|
|
|
matchlet->type = G_FILE_TYPE_SYMBOLIC_LINK;
|
|
|
|
else
|
|
|
|
matchlet->type = G_FILE_TYPE_UNKNOWN;
|
|
|
|
for (i = 1; parts[i]; i++)
|
|
|
|
{
|
|
|
|
if (strcmp (parts[i], "executable") == 0)
|
|
|
|
matchlet->executable = 1;
|
|
|
|
else if (strcmp (parts[i], "match-case") == 0)
|
|
|
|
matchlet->match_case = 1;
|
|
|
|
else if (strcmp (parts[i], "non-empty") == 0)
|
|
|
|
matchlet->non_empty = 1;
|
|
|
|
else if (strcmp (parts[i], "on-disc") == 0)
|
|
|
|
matchlet->on_disc = 1;
|
|
|
|
else
|
|
|
|
matchlet->mimetype = g_strdup (parts[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (parts);
|
|
|
|
|
|
|
|
return matchlet;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
cmp_match (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
const TreeMatch *aa = (const TreeMatch *)a;
|
|
|
|
const TreeMatch *bb = (const TreeMatch *)b;
|
|
|
|
|
|
|
|
return bb->priority - aa->priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
insert_match (TreeMatch *match)
|
|
|
|
{
|
|
|
|
tree_matches = g_list_insert_sorted (tree_matches, match, cmp_match);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
insert_matchlet (TreeMatch *match,
|
|
|
|
TreeMatchlet *matchlet,
|
|
|
|
gint depth)
|
|
|
|
{
|
|
|
|
if (depth == 0)
|
|
|
|
match->matches = g_list_append (match->matches, matchlet);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GList *last;
|
|
|
|
TreeMatchlet *m;
|
|
|
|
|
|
|
|
last = g_list_last (match->matches);
|
|
|
|
if (!last)
|
|
|
|
{
|
|
|
|
tree_matchlet_free (matchlet);
|
|
|
|
g_warning ("can't insert tree matchlet at depth %d", depth);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = (TreeMatchlet *) last->data;
|
|
|
|
while (--depth > 0)
|
|
|
|
{
|
|
|
|
last = g_list_last (m->matches);
|
|
|
|
if (!last)
|
|
|
|
{
|
|
|
|
tree_matchlet_free (matchlet);
|
|
|
|
g_warning ("can't insert tree matchlet at depth %d", depth);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = (TreeMatchlet *) last->data;
|
|
|
|
}
|
|
|
|
m->matches = g_list_append (m->matches, matchlet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
read_tree_magic_from_directory (const gchar *prefix)
|
|
|
|
{
|
|
|
|
gchar *filename;
|
|
|
|
gchar *text;
|
|
|
|
gsize len;
|
|
|
|
gchar **lines;
|
|
|
|
gint i;
|
|
|
|
TreeMatch *match;
|
|
|
|
TreeMatchlet *matchlet;
|
|
|
|
gint depth;
|
|
|
|
|
|
|
|
filename = g_build_filename (prefix, "mime", "treemagic", NULL);
|
|
|
|
|
|
|
|
if (g_file_get_contents (filename, &text, &len, NULL))
|
|
|
|
{
|
|
|
|
if (strcmp (text, "MIME-TreeMagic") == 0)
|
|
|
|
{
|
|
|
|
lines = g_strsplit (text + strlen ("MIME-TreeMagic") + 2, "\n", 0);
|
|
|
|
match = NULL;
|
|
|
|
for (i = 0; lines[i] && lines[i][0]; i++)
|
|
|
|
{
|
|
|
|
if (lines[i][0] == '[')
|
|
|
|
{
|
|
|
|
match = parse_header (lines[i]);
|
|
|
|
insert_match (match);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
matchlet = parse_match_line (lines[i], &depth);
|
|
|
|
insert_matchlet (match, matchlet, depth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (lines);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_warning ("%s: header not found, skipping\n", filename);
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_mime_reload (void *user_data)
|
|
|
|
{
|
|
|
|
need_reload = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_magic_shutdown (void)
|
|
|
|
{
|
|
|
|
g_list_foreach (tree_matches, (GFunc)tree_match_free, NULL);
|
|
|
|
g_list_free (tree_matches);
|
|
|
|
tree_matches = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_magic_init (void)
|
|
|
|
{
|
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
const gchar *dir;
|
|
|
|
const gchar * const * dirs;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
{
|
|
|
|
initialized = TRUE;
|
|
|
|
|
|
|
|
xdg_mime_register_reload_callback (xdg_mime_reload, NULL, NULL);
|
|
|
|
need_reload = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_reload)
|
|
|
|
{
|
|
|
|
need_reload = FALSE;
|
|
|
|
|
|
|
|
tree_magic_shutdown ();
|
|
|
|
|
|
|
|
dir = g_get_user_data_dir ();
|
|
|
|
read_tree_magic_from_directory (dir);
|
|
|
|
dirs = g_get_system_data_dirs ();
|
|
|
|
for (i = 0; dirs[i]; i++)
|
|
|
|
read_tree_magic_from_directory (dirs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* a filtering enumerator */
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gchar *path;
|
|
|
|
gint depth;
|
|
|
|
gboolean ignore_case;
|
|
|
|
gchar **components;
|
|
|
|
gchar **case_components;
|
|
|
|
GFileEnumerator **enumerators;
|
|
|
|
GFile **children;
|
|
|
|
} Enumerator;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
component_match (Enumerator *e,
|
|
|
|
gint depth,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
gchar *case_folded, *key;
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
if (strcmp (name, e->components[depth]) == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (!e->ignore_case)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case_folded = g_utf8_casefold (name, -1);
|
|
|
|
key = g_utf8_collate_key (case_folded, -1);
|
|
|
|
|
|
|
|
found = strcmp (key, e->case_components[depth]) == 0;
|
|
|
|
|
|
|
|
g_free (case_folded);
|
|
|
|
g_free (key);
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GFile *
|
|
|
|
next_match_recurse (Enumerator *e,
|
|
|
|
gint depth)
|
|
|
|
{
|
|
|
|
GFile *file;
|
|
|
|
GFileInfo *info;
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
if (e->enumerators[depth] == NULL)
|
|
|
|
{
|
|
|
|
if (depth > 0)
|
|
|
|
{
|
|
|
|
file = next_match_recurse (e, depth - 1);
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
e->children[depth] = file;
|
|
|
|
e->enumerators[depth] = g_file_enumerate_children (file,
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_NAME,
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (e->enumerators[depth] == NULL)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((info = g_file_enumerator_next_file (e->enumerators[depth], NULL, NULL)))
|
|
|
|
{
|
|
|
|
name = g_file_info_get_name (info);
|
|
|
|
if (component_match (e, depth, name))
|
|
|
|
{
|
|
|
|
file = g_file_get_child (e->children[depth], name);
|
|
|
|
g_object_unref (info);
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
g_object_unref (info);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (e->enumerators[depth]);
|
|
|
|
e->enumerators[depth] = NULL;
|
|
|
|
g_object_unref (e->children[depth]);
|
|
|
|
e->children[depth] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GFile *
|
|
|
|
enumerator_next (Enumerator *e)
|
|
|
|
{
|
|
|
|
return next_match_recurse (e, e->depth - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Enumerator *
|
|
|
|
enumerator_new (GFile *root,
|
|
|
|
const char *path,
|
|
|
|
gboolean ignore_case)
|
|
|
|
{
|
|
|
|
Enumerator *e;
|
|
|
|
gint i;
|
|
|
|
gchar *case_folded;
|
|
|
|
|
|
|
|
e = g_new0 (Enumerator, 1);
|
|
|
|
e->path = g_strdup (path);
|
|
|
|
e->ignore_case = ignore_case;
|
|
|
|
|
|
|
|
e->components = g_strsplit (e->path, G_DIR_SEPARATOR_S, -1);
|
|
|
|
e->depth = g_strv_length (e->components);
|
|
|
|
if (e->ignore_case)
|
|
|
|
{
|
|
|
|
e->case_components = g_new0 (char *, e->depth + 1);
|
|
|
|
for (i = 0; e->components[i]; i++)
|
|
|
|
{
|
|
|
|
case_folded = g_utf8_casefold (e->components[i], -1);
|
|
|
|
e->case_components[i] = g_utf8_collate_key (case_folded, -1);
|
|
|
|
g_free (case_folded);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
e->children = g_new0 (GFile *, e->depth);
|
|
|
|
e->children[0] = g_object_ref (root);
|
|
|
|
e->enumerators = g_new0 (GFileEnumerator *, e->depth);
|
|
|
|
e->enumerators[0] = g_file_enumerate_children (root,
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_NAME,
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
enumerator_free (Enumerator *e)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < e->depth; i++)
|
|
|
|
{
|
|
|
|
if (e->enumerators[i])
|
|
|
|
g_object_unref (e->enumerators[i]);
|
|
|
|
if (e->children[i])
|
|
|
|
g_object_unref (e->children[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (e->enumerators);
|
|
|
|
g_free (e->children);
|
|
|
|
g_strfreev (e->components);
|
|
|
|
if (e->case_components)
|
|
|
|
g_strfreev (e->case_components);
|
|
|
|
g_free (e->path);
|
|
|
|
g_free (e);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
matchlet_match (TreeMatchlet *matchlet,
|
|
|
|
GFile *root)
|
|
|
|
{
|
|
|
|
GFile *file;
|
|
|
|
GFileInfo *info;
|
|
|
|
gboolean result;
|
|
|
|
const gchar *attrs;
|
|
|
|
Enumerator *e;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
e = enumerator_new (root, matchlet->path, !matchlet->match_case);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
file = enumerator_next (e);
|
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
enumerator_free (e);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (matchlet->mimetype)
|
|
|
|
attrs = G_FILE_ATTRIBUTE_STANDARD_TYPE ","
|
|
|
|
G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE ","
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE;
|
|
|
|
else
|
|
|
|
attrs = G_FILE_ATTRIBUTE_STANDARD_TYPE ","
|
|
|
|
G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE;
|
|
|
|
info = g_file_query_info (file,
|
|
|
|
attrs,
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
result = TRUE;
|
|
|
|
|
|
|
|
if (matchlet->type != G_FILE_TYPE_UNKNOWN &&
|
|
|
|
g_file_info_get_file_type (info) != matchlet->type)
|
|
|
|
result = FALSE;
|
|
|
|
|
|
|
|
if (matchlet->executable &&
|
|
|
|
!g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE))
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = FALSE;
|
|
|
|
|
|
|
|
if (result && matchlet->non_empty)
|
|
|
|
{
|
|
|
|
GFileEnumerator *child_enum;
|
|
|
|
GFileInfo *child_info;
|
|
|
|
|
|
|
|
child_enum = g_file_enumerate_children (file,
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_NAME,
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (child_enum)
|
|
|
|
{
|
|
|
|
child_info = g_file_enumerator_next_file (child_enum, NULL, NULL);
|
|
|
|
if (child_info)
|
|
|
|
g_object_unref (child_info);
|
|
|
|
else
|
|
|
|
result = FALSE;
|
|
|
|
g_object_unref (child_enum);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result && matchlet->mimetype)
|
|
|
|
{
|
|
|
|
if (strcmp (matchlet->mimetype, g_file_info_get_content_type (info)) != 0)
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
g_object_unref (file);
|
|
|
|
}
|
|
|
|
while (!result);
|
|
|
|
|
|
|
|
enumerator_free (e);
|
|
|
|
|
|
|
|
if (!matchlet->matches)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
for (l = matchlet->matches; l; l = l->next)
|
|
|
|
{
|
|
|
|
TreeMatchlet *submatchlet;
|
|
|
|
|
|
|
|
submatchlet = l->data;
|
|
|
|
if (matchlet_match (submatchlet, root))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
match_match (TreeMatch *match,
|
|
|
|
GFile *root,
|
|
|
|
GPtrArray *types)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = match->matches; l; l = l->next)
|
|
|
|
{
|
|
|
|
TreeMatchlet *matchlet = l->data;
|
|
|
|
if (matchlet_match (matchlet, root))
|
|
|
|
{
|
|
|
|
g_ptr_array_add (types, g_strdup (match->contenttype));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* g_content_type_guess_for_tree:
|
|
|
|
* @root: the root of the tree to guess a type for
|
|
|
|
*
|
|
|
|
* Tries to guess the type of the tree with root @root, by
|
|
|
|
* looking at the files it contains. The result is an array
|
|
|
|
* of content types, with the best guess coming first.
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
* specification for more on x-content types.
|
|
|
|
*
|
|
|
|
* This function is useful in the implementation of g_mount_guess_content_type().
|
|
|
|
*
|
|
|
|
* Returns: an %NULL-terminated array of zero or more content types, or %NULL.
|
|
|
|
* Free with g_strfreev()
|
|
|
|
*
|
|
|
|
* Since: 2.18
|
|
|
|
*/
|
|
|
|
char **
|
|
|
|
g_content_type_guess_for_tree (GFile *root)
|
|
|
|
{
|
|
|
|
GPtrArray *types;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
types = g_ptr_array_new ();
|
|
|
|
|
|
|
|
G_LOCK (gio_treemagic);
|
|
|
|
|
|
|
|
tree_magic_init ();
|
|
|
|
for (l = tree_matches; l; l = l->next)
|
|
|
|
{
|
|
|
|
TreeMatch *match = l->data;
|
|
|
|
match_match (match, root, types);
|
|
|
|
}
|
|
|
|
|
|
|
|
G_UNLOCK (gio_treemagic);
|
|
|
|
|
|
|
|
g_ptr_array_add (types, NULL);
|
|
|
|
|
|
|
|
return (char **)g_ptr_array_free (types, FALSE);
|
|
|
|
}
|
|
|
|
|
2007-11-26 17:13:05 +01:00
|
|
|
#endif /* Unix version */
|
2007-11-28 13:39:07 +01:00
|
|
|
|
|
|
|
#define __G_CONTENT_TYPE_C__
|
|
|
|
#include "gioaliasdef.c"
|