[Xfce4-commits] [apps/xfdashboard] 04/08: Respect score of items in result set when sorting.

noreply at xfce.org noreply at xfce.org
Mon Jan 25 13:21:13 CET 2016


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit 5ba001585d60cb2d8c869a5f4779ec1bbfe20b7d
Author: Stephan Haller <nomad at froevel.de>
Date:   Mon Jan 25 11:42:59 2016 +0100

    Respect score of items in result set when sorting.
    
    This should complete issue GH #106
---
 xfdashboard/search-result-set.c |   26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/xfdashboard/search-result-set.c b/xfdashboard/search-result-set.c
index 5b2cb0f..3b3154a 100644
--- a/xfdashboard/search-result-set.c
+++ b/xfdashboard/search-result-set.c
@@ -128,13 +128,37 @@ static gint _xfdashboard_search_result_set_sort_internal(gconstpointer inLeft,
 	XfdashboardSearchResultSet				*self=XFDASHBOARD_SEARCH_RESULT_SET(inUserData);
 	XfdashboardSearchResultSetPrivate		*priv=self->priv;
 	GVariant								*left;
+	XfdashboardSearchResultSetItemData		*leftData;
 	GVariant								*right;
+	XfdashboardSearchResultSetItemData		*rightData;
+	gint									result;
+
+	result=0;
 
 	/* Get items to compare */
 	left=(GVariant*)inLeft;
 	right=(GVariant*)inRight;
 
-	/* Call sorting callback function now */
+	/* Get score for each item to compare for sorting if for both items available */
+	leftData=_xfdashboard_search_result_set_item_data_get(self, left);
+	rightData=_xfdashboard_search_result_set_item_data_get(self, right);
+	if(leftData && rightData)
+	{
+		/* Set result to corresponding value and other than null if the
+		 * scores are not equal.
+		 */
+		if(leftData->score < rightData->score) result=1;
+		if(leftData->score > rightData->score) result=-1;
+	}
+	if(leftData) _xfdashboard_search_result_set_item_data_unref(leftData);
+	if(rightData) _xfdashboard_search_result_set_item_data_unref(rightData);
+
+	/* If both items do not have the same score the result is set to value
+	 * other than zero. So return it now.
+	 */
+	if(result!=0) return(result);
+
+	/* Call sorting callback function now if both have the same score */
 	return((priv->sortCallback)(left, right, priv->sortUserData));
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list