25
25
#include "helpers.h"
27
gboolean verify_keyfile (GKeyFile * inkeyfile, const gchar * desktop);
29
/* Try to find a desktop file in a particular data directory */
31
try_dir (const char * dir, const gchar * desktop)
33
gchar * fullpath = g_build_filename(dir, "applications", desktop, NULL);
34
GKeyFile * keyfile = g_key_file_new();
36
/* NOTE: Leaving off the error here as we'll get a bunch of them,
37
so individuals aren't really useful */
38
gboolean loaded = g_key_file_load_from_file(keyfile, fullpath, G_KEY_FILE_NONE, NULL);
43
g_key_file_free(keyfile);
47
if (!verify_keyfile(keyfile, desktop)) {
48
g_key_file_free(keyfile);
55
/* Check to make sure we have the sections and keys we want */
57
verify_keyfile (GKeyFile * inkeyfile, const gchar * desktop)
59
if (inkeyfile == NULL) return FALSE;
61
if (!g_key_file_has_group(inkeyfile, "Desktop Entry")) {
62
g_warning("Desktop file '%s' is missing the 'Desktop Entry' group", desktop);
66
if (!g_key_file_has_key(inkeyfile, "Desktop Entry", "Exec", NULL)) {
67
g_warning("Desktop file '%s' is missing the 'Exec' key", desktop);
75
28
main (int argc, char * argv[])
82
gchar * desktop = g_strdup_printf("%s.desktop", argv[1]);
84
const char * const * data_dirs = g_get_system_data_dirs();
85
GKeyFile * keyfile = NULL;
88
keyfile = try_dir(g_get_user_data_dir(), desktop);
90
for (i = 0; data_dirs[i] != NULL && keyfile == NULL; i++) {
91
keyfile = try_dir(data_dirs[i], desktop);
35
GKeyFile * keyfile = keyfile_for_appid(argv[1]);
94
37
if (keyfile == NULL) {
95
38
g_error("Unable to find keyfile for application '%s'", argv[0]);