[Xfce4-commits] [xfce/thunar] 01/01: thunar-wallpaper: Check if file is really an image (bug #11565)

noreply at xfce.org noreply at xfce.org
Sat Feb 21 20:26:48 CET 2015


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository xfce/thunar.

commit 77738a08e24f8b212feedfa42d8997c081dfaaef
Author: Thaddaeus Tintenfisch <thad.fisch at gmail.com>
Date:   Fri Feb 20 19:38:26 2015 +0100

    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.
---
 plugins/thunar-wallpaper/twp-provider.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/plugins/thunar-wallpaper/twp-provider.c b/plugins/thunar-wallpaper/twp-provider.c
index 0dbaa53..f070e62 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);
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list