[gtk+/places-sidebar] Add API to GtkBookmarksManager for built-in bookmarks
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/places-sidebar] Add API to GtkBookmarksManager for built-in bookmarks
- Date: Mon, 21 Jan 2013 22:51:43 +0000 (UTC)
commit 35a56ba98742a4a53127db188585dfcf6092fda6
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Jan 21 17:32:02 2013 -0500
Add API to GtkBookmarksManager for built-in bookmarks
I.e. those that are added automatically from XDG dirs.
gtk/gtkbookmarksmanager.c | 61 +++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkbookmarksmanager.h | 8 ++++++
2 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkbookmarksmanager.c b/gtk/gtkbookmarksmanager.c
index d8ac872..45acd47 100644
--- a/gtk/gtkbookmarksmanager.c
+++ b/gtk/gtkbookmarksmanager.c
@@ -523,3 +523,64 @@ _gtk_bookmarks_manager_set_bookmark_label (GtkBookmarksManager *manager,
return TRUE;
}
+
+gboolean
+_gtk_bookmarks_manager_get_xdg_type (GtkBookmarksManager *manager,
+ GFile *file,
+ GUserDirectory *directory)
+{
+ GSList *link;
+ gboolean match;
+ GFile *location;
+ const gchar *path;
+ GUserDirectory dir;
+ GtkBookmark *bookmark;
+
+ link = find_bookmark_link_for_file (manager->bookmarks, file, NULL);
+ if (!link)
+ return FALSE;
+
+ match = FALSE;
+ bookmark = link->data;
+
+ for (dir = 0; dir < G_USER_N_DIRECTORIES; dir++)
+ {
+ path = g_get_user_special_dir (dir);
+ if (!path)
+ continue;
+
+ location = g_file_new_for_path (path);
+ match = g_file_equal (location, bookmark->file);
+ g_object_unref (location);
+
+ if (match)
+ break;
+ }
+
+ if (match && directory != NULL)
+ *directory = dir;
+
+ return match;
+}
+
+gboolean
+_gtk_bookmarks_manager_get_is_builtin (GtkBookmarksManager *manager,
+ GFile *file)
+{
+ GUserDirectory xdg_type;
+
+ /* if this is not an XDG dir, it's never builtin */
+ if (!_gtk_bookmarks_manager_get_xdg_type (manager, file, &xdg_type))
+ return FALSE;
+
+ /* exclude XDG locations we don't display by default */
+ return _gtk_bookmarks_manager_get_is_xdg_dir_builtin (xdg_type);
+}
+
+gboolean
+_gtk_bookmarks_manager_get_is_xdg_dir_builtin (GUserDirectory xdg_type)
+{
+ return (xdg_type != G_USER_DIRECTORY_DESKTOP) &&
+ (xdg_type != G_USER_DIRECTORY_TEMPLATES) &&
+ (xdg_type != G_USER_DIRECTORY_PUBLIC_SHARE);
+}
diff --git a/gtk/gtkbookmarksmanager.h b/gtk/gtkbookmarksmanager.h
index 005a315..44db7b6 100644
--- a/gtk/gtkbookmarksmanager.h
+++ b/gtk/gtkbookmarksmanager.h
@@ -77,4 +77,12 @@ gboolean _gtk_bookmarks_manager_set_bookmark_label (GtkBookmarksManager *manager
const gchar *label,
GError **error);
+gboolean _gtk_bookmarks_manager_get_xdg_type (GtkBookmarksManager *manager,
+ GFile *file,
+ GUserDirectory *directory);
+gboolean _gtk_bookmarks_manager_get_is_builtin (GtkBookmarksManager *manager,
+ GFile *file);
+
+gboolean _gtk_bookmarks_manager_get_is_xdg_dir_builtin (GUserDirectory xdg_type);
+
#endif /* __GTK_BOOKMARKS_MANAGER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]