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

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

commit d2d2023a545fd4022a6c08895acd999f7923d19e
Author: Stephan Haller <no...@froevel.de>
Date:   Sun Jan 31 16:13:36 2016 +0100

    Fix moving selection beyond limits of search result container, e.g. select 
first item in next search provider if moving selection in current provider 
would be "behind" last item.
---
 xfdashboard/search-result-container.c |  119 ++++++++++---
 xfdashboard/search-result-container.h |    3 +-
 xfdashboard/search-view.c             |  309 +++++++++++++++++++++------------
 3 files changed, 296 insertions(+), 135 deletions(-)

diff --git a/xfdashboard/search-result-container.c 
b/xfdashboard/search-result-container.c
index 20a3476..8c943fb 100644
--- a/xfdashboard/search-result-container.c
+++ b/xfdashboard/search-result-container.c
@@ -750,7 +750,8 @@ static void 
_xfdashboard_search_result_container_update_result_items(Xfdashboard
 static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_icon_mode(XfdashboardSearchResultContainer
 *self,
                                                                                
                                                                                
                ClutterActor *inSelection,
                                                                                
                                                                                
                XfdashboardSelectionTarget inDirection,
-                                                                               
                                                                                
                XfdashboardView *inView)
+                                                                               
                                                                                
                XfdashboardView *inView,
+                                                                               
                                                                                
                gboolean inAllowWrap)
 {
        XfdashboardSearchResultContainerPrivate         *priv;
        ClutterActor                                                            
*selection;
@@ -764,6 +765,7 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
        gint                                                                    
        newSelectionIndex;
        ClutterActorIter                                                        
iter;
        ClutterActor                                                            
*child;
+       gboolean                                                                
        needsWrap;
 
        g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_RESULT_CONTAINER(self), 
NULL);
        g_return_val_if_fail(CLUTTER_IS_ACTOR(inSelection), NULL);
@@ -771,6 +773,7 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
        priv=self->priv;
        selection=inSelection;
        newSelection=NULL;
+       needsWrap=FALSE;
 
        /* Get number of rows and columns and also get number of children
         * of layout manager.
@@ -800,6 +803,8 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
                        {
                                currentSelectionRow++;
                                
newSelectionIndex=(currentSelectionRow*columns)-1;
+
+                               needsWrap=TRUE;
                        }
                                else newSelectionIndex=currentSelectionIndex-1;
 
@@ -813,6 +818,7 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
                                currentSelectionIndex==numberChildren)
                        {
                                newSelectionIndex=(currentSelectionRow*columns);
+                               needsWrap=TRUE;
                        }
                                else newSelectionIndex=currentSelectionIndex+1;
 
@@ -822,7 +828,11 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
 
                case XFDASHBOARD_SELECTION_TARGET_UP:
                        currentSelectionRow--;
-                       if(currentSelectionRow<0) currentSelectionRow=rows-1;
+                       if(currentSelectionRow<0)
+                       {
+                               currentSelectionRow=rows-1;
+                               needsWrap=TRUE;
+                       }
                        
newSelectionIndex=(currentSelectionRow*columns)+currentSelectionColumn;
 
                        newSelectionIndex=MIN(newSelectionIndex, 
numberChildren-1);
@@ -831,7 +841,11 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
 
                case XFDASHBOARD_SELECTION_TARGET_DOWN:
                        currentSelectionRow++;
-                       if(currentSelectionRow>=rows) currentSelectionRow=0;
+                       if(currentSelectionRow>=rows)
+                       {
+                               currentSelectionRow=0;
+                               needsWrap=TRUE;
+                       }
                        
newSelectionIndex=(currentSelectionRow*columns)+currentSelectionColumn;
 
                        newSelectionIndex=MIN(newSelectionIndex, 
numberChildren-1);
@@ -875,15 +889,24 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
                        break;
        }
 
-       /* If new selection could be found override current selection with it */
+       /* If new selection could be found override current selection with it.
+        * But also check if new selection needs to wrap (crossing boundaries
+        * like going to the beginning because it's gone beyond end) and if
+        * wrapping is allowed.
+        */
        if(newSelection) selection=newSelection;
 
+       if(selection && needsWrap && !inAllowWrap) selection=NULL;
+
        /* Return new selection */
-       g_debug("Selecting %s at %s for current selection %s in direction %u",
+       g_debug("Selecting %s in icon mode at %s for current selection %s in 
direction %u with wrapping %s and wrapping %s",
                        selection ? G_OBJECT_TYPE_NAME(selection) : "<nil>",
                        G_OBJECT_TYPE_NAME(self),
                        inSelection ? G_OBJECT_TYPE_NAME(inSelection) : "<nil>",
-                       inDirection);
+                       inDirection,
+                       inAllowWrap ? "allowed" : "denied",
+                       needsWrap ? "needed" : "not needed");
+
        return(selection);
 }
 
@@ -891,11 +914,13 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_ic
 static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_list_mode(XfdashboardSearchResultContainer
 *self,
                                                                                
                                                                                
                ClutterActor *inSelection,
                                                                                
                                                                                
                XfdashboardSelectionTarget inDirection,
-                                                                               
                                                                                
                XfdashboardView *inView)
+                                                                               
                                                                                
                XfdashboardView *inView,
+                                                                               
                                                                                
                gboolean inAllowWrap)
 {
        XfdashboardSearchResultContainerPrivate         *priv;
        ClutterActor                                                            
*selection;
        ClutterActor                                                            
*newSelection;
+       gboolean                                                                
        needsWrap;
 
        g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_RESULT_CONTAINER(self), 
NULL);
        g_return_val_if_fail(CLUTTER_IS_ACTOR(inSelection), NULL);
@@ -903,6 +928,7 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_li
        priv=self->priv;
        selection=inSelection;
        newSelection=NULL;
+       needsWrap=FALSE;
 
        /* Find target selection */
        switch(inDirection)
@@ -916,12 +942,20 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_li
 
                case XFDASHBOARD_SELECTION_TARGET_UP:
                        
newSelection=clutter_actor_get_previous_sibling(inSelection);
-                       if(!newSelection) 
newSelection=clutter_actor_get_last_child(priv->itemsContainer);
+                       if(!newSelection)
+                       {
+                               
newSelection=clutter_actor_get_last_child(priv->itemsContainer);
+                               needsWrap=TRUE;
+                       }
                        break;
 
                case XFDASHBOARD_SELECTION_TARGET_DOWN:
                        
newSelection=clutter_actor_get_next_sibling(inSelection);
-                       if(!newSelection) 
newSelection=clutter_actor_get_first_child(priv->itemsContainer);
+                       if(!newSelection)
+                       {
+                               
newSelection=clutter_actor_get_first_child(priv->itemsContainer);
+                               needsWrap=TRUE;
+                       }
                        break;
 
                case XFDASHBOARD_SELECTION_TARGET_PAGE_UP:
@@ -971,9 +1005,15 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_li
                                        if(childY1>limitY || childY2>limitY) 
newSelection=child;
                                }
 
+                               /* If new selection is the same is current 
selection
+                                * then we did not find a new selection.
+                                */
+                               if(newSelection==inSelection) newSelection=NULL;
+
                                /* If no child could be found select last one */
                                if(!newSelection)
                                {
+                                       needsWrap=TRUE;
                                        
if(inDirection==XFDASHBOARD_SELECTION_TARGET_PAGE_UP)
                                        {
                                                
newSelection=clutter_actor_get_first_child(priv->itemsContainer);
@@ -999,15 +1039,24 @@ static ClutterActor* 
_xfdashboard_search_result_container_find_selection_from_li
                        break;
        }
 
-       /* If new selection could be found override current selection with it */
+       /* If new selection could be found override current selection with it.
+        * But also check if new selection needs to wrap (crossing boundaries
+        * like going to the beginning because it's gone beyond end) and if
+        * wrapping is allowed.
+        */
        if(newSelection) selection=newSelection;
 
+       if(selection && needsWrap && !inAllowWrap) selection=NULL;
+
        /* Return new selection */
-       g_debug("Selecting %s at %s for current selection %s in direction %u",
+       g_debug("Selecting %s in list mode at %s for current selection %s in 
direction %u with wrapping %s and wrapping %s",
                        selection ? G_OBJECT_TYPE_NAME(selection) : "<nil>",
                        G_OBJECT_TYPE_NAME(self),
                        inSelection ? G_OBJECT_TYPE_NAME(inSelection) : "<nil>",
-                       inDirection);
+                       inDirection,
+                       inAllowWrap ? "allowed" : "denied",
+                       needsWrap ? "needed" : "not needed");
+
        return(selection);
 }
 
@@ -1721,7 +1770,8 @@ gboolean 
xfdashboard_search_result_container_set_selection(XfdashboardSearchResu
 ClutterActor* 
xfdashboard_search_result_container_find_selection(XfdashboardSearchResultContainer
 *self,
                                                                                
                                                        ClutterActor 
*inSelection,
                                                                                
                                                        
XfdashboardSelectionTarget inDirection,
-                                                                               
                                                        XfdashboardView *inView)
+                                                                               
                                                        XfdashboardView *inView,
+                                                                               
                                                        gboolean inAllowWrap)
 {
        XfdashboardSearchResultContainerPrivate         *priv;
        ClutterActor                                                            
*selection;
@@ -1733,10 +1783,24 @@ ClutterActor* 
xfdashboard_search_result_container_find_selection(XfdashboardSear
        g_return_val_if_fail(inDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT, 
NULL);
 
        priv=self->priv;
-       selection=inSelection;
+       selection=NULL;
        newSelection=NULL;
 
-       /* If there is nothing selected, select first actor and return */
+       /* If first selection is requested, select first actor and return */
+       if(inDirection==XFDASHBOARD_SELECTION_TARGET_FIRST)
+       {
+               
newSelection=clutter_actor_get_first_child(priv->itemsContainer);
+               return(newSelection);
+       }
+
+       /* If last selection is requested, select last actor and return */
+       if(inDirection==XFDASHBOARD_SELECTION_TARGET_LAST)
+       {
+               newSelection=clutter_actor_get_last_child(priv->itemsContainer);
+               return(newSelection);
+       }
+
+       /* If there is nothing selected, select the first actor and return */
        if(!inSelection)
        {
                
newSelection=clutter_actor_get_first_child(priv->itemsContainer);
@@ -1774,25 +1838,25 @@ ClutterActor* 
xfdashboard_search_result_container_find_selection(XfdashboardSear
                case XFDASHBOARD_SELECTION_TARGET_PAGE_DOWN:
                        if(priv->viewMode==XFDASHBOARD_VIEW_MODE_LIST)
                        {
-                               
newSelection=_xfdashboard_search_result_container_find_selection_from_list_mode(self,
 inSelection, inDirection, inView);
+                               
newSelection=_xfdashboard_search_result_container_find_selection_from_list_mode(self,
 inSelection, inDirection, inView, inAllowWrap);
                        }
                                else
                                {
-                                       
newSelection=_xfdashboard_search_result_container_find_selection_from_icon_mode(self,
 inSelection, inDirection, inView);
+                                       
newSelection=_xfdashboard_search_result_container_find_selection_from_icon_mode(self,
 inSelection, inDirection, inView, inAllowWrap);
                                }
                        break;
 
-               case XFDASHBOARD_SELECTION_TARGET_FIRST:
-                       
newSelection=clutter_actor_get_first_child(priv->itemsContainer);
+               case XFDASHBOARD_SELECTION_TARGET_NEXT:
+                       
newSelection=clutter_actor_get_next_sibling(inSelection);
+                       if(!newSelection && inAllowWrap) 
newSelection=clutter_actor_get_previous_sibling(inSelection);
                        break;
 
+               case XFDASHBOARD_SELECTION_TARGET_FIRST:
                case XFDASHBOARD_SELECTION_TARGET_LAST:
-                       
newSelection=clutter_actor_get_last_child(priv->itemsContainer);
-                       break;
-
-               case XFDASHBOARD_SELECTION_TARGET_NEXT:
-                       
newSelection=clutter_actor_get_next_sibling(inSelection);
-                       if(!newSelection) 
newSelection=clutter_actor_get_previous_sibling(inSelection);
+                       /* These directions should be handled at beginning of 
this function
+                        * and therefore should never be reached!
+                        */
+                       g_assert_not_reached();
                        break;
 
                default:
@@ -1812,11 +1876,12 @@ ClutterActor* 
xfdashboard_search_result_container_find_selection(XfdashboardSear
        if(newSelection) selection=newSelection;
 
        /* Return new selection found */
-       g_debug("Selecting %s at %s for current selection %s in direction %u",
+       g_debug("Selecting %s at %s for current selection %s in direction %u 
with wrapping %s",
                        selection ? G_OBJECT_TYPE_NAME(selection) : "<nil>",
                        G_OBJECT_TYPE_NAME(self),
                        inSelection ? G_OBJECT_TYPE_NAME(inSelection) : "<nil>",
-                       inDirection);
+                       inDirection,
+                       inAllowWrap ? "allowed" : "denied");
 
        return(selection);
 }
diff --git a/xfdashboard/search-result-container.h 
b/xfdashboard/search-result-container.h
index 554bbea..7fa5f53 100644
--- a/xfdashboard/search-result-container.h
+++ b/xfdashboard/search-result-container.h
@@ -100,7 +100,8 @@ gboolean 
xfdashboard_search_result_container_set_selection(XfdashboardSearchResu
 ClutterActor* 
xfdashboard_search_result_container_find_selection(XfdashboardSearchResultContainer
 *self,
                                                                                
                                                        ClutterActor 
*inSelection,
                                                                                
                                                        
XfdashboardSelectionTarget inDirection,
-                                                                               
                                                        XfdashboardView 
*inView);
+                                                                               
                                                        XfdashboardView *inView,
+                                                                               
                                                        gboolean inAllowWrap);
 void 
xfdashboard_search_result_container_activate_selection(XfdashboardSearchResultContainer
 *self,
                                                                                
                                                        ClutterActor 
*inSelection);
 
diff --git a/xfdashboard/search-view.c b/xfdashboard/search-view.c
index fb33ed4..64dbe0d 100644
--- a/xfdashboard/search-view.c
+++ b/xfdashboard/search-view.c
@@ -547,7 +547,8 @@ static void 
_xfdashboard_search_view_on_provider_container_destroyed(ClutterActo
                                
selectableActor=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(iterProviderData->container),
                                                                                
                                                                                
        NULL,
                                                                                
                                                                                
        XFDASHBOARD_SELECTION_TARGET_FIRST,
-                                                                               
                                                                                
        XFDASHBOARD_VIEW(self));
+                                                                               
                                                                                
        XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
        FALSE);
                                if(selectableActor)
                                {
                                        newSelection=selectableActor;
@@ -572,7 +573,8 @@ static void 
_xfdashboard_search_view_on_provider_container_destroyed(ClutterActo
                                
selectableActor=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(iterProviderData->container),
                                                                                
                                                                                
        NULL,
                                                                                
                                                                                
        XFDASHBOARD_SELECTION_TARGET_FIRST,
-                                                                               
                                                                                
        XFDASHBOARD_VIEW(self));
+                                                                               
                                                                                
        XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
        FALSE);
                                if(selectableActor)
                                {
                                        newSelection=selectableActor;
@@ -1020,6 +1022,180 @@ static gboolean 
_xfdashboard_search_view_focusable_set_selection(XfdashboardFocu
 }
 
 /* Find requested selection target depending of current selection */
+static ClutterActor* 
_xfdashboard_search_view_focusable_find_selection_internal_backwards(XfdashboardSearchView
 *self,
+                                                                               
                                                                                
                        XfdashboardSearchResultContainer *inContainer,
+                                                                               
                                                                                
                        ClutterActor *inSelection,
+                                                                               
                                                                                
                        XfdashboardSelectionTarget inDirection,
+                                                                               
                                                                                
                        GList *inCurrentProviderIter,
+                                                                               
                                                                                
                        XfdashboardSelectionTarget inNextContainerDirection)
+{
+       ClutterActor                                                    
*newSelection;
+       GList                                                                   
*iter;
+       XfdashboardSearchViewProviderData               *providerData;
+
+       g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_VIEW(self), NULL);
+       
g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_RESULT_CONTAINER(inContainer), NULL);
+       g_return_val_if_fail(CLUTTER_IS_ACTOR(inSelection), NULL);
+       g_return_val_if_fail(inDirection>XFDASHBOARD_SELECTION_TARGET_NONE, 
NULL);
+       g_return_val_if_fail(inDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT, 
NULL);
+       g_return_val_if_fail(inCurrentProviderIter, NULL);
+       
g_return_val_if_fail(inNextContainerDirection>XFDASHBOARD_SELECTION_TARGET_NONE,
 NULL);
+       
g_return_val_if_fail(inNextContainerDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT,
 NULL);
+
+       /* Ask current provider to find selection for requested direction */
+       
newSelection=xfdashboard_search_result_container_find_selection(inContainer,
+                                                                               
                                                        inSelection,
+                                                                               
                                                        inDirection,
+                                                                               
                                                        XFDASHBOARD_VIEW(self),
+                                                                               
                                                        FALSE);
+
+       /* If current provider does not return a matching selection for 
requested,
+        * iterate backwards through providers beginning at current provider and
+        * return the last actor of first provider having an existing container
+        * while iterating.
+        */
+       if(!newSelection)
+       {
+               for(iter=g_list_previous(inCurrentProviderIter); iter && 
!newSelection; iter=g_list_previous(iter))
+               {
+                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
+
+                       if(providerData &&
+                               providerData->container)
+                       {
+                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
+                                                                               
                                                                                
NULL,
+                                                                               
                                                                                
inNextContainerDirection,
+                                                                               
                                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
FALSE);
+                       }
+               }
+       }
+
+       /* If we still have no new selection found, do the same as above but
+        * iterate from end of list of providers backwards to current provider.
+        */
+       if(!newSelection)
+       {
+               for(iter=g_list_last(inCurrentProviderIter); iter && 
iter!=inCurrentProviderIter && !newSelection; iter=g_list_previous(iter))
+               {
+                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
+
+                       if(providerData &&
+                               providerData->container)
+                       {
+                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
+                                                                               
                                                                                
NULL,
+                                                                               
                                                                                
inNextContainerDirection,
+                                                                               
                                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
FALSE);
+                       }
+               }
+       }
+
+       /* If we still have no selection the last resort is to find a selection
+        * at current provider but this time allow wrapping.
+        */
+       if(!newSelection)
+       {
+               
newSelection=xfdashboard_search_result_container_find_selection(inContainer,
+                                                                               
                                                                inSelection,
+                                                                               
                                                                inDirection,
+                                                                               
                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                TRUE);
+       }
+
+       /* Return selection found which may be NULL */
+       return(newSelection);
+}
+
+static ClutterActor* 
_xfdashboard_search_view_focusable_find_selection_internal_forwards(XfdashboardSearchView
 *self,
+                                                                               
                                                                                
                        XfdashboardSearchResultContainer *inContainer,
+                                                                               
                                                                                
                        ClutterActor *inSelection,
+                                                                               
                                                                                
                        XfdashboardSelectionTarget inDirection,
+                                                                               
                                                                                
                        GList *inCurrentProviderIter,
+                                                                               
                                                                                
                        XfdashboardSelectionTarget inNextContainerDirection)
+{
+       ClutterActor                                                    
*newSelection;
+       GList                                                                   
*iter;
+       XfdashboardSearchViewProviderData               *providerData;
+
+       g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_VIEW(self), NULL);
+       
g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_RESULT_CONTAINER(inContainer), NULL);
+       g_return_val_if_fail(CLUTTER_IS_ACTOR(inSelection), NULL);
+       g_return_val_if_fail(inDirection>XFDASHBOARD_SELECTION_TARGET_NONE, 
NULL);
+       g_return_val_if_fail(inDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT, 
NULL);
+       g_return_val_if_fail(inCurrentProviderIter, NULL);
+       
g_return_val_if_fail(inNextContainerDirection>XFDASHBOARD_SELECTION_TARGET_NONE,
 NULL);
+       
g_return_val_if_fail(inNextContainerDirection<=XFDASHBOARD_SELECTION_TARGET_NEXT,
 NULL);
+
+       /* Ask current provider to find selection for requested direction */
+       
newSelection=xfdashboard_search_result_container_find_selection(inContainer,
+                                                                               
                                                        inSelection,
+                                                                               
                                                        inDirection,
+                                                                               
                                                        XFDASHBOARD_VIEW(self),
+                                                                               
                                                        FALSE);
+
+       /* If current provider does not return a matching selection for 
requested,
+        * iterate forwards through providers beginning at current provider and
+        * return the last actor of first provider having an existing container
+        * while iterating.
+        */
+       if(!newSelection)
+       {
+               for(iter=g_list_next(inCurrentProviderIter); iter && 
!newSelection; iter=g_list_next(iter))
+               {
+                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
+
+                       if(providerData &&
+                               providerData->container)
+                       {
+                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
+                                                                               
                                                                                
NULL,
+                                                                               
                                                                                
inNextContainerDirection,
+                                                                               
                                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
FALSE);
+                       }
+               }
+       }
+
+       /* If we still have no new selection found, do the same as above but
+        * iterate from start of list of providers forwards to current provider.
+        */
+       if(!newSelection)
+       {
+               for(iter=g_list_first(inCurrentProviderIter); iter && 
iter!=inCurrentProviderIter && !newSelection; iter=g_list_next(iter))
+               {
+                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
+
+                       if(providerData &&
+                               providerData->container)
+                       {
+                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
+                                                                               
                                                                                
NULL,
+                                                                               
                                                                                
inNextContainerDirection,
+                                                                               
                                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
FALSE);
+                       }
+               }
+       }
+
+       /* If we still have no selection the last resort is to find a selection
+        * at current provider but this time allow wrapping.
+        */
+       if(!newSelection)
+       {
+               
newSelection=xfdashboard_search_result_container_find_selection(inContainer,
+                                                                               
                                                                inSelection,
+                                                                               
                                                                inDirection,
+                                                                               
                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                TRUE);
+       }
+
+       /* Return selection found which may be NULL */
+       return(newSelection);
+}
+
 static ClutterActor* 
_xfdashboard_search_view_focusable_find_selection(XfdashboardFocusable 
*inFocusable,
                                                                                
                                                                                
ClutterActor *inSelection,
                                                                                
                                                                                
XfdashboardSelectionTarget inDirection)
@@ -1061,7 +1237,8 @@ static ClutterActor* 
_xfdashboard_search_view_focusable_find_selection(Xfdashboa
                                
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
                                                                                
                                                                                
NULL,
                                                                                
                                                                                
XFDASHBOARD_SELECTION_TARGET_FIRST,
-                                                                               
                                                                                
XFDASHBOARD_VIEW(self));
+                                                                               
                                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
FALSE);
                                if(newSelection) 
newSelectionProvider=providerData;
                        }
                }
@@ -1091,7 +1268,8 @@ static ClutterActor* 
_xfdashboard_search_view_focusable_find_selection(Xfdashboa
                                
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
                                                                                
                                                                                
inSelection,
                                                                                
                                                                                
XFDASHBOARD_SELECTION_TARGET_FIRST,
-                                                                               
                                                                                
XFDASHBOARD_VIEW(self));
+                                                                               
                                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
FALSE);
                                if(newSelection) 
newSelectionProvider=providerData;
                        }
                }
@@ -1121,7 +1299,8 @@ static ClutterActor* 
_xfdashboard_search_view_focusable_find_selection(Xfdashboa
                                
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
                                                                                
                                                                                
inSelection,
                                                                                
                                                                                
XFDASHBOARD_SELECTION_TARGET_LAST,
-                                                                               
                                                                                
XFDASHBOARD_VIEW(self));
+                                                                               
                                                                                
XFDASHBOARD_VIEW(self),
+                                                                               
                                                                                
FALSE);
                                if(newSelection) 
newSelectionProvider=providerData;
                        }
                }
@@ -1166,117 +1345,33 @@ static ClutterActor* 
_xfdashboard_search_view_focusable_find_selection(Xfdashboa
                case XFDASHBOARD_SELECTION_TARGET_UP:
                case XFDASHBOARD_SELECTION_TARGET_PAGE_LEFT:
                case XFDASHBOARD_SELECTION_TARGET_PAGE_UP:
-                       /* Ask current provider to find selection for requested 
direction */
-                       
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container),
-                                                                               
                                                                        
inSelection,
-                                                                               
                                                                        
inDirection,
-                                                                               
                                                                        
XFDASHBOARD_VIEW(self));
-
-                       /* If current provider does not return a matching 
selection for requested,
-                        * iterate backwards through providers beginning at 
current provider and
-                        * return the last actor of first provider having an 
existing container
-                        * while iterating.
-                        */
-                       if(!newSelection)
-                       {
-                               for(iter=g_list_previous(currentProviderIter); 
iter && !newSelection; iter=g_list_previous(iter))
-                               {
-                                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
-
-                                       if(providerData &&
-                                               providerData->container)
-                                       {
-                                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
-                                                                               
                                                                                
                NULL,
-                                                                               
                                                                                
                XFDASHBOARD_SELECTION_TARGET_LAST,
-                                                                               
                                                                                
                XFDASHBOARD_VIEW(self));
-                                       }
-                               }
-                       }
+                       
newSelection=_xfdashboard_search_view_focusable_find_selection_internal_backwards(self,
+                                                                               
                                                                                
                                
XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container),
+                                                                               
                                                                                
                                inSelection,
+                                                                               
                                                                                
                                inDirection,
+                                                                               
                                                                                
                                currentProviderIter,
+                                                                               
                                                                                
                                XFDASHBOARD_SELECTION_TARGET_LAST);
                        break;
 
                case XFDASHBOARD_SELECTION_TARGET_RIGHT:
                case XFDASHBOARD_SELECTION_TARGET_DOWN:
                case XFDASHBOARD_SELECTION_TARGET_PAGE_RIGHT:
                case XFDASHBOARD_SELECTION_TARGET_PAGE_DOWN:
-                       /* Ask current provider to find selection for requested 
direction */
-                       
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container),
-                                                                               
                                                                        
inSelection,
-                                                                               
                                                                        
inDirection,
-                                                                               
                                                                        
XFDASHBOARD_VIEW(self));
-
-                       /* If current provider does not return a matching 
selection for requested,
-                        * iterate forwards through providers beginning at 
current provider and
-                        * return the first actor of first provider having an 
existing container
-                        * while iterating.
-                        */
-                       if(!newSelection)
-                       {
-                               for(iter=g_list_next(currentProviderIter); iter 
&& !newSelection; iter=g_list_next(iter))
-                               {
-                                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
-
-                                       if(providerData &&
-                                               providerData->container)
-                                       {
-                                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
-                                                                               
                                                                                
                NULL,
-                                                                               
                                                                                
                XFDASHBOARD_SELECTION_TARGET_FIRST,
-                                                                               
                                                                                
                XFDASHBOARD_VIEW(self));
-                                       }
-                               }
-                       }
+                       
newSelection=_xfdashboard_search_view_focusable_find_selection_internal_forwards(self,
+                                                                               
                                                                                
                                
XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container),
+                                                                               
                                                                                
                                inSelection,
+                                                                               
                                                                                
                                inDirection,
+                                                                               
                                                                                
                                currentProviderIter,
+                                                                               
                                                                                
                                XFDASHBOARD_SELECTION_TARGET_FIRST);
                        break;
 
                case XFDASHBOARD_SELECTION_TARGET_NEXT:
-                       /* Ask current provider to find selection for requested 
direction */
-                       
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container),
-                                                                               
                                                                        
inSelection,
-                                                                               
                                                                        
inDirection,
-                                                                               
                                                                        
XFDASHBOARD_VIEW(self));
-
-                       /* If current provider does not return a matching 
selection for requested,
-                        * iterate forwards through providers beginning at 
current provider and
-                        * return the first actor of first provider having an 
existing container
-                        * while iterating.
-                        */
-                       if(!newSelection)
-                       {
-                               for(iter=g_list_next(currentProviderIter); iter 
&& !newSelection; iter=g_list_next(iter))
-                               {
-                                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
-
-                                       if(providerData &&
-                                               providerData->container)
-                                       {
-                                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
-                                                                               
                                                                                
                NULL,
-                                                                               
                                                                                
                XFDASHBOARD_SELECTION_TARGET_FIRST,
-                                                                               
                                                                                
                XFDASHBOARD_VIEW(self));
-                                       }
-                               }
-                       }
-
-                       /* If still no matching selection was found then 
iterate backwards through
-                        * providers beginning at current provider and return 
the last actor of first
-                        * provider having an existing container while 
iterating.
-                        */
-                       if(!newSelection)
-                       {
-                               for(iter=g_list_previous(currentProviderIter); 
iter && !newSelection; iter=g_list_previous(iter))
-                               {
-                                       
providerData=(XfdashboardSearchViewProviderData*)iter->data;
-
-                                       if(providerData &&
-                                               providerData->container)
-                                       {
-                                               
newSelection=xfdashboard_search_result_container_find_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(providerData->container),
-                                                                               
                                                                                
                NULL,
-                                                                               
                                                                                
                XFDASHBOARD_SELECTION_TARGET_LAST,
-                                                                               
                                                                                
                XFDASHBOARD_VIEW(self));
-                                       }
-                               }
-                       }
+                       
newSelection=_xfdashboard_search_view_focusable_find_selection_internal_forwards(self,
+                                                                               
                                                                                
                                
XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container),
+                                                                               
                                                                                
                                inSelection,
+                                                                               
                                                                                
                                inDirection,
+                                                                               
                                                                                
                                currentProviderIter,
+                                                                               
                                                                                
                                XFDASHBOARD_SELECTION_TARGET_FIRST);
                        break;
 
                case XFDASHBOARD_SELECTION_TARGET_FIRST:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to