ShellAppCache: add cache to help keep I/O off main thread

A number of things can result in doing I/O on the main thread such as
loading GAppInfo or folder translations. The ShellAppCache provides a
layer of abstraction around those things so that we can keep that work
off the main thread by delaying a short while and processing the work
synchronously off-main-thread.

The results can then be marshalled back to the main thread for use by
the rest of the system via the ShellAppCache::changed() signal.
This commit is contained in:
Christian Hergert
2020-02-26 23:08:14 -08:00
parent f597a0a11c
commit 2c549bfbbe
3 changed files with 407 additions and 0 deletions

19
src/shell-app-cache.h Normal file
View File

@@ -0,0 +1,19 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
#ifndef __SHELL_APP_CACHE__
#define __SHELL_APP_CACHE__
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#define SHELL_TYPE_APP_CACHE (shell_app_cache_get_type())
G_DECLARE_FINAL_TYPE (ShellAppCache, shell_app_cache, SHELL, APP_CACHE, GObject)
ShellAppCache *shell_app_cache_get_default (void);
GList *shell_app_cache_get_all (ShellAppCache *cache);
GDesktopAppInfo *shell_app_cache_get_info (ShellAppCache *cache,
const char *id);
char *shell_app_cache_translate_folder (ShellAppCache *cache,
const char *name);
#endif /* __SHELL_APP_CACHE__ */