From fa45eaa48e679ddf2c264185e624723a7c1c27ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:22:24 -0500 Subject: Switching the get_position() function to look at the visibility of the applications. --- src/application-service-appstore.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 00de4b9..1b10033 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -342,18 +342,34 @@ string_to_status(const gchar * status_string) } /* A small helper function to get the position of an application - in the app list. */ + in the app list of the applications that are visible. */ static gint get_position (Application * app) { ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; - GList * applistitem = g_list_find(priv->applications, app); - if (applistitem == NULL) { - return -1; + GList * lapp; + gint count; + + /* Go through the list and try to find ours */ + for (lapp = priv->applications, count = 0; lapp != NULL; lapp = g_list_next(lapp), count++) { + if (lapp->data == app) { + break; + } + + /* If the selected app isn't visible let's not + count it's position */ + Application * thisapp = (Application *)(lapp->data); + if (thisapp->visible_state == VISIBLE_STATE_HIDDEN) { + count--; + } } - return g_list_position(priv->applications, applistitem); + if (lapp == NULL) { + return -1; + } + + return count; } /* A simple global function for dealing with freeing the information -- cgit v1.2.3