[Xfce4-commits] [xfce/thunar] 02/03: sendto plugin: extract function tse_file_is_archive (Bug #15916)

noreply at xfce.org noreply at xfce.org
Tue Sep 3 22:48:14 CEST 2019


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

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit 3ecc5abcf76251795944b8050c302326995584fe
Author: Sergey Ponomarev <stokito at gmail.com>
Date:   Mon Sep 2 11:50:15 2019 +0300

    sendto plugin: extract function tse_file_is_archive
    (Bug #15916)
    
    Signed-off-by: Sergey Ponomarev <stokito at gmail.com>
    Signed-off-by: Alexander Schwinn <alexxcons at xfce.org>
---
 plugins/thunar-sendto-email/main.c | 42 ++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/plugins/thunar-sendto-email/main.c b/plugins/thunar-sendto-email/main.c
index 9b212b1..a324470 100644
--- a/plugins/thunar-sendto-email/main.c
+++ b/plugins/thunar-sendto-email/main.c
@@ -139,12 +139,36 @@ tse_error (GError      *error,
   g_free (primary_text);
 }
 
+/**
+ * Check if the single file is already an archive
+ **/
+static gboolean
+tse_file_is_archive (GFileInfo *file_info)
+{
+  const gchar *content_type;
+  guint        n;
+  /* determine the content type */
+  content_type = g_file_info_get_content_type (file_info);
+  if (content_type == NULL)
+  {
+    return FALSE;
+  }
+  for (n = 0; n < G_N_ELEMENTS (TSE_MIME_TYPES); ++n)
+  {
+    /* check if this mime type matches */
+    if (g_content_type_is_a (content_type, TSE_MIME_TYPES[n]))
+    {
+      /* yep, that's a match then */
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
 
 
 static gint
 tse_ask_compress (GList *infos)
 {
-  const gchar *content_type;
   TseData     *tse_data;
   GtkWidget   *message;
   guint64      total_size = 0;
@@ -152,7 +176,6 @@ tse_ask_compress (GList *infos)
   gint         response = TSE_RESPONSE_PLAIN;
   gint         n_archives = 0;
   gint         n_infos = 0;
-  guint        n;
 
   /* check the file infos */
   for (lp = infos; lp != NULL; lp = lp->next, ++n_infos)
@@ -163,19 +186,8 @@ tse_ask_compress (GList *infos)
       if (g_file_info_get_file_type (tse_data->info) == G_FILE_TYPE_DIRECTORY)
         return TSE_RESPONSE_COMPRESS;
 
-      /* determine the content type */
-      content_type = g_file_info_get_content_type (tse_data->info);
-      /* check if the single file is already an archive */
-      for (n = 0; n < G_N_ELEMENTS (TSE_MIME_TYPES); ++n)
-        {
-          /* check if this mime type matches */
-          if (content_type != NULL && g_content_type_is_a (content_type, TSE_MIME_TYPES[n]))
-            {
-              /* yep, that's a match then */
-              ++n_archives;
-              break;
-            }
-        }
+      if (tse_file_is_archive (tse_data->info))
+        ++n_archives;
 
       /* add file size to total */
       total_size += g_file_info_get_size (tse_data->info);

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


More information about the Xfce4-commits mailing list