mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
GDesktopAppInfo: rewrite content type code
Redo the code for type-based selection of applications (all, recommended, default, fallback) based on the new DesktopFileDir structures that we introduced last cycle. At the same time, we expand the functionality to add support for the new features of the specification: - moving ~/.local/share/applications/mimeapps.list to ~/.config/ - per-desktop default applications (via XDG_CURRENT_DESKTOP) - sysadmin customisation of defaults (via /etc/xdg/mimeapps.list) - deprecation of the old defaults.list, favouring the use of /usr/share/applications/mimeapps.list (or gnome-mimeapps.list) to accomplish the same We modify the mimeapps testcase to check for mimeapps.list having been created in XDG_CONFIG_HOME instead of XDG_DATA_HOME. The modification is a net reduction of code (due to less duplication in bookkeeping). It is also an increase in performance and reduction in memory consumption (due to simplified data structures). Finally, it removes the stat-based timestamp checking in favour of the GFileMonitor-based approach that was already being used in the implementation of DesktopFileDir (in order to know if we had to rescan the desktop files themselves). https://bugzilla.gnome.org/show_bug.cgi?id=728040
This commit is contained in:
parent
caf0f1df1c
commit
6fd5a8cdaa
File diff suppressed because it is too large
Load Diff
@ -104,6 +104,7 @@ static void
|
||||
setup (void)
|
||||
{
|
||||
gchar *dir;
|
||||
gchar *xdgconfighome;
|
||||
gchar *xdgdatahome;
|
||||
gchar *xdgdatadir;
|
||||
gchar *appdir;
|
||||
@ -114,8 +115,11 @@ setup (void)
|
||||
GError *error = NULL;
|
||||
|
||||
dir = g_get_current_dir ();
|
||||
xdgconfighome = g_build_filename (dir, "xdgconfighome", NULL);
|
||||
xdgdatahome = g_build_filename (dir, "xdgdatahome", NULL);
|
||||
xdgdatadir = g_build_filename (dir, "xdgdatadir", NULL);
|
||||
g_test_message ("setting XDG_CONFIG_HOME to '%s'\n", xdgconfighome);
|
||||
g_setenv ("XDG_CONFIG_HOME", xdgconfighome, TRUE);
|
||||
g_test_message ("setting XDG_DATA_HOME to '%s'\n", xdgdatahome);
|
||||
g_setenv ("XDG_DATA_HOME", xdgdatahome, TRUE);
|
||||
g_test_message ("setting XDG_DATA_DIRS to '%s'\n", xdgdatadir);
|
||||
@ -184,6 +188,7 @@ setup (void)
|
||||
g_free (name);
|
||||
|
||||
g_free (dir);
|
||||
g_free (xdgconfighome);
|
||||
g_free (xdgdatahome);
|
||||
g_free (xdgdatadir);
|
||||
g_free (apphome);
|
||||
@ -297,7 +302,7 @@ test_mime_file (void)
|
||||
const gchar *contenttype = "application/pdf";
|
||||
|
||||
dir = g_get_current_dir ();
|
||||
mimeapps = g_build_filename (dir, "xdgdatahome", "applications", "mimeapps.list", NULL);
|
||||
mimeapps = g_build_filename (dir, "xdgconfighome", "mimeapps.list", NULL);
|
||||
|
||||
/* clear things out */
|
||||
g_app_info_reset_type_associations (contenttype);
|
||||
|
Loading…
Reference in New Issue
Block a user