[nautilus/gnome-2-32: 4/283] Add a method to move bookmarks in the list.
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-2-32: 4/283] Add a method to move bookmarks in the list.
- Date: Thu, 12 Aug 2010 11:04:21 +0000 (UTC)
commit faeb56ebd1a76354dc4675f8e97c5a325385e325
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Apr 11 15:02:37 2010 +0200
Add a method to move bookmarks in the list.
So that moving a bookmark in the list doesn't trigger two
'contents-changed' signals in a row.
src/nautilus-bookmark-list.c | 35 +++++++++++++++++++++++++++++++++++
src/nautilus-bookmark-list.h | 3 +++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index 17c0545..67be610 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -317,6 +317,41 @@ nautilus_bookmark_list_delete_item_at (NautilusBookmarkList *bookmarks,
}
/**
+ * nautilus_bookmark_list_move_item:
+ *
+ * Move the item from the given position to the destination.
+ * @index: the index of the first bookmark.
+ * @destination: the index of the second bookmark.
+ **/
+void
+nautilus_bookmark_list_move_item (NautilusBookmarkList *bookmarks,
+ guint index,
+ guint destination)
+{
+ GList *bookmark_item;
+
+ if (index == destination) {
+ return;
+ }
+
+ bookmark_item = g_list_nth (bookmarks->list, index);
+ bookmarks->list = g_list_remove_link (bookmarks->list,
+ bookmark_item);
+
+ if (index < destination) {
+ bookmarks->list = g_list_insert (bookmarks->list,
+ bookmark_item->data,
+ destination - 1);
+ } else {
+ bookmarks->list = g_list_insert (bookmarks->list,
+ bookmark_item->data,
+ destination);
+ }
+
+ nautilus_bookmark_list_contents_changed (bookmarks);
+}
+
+/**
* nautilus_bookmark_list_delete_items_with_uri:
*
* Delete all bookmarks with the given uri.
diff --git a/src/nautilus-bookmark-list.h b/src/nautilus-bookmark-list.h
index 5bcb114..f611681 100644
--- a/src/nautilus-bookmark-list.h
+++ b/src/nautilus-bookmark-list.h
@@ -74,6 +74,9 @@ void nautilus_bookmark_list_insert_item (NautilusBook
guint nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks);
NautilusBookmark * nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks,
guint index);
+void nautilus_bookmark_list_move_item (NautilusBookmarkList *bookmarks,
+ guint index,
+ guint destination);
void nautilus_bookmark_list_set_window_geometry (NautilusBookmarkList *bookmarks,
const char *geometry);
const char * nautilus_bookmark_list_get_window_geometry (NautilusBookmarkList *bookmarks);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]