[nautilus/gnome-3-6] file-utilities: export special_directory_get_icon()



commit 6fefabd53655fa886f2c3240374f99f9e8f3cdd5
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Sep 26 13:11:31 2012 -0400

    file-utilities: export special_directory_get_icon()
    
    Will be useful to get the icon for XDG bookmarks.

 libnautilus-private/nautilus-file-utilities.c |   39 +++++++++++++++++++++++++
 libnautilus-private/nautilus-file-utilities.h |    3 ++
 libnautilus-private/nautilus-icon-names.h     |   11 ++++++-
 src/nautilus-places-sidebar.c                 |   27 +----------------
 4 files changed, 52 insertions(+), 28 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index 08b7b54..d0e31c2 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -26,6 +26,7 @@
 #include "nautilus-file-utilities.h"
 
 #include "nautilus-global-preferences.h"
+#include "nautilus-icon-names.h"
 #include "nautilus-lib-self-check-functions.h"
 #include "nautilus-metadata.h"
 #include "nautilus-file.h"
@@ -1009,6 +1010,44 @@ have_program_in_path (const char *name)
         return result;
 }
 
+static GIcon *
+special_directory_get_icon (GUserDirectory directory,
+			    gboolean symbolic)
+{
+
+#define ICON_CASE(x)							 \
+	case G_USER_DIRECTORY_ ## x:					 \
+		return (symbolic) ? g_themed_icon_new (NAUTILUS_ICON_FOLDER_ ## x) : g_themed_icon_new (NAUTILUS_ICON_FULLCOLOR_FOLDER_ ## x);
+
+	switch (directory) {
+
+		ICON_CASE (DOCUMENTS);
+		ICON_CASE (DOWNLOAD);
+		ICON_CASE (MUSIC);
+		ICON_CASE (PICTURES);
+		ICON_CASE (PUBLIC_SHARE);
+		ICON_CASE (TEMPLATES);
+		ICON_CASE (VIDEOS);
+
+	default:
+		return (symbolic) ? g_themed_icon_new (NAUTILUS_ICON_FOLDER) : g_themed_icon_new (NAUTILUS_ICON_FULLCOLOR_FOLDER);
+	}
+
+#undef ICON_CASE
+}
+
+GIcon *
+nautilus_special_directory_get_symbolic_icon (GUserDirectory directory)
+{
+	return special_directory_get_icon (directory, TRUE);
+}
+
+GIcon *
+nautilus_special_directory_get_icon (GUserDirectory directory)
+{
+	return special_directory_get_icon (directory, FALSE);
+}
+
 gboolean
 nautilus_is_file_roller_installed (void)
 {
diff --git a/libnautilus-private/nautilus-file-utilities.h b/libnautilus-private/nautilus-file-utilities.h
index 5ff4811..0c3b3c8 100644
--- a/libnautilus-private/nautilus-file-utilities.h
+++ b/libnautilus-private/nautilus-file-utilities.h
@@ -61,6 +61,9 @@ char *	 nautilus_compute_title_for_location	     (GFile *file);
 
 gboolean nautilus_is_file_roller_installed           (void);
 
+GIcon *  nautilus_special_directory_get_icon         (GUserDirectory directory);
+GIcon *  nautilus_special_directory_get_symbolic_icon (GUserDirectory directory);
+
 gboolean nautilus_uri_parse                          (const char  *uri,
 						      char       **host,
 						      guint16     *port,
diff --git a/libnautilus-private/nautilus-icon-names.h b/libnautilus-private/nautilus-icon-names.h
index 715ecdb..ddc4543 100644
--- a/libnautilus-private/nautilus-icon-names.h
+++ b/libnautilus-private/nautilus-icon-names.h
@@ -30,8 +30,15 @@
 #define NAUTILUS_DESKTOP_ICON_NETWORK    "network-workgroup"
 
 /* Fullcolor icons */
-#define NAUTILUS_ICON_FULLCOLOR_FOLDER        "folder"
-#define NAUTILUS_ICON_FULLCOLOR_FOLDER_REMOTE "folder-remote"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER              "folder"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_REMOTE       "folder-remote"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_DOCUMENTS    "folder-documents"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_DOWNLOAD     "folder-download"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_MUSIC        "folder-music"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_PICTURES     "folder-pictures"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_PUBLIC_SHARE "folder-publicshare"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_TEMPLATES    "folder-templates"
+#define NAUTILUS_ICON_FULLCOLOR_FOLDER_VIDEOS       "folder-videos"
 #define NAUTILUS_ICON_FULLCOLOR_FOLDER_SAVED_SEARCH "folder-saved-search"
 
 /* Other icons */
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index 29b4e21..9236dbd 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -396,31 +396,6 @@ sidebar_update_restore_selection (NautilusPlacesSidebar *sidebar,
 	}
 }
 
-static GIcon *
-special_directory_get_gicon (GUserDirectory directory)
-{
-
-#define ICON_CASE(x)				\
-	case G_USER_DIRECTORY_ ## x:					\
-		return g_themed_icon_new (NAUTILUS_ICON_FOLDER_ ## x);
-
-	switch (directory) {
-
-		ICON_CASE (DOCUMENTS);
-		ICON_CASE (DOWNLOAD);
-		ICON_CASE (MUSIC);
-		ICON_CASE (PICTURES);
-		ICON_CASE (PUBLIC_SHARE);
-		ICON_CASE (TEMPLATES);
-		ICON_CASE (VIDEOS);
-
-	default:
-		return g_themed_icon_new ("folder-symbolic");
-	}
-
-#undef ICON_CASE
-}
-
 static gboolean
 recent_is_supported (void)
 {
@@ -475,7 +450,7 @@ add_special_dirs (NautilusPlacesSidebar *sidebar)
 
 		root = g_file_new_for_path (path);
 		name = g_file_get_basename (root);
-		icon = special_directory_get_gicon (index);
+		icon = nautilus_special_directory_get_symbolic_icon (index);
 		mount_uri = g_file_get_uri (root);
 		tooltip = g_file_get_parse_name (root);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]