[Goodies-commits] r6334 - in sion/trunk: . src

Enrico Troeger enrico at xfce.org
Fri Dec 19 20:00:56 CET 2008


Author: enrico
Date: 2008-12-19 19:00:56 +0000 (Fri, 19 Dec 2008)
New Revision: 6334

Modified:
   sion/trunk/ChangeLog
   sion/trunk/TODO
   sion/trunk/src/window.c
Log:
Sort bookmarks always automatically.

Modified: sion/trunk/ChangeLog
===================================================================
--- sion/trunk/ChangeLog	2008-12-19 18:42:08 UTC (rev 6333)
+++ sion/trunk/ChangeLog	2008-12-19 19:00:56 UTC (rev 6334)
@@ -5,6 +5,8 @@
  * configure:
    Remove coloured output.
    Remove unnecessary checks and code and avoid using 'which'.
+ * src/window.c:
+   Sort bookmarks always automatically.
 
 
 2008-12-18  Enrico Tröger  <enrico(at)xfce(dot)org>

Modified: sion/trunk/TODO
===================================================================
--- sion/trunk/TODO	2008-12-19 18:42:08 UTC (rev 6333)
+++ sion/trunk/TODO	2008-12-19 19:00:56 UTC (rev 6334)
@@ -3,4 +3,3 @@
 - progressdialog when mounting
 - allow usernames which include a '@' char
 - Fix 'Create Bookmark'
-- sort bookmarks

Modified: sion/trunk/src/window.c
===================================================================
--- sion/trunk/src/window.c	2008-12-19 18:42:08 UTC (rev 6333)
+++ sion/trunk/src/window.c	2008-12-19 19:00:56 UTC (rev 6334)
@@ -672,10 +672,30 @@
 }
 
 
+static gint sort_bookmarks(gconstpointer a, gconstpointer b)
+{
+	SionBookmark *bm_a = SION_BOOKMARK(((GPtrArray*)a)->pdata);
+	SionBookmark *bm_b = SION_BOOKMARK(((GPtrArray*)b)->pdata);
+	const gchar *name_a = sion_bookmark_get_name(bm_a);
+	const gchar *name_b = sion_bookmark_get_name(bm_b);
+
+	if (name_a == NULL)
+		return 1;
+	if (name_b == NULL)
+		return -1;
+
+	return strcmp(name_a, name_b);
+}
+
+
 void sion_window_update_bookmarks(SionWindow *window)
 {
 	SionWindowPrivate *priv = SION_WINDOW_GET_PRIVATE(window);
+	SionBookmarkList *bookmarks = sion_settings_get_bookmarks(priv->settings);
 
+	/* sort the bookmarks */
+	g_ptr_array_sort(bookmarks, sort_bookmarks);
+
 	/* writing to the 'settings' property will update the menus */
 	g_object_set(priv->action_bookmarks, "settings", priv->settings, NULL);
 }




More information about the Goodies-commits mailing list