diff options
author | Thaddaeus Tintenfisch <thad.fisch@gmail.com> | 2015-02-20 19:38:26 +0100 |
---|---|---|
committer | Harald Judt <h.judt@gmx.at> | 2015-02-21 20:16:36 +0100 |
commit | 77738a08e24f8b212feedfa42d8997c081dfaaef (patch) | |
tree | d691e466a0b3420a783e26802005f6d550b61fc2 /plugins | |
parent | 5fce9935106eebb8ac7b9dd2b0aa5a1a42e41721 (diff) | |
download | thunar-77738a08e24f8b212feedfa42d8997c081dfaaef.tar.gz |
thunar-wallpaper: Check if file is really an image (bug #11565)
This change prevents the "Set as wallpaper" entry from showing up in the
xfdesktop context menu for plain text files. For reasons yet unknown,
this is not necessary for the context menu in thunar.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/thunar-wallpaper/twp-provider.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/plugins/thunar-wallpaper/twp-provider.c b/plugins/thunar-wallpaper/twp-provider.c index 0dbaa538..f070e620 100644 --- a/plugins/thunar-wallpaper/twp-provider.c +++ b/plugins/thunar-wallpaper/twp-provider.c @@ -132,6 +132,7 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider, GtkWidget *action = NULL; GFile *location; GList *actions = NULL; + gchar *mime_type; gchar selection_name[100]; Atom xfce_selection_atom; Atom nautilus_selection_atom; @@ -158,10 +159,14 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider, if (!thunarx_file_info_is_directory (files->data)) { - if (thunarx_file_info_has_mime_type (files->data, "image/jpeg") - ||thunarx_file_info_has_mime_type (files->data, "image/png") - ||thunarx_file_info_has_mime_type (files->data, "image/svg+xml") - ||thunarx_file_info_has_mime_type (files->data, "image/svg+xml-compressed")) + /* get the mime type of the file */ + mime_type = thunarx_file_info_get_mime_type (files->data); + + if (g_str_has_prefix (mime_type, "image/") + && (thunarx_file_info_has_mime_type (files->data, "image/jpeg") + || thunarx_file_info_has_mime_type (files->data, "image/png") + || thunarx_file_info_has_mime_type (files->data, "image/svg+xml") + || thunarx_file_info_has_mime_type (files->data, "image/svg+xml-compressed"))) { action = g_object_new (GTK_TYPE_ACTION, "name", "Twp::setwallpaper", @@ -172,6 +177,7 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider, actions = g_list_append (actions, action); } + g_free(mime_type); } } |