aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-01-19 20:57:26 -0600
committerTed Gould <ted@gould.cx>2010-01-19 20:57:26 -0600
commita634890d9684f87b796670c89383066bb674863d (patch)
tree54183343d77b42602fe192c4e14e7cfe92618448
parent570fc9486cb9f0a442ce0989c2bff1bc7942e67f (diff)
downloadayatana-indicator-application-a634890d9684f87b796670c89383066bb674863d.tar.gz
ayatana-indicator-application-a634890d9684f87b796670c89383066bb674863d.tar.bz2
ayatana-indicator-application-a634890d9684f87b796670c89383066bb674863d.zip
Switching to inserting in the application array using a sort function. Looking that up in the LRU file DB.
-rw-r--r--src/application-service-appstore.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c
index 7d925d2..4cb2ab6 100644
--- a/src/application-service-appstore.c
+++ b/src/application-service-appstore.c
@@ -350,6 +350,18 @@ can_add_application (GList *applications, Application *app)
return TRUE;
}
+/* This function takes two Application structure
+ pointers and uses the lrufile to compare them. */
+static gint
+app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata)
+{
+ Application * appa = (Application *)a;
+ Application * appb = (Application *)b;
+ AppLruFile * lrufile = (AppLruFile *)userdata;
+
+ return app_lru_file_sort(lrufile, appa->id, appb->id);
+}
+
/* Change the status of the application. If we're going passive
it removes it from the panel. If we're coming online, then
it add it to the panel. Otherwise it changes the icon. */
@@ -384,16 +396,12 @@ apply_status (Application * app, ApplicationStatus status)
if (app->status == APP_STATUS_PASSIVE) {
if (can_add_application (priv->applications, app)) {
/* Put on panel */
- priv->applications = g_list_prepend (priv->applications, app);
-
- /* TODO: We need to have the position determined better. This
- would involve looking at the name and category and sorting
- it with the other entries. */
+ priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile);
g_signal_emit(G_OBJECT(app->appstore),
signals[APPLICATION_ADDED], 0,
newicon,
- 0, /* Position */
+ g_list_index(priv->applications, app), /* Position */
app->dbus_name,
app->menu,
app->icon_path,