[nautilus] bookmark: add nautilus_bookmark_get_is_builtin()



commit 71ad0d3adc2553ef5bcd06ec32600302e9169765
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 22 16:56:19 2012 -0400

    bookmark: add nautilus_bookmark_get_is_builtin()
    
    Move the builtin check for bookmarks from the sidebar to a method on
    NautilusBookmark itself, since we need to use the same check in the
    bookmark window.

 libnautilus-private/nautilus-bookmark.c |   20 ++++++++++++++++++++
 libnautilus-private/nautilus-bookmark.h |    1 +
 src/nautilus-bookmark-list.c            |   13 ++++++++++++-
 src/nautilus-places-sidebar.c           |   21 +--------------------
 4 files changed, 34 insertions(+), 21 deletions(-)
---
diff --git a/libnautilus-private/nautilus-bookmark.c b/libnautilus-private/nautilus-bookmark.c
index 2cb8e9f..4b3652d 100644
--- a/libnautilus-private/nautilus-bookmark.c
+++ b/libnautilus-private/nautilus-bookmark.c
@@ -35,6 +35,7 @@
 
 #include <libnautilus-private/nautilus-file.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
+#include <libnautilus-private/nautilus-global-preferences.h>
 #include <libnautilus-private/nautilus-icon-names.h>
 
 #define DEBUG_FLAG NAUTILUS_DEBUG_BOOKMARKS
@@ -184,6 +185,25 @@ apply_warning_emblem (GIcon **base,
 }
 
 gboolean
+nautilus_bookmark_get_is_builtin (NautilusBookmark *bookmark)
+{
+	GUserDirectory xdg_type;
+
+	/* if this is not an XDG dir, it's never builtin */
+	if (!nautilus_bookmark_get_xdg_type (bookmark, &xdg_type)) {
+		return FALSE;
+	}
+
+	/* exclude XDG locations which are not in our builtin list */
+	if (xdg_type == G_USER_DIRECTORY_DESKTOP &&
+	    !g_settings_get_boolean (gnome_background_preferences, NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
+		return FALSE;
+	}
+
+	return (xdg_type != G_USER_DIRECTORY_TEMPLATES) && (xdg_type != G_USER_DIRECTORY_PUBLIC_SHARE);
+}
+
+gboolean
 nautilus_bookmark_get_xdg_type (NautilusBookmark *bookmark,
 				GUserDirectory   *directory)
 {
diff --git a/libnautilus-private/nautilus-bookmark.h b/libnautilus-private/nautilus-bookmark.h
index aa62e35..736e41a 100644
--- a/libnautilus-private/nautilus-bookmark.h
+++ b/libnautilus-private/nautilus-bookmark.h
@@ -74,6 +74,7 @@ GIcon *               nautilus_bookmark_get_symbolic_icon      (NautilusBookmark
 gboolean              nautilus_bookmark_get_exists             (NautilusBookmark      *bookmark);
 gboolean              nautilus_bookmark_get_xdg_type           (NautilusBookmark      *bookmark,
 								GUserDirectory        *directory);
+gboolean              nautilus_bookmark_get_is_builtin         (NautilusBookmark      *bookmark);
 gboolean	      nautilus_bookmark_get_has_custom_name    (NautilusBookmark      *bookmark);
 void                  nautilus_bookmark_set_custom_name        (NautilusBookmark      *bookmark,
 								const char            *new_name);
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index c67701a..a5da71a 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -670,11 +670,22 @@ gboolean
 nautilus_bookmark_list_can_bookmark_location (NautilusBookmarkList *list,
 					      GFile                *location)
 {
+	NautilusBookmark *bookmark;
+	gboolean is_builtin;
+
 	if (nautilus_bookmark_list_item_with_location (list, location, NULL)) {
 		return FALSE;
 	}
 
-	return !nautilus_is_home_directory (location);
+	if (nautilus_is_home_directory (location)) {
+		return FALSE;
+	}
+
+	bookmark = nautilus_bookmark_new (location, NULL);
+	is_builtin = nautilus_bookmark_get_is_builtin (bookmark);
+	g_object_unref (bookmark);
+
+	return !is_builtin;
 }
 
 /**
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index c3ac909..1a732e8 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -442,25 +442,6 @@ add_special_dirs (NautilusPlacesSidebar *sidebar)
 	g_list_free (dirs);
 }
 
-static gboolean
-should_display_bookmark (NautilusBookmark *bookmark)
-{
-	GUserDirectory xdg_type;
-
-	/* if this is not an XDG dir, always display */
-	if (!nautilus_bookmark_get_xdg_type (bookmark, &xdg_type)) {
-		return TRUE;
-	}
-
-	/* show XDG locations which are not in our builtin list */
-	if (xdg_type == G_USER_DIRECTORY_DESKTOP &&
-	    !g_settings_get_boolean (gnome_background_preferences, NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
-		return TRUE;
-	}
-
-	return (xdg_type == G_USER_DIRECTORY_TEMPLATES) || (xdg_type == G_USER_DIRECTORY_PUBLIC_SHARE);
-}
-
 static void
 update_places (NautilusPlacesSidebar *sidebar)
 {
@@ -762,7 +743,7 @@ update_places (NautilusPlacesSidebar *sidebar)
 			continue;
 		}
 
-		if (!should_display_bookmark (bookmark)) {
+		if (nautilus_bookmark_get_is_builtin (bookmark)) {
 			g_object_unref (root);
 			continue;
 		}



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