1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
4 * Copyright © 2007 Ryan Lortie
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 * Boston, MA 02111-1307, USA.
21 * Author: Alexander Larsson <alexl@redhat.com>
31 #include "gcontenttypeprivate.h"
32 #include "gdesktopappinfo.h"
34 #include "gthemedicon.h"
35 #include "gfileicon.h"
36 #include <glib/gstdio.h>
42 * SECTION:gdesktopappinfo
43 * @short_description: Application information from desktop files
44 * @include: gio/gdesktopappinfo.h
46 * #GDesktopAppInfo is an implementation of #GAppInfo based on
51 #define DEFAULT_APPLICATIONS_GROUP "Default Applications"
52 #define MIME_CACHE_GROUP "MIME Cache"
54 static void g_desktop_app_info_iface_init (GAppInfoIface *iface);
56 static GList *get_all_desktop_entries_for_mime_type (const char *base_mime_type);
57 static void mime_info_cache_reload (const char *dir);
59 struct _GDesktopAppInfo
61 GObject parent_instance;
67 /* FIXME: what about GenericName ? */
81 guint startup_notify : 1;
82 /* FIXME: what about StartupWMClass ? */
85 G_DEFINE_TYPE_WITH_CODE (GDesktopAppInfo, g_desktop_app_info, G_TYPE_OBJECT,
86 G_IMPLEMENT_INTERFACE (G_TYPE_APP_INFO,
87 g_desktop_app_info_iface_init))
90 search_path_init (gpointer data)
93 const char * const *data_dirs;
94 const char *user_data_dir;
97 data_dirs = g_get_system_data_dirs ();
98 length = g_strv_length ((char **) data_dirs);
100 args = g_new (char *, length + 2);
103 user_data_dir = g_get_user_data_dir ();
104 args[j++] = g_build_filename (user_data_dir, "applications", NULL);
105 for (i = 0; i < length; i++)
106 args[j++] = g_build_filename (data_dirs[i],
107 "applications", NULL);
113 static const char * const *
114 get_applications_search_path (void)
116 static GOnce once_init = G_ONCE_INIT;
117 return g_once (&once_init, search_path_init, NULL);
121 g_desktop_app_info_finalize (GObject *object)
123 GDesktopAppInfo *info;
125 info = G_DESKTOP_APP_INFO (object);
127 g_free (info->desktop_id);
128 g_free (info->filename);
130 g_free (info->comment);
131 g_free (info->icon_name);
133 g_object_unref (info->icon);
134 g_strfreev (info->only_show_in);
135 g_strfreev (info->not_show_in);
136 g_free (info->try_exec);
138 g_free (info->binary);
141 G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize (object);
145 g_desktop_app_info_class_init (GDesktopAppInfoClass *klass)
147 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
149 gobject_class->finalize = g_desktop_app_info_finalize;
153 g_desktop_app_info_init (GDesktopAppInfo *local)
158 * g_desktop_app_info_new_from_filename:
159 * @filename: a string containing a file name.
161 * Creates a new #GDesktopAppInfo.
163 * Returns: a new #GDesktopAppInfo or %NULL on error.
166 g_desktop_app_info_new_from_filename (const char *filename)
168 GDesktopAppInfo *info;
174 key_file = g_key_file_new ();
176 if (!g_key_file_load_from_file (key_file,
182 start_group = g_key_file_get_start_group (key_file);
183 if (start_group == NULL || strcmp (start_group, G_KEY_FILE_DESKTOP_GROUP) != 0)
185 g_free (start_group);
188 g_free (start_group);
190 type = g_key_file_get_string (key_file,
191 G_KEY_FILE_DESKTOP_GROUP,
192 G_KEY_FILE_DESKTOP_KEY_TYPE,
194 if (type == NULL || strcmp (type, G_KEY_FILE_DESKTOP_TYPE_APPLICATION) != 0)
201 try_exec = g_key_file_get_string (key_file,
202 G_KEY_FILE_DESKTOP_GROUP,
203 G_KEY_FILE_DESKTOP_KEY_TRY_EXEC,
208 t = g_find_program_in_path (try_exec);
217 info = g_object_new (G_TYPE_DESKTOP_APP_INFO, NULL);
218 info->filename = g_strdup (filename);
220 info->name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
221 info->comment = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
222 info->nodisplay = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, NULL) != FALSE;
223 info->icon_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL);
224 info->only_show_in = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN, NULL, NULL);
225 info->not_show_in = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN, NULL, NULL);
226 info->try_exec = try_exec;
227 info->exec = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
228 info->path = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, NULL);
229 info->terminal = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TERMINAL, NULL) != FALSE;
230 info->startup_notify = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, NULL) != FALSE;
231 info->hidden = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL) != FALSE;
236 if (g_path_is_absolute (info->icon_name))
240 file = g_file_new_for_path (info->icon_name);
241 info->icon = g_file_icon_new (file);
242 g_object_unref (file);
245 info->icon = g_themed_icon_new (info->icon_name);
256 while (*p != ' ' && *p != 0)
259 info->binary = g_strndup (start, p - start);
266 * g_desktop_app_info_new:
267 * @desktop_id: the desktop file id
269 * Creates a new #GDesktopAppInfo.
271 * Returns: a new #GDesktopAppInfo, or %NULL if no desktop file with that id
274 g_desktop_app_info_new (const char *desktop_id)
276 GDesktopAppInfo *appinfo;
277 const char * const *dirs;
280 dirs = get_applications_search_path ();
282 for (i = 0; dirs[i] != NULL; i++)
288 filename = g_build_filename (dirs[i], desktop_id, NULL);
289 appinfo = g_desktop_app_info_new_from_filename (filename);
296 basename = g_strdup (desktop_id);
298 while ((p = strchr (p, '-')) != NULL)
302 filename = g_build_filename (dirs[i], basename, NULL);
303 appinfo = g_desktop_app_info_new_from_filename (filename);
318 appinfo->desktop_id = g_strdup (desktop_id);
320 if (g_desktop_app_info_get_is_hidden (appinfo))
322 g_object_unref (appinfo);
330 g_desktop_app_info_dup (GAppInfo *appinfo)
332 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
333 GDesktopAppInfo *new_info;
335 new_info = g_object_new (G_TYPE_DESKTOP_APP_INFO, NULL);
337 new_info->filename = g_strdup (info->filename);
338 new_info->desktop_id = g_strdup (info->desktop_id);
340 new_info->name = g_strdup (info->name);
341 new_info->comment = g_strdup (info->comment);
342 new_info->nodisplay = info->nodisplay;
343 new_info->icon_name = g_strdup (info->icon_name);
344 new_info->icon = g_object_ref (info->icon);
345 new_info->only_show_in = g_strdupv (info->only_show_in);
346 new_info->not_show_in = g_strdupv (info->not_show_in);
347 new_info->try_exec = g_strdup (info->try_exec);
348 new_info->exec = g_strdup (info->exec);
349 new_info->binary = g_strdup (info->binary);
350 new_info->path = g_strdup (info->path);
351 new_info->hidden = info->hidden;
352 new_info->terminal = info->terminal;
353 new_info->startup_notify = info->startup_notify;
355 return G_APP_INFO (new_info);
359 g_desktop_app_info_equal (GAppInfo *appinfo1,
362 GDesktopAppInfo *info1 = G_DESKTOP_APP_INFO (appinfo1);
363 GDesktopAppInfo *info2 = G_DESKTOP_APP_INFO (appinfo2);
365 if (info1->desktop_id == NULL ||
366 info2->desktop_id == NULL)
369 return strcmp (info1->desktop_id, info2->desktop_id) == 0;
373 g_desktop_app_info_get_id (GAppInfo *appinfo)
375 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
377 return info->desktop_id;
381 g_desktop_app_info_get_name (GAppInfo *appinfo)
383 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
385 if (info->name == NULL)
391 * g_desktop_app_info_get_is_hidden:
392 * @info: a #GDesktopAppInfo.
394 * A desktop file is hidden if the Hidden key in it is
397 * Returns: %TRUE if hidden, %FALSE otherwise.
400 g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info)
406 g_desktop_app_info_get_description (GAppInfo *appinfo)
408 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
410 return info->comment;
414 g_desktop_app_info_get_executable (GAppInfo *appinfo)
416 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
422 g_desktop_app_info_get_icon (GAppInfo *appinfo)
424 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
430 expand_macro_single (char macro, GFile *file)
435 path = g_file_get_path (file);
436 uri = g_file_get_uri (file);
442 result = g_shell_quote (uri);
447 result = g_shell_quote (path);
452 result = g_shell_quote (g_path_get_dirname (path));
457 result = g_shell_quote (g_path_get_basename (path));
468 expand_macro (char macro,
470 GDesktopAppInfo *info,
473 GList *files = *file_list;
476 g_return_if_fail (exec != NULL);
486 expanded = expand_macro_single (macro, files->data);
489 g_string_append (exec, expanded);
503 expanded = expand_macro_single (macro, files->data);
506 g_string_append (exec, expanded);
512 if (files != NULL && expanded)
513 g_string_append_c (exec, ' ');
521 g_string_append (exec, "--icon ");
522 g_string_append (exec, info->icon_name);
528 g_string_append (exec, info->name);
533 g_string_append (exec, info->filename);
536 case 'm': /* deprecated */
540 g_string_append_c (exec, '%');
548 expand_application_parameters (GDesktopAppInfo *info,
554 GList *file_list = *files;
555 const char *p = info->exec;
556 GString *expanded_exec = g_string_new (NULL);
559 if (info->exec == NULL)
561 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
562 _("Desktop file didn't specify Exec field"));
568 if (p[0] == '%' && p[1] != '\0')
570 expand_macro (p[1], expanded_exec, info, files);
574 g_string_append_c (expanded_exec, *p);
579 /* No file substitutions */
580 if (file_list == *files && file_list != NULL)
582 /* If there is no macro default to %f. This is also what KDE does */
583 g_string_append_c (expanded_exec, ' ');
584 expand_macro ('f', expanded_exec, info, files);
587 res = g_shell_parse_argv (expanded_exec->str, argc, argv, error);
588 g_string_free (expanded_exec, TRUE);
593 prepend_terminal_to_vector (int *argc,
600 char **term_argv = NULL;
605 g_return_val_if_fail (argc != NULL, FALSE);
606 g_return_val_if_fail (argv != NULL, FALSE);
614 /* compute size if not given */
617 for (i = 0; the_argv[i] != NULL; i++)
623 term_argv = g_new0 (char *, 3);
625 check = g_find_program_in_path ("gnome-terminal");
628 term_argv[0] = check;
629 /* Note that gnome-terminal takes -x and
630 * as -e in gnome-terminal is broken we use that. */
631 term_argv[1] = g_strdup ("-x");
636 check = g_find_program_in_path ("nxterm");
638 check = g_find_program_in_path ("color-xterm");
640 check = g_find_program_in_path ("rxvt");
642 check = g_find_program_in_path ("xterm");
644 check = g_find_program_in_path ("dtterm");
647 check = g_strdup ("xterm");
648 g_warning ("couldn't find a terminal, falling back to xterm");
650 term_argv[0] = check;
651 term_argv[1] = g_strdup ("-e");
654 real_argc = term_argc + *argc;
655 real_argv = g_new (char *, real_argc + 1);
657 for (i = 0; i < term_argc; i++)
658 real_argv[i] = term_argv[i];
660 for (j = 0; j < *argc; j++, i++)
661 real_argv[i] = (char *)the_argv[j];
669 /* we use g_free here as we sucked all the inner strings
670 * out from it into real_argv */
675 #endif /* G_OS_WIN32 */
678 /* '=' is the new '\0'.
679 * DO NOT CALL unless at least one string ends with '='
682 is_env (const char *a,
687 if (*a == 0 || *b == 0)
700 /* free with g_strfreev */
702 replace_env_var (char **old_environ,
704 const char *new_value)
706 int length, new_length;
707 int index, new_index;
711 /* do two things at once:
712 * - discover the length of the environment ('length')
713 * - find the location (if any) of the env var ('index')
716 for (length = 0; old_environ[length]; length++)
718 /* if we already have it in our environment, replace */
719 if (is_env (old_environ[length], env_var))
724 /* no current env var, no desired env value.
727 if (new_value == NULL && index == -1)
730 /* in all cases now, we will be using a modified environment.
731 * determine its length and allocated it.
734 * new_index = location to insert, if any
735 * new_length = length of the new array
736 * new_environ = the pointer array for the new environment
739 if (new_value == NULL && index >= 0)
741 /* in this case, we will be removing an entry */
742 new_length = length - 1;
745 else if (new_value != NULL && index < 0)
747 /* in this case, we will be adding an entry to the end */
748 new_length = length + 1;
752 /* in this case, we will be replacing the existing entry */
758 new_environ = g_malloc (sizeof (char *) * (new_length + 1));
759 new_environ[new_length] = NULL;
761 /* now we do the copying.
762 * for each entry in the new environment, we decide what to do
766 for (new_i = 0; new_i < new_length; new_i++)
768 if (new_i == new_index)
770 /* insert our new item */
771 new_environ[new_i] = g_strconcat (env_var,
776 /* if we had an old entry, skip it now */
782 /* if this is the old DESKTOP_STARTUP_ID, skip it */
786 /* copy an old item */
787 new_environ[new_i] = g_strdup (old_environ[i]);
792 g_strfreev (old_environ);
798 dup_list_segment (GList *start,
804 while (start != NULL && start != end)
806 res = g_list_prepend (res, start->data);
810 return g_list_reverse (res);
813 #ifdef HAVE__NSGETENVIRON
814 #define environ (*_NSGetEnviron())
815 #elif !defined(G_OS_WIN32)
817 /* According to the Single Unix Specification, environ is not in
818 * * any system header, although unistd.h often declares it.
820 extern char **environ;
824 g_desktop_app_info_launch (GAppInfo *appinfo,
826 GAppLaunchContext *launch_context,
829 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
830 gboolean completed = FALSE;
832 GList *launched_files;
839 g_return_val_if_fail (appinfo != NULL, FALSE);
847 if (!expand_application_parameters (info, &files,
848 &argc, &argv, error))
851 if (info->terminal && !prepend_terminal_to_vector (&argc, &argv))
853 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
854 _("Unable to find terminal required for application"));
861 launched_files = dup_list_segment (old_files, files);
863 display = g_app_launch_context_get_display (launch_context,
868 if (info->startup_notify)
869 sn_id = g_app_launch_context_get_startup_notify_id (launch_context,
873 if (display || sn_id)
877 envp = g_new0 (char *, 1);
879 envp = g_strdupv (environ);
883 envp = replace_env_var (envp,
888 envp = replace_env_var (envp,
889 "DESKTOP_STARTUP_ID",
895 g_list_free (launched_files);
898 if (!g_spawn_async (info->path, /* working directory */
901 G_SPAWN_SEARCH_PATH /* flags */,
902 NULL /* child_setup */,
904 NULL /* child_pid */,
909 g_app_launch_context_launch_failed (launch_context, sn_id);
923 while (files != NULL);
935 g_desktop_app_info_supports_uris (GAppInfo *appinfo)
937 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
940 ((strstr (info->exec, "%u") != NULL) ||
941 (strstr (info->exec, "%U") != NULL));
945 g_desktop_app_info_launch_uris (GAppInfo *appinfo,
947 GAppLaunchContext *launch_context,
957 file = g_file_new_for_uri (uris->data);
959 g_warning ("Invalid uri passed to g_desktop_app_info_launch_uris");
962 files = g_list_prepend (files, file);
965 files = g_list_reverse (files);
967 res = g_desktop_app_info_launch (appinfo, files, launch_context, error);
969 g_list_foreach (files, (GFunc)g_object_unref, NULL);
976 g_desktop_app_info_should_show (GAppInfo *appinfo,
977 const char *desktop_env)
979 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
986 if (info->only_show_in)
988 if (desktop_env == NULL)
992 for (i = 0; info->only_show_in[i] != NULL; i++)
994 if (strcmp (info->only_show_in[i], desktop_env) == 0)
1004 if (info->not_show_in && desktop_env)
1006 for (i = 0; info->not_show_in[i] != NULL; i++)
1008 if (strcmp (info->not_show_in[i], desktop_env) == 0)
1022 ensure_dir (DirType type,
1025 char *path, *display_name;
1028 if (type == APP_DIR)
1029 path = g_build_filename (g_get_user_data_dir (), "applications", NULL);
1031 path = g_build_filename (g_get_user_data_dir (), "mime", "packages", NULL);
1034 if (g_mkdir_with_parents (path, 0700) == 0)
1038 display_name = g_filename_display_name (path);
1039 if (type == APP_DIR)
1040 g_set_error (error, G_IO_ERROR, g_io_error_from_errno (err),
1041 _("Can't create user application configuration folder %s: %s"),
1042 display_name, g_strerror (err));
1044 g_set_error (error, G_IO_ERROR, g_io_error_from_errno (err),
1045 _("Can't create user MIME configuration folder %s: %s"),
1046 display_name, g_strerror (err));
1048 g_free (display_name);
1055 update_default_list (const char *desktop_id,
1056 const char *content_type,
1060 char *dirname, *filename;
1062 gboolean load_succeeded, res;
1065 gsize length, data_size;
1069 dirname = ensure_dir (APP_DIR, error);
1073 filename = g_build_filename (dirname, "defaults.list", NULL);
1076 key_file = g_key_file_new ();
1077 load_succeeded = g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL);
1078 if (!load_succeeded || !g_key_file_has_group (key_file, DEFAULT_APPLICATIONS_GROUP))
1080 g_key_file_free (key_file);
1081 key_file = g_key_file_new ();
1085 old_list = g_key_file_get_string_list (key_file, DEFAULT_APPLICATIONS_GROUP,
1086 content_type, &length, NULL);
1088 list = g_new (char *, 1 + length + 1);
1092 list[i++] = g_strdup (desktop_id);
1095 for (j = 0; old_list[j] != NULL; j++)
1097 if (strcmp (old_list[j], desktop_id) != 0)
1098 list[i++] = g_strdup (old_list[j]);
1103 g_strfreev (old_list);
1105 g_key_file_set_string_list (key_file,
1106 DEFAULT_APPLICATIONS_GROUP,
1108 (const char * const *)list, i);
1112 data = g_key_file_to_data (key_file, &data_size, error);
1113 g_key_file_free (key_file);
1115 res = g_file_set_contents (filename, data, data_size, error);
1117 mime_info_cache_reload (NULL);
1126 g_desktop_app_info_set_as_default_for_type (GAppInfo *appinfo,
1127 const char *content_type,
1130 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
1132 if (!g_app_info_add_supports_type (appinfo, content_type, error))
1135 return update_default_list (info->desktop_id, content_type, TRUE, error);
1139 update_program_done (GPid pid,
1143 /* Did the application exit correctly */
1144 if (WIFEXITED (status) &&
1145 WEXITSTATUS (status) == 0)
1147 /* Here we could clean out any caches in use */
1152 run_update_command (char *command,
1161 GError *error = NULL;
1164 argv[1] = g_build_filename (g_get_user_data_dir (), subdir, NULL);
1166 if (g_spawn_async ("/", argv,
1168 G_SPAWN_SEARCH_PATH |
1169 G_SPAWN_STDOUT_TO_DEV_NULL |
1170 G_SPAWN_STDERR_TO_DEV_NULL |
1171 G_SPAWN_DO_NOT_REAP_CHILD,
1172 NULL, NULL, /* No setup function */
1175 g_child_watch_add (pid, update_program_done, NULL);
1178 /* If we get an error at this point, it's quite likely the user doesn't
1179 * have an installed copy of either 'update-mime-database' or
1180 * 'update-desktop-database'. I don't think we want to popup an error
1181 * dialog at this point, so we just do a g_warning to give the user a
1182 * chance of debugging it.
1184 g_warning ("%s", error->message);
1191 g_desktop_app_info_set_as_default_for_extension (GAppInfo *appinfo,
1192 const char *extension,
1195 char *filename, *basename, *mimetype;
1199 dirname = ensure_dir (MIMETYPE_DIR, error);
1203 basename = g_strdup_printf ("user-extension-%s.xml", extension);
1204 filename = g_build_filename (dirname, basename, NULL);
1208 mimetype = g_strdup_printf ("application/x-extension-%s", extension);
1210 if (!g_file_test (filename, G_FILE_TEST_EXISTS))
1215 g_strdup_printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1216 "<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">\n"
1217 " <mime-type type=\"%s\">\n"
1218 " <comment>%s document</comment>\n"
1219 " <glob pattern=\"*.%s\"/>\n"
1221 "</mime-info>\n", mimetype, extension, extension);
1223 g_file_set_contents (filename, contents, -1, NULL);
1226 run_update_command ("update-mime-database", "mime");
1230 res = g_desktop_app_info_set_as_default_for_type (appinfo,
1240 g_desktop_app_info_add_supports_type (GAppInfo *appinfo,
1241 const char *content_type,
1244 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
1246 char *new_mimetypes, *old_mimetypes, *content;
1250 keyfile = g_key_file_new ();
1251 if (!g_key_file_load_from_file (keyfile, info->filename,
1252 G_KEY_FILE_KEEP_COMMENTS |
1253 G_KEY_FILE_KEEP_TRANSLATIONS, error))
1255 g_key_file_free (keyfile);
1259 old_mimetypes = g_key_file_get_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL);
1260 new_mimetypes = g_strconcat (content_type, ";", old_mimetypes, NULL);
1261 g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, new_mimetypes);
1262 g_free (old_mimetypes);
1263 g_free (new_mimetypes);
1265 content = g_key_file_to_data (keyfile, NULL, NULL);
1266 g_key_file_free (keyfile);
1268 dirname = ensure_dir (APP_DIR, error);
1275 filename = g_build_filename (dirname, info->desktop_id, NULL);
1278 if (!g_file_set_contents (filename, content, -1, error))
1287 run_update_command ("update-desktop-database", "applications");
1292 g_desktop_app_info_can_remove_supports_type (GAppInfo *appinfo)
1294 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
1297 user_dirname = g_build_filename (g_get_user_data_dir (), "applications", NULL);
1298 return g_str_has_prefix (info->filename, user_dirname);
1302 g_desktop_app_info_remove_supports_type (GAppInfo *appinfo,
1303 const char *content_type,
1306 GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
1308 char *new_mimetypes, *old_mimetypes, *content;
1313 keyfile = g_key_file_new ();
1314 if (!g_key_file_load_from_file (keyfile, info->filename,
1315 G_KEY_FILE_KEEP_COMMENTS |
1316 G_KEY_FILE_KEEP_TRANSLATIONS, error))
1318 g_key_file_free (keyfile);
1322 old_mimetypes = g_key_file_get_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL);
1323 new_mimetypes = g_strdup (old_mimetypes);
1326 found = strstr (new_mimetypes, content_type);
1327 if (found && *(found + strlen (content_type)) == ';')
1329 char *rest = found + strlen (content_type) + 1;
1330 memmove (found, rest, strlen (rest) + 1);
1332 g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, new_mimetypes);
1333 g_free (old_mimetypes);
1334 g_free (new_mimetypes);
1336 content = g_key_file_to_data (keyfile, NULL, NULL);
1337 g_key_file_free (keyfile);
1339 dirname = ensure_dir (APP_DIR, error);
1346 filename = g_build_filename (dirname, info->desktop_id, NULL);
1348 if (!g_file_set_contents (filename, content, -1, error))
1357 run_update_command ("update-desktop-database", "applications");
1359 return update_default_list (info->desktop_id, content_type, FALSE, error);
1363 * g_app_info_create_from_commandline:
1364 * @commandline: the commandline to use
1365 * @application_name: the application name, or %NULL to use @commandline
1366 * @flags: flags that can specify details of the created #GAppInfo
1367 * @error: a #GError location to store the error occuring, %NULL to ignore.
1369 * Creates a new #GAppInfo from the given information.
1371 * Returns: new #GAppInfo for given command.
1374 g_app_info_create_from_commandline (const char *commandline,
1375 const char *application_name,
1376 GAppInfoCreateFlags flags,
1382 char *basename, *exec, *filename, *comment;
1383 char *data, *desktop_id;
1386 GDesktopAppInfo *info;
1389 dirname = ensure_dir (APP_DIR, error);
1393 key_file = g_key_file_new ();
1395 g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
1396 "Encoding", "UTF-8");
1397 g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
1398 G_KEY_FILE_DESKTOP_KEY_VERSION, "1.0");
1399 g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
1400 G_KEY_FILE_DESKTOP_KEY_TYPE,
1401 G_KEY_FILE_DESKTOP_TYPE_APPLICATION);
1402 if (flags & G_APP_INFO_CREATE_NEEDS_TERMINAL)
1403 g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP,
1404 G_KEY_FILE_DESKTOP_KEY_TERMINAL, TRUE);
1406 exec = g_strconcat (commandline, " %f", NULL);
1407 g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
1408 G_KEY_FILE_DESKTOP_KEY_EXEC, exec);
1411 /* FIXME: this should be more robust. Maybe g_shell_parse_argv and use argv[0] */
1412 split = g_strsplit (commandline, " ", 2);
1413 basename = g_path_get_basename (split[0]);
1415 g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
1416 G_KEY_FILE_DESKTOP_KEY_NAME, application_name?application_name:basename);
1418 comment = g_strdup_printf (_("Custom definition for %s"), basename);
1419 g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
1420 G_KEY_FILE_DESKTOP_KEY_COMMENT, comment);
1423 g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP,
1424 G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, TRUE);
1426 data = g_key_file_to_data (key_file, &data_size, NULL);
1427 g_key_file_free (key_file);
1429 desktop_id = g_strdup_printf ("userapp-%s-XXXXXX.desktop", basename);
1431 filename = g_build_filename (dirname, desktop_id, NULL);
1432 g_free (desktop_id);
1435 fd = g_mkstemp (filename);
1440 display_name = g_filename_display_name (filename);
1441 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
1442 _("Can't create user desktop file %s"), display_name);
1443 g_free (display_name);
1449 desktop_id = g_path_get_basename (filename);
1453 res = g_file_set_contents (filename, data, data_size, error);
1456 g_free (desktop_id);
1461 run_update_command ("update-desktop-database", "applications");
1463 info = g_desktop_app_info_new_from_filename (filename);
1466 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
1467 _("Can't load just created desktop file"));
1469 info->desktop_id = g_strdup (desktop_id);
1471 g_free (desktop_id);
1473 return G_APP_INFO (info);
1478 g_desktop_app_info_iface_init (GAppInfoIface *iface)
1480 iface->dup = g_desktop_app_info_dup;
1481 iface->equal = g_desktop_app_info_equal;
1482 iface->get_id = g_desktop_app_info_get_id;
1483 iface->get_name = g_desktop_app_info_get_name;
1484 iface->get_description = g_desktop_app_info_get_description;
1485 iface->get_executable = g_desktop_app_info_get_executable;
1486 iface->get_icon = g_desktop_app_info_get_icon;
1487 iface->launch = g_desktop_app_info_launch;
1488 iface->supports_uris = g_desktop_app_info_supports_uris;
1489 iface->launch_uris = g_desktop_app_info_launch_uris;
1490 iface->should_show = g_desktop_app_info_should_show;
1491 iface->set_as_default_for_type = g_desktop_app_info_set_as_default_for_type;
1492 iface->set_as_default_for_extension = g_desktop_app_info_set_as_default_for_extension;
1493 iface->add_supports_type = g_desktop_app_info_add_supports_type;
1494 iface->can_remove_supports_type = g_desktop_app_info_can_remove_supports_type;
1495 iface->remove_supports_type = g_desktop_app_info_remove_supports_type;
1499 app_info_in_list (GAppInfo *info,
1502 while (list != NULL)
1504 if (g_app_info_equal (info, list->data))
1513 * g_app_info_get_all_for_type:
1514 * @content_type: the content type to find a #GAppInfo for
1516 * Gets a list of all #GAppInfo s for a given content type.
1518 * Returns: #GList of #GAppInfo s for given @content_type.
1521 g_app_info_get_all_for_type (const char *content_type)
1523 GList *desktop_entries, *l;
1525 GDesktopAppInfo *info;
1527 desktop_entries = get_all_desktop_entries_for_mime_type (content_type);
1530 for (l = desktop_entries; l != NULL; l = l->next)
1532 char *desktop_entry = l->data;
1534 info = g_desktop_app_info_new (desktop_entry);
1537 if (app_info_in_list (G_APP_INFO (info), infos))
1538 g_object_unref (info);
1540 infos = g_list_prepend (infos, info);
1542 g_free (desktop_entry);
1545 g_list_free (desktop_entries);
1547 return g_list_reverse (infos);
1552 * g_app_info_get_default_for_type:
1553 * @content_type: the content type to find a #GAppInfo for
1554 * @must_support_uris: if %TRUE, the #GAppInfo is expected to
1557 * Gets the #GAppInfo that correspond to a given content type.
1559 * Returns: #GAppInfo for given @content_type.
1562 g_app_info_get_default_for_type (const char *content_type,
1563 gboolean must_support_uris)
1565 GList *desktop_entries, *l;
1568 desktop_entries = get_all_desktop_entries_for_mime_type (content_type);
1571 for (l = desktop_entries; l != NULL; l = l->next)
1573 char *desktop_entry = l->data;
1575 info = (GAppInfo *)g_desktop_app_info_new (desktop_entry);
1578 if (must_support_uris && !g_app_info_supports_uris (info))
1580 g_object_unref (info);
1588 g_list_foreach (desktop_entries, (GFunc)g_free, NULL);
1589 g_list_free (desktop_entries);
1596 * g_app_info_get_default_for_uri_scheme:
1597 * @uri_scheme: a string containing a URI scheme.
1599 * Gets the default application for launching applications
1600 * using this URI scheme.
1602 * TODO: This is currently unimplemented.
1607 g_app_info_get_default_for_uri_scheme (const char *uri_scheme)
1609 /* TODO: Implement this using giomodules, reading the gconf settings
1610 * in /desktop/gnome/url-handlers
1617 get_apps_from_dir (GHashTable *apps,
1618 const char *dirname,
1622 const char *basename;
1623 char *filename, *subprefix, *desktop_id;
1625 GDesktopAppInfo *appinfo;
1627 dir = g_dir_open (dirname, 0, NULL);
1630 while ((basename = g_dir_read_name (dir)) != NULL)
1632 filename = g_build_filename (dirname, basename, NULL);
1633 if (g_str_has_suffix (basename, ".desktop"))
1635 desktop_id = g_strconcat (prefix, basename, NULL);
1637 /* Use _extended so we catch NULLs too (hidden) */
1638 if (!g_hash_table_lookup_extended (apps, desktop_id, NULL, NULL))
1640 appinfo = g_desktop_app_info_new_from_filename (filename);
1642 /* Don't return apps that don't take arguments */
1644 (g_desktop_app_info_get_is_hidden (appinfo) ||
1646 strstr (appinfo->exec,"%U") == NULL &&
1647 strstr (appinfo->exec,"%u") == NULL &&
1648 strstr (appinfo->exec,"%f") == NULL &&
1649 strstr (appinfo->exec,"%F") == NULL)))
1651 g_object_unref (appinfo);
1656 if (appinfo != NULL || hidden)
1658 g_hash_table_insert (apps, g_strdup (desktop_id), appinfo);
1662 /* Reuse instead of strdup here */
1663 appinfo->desktop_id = desktop_id;
1668 g_free (desktop_id);
1672 if (g_file_test (filename, G_FILE_TEST_IS_DIR))
1674 subprefix = g_strconcat (prefix, basename, "-", NULL);
1675 get_apps_from_dir (apps, filename, subprefix);
1687 * g_app_info_get_all:
1689 * Gets a list of all of the applications currently registered on this system.
1691 * Returns: a newly allocated #GList of references to #GAppInfo<!---->s.
1694 g_app_info_get_all (void)
1696 const char * const *dirs;
1698 GHashTableIter iter;
1703 dirs = get_applications_search_path ();
1705 apps = g_hash_table_new_full (g_str_hash, g_str_equal,
1709 for (i = 0; dirs[i] != NULL; i++)
1710 get_apps_from_dir (apps, dirs[i], "");
1714 g_hash_table_iter_init (&iter, apps);
1715 while (g_hash_table_iter_next (&iter, NULL, &value))
1716 infos = g_list_prepend (infos, value);
1718 g_hash_table_destroy (apps);
1720 return g_list_reverse (infos);
1723 /* Cacheing of mimeinfo.cache and defaults.list files */
1727 GHashTable *mime_info_cache_map;
1728 GHashTable *defaults_list_map;
1729 time_t mime_info_cache_timestamp;
1730 time_t defaults_list_timestamp;
1734 GList *dirs; /* mimeinfo.cache and defaults.list */
1735 GHashTable *global_defaults_cache; /* global results of defaults.list lookup and validation */
1736 time_t last_stat_time;
1737 guint should_ping_mime_monitor : 1;
1740 static MimeInfoCache *mime_info_cache = NULL;
1741 G_LOCK_DEFINE_STATIC (mime_info_cache);
1743 static void mime_info_cache_dir_add_desktop_entries (MimeInfoCacheDir *dir,
1744 const char *mime_type,
1745 char **new_desktop_file_ids);
1747 static MimeInfoCache * mime_info_cache_new (void);
1750 destroy_info_cache_value (gpointer key,
1754 g_list_foreach (value, (GFunc)g_free, NULL);
1755 g_list_free (value);
1759 destroy_info_cache_map (GHashTable *info_cache_map)
1761 g_hash_table_foreach (info_cache_map, (GHFunc)destroy_info_cache_value, NULL);
1762 g_hash_table_destroy (info_cache_map);
1766 mime_info_cache_dir_out_of_date (MimeInfoCacheDir *dir,
1767 const char *cache_file,
1773 filename = g_build_filename (dir->path, cache_file, NULL);
1775 if (g_stat (filename, &buf) < 0)
1782 if (buf.st_mtime != *timestamp)
1788 /* Call with lock held */
1790 remove_all (gpointer key,
1799 mime_info_cache_blow_global_cache (void)
1801 g_hash_table_foreach_remove (mime_info_cache->global_defaults_cache,
1806 mime_info_cache_dir_init (MimeInfoCacheDir *dir)
1810 gchar *filename, **mime_types;
1817 if (dir->mime_info_cache_map != NULL &&
1818 !mime_info_cache_dir_out_of_date (dir, "mimeinfo.cache",
1819 &dir->mime_info_cache_timestamp))
1822 if (dir->mime_info_cache_map != NULL)
1823 destroy_info_cache_map (dir->mime_info_cache_map);
1825 dir->mime_info_cache_map = g_hash_table_new_full (g_str_hash, g_str_equal,
1826 (GDestroyNotify) g_free,
1829 key_file = g_key_file_new ();
1831 filename = g_build_filename (dir->path, "mimeinfo.cache", NULL);
1833 if (g_stat (filename, &buf) < 0)
1836 if (dir->mime_info_cache_timestamp > 0)
1837 mime_info_cache->should_ping_mime_monitor = TRUE;
1839 dir->mime_info_cache_timestamp = buf.st_mtime;
1841 g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &load_error);
1846 if (load_error != NULL)
1849 mime_types = g_key_file_get_keys (key_file, MIME_CACHE_GROUP,
1852 if (load_error != NULL)
1855 for (i = 0; mime_types[i] != NULL; i++)
1857 gchar **desktop_file_ids;
1858 char *unaliased_type;
1859 desktop_file_ids = g_key_file_get_string_list (key_file,
1865 if (desktop_file_ids == NULL)
1868 unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
1869 mime_info_cache_dir_add_desktop_entries (dir,
1872 g_free (unaliased_type);
1874 g_strfreev (desktop_file_ids);
1877 g_strfreev (mime_types);
1878 g_key_file_free (key_file);
1883 g_key_file_free (key_file);
1885 if (mime_types != NULL)
1886 g_strfreev (mime_types);
1889 g_error_free (load_error);
1893 mime_info_cache_dir_init_defaults_list (MimeInfoCacheDir *dir)
1897 gchar *filename, **mime_types;
1898 char *unaliased_type;
1899 char **desktop_file_ids;
1906 if (dir->defaults_list_map != NULL &&
1907 !mime_info_cache_dir_out_of_date (dir, "defaults.list",
1908 &dir->defaults_list_timestamp))
1911 if (dir->defaults_list_map != NULL)
1912 g_hash_table_destroy (dir->defaults_list_map);
1914 dir->defaults_list_map = g_hash_table_new_full (g_str_hash, g_str_equal,
1915 g_free, (GDestroyNotify)g_strfreev);
1917 key_file = g_key_file_new ();
1919 filename = g_build_filename (dir->path, "defaults.list", NULL);
1920 if (g_stat (filename, &buf) < 0)
1923 if (dir->defaults_list_timestamp > 0)
1924 mime_info_cache->should_ping_mime_monitor = TRUE;
1926 dir->defaults_list_timestamp = buf.st_mtime;
1928 g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &load_error);
1932 if (load_error != NULL)
1935 mime_types = g_key_file_get_keys (key_file, DEFAULT_APPLICATIONS_GROUP,
1938 if (load_error != NULL)
1941 for (i = 0; mime_types[i] != NULL; i++)
1943 desktop_file_ids = g_key_file_get_string_list (key_file,
1944 DEFAULT_APPLICATIONS_GROUP,
1948 if (desktop_file_ids == NULL)
1951 unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
1952 g_hash_table_replace (dir->defaults_list_map,
1957 g_strfreev (mime_types);
1958 g_key_file_free (key_file);
1963 g_key_file_free (key_file);
1965 if (mime_types != NULL)
1966 g_strfreev (mime_types);
1969 g_error_free (load_error);
1972 static MimeInfoCacheDir *
1973 mime_info_cache_dir_new (const char *path)
1975 MimeInfoCacheDir *dir;
1977 dir = g_new0 (MimeInfoCacheDir, 1);
1978 dir->path = g_strdup (path);
1984 mime_info_cache_dir_free (MimeInfoCacheDir *dir)
1989 if (dir->mime_info_cache_map != NULL)
1991 destroy_info_cache_map (dir->mime_info_cache_map);
1992 dir->mime_info_cache_map = NULL;
1996 if (dir->defaults_list_map != NULL)
1998 g_hash_table_destroy (dir->defaults_list_map);
1999 dir->defaults_list_map = NULL;
2006 mime_info_cache_dir_add_desktop_entries (MimeInfoCacheDir *dir,
2007 const char *mime_type,
2008 char **new_desktop_file_ids)
2010 GList *desktop_file_ids;
2013 desktop_file_ids = g_hash_table_lookup (dir->mime_info_cache_map,
2016 for (i = 0; new_desktop_file_ids[i] != NULL; i++)
2018 if (!g_list_find (desktop_file_ids, new_desktop_file_ids[i]))
2019 desktop_file_ids = g_list_append (desktop_file_ids,
2020 g_strdup (new_desktop_file_ids[i]));
2023 g_hash_table_insert (dir->mime_info_cache_map, g_strdup (mime_type), desktop_file_ids);
2027 mime_info_cache_init_dir_lists (void)
2029 const char * const *dirs;
2032 mime_info_cache = mime_info_cache_new ();
2034 dirs = get_applications_search_path ();
2036 for (i = 0; dirs[i] != NULL; i++)
2038 MimeInfoCacheDir *dir;
2040 dir = mime_info_cache_dir_new (dirs[i]);
2044 mime_info_cache_dir_init (dir);
2045 mime_info_cache_dir_init_defaults_list (dir);
2047 mime_info_cache->dirs = g_list_append (mime_info_cache->dirs, dir);
2053 mime_info_cache_update_dir_lists (void)
2057 tmp = mime_info_cache->dirs;
2061 MimeInfoCacheDir *dir = (MimeInfoCacheDir *) tmp->data;
2063 /* No need to do this if we had file monitors... */
2064 mime_info_cache_blow_global_cache ();
2065 mime_info_cache_dir_init (dir);
2066 mime_info_cache_dir_init_defaults_list (dir);
2073 mime_info_cache_init (void)
2075 G_LOCK (mime_info_cache);
2076 if (mime_info_cache == NULL)
2077 mime_info_cache_init_dir_lists ();
2083 if (now >= mime_info_cache->last_stat_time + 10)
2085 mime_info_cache_update_dir_lists ();
2086 mime_info_cache->last_stat_time = now;
2090 if (mime_info_cache->should_ping_mime_monitor)
2092 /* g_idle_add (emit_mime_changed, NULL); */
2093 mime_info_cache->should_ping_mime_monitor = FALSE;
2096 G_UNLOCK (mime_info_cache);
2099 static MimeInfoCache *
2100 mime_info_cache_new (void)
2102 MimeInfoCache *cache;
2104 cache = g_new0 (MimeInfoCache, 1);
2106 cache->global_defaults_cache = g_hash_table_new_full (g_str_hash, g_str_equal,
2107 (GDestroyNotify) g_free,
2108 (GDestroyNotify) g_free);
2113 mime_info_cache_free (MimeInfoCache *cache)
2118 g_list_foreach (cache->dirs,
2119 (GFunc) mime_info_cache_dir_free,
2121 g_list_free (cache->dirs);
2122 g_hash_table_destroy (cache->global_defaults_cache);
2127 * mime_info_cache_reload:
2128 * @dir: directory path which needs reloading.
2130 * Reload the mime information for the @dir.
2133 mime_info_cache_reload (const char *dir)
2135 /* FIXME: just reload the dir that needs reloading,
2136 * don't blow the whole cache
2138 if (mime_info_cache != NULL)
2140 G_LOCK (mime_info_cache);
2141 mime_info_cache_free (mime_info_cache);
2142 mime_info_cache = NULL;
2143 G_UNLOCK (mime_info_cache);
2148 append_desktop_entry (GList *list,
2149 const char *desktop_entry)
2151 /* Add if not already in list, and valid */
2152 if (!g_list_find_custom (list, desktop_entry, (GCompareFunc) strcmp))
2153 list = g_list_prepend (list, g_strdup (desktop_entry));
2159 * get_all_desktop_entries_for_mime_type:
2160 * @mime_type: a mime type.
2162 * Returns all the desktop ids for @mime_type. The desktop files
2163 * are listed in an order so that default applications are listed before
2164 * non-default ones, and handlers for inherited mimetypes are listed
2165 * after the base ones.
2167 * Return value: a #GList containing the desktop ids which claim
2168 * to handle @mime_type.
2171 get_all_desktop_entries_for_mime_type (const char *base_mime_type)
2173 GList *desktop_entries, *list, *dir_list, *tmp;
2174 MimeInfoCacheDir *dir;
2177 char **default_entries;
2180 mime_info_cache_init ();
2182 mime_types = _g_unix_content_type_get_parents (base_mime_type);
2183 G_LOCK (mime_info_cache);
2185 desktop_entries = NULL;
2186 for (i = 0; mime_types[i] != NULL; i++)
2188 mime_type = mime_types[i];
2190 /* Go through all apps listed as defaults */
2191 for (dir_list = mime_info_cache->dirs;
2193 dir_list = dir_list->next)
2195 dir = dir_list->data;
2196 default_entries = g_hash_table_lookup (dir->defaults_list_map, mime_type);
2197 for (j = 0; default_entries != NULL && default_entries[j] != NULL; j++)
2198 desktop_entries = append_desktop_entry (desktop_entries, default_entries[j]);
2201 /* Go through all entries that support the mimetype */
2202 for (dir_list = mime_info_cache->dirs;
2204 dir_list = dir_list->next)
2206 dir = dir_list->data;
2208 list = g_hash_table_lookup (dir->mime_info_cache_map, mime_type);
2209 for (tmp = list; tmp != NULL; tmp = tmp->next)
2210 desktop_entries = append_desktop_entry (desktop_entries, tmp->data);
2214 G_UNLOCK (mime_info_cache);
2216 g_strfreev (mime_types);
2218 desktop_entries = g_list_reverse (desktop_entries);
2220 return desktop_entries;
2223 #define __G_DESKTOP_APP_INFO_C__
2224 #include "gioaliasdef.c"