[gimp] plug-ins: some cleaup in file-raw, mostly formatting



commit 3b950f6177062da408266be5ba472df8d84a2121
Author: Michael Natterer <mitch gimp org>
Date:   Fri Jan 5 14:31:40 2018 +0100

    plug-ins: some cleaup in file-raw, mostly formatting

 plug-ins/file-raw/file-darktable.c   |   35 ++++++++++++++++++++-------------
 plug-ins/file-raw/file-raw-utils.c   |   11 +++++++--
 plug-ins/file-raw/file-raw-utils.h   |   14 +++++++-----
 plug-ins/file-raw/file-rawtherapee.c |   23 +++++++++++----------
 4 files changed, 49 insertions(+), 34 deletions(-)
---
diff --git a/plug-ins/file-raw/file-darktable.c b/plug-ins/file-raw/file-darktable.c
index 41167a4..a15d58e 100644
--- a/plug-ins/file-raw/file-darktable.c
+++ b/plug-ins/file-raw/file-darktable.c
@@ -21,9 +21,6 @@
 
 #include "config.h"
 
-#include <stdlib.h>
-#include <errno.h>
-
 #include <glib/gstdio.h>
 
 #include <libgimp/gimp.h>
@@ -34,9 +31,10 @@
 #include "file-raw-utils.h"
 
 
-#define LOAD_THUMB_PROC "file-darktable-load-thumb"
+#define LOAD_THUMB_PROC   "file-darktable-load-thumb"
 #define REGISTRY_KEY_BASE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable"
 
+
 static void     init                 (void);
 static void     query                (void);
 static void     run                  (const gchar      *name,
@@ -54,6 +52,7 @@ static gint32   load_thumbnail_image (const gchar      *filename,
                                       gint             *height,
                                       GError          **error);
 
+
 const GimpPlugInInfo PLUG_IN_INFO =
 {
   init,  /* init_proc */
@@ -111,7 +110,7 @@ init (void)
   gboolean  debug_prints     = g_getenv ("DARKTABLE_DEBUG") != NULL;
 
   if (debug_prints)
-    printf ("[%s] trying to call '%s'\n", __FILE__, exec_path);
+    g_printf ("[%s] trying to call '%s'\n", __FILE__, exec_path);
 
   if (g_spawn_sync (NULL,
                     argv,
@@ -158,25 +157,31 @@ init (void)
                 }
             }
         }
+
       g_match_info_free (matches);
       g_regex_unref (regex);
     }
   else if (debug_prints)
-    printf ("[%s] g_spawn_sync failed\n", __FILE__);
+    {
+      g_printf ("[%s] g_spawn_sync failed\n", __FILE__);
+    }
 
   if (debug_prints)
     {
       if (error)
-        printf ("[%s] error: %s\n", __FILE__, error->message);
+        g_printf ("[%s] error: %s\n", __FILE__, error->message);
+
       if (darktable_stdout && *darktable_stdout)
-        printf ("[%s] stdout:\n%s\n", __FILE__, darktable_stdout);
+        g_printf ("[%s] stdout:\n%s\n", __FILE__, darktable_stdout);
+
       if (darktable_stderr && *darktable_stderr)
-        printf ("[%s] stderr:\n%s\n", __FILE__, darktable_stderr);
-      printf ("[%s] have_darktable: %d\n", __FILE__, have_darktable);
+        g_printf ("[%s] stderr:\n%s\n", __FILE__, darktable_stderr);
+
+      g_printf ("[%s] have_darktable: %d\n", __FILE__, have_darktable);
     }
 
-  if (error)
-    g_error_free (error);
+  g_clear_error (&error);
+
   g_free (darktable_stdout);
   g_free (darktable_stderr);
   g_free (exec_path);
@@ -423,10 +428,12 @@ load_image (const gchar  *filename,
   if (debug_prints)
     {
       if (darktable_stdout && *darktable_stdout)
-        printf ("%s\n", darktable_stdout);
+        g_printf ("%s\n", darktable_stdout);
+
       if (darktable_stderr && *darktable_stderr)
-        printf ("%s\n", darktable_stderr);
+        g_printf ("%s\n", darktable_stderr);
     }
+
   g_free (darktable_stdout);
   g_free (darktable_stderr);
 
diff --git a/plug-ins/file-raw/file-raw-utils.c b/plug-ins/file-raw/file-raw-utils.c
index 37a820c..6bf73c6 100644
--- a/plug-ins/file-raw/file-raw-utils.c
+++ b/plug-ins/file-raw/file-raw-utils.c
@@ -55,7 +55,7 @@ file_raw_get_executable_path (const gchar *main_executable,
    * We assume that just appending the suffix to that value will work.
    * That means that on Windows there should be no ".exe"!
    */
-  const gchar *dt_env = env_variable? g_getenv (env_variable) : NULL;
+  const gchar *dt_env = env_variable ? g_getenv (env_variable) : NULL;
 
   if (dt_env)
     return g_strconcat (dt_env, suffix, NULL);
@@ -96,8 +96,8 @@ file_raw_get_executable_path (const gchar *main_executable,
                */
               len = CFStringGetLength (path);
               ret = g_malloc0 (len * 2 * sizeof (gchar));
-              if (!CFStringGetCString (path, ret, 2 * len * sizeof (gchar),
-                                       kCFStringEncodingUTF8))
+              if (! CFStringGetCString (path, ret, 2 * len * sizeof (gchar),
+                                        kCFStringEncodingUTF8))
                 ret = NULL;
 
               CFRelease (path);
@@ -108,10 +108,12 @@ file_raw_get_executable_path (const gchar *main_executable,
               if (ret)
                 return ret;
             }
+
           CFRelease (bundle_id);
         }
       /* else, app bundle was not found, try path search as last resort. */
     }
+
 #elif defined (GDK_WINDOWING_WIN32)
   if (win32_registry_key_base)
     {
@@ -125,6 +127,7 @@ file_raw_get_executable_path (const gchar *main_executable,
         registry_key = g_strconcat (win32_registry_key_base, suffix, ".exe", NULL);
       else
         registry_key = g_strconcat (win32_registry_key_base, ".exe", NULL);
+
       status = RegGetValue (HKEY_LOCAL_MACHINE, registry_key, "", RRF_RT_ANY,
                             NULL, (PVOID)&path, &buffer_size);
 
@@ -137,7 +140,9 @@ file_raw_get_executable_path (const gchar *main_executable,
 
   /* Finally, the last resort. */
   *search_path = TRUE;
+
   if (suffix)
     return g_strconcat (main_executable, suffix, NULL);
+
   return g_strdup (main_executable);
 }
diff --git a/plug-ins/file-raw/file-raw-utils.h b/plug-ins/file-raw/file-raw-utils.h
index ec0e2a2..10250f5 100644
--- a/plug-ins/file-raw/file-raw-utils.h
+++ b/plug-ins/file-raw/file-raw-utils.h
@@ -21,11 +21,13 @@
 #ifndef __FILE_RAW_UTILS_H__
 #define __FILE_RAW_UTILS_H__
 
-gchar  * file_raw_get_executable_path  (const gchar *main_executable,
-                                        const gchar *suffix,
-                                        const gchar *env_variable,
-                                        const gchar *mac_bundle_id,
-                                        const gchar *win32_registry_key_base,
-                                        gboolean    *search_path);
+
+gchar * file_raw_get_executable_path (const gchar *main_executable,
+                                      const gchar *suffix,
+                                      const gchar *env_variable,
+                                      const gchar *mac_bundle_id,
+                                      const gchar *win32_registry_key_base,
+                                      gboolean    *search_path);
+
 
 #endif /* __FILE_RAW_UTILS_H__ */
diff --git a/plug-ins/file-raw/file-rawtherapee.c b/plug-ins/file-raw/file-rawtherapee.c
index eb3900e..f467727 100644
--- a/plug-ins/file-raw/file-rawtherapee.c
+++ b/plug-ins/file-raw/file-rawtherapee.c
@@ -22,9 +22,6 @@
 
 #include "config.h"
 
-#include <stdlib.h>
-#include <errno.h>
-
 #include <glib/gstdio.h>
 
 #include <libgimp/gimp.h>
@@ -116,7 +113,8 @@ init (void)
                     NULL,
                     NULL))
     {
-      int rtmajor = 0, rtminor = 0;
+      gint rtmajor = 0;
+      gint rtminor = 0;
 
       if (sscanf (rawtherapee_stdout,
                   "RawTherapee, version %d.%d",
@@ -128,6 +126,7 @@ init (void)
 
       g_free (rawtherapee_stdout);
     }
+
   g_free (exec_path);
 
   if (! have_rawtherapee)
@@ -419,12 +418,14 @@ load_thumbnail_image (const gchar   *filename,
       NULL
     };
 
-  if (thumb_pp3_f) {
-    if (fprintf (thumb_pp3_f, pp3_content, thumb_size, thumb_size) < 0) {
-      fclose (thumb_pp3_f);
-      thumb_pp3_f = NULL;
+  if (thumb_pp3_f)
+    {
+      if (fprintf (thumb_pp3_f, pp3_content, thumb_size, thumb_size) < 0)
+        {
+          fclose (thumb_pp3_f);
+          thumb_pp3_f = NULL;
+        }
     }
-  }
 
   gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
                              gimp_filename_to_utf8 (filename));
@@ -456,9 +457,9 @@ load_thumbnail_image (const gchar   *filename,
 
   gimp_progress_update (1.0);
 
-  if (thumb_pp3_f) {
+  if (thumb_pp3_f)
     fclose (thumb_pp3_f);
-  }
+
   g_unlink (thumb_pp3);
   g_free (filename_out);
   g_free (thumb_pp3);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]