#include <errno.h>
#include <string.h>
#include <unistd.h>
-#include <sys/wait.h>
#ifdef HAVE_CRT_EXTERNS_H
#include <crt_externs.h>
char *path;
char *categories;
char *startup_wm_class;
+ char **mime_types;
guint nodisplay : 1;
guint hidden : 1;
g_free (info->path);
g_free (info->categories);
g_free (info->startup_wm_class);
+ g_strfreev (info->mime_types);
G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize (object);
}
info->hidden = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL) != FALSE;
info->categories = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_CATEGORIES, NULL);
info->startup_wm_class = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, STARTUP_WM_CLASS_KEY, NULL);
+ info->mime_types = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL, NULL);
info->icon = NULL;
if (info->icon_name)
* the connection if we were the initial owner.
*/
g_dbus_connection_flush (session_bus, NULL, NULL, NULL);
- g_object_unref (session_bus);
}
completed = TRUE;
out:
+ g_clear_object (&session_bus);
g_strfreev (argv);
g_strfreev (envp);
gpointer data)
{
/* Did the application exit correctly */
- if (WIFEXITED (status) &&
- WEXITSTATUS (status) == 0)
+ if (g_spawn_check_exit_status (status, NULL))
{
/* Here we could clean out any caches in use */
}
error);
}
+static const char **
+g_desktop_app_info_get_supported_types (GAppInfo *appinfo)
+{
+ GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
+
+ return (const char**) info->mime_types;
+}
+
+
static gboolean
g_desktop_app_info_ensure_saved (GDesktopAppInfo *info,
GError **error)
close (fd);
res = g_file_set_contents (filename, data, data_size, error);
+ g_free (data);
if (!res)
{
g_free (desktop_id);
*
* Creates a new #GAppInfo from the given information.
*
+ * Note that for @commandline, the quoting rules of the Exec key of the
+ * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">freedesktop.org Desktop
+ * Entry Specification</ulink> are applied. For example, if the @commandline contains
+ * percent-encoded URIs, the percent-character must be doubled in order to prevent it from
+ * being swallowed by Exec key unquoting. See the specification for exact quoting rules.
+ *
* Returns: (transfer full): new #GAppInfo for given command.
**/
GAppInfo *
iface->get_commandline = g_desktop_app_info_get_commandline;
iface->get_display_name = g_desktop_app_info_get_display_name;
iface->set_as_last_used_for_type = g_desktop_app_info_set_as_last_used_for_type;
+ iface->get_supported_types = g_desktop_app_info_get_supported_types;
}
static gboolean
char **mime_types;
char **default_entries;
char **removed_associations;
+ gboolean already_found_handler;
int i, j, k;
GPtrArray *array;
char **anc;
{
mime_type = mime_types[i];
+ /* This is true if we already found a handler for a more specific
+ mimetype. If its set we ignore any defaults for the less specific
+ mimetypes. */
+ already_found_handler = (desktop_entries != NULL);
+
/* Go through all apps listed in user and system dirs */
for (dir_list = mime_info_cache->dirs;
dir_list != NULL;
/* Pick the explicit default application if we got no result earlier
* (ie, for more specific mime types)
*/
- if (desktop_entries == NULL)
+ if (!already_found_handler)
{
entry = g_hash_table_lookup (dir->mimeapps_list_defaults_map, mime_type);
default_entries = g_hash_table_lookup (dir->defaults_list_map, mime_type);
for (j = 0; default_entries != NULL && default_entries[j] != NULL; j++)
{
- if (default_entry == NULL && old_default_entry == NULL)
+ if (default_entry == NULL && old_default_entry == NULL && !already_found_handler)
old_default_entry = g_strdup (default_entries[j]);
desktop_entries = append_desktop_entry (desktop_entries, default_entries[j], removed_entries);