Blame src/nautilus-metadata.c

Packit a189e0
/* nautilus-metadata.c - metadata utils
Packit a189e0
 *
Packit a189e0
 * Copyright (C) 2009 Red Hatl, Inc.
Packit a189e0
 *
Packit a189e0
 * This library is free software; you can redistribute it and/or
Packit a189e0
 * modify it under the terms of the GNU Library General Public
Packit a189e0
 * License as published by the Free Software Foundation; either
Packit a189e0
 * version 2 of the License, or (at your option) any later version.
Packit a189e0
 *
Packit a189e0
 * This library is distributed in the hope that it will be useful,
Packit a189e0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a189e0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a189e0
 * Library General Public License for more details.
Packit a189e0
 *
Packit a189e0
 * You should have received a copy of the GNU Library General Public
Packit a189e0
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit a189e0
 */
Packit a189e0
Packit a189e0
#include <config.h>
Packit a189e0
#include "nautilus-metadata.h"
Packit a189e0
#include <glib.h>
Packit a189e0
Packit a189e0
static char *used_metadata_names[] =
Packit a189e0
{
Packit a189e0
    NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY,
Packit a189e0
    NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED,
Packit a189e0
    NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN,
Packit a189e0
    NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED,
Packit a189e0
    NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS,
Packit a189e0
    NAUTILUS_METADATA_KEY_LIST_VIEW_COLUMN_ORDER,
Packit a189e0
    NAUTILUS_METADATA_KEY_CUSTOM_ICON,
Packit a189e0
    NAUTILUS_METADATA_KEY_CUSTOM_ICON_NAME,
Packit a189e0
    NAUTILUS_METADATA_KEY_EMBLEMS,
Packit a189e0
    NAUTILUS_METADATA_KEY_DESKTOP_FILE_TRUSTED,
Packit a189e0
    NULL
Packit a189e0
};
Packit a189e0
Packit a189e0
guint
Packit a189e0
nautilus_metadata_get_id (const char *metadata)
Packit a189e0
{
Packit a189e0
    static GHashTable *hash;
Packit a189e0
    int i;
Packit a189e0
Packit a189e0
    if (hash == NULL)
Packit a189e0
    {
Packit a189e0
        hash = g_hash_table_new (g_str_hash, g_str_equal);
Packit a189e0
        for (i = 0; used_metadata_names[i] != NULL; i++)
Packit a189e0
        {
Packit a189e0
            g_hash_table_insert (hash,
Packit a189e0
                                 used_metadata_names[i],
Packit a189e0
                                 GINT_TO_POINTER (i + 1));
Packit a189e0
        }
Packit a189e0
    }
Packit a189e0
Packit a189e0
    return GPOINTER_TO_INT (g_hash_table_lookup (hash, metadata));
Packit a189e0
}