[nautilus] Add new icon flags to use mount icons.
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Add new icon flags to use mount icons.
- Date: Sat, 8 May 2010 12:44:50 +0000 (UTC)
commit 38c5b7ee06b4f8d90689dfd8fa5e010066a0b233
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat May 8 14:35:22 2010 +0200
Add new icon flags to use mount icons.
This will allow us to be more consistent with mount icons around and
refactor some code as well.
libnautilus-private/nautilus-file.c | 42 +++++++++++++++++++++++++++++++---
libnautilus-private/nautilus-file.h | 6 ++++-
2 files changed, 43 insertions(+), 5 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 7890211..c484901 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -4055,7 +4055,9 @@ nautilus_file_get_gicon (NautilusFile *file,
const char * const * names;
const char *name;
GPtrArray *prepend_array;
- GIcon *icon;
+ GMount *mount;
+ GIcon *icon, *mount_icon = NULL, *emblemed_icon;
+ GEmblem *emblem;
int i;
gboolean is_folder = FALSE, is_preview = FALSE, is_inode_directory = FALSE;
@@ -4065,10 +4067,23 @@ nautilus_file_get_gicon (NautilusFile *file,
if (file->details->icon) {
icon = NULL;
-
+
+ /* fetch the mount icon here, we'll use it later */
+ if (flags & NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON ||
+ flags & NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM) {
+ mount = nautilus_file_get_mount (file);
+
+ if (mount != NULL) {
+ mount_icon = g_mount_get_icon (mount);
+ g_object_unref (mount);
+ }
+ }
+
if (((flags & NAUTILUS_FILE_ICON_FLAGS_EMBEDDING_TEXT) ||
(flags & NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT) ||
(flags & NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER) ||
+ (flags & NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON) ||
+ (flags & NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM) ||
((flags & NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING) == 0 &&
nautilus_file_has_open_window (file))) &&
G_IS_THEMED_ICON (file->details->icon)) {
@@ -4120,13 +4135,32 @@ nautilus_file_get_gicon (NautilusFile *file,
g_ptr_array_foreach (prepend_array, (GFunc) prepend_icon_name, icon);
}
- g_ptr_array_free (prepend_array, TRUE);
+ g_ptr_array_free (prepend_array, TRUE);
}
if (icon == NULL) {
icon = g_object_ref (file->details->icon);
}
-
+
+ if ((flags & NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON) &&
+ mount_icon != NULL) {
+ g_object_unref (icon);
+ icon = mount_icon;
+ } else if ((flags & NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM) &&
+ mount_icon != NULL) {
+
+ emblem = g_emblem_new (mount_icon);
+ emblemed_icon = g_emblemed_icon_new (icon, emblem);
+
+ g_object_unref (emblem);
+ g_object_unref (icon);
+ g_object_unref (mount_icon);
+
+ icon = emblemed_icon;
+ } else if (mount_icon != NULL) {
+ g_object_unref (mount_icon);
+ }
+
return icon;
}
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 952a09b..6959b1f 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -78,7 +78,11 @@ typedef enum {
NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT = (1<<3),
NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER = (1<<4),
/* whether the thumbnail size must match the display icon size */
- NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE = (1<<5)
+ NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE = (1<<5),
+ /* uses the icon of the mount if present */
+ NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON = (1<<6),
+ /* render the mount icon as an emblem over the regular one */
+ NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM = (1<<7)
} NautilusFileIconFlags;
/* Emblems sometimes displayed for NautilusFiles. Do not localize. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]