summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-10-22 16:56:19 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-10-22 16:56:19 -0400
commit71ad0d3adc2553ef5bcd06ec32600302e9169765 (patch)
tree0391df623c477d037bfd5320fb807ae7f165da36
parent1dcd2d816a1278f7eec1d074ec5d9134af34a803 (diff)
downloadnautilus-71ad0d3adc2553ef5bcd06ec32600302e9169765.tar.gz
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.
-rw-r--r--libnautilus-private/nautilus-bookmark.c20
-rw-r--r--libnautilus-private/nautilus-bookmark.h1
-rw-r--r--src/nautilus-bookmark-list.c13
-rw-r--r--src/nautilus-places-sidebar.c21
4 files changed, 34 insertions, 21 deletions
diff --git a/libnautilus-private/nautilus-bookmark.c b/libnautilus-private/nautilus-bookmark.c
index 2cb8e9fee..4b3652d75 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 aa62e35d9..736e41a31 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 c67701a34..a5da71aad 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 c3ac90919..1a732e8dd 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;
}