mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-14 19:55:12 +01:00
Don't make local copy of desktop file for mimetype changes if the file
2008-01-25 Alexander Larsson <alexl@redhat.com> * gdesktopappinfo.c: Don't make local copy of desktop file for mimetype changes if the file already supports the new mimetype. svn path=/trunk/; revision=6372
This commit is contained in:
parent
5c88ca814c
commit
331d373e9a
@ -1,3 +1,10 @@
|
|||||||
|
2008-01-25 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* gdesktopappinfo.c:
|
||||||
|
Don't make local copy of desktop file
|
||||||
|
for mimetype changes if the file already
|
||||||
|
supports the new mimetype.
|
||||||
|
|
||||||
2008-01-25 Matthias Clasen <mclasen@redhat.com>
|
2008-01-25 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* ginputstream.c:
|
* ginputstream.c:
|
||||||
|
@ -79,6 +79,7 @@ struct _GDesktopAppInfo
|
|||||||
GIcon *icon;
|
GIcon *icon;
|
||||||
char **only_show_in;
|
char **only_show_in;
|
||||||
char **not_show_in;
|
char **not_show_in;
|
||||||
|
char **mimetypes;
|
||||||
char *try_exec;
|
char *try_exec;
|
||||||
char *exec;
|
char *exec;
|
||||||
char *binary;
|
char *binary;
|
||||||
@ -142,6 +143,7 @@ g_desktop_app_info_finalize (GObject *object)
|
|||||||
g_object_unref (info->icon);
|
g_object_unref (info->icon);
|
||||||
g_strfreev (info->only_show_in);
|
g_strfreev (info->only_show_in);
|
||||||
g_strfreev (info->not_show_in);
|
g_strfreev (info->not_show_in);
|
||||||
|
g_strfreev (info->mimetypes);
|
||||||
g_free (info->try_exec);
|
g_free (info->try_exec);
|
||||||
g_free (info->exec);
|
g_free (info->exec);
|
||||||
g_free (info->binary);
|
g_free (info->binary);
|
||||||
@ -238,6 +240,7 @@ g_desktop_app_info_new_from_filename (const char *filename)
|
|||||||
info->icon_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL);
|
info->icon_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL);
|
||||||
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);
|
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);
|
||||||
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);
|
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);
|
||||||
|
info->mimetypes = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL, NULL);
|
||||||
info->try_exec = try_exec;
|
info->try_exec = try_exec;
|
||||||
info->exec = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
|
info->exec = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
|
||||||
info->path = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, NULL);
|
info->path = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, NULL);
|
||||||
@ -1299,6 +1302,24 @@ g_desktop_app_info_set_as_default_for_extension (GAppInfo *appinfo,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
g_desktop_app_info_supports_mimetype (GDesktopAppInfo *appinfo,
|
||||||
|
const char *mimetype)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (appinfo->mimetypes == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
for (i = 0; appinfo->mimetypes[i] != NULL; i++)
|
||||||
|
{
|
||||||
|
if (strcmp (appinfo->mimetypes[i], mimetype) == 0)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_desktop_app_info_add_supports_type (GAppInfo *appinfo,
|
g_desktop_app_info_add_supports_type (GAppInfo *appinfo,
|
||||||
const char *content_type,
|
const char *content_type,
|
||||||
@ -1310,6 +1331,9 @@ g_desktop_app_info_add_supports_type (GAppInfo *appinfo,
|
|||||||
char *dirname;
|
char *dirname;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
|
if (g_desktop_app_info_supports_mimetype (info, content_type))
|
||||||
|
return TRUE; /* Already supported */
|
||||||
|
|
||||||
keyfile = g_key_file_new ();
|
keyfile = g_key_file_new ();
|
||||||
if (!g_key_file_load_from_file (keyfile, info->filename,
|
if (!g_key_file_load_from_file (keyfile, info->filename,
|
||||||
G_KEY_FILE_KEEP_COMMENTS |
|
G_KEY_FILE_KEEP_COMMENTS |
|
||||||
@ -1373,6 +1397,9 @@ g_desktop_app_info_remove_supports_type (GAppInfo *appinfo,
|
|||||||
char *filename;
|
char *filename;
|
||||||
char *dirname;
|
char *dirname;
|
||||||
|
|
||||||
|
if (!g_desktop_app_info_supports_mimetype (info, content_type))
|
||||||
|
return TRUE; /* Already not supported */
|
||||||
|
|
||||||
keyfile = g_key_file_new ();
|
keyfile = g_key_file_new ();
|
||||||
if (!g_key_file_load_from_file (keyfile, info->filename,
|
if (!g_key_file_load_from_file (keyfile, info->filename,
|
||||||
G_KEY_FILE_KEEP_COMMENTS |
|
G_KEY_FILE_KEEP_COMMENTS |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user