[glib] add private header with attribute ids
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Subject: [glib] add private header with attribute ids
- Date: Tue, 30 Jun 2009 07:32:00 +0000 (UTC)
commit ceba40c27d5166a07a0925d2e158ca1809cc1ce3
Author: Benjamin Otte <otte gnome org>
Date: Mon Jun 29 13:55:22 2009 +0200
add private header with attribute ids
attribute ids are generated when the attribute hash is initialized. This
way we can guarantee that the ids match every time.
gio/Makefile.am | 1 +
gio/gfileinfo-priv.h | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++
gio/gfileinfo.c | 79 +++++++++++++++++++++++++++++++++++++++-
3 files changed, 178 insertions(+), 1 deletions(-)
---
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 1376443..59d5264 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -202,6 +202,7 @@ libgio_2_0_la_SOURCES = \
gfileenumerator.c \
gfileicon.c \
gfileinfo.c \
+ gfileinfo-priv.h \
gfileinputstream.c \
gfilemonitor.c \
gfilenamecompleter.c \
diff --git a/gio/gfileinfo-priv.h b/gio/gfileinfo-priv.h
new file mode 100644
index 0000000..f747ece
--- /dev/null
+++ b/gio/gfileinfo-priv.h
@@ -0,0 +1,99 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ * 2009 Benjamin Otte
+ *
+ * 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: Benjamin Otte <otte gnome org>
+ */
+
+#ifndef __G_FILE_INFO_PRIV_H__
+#define __G_FILE_INFO_PRIV_H__
+
+#include "gfileinfo.h"
+
+#define G_FILE_ATTRIBUTE_ID_STANDARD_TYPE (1048576 + 1)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_HIDDEN (1048576 + 2)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_BACKUP (1048576 + 3)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_SYMLINK (1048576 + 4)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_IS_VIRTUAL (1048576 + 5)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_NAME (1048576 + 6)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_DISPLAY_NAME (1048576 + 7)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_EDIT_NAME (1048576 + 8)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_COPY_NAME (1048576 + 9)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_DESCRIPTION (1048576 + 10)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_ICON (1048576 + 11)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_CONTENT_TYPE (1048576 + 12)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_FAST_CONTENT_TYPE (1048576 + 13)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_SIZE (1048576 + 14)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_ALLOCATED_SIZE (1048576 + 15)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_SYMLINK_TARGET (1048576 + 16)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_TARGET_URI (1048576 + 17)
+#define G_FILE_ATTRIBUTE_ID_STANDARD_SORT_ORDER (1048576 + 18)
+#define G_FILE_ATTRIBUTE_ID_ETAG_VALUE (2097152 + 1)
+#define G_FILE_ATTRIBUTE_ID_ID_FILE (3145728 + 1)
+#define G_FILE_ATTRIBUTE_ID_ID_FILESYSTEM (3145728 + 2)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_READ (4194304 + 1)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_WRITE (4194304 + 2)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_EXECUTE (4194304 + 3)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_DELETE (4194304 + 4)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_TRASH (4194304 + 5)
+#define G_FILE_ATTRIBUTE_ID_ACCESS_CAN_RENAME (4194304 + 6)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_MOUNT (5242880 + 1)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_UNMOUNT (5242880 + 2)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_EJECT (5242880 + 3)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_UNIX_DEVICE (5242880 + 4)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_HAL_UDI (5242880 + 5)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_START (5242880 + 6)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_CAN_STOP (5242880 + 7)
+#define G_FILE_ATTRIBUTE_ID_MOUNTABLE_START_STOP_TYPE (5242880 + 8)
+#define G_FILE_ATTRIBUTE_ID_TIME_MODIFIED (6291456 + 1)
+#define G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_USEC (6291456 + 2)
+#define G_FILE_ATTRIBUTE_ID_TIME_ACCESS (6291456 + 3)
+#define G_FILE_ATTRIBUTE_ID_TIME_ACCESS_USEC (6291456 + 4)
+#define G_FILE_ATTRIBUTE_ID_TIME_CHANGED (6291456 + 5)
+#define G_FILE_ATTRIBUTE_ID_TIME_CHANGED_USEC (6291456 + 6)
+#define G_FILE_ATTRIBUTE_ID_TIME_CREATED (6291456 + 7)
+#define G_FILE_ATTRIBUTE_ID_TIME_CREATED_USEC (6291456 + 8)
+#define G_FILE_ATTRIBUTE_ID_UNIX_DEVICE (7340032 + 1)
+#define G_FILE_ATTRIBUTE_ID_UNIX_INODE (7340032 + 2)
+#define G_FILE_ATTRIBUTE_ID_UNIX_MODE (7340032 + 3)
+#define G_FILE_ATTRIBUTE_ID_UNIX_NLINK (7340032 + 4)
+#define G_FILE_ATTRIBUTE_ID_UNIX_UID (7340032 + 5)
+#define G_FILE_ATTRIBUTE_ID_UNIX_GID (7340032 + 6)
+#define G_FILE_ATTRIBUTE_ID_UNIX_RDEV (7340032 + 7)
+#define G_FILE_ATTRIBUTE_ID_UNIX_BLOCK_SIZE (7340032 + 8)
+#define G_FILE_ATTRIBUTE_ID_UNIX_BLOCKS (7340032 + 9)
+#define G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT (7340032 + 10)
+#define G_FILE_ATTRIBUTE_ID_DOS_IS_ARCHIVE (8388608 + 1)
+#define G_FILE_ATTRIBUTE_ID_DOS_IS_SYSTEM (8388608 + 2)
+#define G_FILE_ATTRIBUTE_ID_OWNER_USER (9437184 + 1)
+#define G_FILE_ATTRIBUTE_ID_OWNER_USER_REAL (9437184 + 2)
+#define G_FILE_ATTRIBUTE_ID_OWNER_GROUP (9437184 + 3)
+#define G_FILE_ATTRIBUTE_ID_THUMBNAIL_PATH (10485760 + 1)
+#define G_FILE_ATTRIBUTE_ID_THUMBNAILING_FAILED (10485760 + 2)
+#define G_FILE_ATTRIBUTE_ID_PREVIEW_ICON (11534336 + 1)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_SIZE (12582912 + 1)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_FREE (12582912 + 2)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_TYPE (12582912 + 3)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_READONLY (12582912 + 4)
+#define G_FILE_ATTRIBUTE_ID_FILESYSTEM_USE_PREVIEW (12582912 + 5)
+#define G_FILE_ATTRIBUTE_ID_GVFS_BACKEND (13631488 + 1)
+#define G_FILE_ATTRIBUTE_ID_SELINUX_CONTEXT (14680064 + 1)
+#define G_FILE_ATTRIBUTE_ID_TRASH_ITEM_COUNT (15728640 + 1)
+
+#endif /* __G_FILE_INFO_PRIV_H__ */
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index 2382b02..c5b8ca8 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -57,6 +57,7 @@
#include <string.h>
#include "gfileinfo.h"
+#include "gfileinfo-priv.h"
#include "gfileattribute-priv.h"
#include "gicon.h"
#include "glibintl.h"
@@ -182,7 +183,83 @@ ensure_attribute_hash (void)
ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
+#define REGISTER_ATTRIBUTE(name) G_STMT_START{\
+ guint _u = _lookup_attribute (G_FILE_ATTRIBUTE_ ## name); \
+ /* use for generating the ID: g_print ("#define G_FILE_ATTRIBUTE_ID_%s (%u + %u)\n", #name + 17, _u & ~ID_MASK, _u & ID_MASK); */ \
+ g_assert (_u == G_FILE_ATTRIBUTE_ID_ ## name); \
+}G_STMT_END
+
+ REGISTER_ATTRIBUTE (STANDARD_TYPE);
+ REGISTER_ATTRIBUTE (STANDARD_IS_HIDDEN);
+ REGISTER_ATTRIBUTE (STANDARD_IS_BACKUP);
+ REGISTER_ATTRIBUTE (STANDARD_IS_SYMLINK);
+ REGISTER_ATTRIBUTE (STANDARD_IS_VIRTUAL);
+ REGISTER_ATTRIBUTE (STANDARD_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_DISPLAY_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_EDIT_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_COPY_NAME);
+ REGISTER_ATTRIBUTE (STANDARD_DESCRIPTION);
+ REGISTER_ATTRIBUTE (STANDARD_ICON);
+ REGISTER_ATTRIBUTE (STANDARD_CONTENT_TYPE);
+ REGISTER_ATTRIBUTE (STANDARD_FAST_CONTENT_TYPE);
+ REGISTER_ATTRIBUTE (STANDARD_SIZE);
+ REGISTER_ATTRIBUTE (STANDARD_ALLOCATED_SIZE);
+ REGISTER_ATTRIBUTE (STANDARD_SYMLINK_TARGET);
+ REGISTER_ATTRIBUTE (STANDARD_TARGET_URI);
+ REGISTER_ATTRIBUTE (STANDARD_SORT_ORDER);
+ REGISTER_ATTRIBUTE (ETAG_VALUE);
+ REGISTER_ATTRIBUTE (ID_FILE);
+ REGISTER_ATTRIBUTE (ID_FILESYSTEM);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_READ);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_WRITE);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_EXECUTE);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_DELETE);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_TRASH);
+ REGISTER_ATTRIBUTE (ACCESS_CAN_RENAME);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_MOUNT);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_UNMOUNT);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_EJECT);
+ REGISTER_ATTRIBUTE (MOUNTABLE_UNIX_DEVICE);
+ REGISTER_ATTRIBUTE (MOUNTABLE_HAL_UDI);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_START);
+ REGISTER_ATTRIBUTE (MOUNTABLE_CAN_STOP);
+ REGISTER_ATTRIBUTE (MOUNTABLE_START_STOP_TYPE);
+ REGISTER_ATTRIBUTE (TIME_MODIFIED);
+ REGISTER_ATTRIBUTE (TIME_MODIFIED_USEC);
+ REGISTER_ATTRIBUTE (TIME_ACCESS);
+ REGISTER_ATTRIBUTE (TIME_ACCESS_USEC);
+ REGISTER_ATTRIBUTE (TIME_CHANGED);
+ REGISTER_ATTRIBUTE (TIME_CHANGED_USEC);
+ REGISTER_ATTRIBUTE (TIME_CREATED);
+ REGISTER_ATTRIBUTE (TIME_CREATED_USEC);
+ REGISTER_ATTRIBUTE (UNIX_DEVICE);
+ REGISTER_ATTRIBUTE (UNIX_INODE);
+ REGISTER_ATTRIBUTE (UNIX_MODE);
+ REGISTER_ATTRIBUTE (UNIX_NLINK);
+ REGISTER_ATTRIBUTE (UNIX_UID);
+ REGISTER_ATTRIBUTE (UNIX_GID);
+ REGISTER_ATTRIBUTE (UNIX_RDEV);
+ REGISTER_ATTRIBUTE (UNIX_BLOCK_SIZE);
+ REGISTER_ATTRIBUTE (UNIX_BLOCKS);
+ REGISTER_ATTRIBUTE (UNIX_IS_MOUNTPOINT);
+ REGISTER_ATTRIBUTE (DOS_IS_ARCHIVE);
+ REGISTER_ATTRIBUTE (DOS_IS_SYSTEM);
+ REGISTER_ATTRIBUTE (OWNER_USER);
+ REGISTER_ATTRIBUTE (OWNER_USER_REAL);
+ REGISTER_ATTRIBUTE (OWNER_GROUP);
+ REGISTER_ATTRIBUTE (THUMBNAIL_PATH);
+ REGISTER_ATTRIBUTE (THUMBNAILING_FAILED);
+ REGISTER_ATTRIBUTE (PREVIEW_ICON);
+ REGISTER_ATTRIBUTE (FILESYSTEM_SIZE);
+ REGISTER_ATTRIBUTE (FILESYSTEM_FREE);
+ REGISTER_ATTRIBUTE (FILESYSTEM_TYPE);
+ REGISTER_ATTRIBUTE (FILESYSTEM_READONLY);
+ REGISTER_ATTRIBUTE (FILESYSTEM_USE_PREVIEW);
+ REGISTER_ATTRIBUTE (GVFS_BACKEND);
+ REGISTER_ATTRIBUTE (SELINUX_CONTEXT);
+ REGISTER_ATTRIBUTE (TRASH_ITEM_COUNT);
+
+#undef REGISTER_ATTRIBUTE
}
static guint32
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]