{
char *dirname, *filename, *string;
GKeyFile *key_file;
- gboolean load_succeeded, res;
+ gboolean load_succeeded, res, explicit_default;
char **old_list, **list;
+ GList *system_list;
gsize length, data_size;
char *data;
int i, j, k;
content_types = g_key_file_get_keys (key_file, DEFAULT_APPLICATIONS_GROUP, NULL, NULL);
}
+ explicit_default = FALSE;
+
for (k = 0; content_types && content_types[k]; k++)
{
/* set as default, if requested so */
content_types[k],
NULL);
else
- g_key_file_set_string (key_file,
- DEFAULT_APPLICATIONS_GROUP,
- content_types[k],
- string);
+ {
+ g_key_file_set_string (key_file,
+ DEFAULT_APPLICATIONS_GROUP,
+ content_types[k],
+ string);
+
+ explicit_default = TRUE;
+ }
g_free (string);
}
content_types[k],
NULL);
else
- g_key_file_set_string_list (key_file,
- ADDED_ASSOCIATIONS_GROUP,
- content_types[k],
- (const char * const *)list, i);
+ {
+ g_key_file_set_string_list (key_file,
+ ADDED_ASSOCIATIONS_GROUP,
+ content_types[k],
+ (const char * const *)list, i);
+
+ /* if we had no explicit default set, we should add the system default to the
+ * list, to avoid overriding it with applications from this list.
+ */
+ if (!explicit_default)
+ {
+ system_list = get_all_desktop_entries_for_mime_type (content_type, (const char **) list, FALSE, NULL);
+
+ if (system_list != NULL)
+ {
+ string = system_list->data;
+
+ g_key_file_set_string (key_file,
+ DEFAULT_APPLICATIONS_GROUP,
+ content_types[k],
+ string);
+ }
+
+ g_list_free_full (system_list, g_free);
+ }
+ }
g_strfreev (list);
}
*
* Gets the #GAppInfo that corresponds to a given content type.
*
- * Returns: #GAppInfo for given @content_type or %NULL on error.
+ * Returns: (transfer full): #GAppInfo for given @content_type or
+ * %NULL on error.
**/
GAppInfo *
g_app_info_get_default_for_type (const char *content_type,
* of the URI, up to but not including the ':', e.g. "http",
* "ftp" or "sip".
*
- * Returns: #GAppInfo for given @uri_scheme or %NULL on error.
+ * Returns: (transfer full): #GAppInfo for given @uri_scheme or %NULL on error.
**/
GAppInfo *
g_app_info_get_default_for_uri_scheme (const char *uri_scheme)