shell-app-system: Cache GAppInfos around
This was called here just to end up emitting ::installed-changed, which would trigger other g_app_info_get_all() calls. Cache it here so it may be reused later on.
This commit is contained in:
parent
3db52155dd
commit
69ad75cf48
@ -50,6 +50,7 @@ struct _ShellAppSystemPrivate {
|
|||||||
GHashTable *running_apps;
|
GHashTable *running_apps;
|
||||||
GHashTable *id_to_app;
|
GHashTable *id_to_app;
|
||||||
GHashTable *startup_wm_class_to_id;
|
GHashTable *startup_wm_class_to_id;
|
||||||
|
GList *installed_apps;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void shell_app_system_finalize (GObject *object);
|
static void shell_app_system_finalize (GObject *object);
|
||||||
@ -82,12 +83,14 @@ static void
|
|||||||
scan_startup_wm_class_to_id (ShellAppSystem *self)
|
scan_startup_wm_class_to_id (ShellAppSystem *self)
|
||||||
{
|
{
|
||||||
ShellAppSystemPrivate *priv = self->priv;
|
ShellAppSystemPrivate *priv = self->priv;
|
||||||
GList *apps, *l;
|
GList *l;
|
||||||
|
|
||||||
g_hash_table_remove_all (priv->startup_wm_class_to_id);
|
g_hash_table_remove_all (priv->startup_wm_class_to_id);
|
||||||
|
|
||||||
apps = g_app_info_get_all ();
|
g_list_free_full (priv->installed_apps, g_object_unref);
|
||||||
for (l = apps; l != NULL; l = l->next)
|
priv->installed_apps = g_app_info_get_all ();
|
||||||
|
|
||||||
|
for (l = priv->installed_apps; l != NULL; l = l->next)
|
||||||
{
|
{
|
||||||
GAppInfo *info = l->data;
|
GAppInfo *info = l->data;
|
||||||
const char *startup_wm_class, *id, *old_id;
|
const char *startup_wm_class, *id, *old_id;
|
||||||
@ -105,8 +108,6 @@ scan_startup_wm_class_to_id (ShellAppSystem *self)
|
|||||||
g_hash_table_insert (priv->startup_wm_class_to_id,
|
g_hash_table_insert (priv->startup_wm_class_to_id,
|
||||||
g_strdup (startup_wm_class), g_strdup (id));
|
g_strdup (startup_wm_class), g_strdup (id));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free_full (apps, g_object_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -198,6 +199,7 @@ shell_app_system_finalize (GObject *object)
|
|||||||
g_hash_table_destroy (priv->running_apps);
|
g_hash_table_destroy (priv->running_apps);
|
||||||
g_hash_table_destroy (priv->id_to_app);
|
g_hash_table_destroy (priv->id_to_app);
|
||||||
g_hash_table_destroy (priv->startup_wm_class_to_id);
|
g_hash_table_destroy (priv->startup_wm_class_to_id);
|
||||||
|
g_list_free_full (priv->installed_apps, g_object_unref);
|
||||||
|
|
||||||
G_OBJECT_CLASS (shell_app_system_parent_class)->finalize (object);
|
G_OBJECT_CLASS (shell_app_system_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -436,3 +438,21 @@ shell_app_system_search (const char *search_string)
|
|||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shell_app_system_get_installed:
|
||||||
|
* @self: the #ShellAppSystem
|
||||||
|
*
|
||||||
|
* Returns all installed apps, as a list of #GAppInfo
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (element-type GAppInfo): a list of #GAppInfo
|
||||||
|
* describing all known applications. This memory is owned by the
|
||||||
|
* #ShellAppSystem and should not be freed.
|
||||||
|
**/
|
||||||
|
GList *
|
||||||
|
shell_app_system_get_installed (ShellAppSystem *self)
|
||||||
|
{
|
||||||
|
ShellAppSystemPrivate *priv = self->priv;
|
||||||
|
|
||||||
|
return priv->installed_apps;
|
||||||
|
}
|
||||||
|
@ -27,4 +27,6 @@ ShellApp *shell_app_system_lookup_desktop_wmclass (ShellAppSystem *s
|
|||||||
GSList *shell_app_system_get_running (ShellAppSystem *self);
|
GSList *shell_app_system_get_running (ShellAppSystem *self);
|
||||||
char ***shell_app_system_search (const char *search_string);
|
char ***shell_app_system_search (const char *search_string);
|
||||||
|
|
||||||
|
GList *shell_app_system_get_installed (ShellAppSystem *self);
|
||||||
|
|
||||||
#endif /* __SHELL_APP_SYSTEM_H__ */
|
#endif /* __SHELL_APP_SYSTEM_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user