[gimp] Issue #2179: Make file_rawtherapee use the registry value that is...



commit 829ca6583d30b80bb48d0395e39468d33cf9cd35
Author: Simon Mueller <s mueller hn web de>
Date:   Fri Sep 7 13:56:15 2018 +0200

    Issue #2179: Make file_rawtherapee use the registry value that is...
    
    ... provided by RawTherapee's installer (version 5.5+).
    
    See https://github.com/Beep6581/RawTherapee/issues/4783.
    This patch required a small change to file_raw_get_executable_path
    because the RawTherapee installer is supposed to work without admin
    privileges and therefore can't write to HKLM.
    
    Reviewer's note (Jehan): RawTherapee's installer does not add the
    registry entry yet. We assume the upstream bug report will end up doing
    so (someone has to make the first step!). :-)

 plug-ins/file-raw/file-darktable.c   |  3 +++
 plug-ins/file-raw/file-raw-utils.c   |  9 +++++++--
 plug-ins/file-raw/file-raw-utils.h   |  1 +
 plug-ins/file-raw/file-rawtherapee.c | 10 +++++++---
 4 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/file-raw/file-darktable.c b/plug-ins/file-raw/file-darktable.c
index ac8b16db77..20c2b67345 100644
--- a/plug-ins/file-raw/file-darktable.c
+++ b/plug-ins/file-raw/file-darktable.c
@@ -98,6 +98,7 @@ init (void)
                                                              "DARKTABLE_EXECUTABLE",
                                                              "org.darktable",
                                                              REGISTRY_KEY_BASE,
+                                                             FALSE,
                                                              &search_path);
   gchar    *argv[]           = { exec_path, "--version", NULL };
   gchar    *darktable_stdout = NULL;
@@ -379,6 +380,7 @@ load_image (const gchar  *filename,
                                                              "DARKTABLE_EXECUTABLE",
                                                              "org.darktable",
                                                              REGISTRY_KEY_BASE,
+                                                             FALSE,
                                                              &search_path);
   gchar    *argv[] =
     {
@@ -472,6 +474,7 @@ load_thumbnail_image (const gchar   *filename,
                                                              "DARKTABLE_EXECUTABLE",
                                                              "org.darktable",
                                                              REGISTRY_KEY_BASE,
+                                                             FALSE,
                                                              &search_path);
   gchar    *argv[] =
     {
diff --git a/plug-ins/file-raw/file-raw-utils.c b/plug-ins/file-raw/file-raw-utils.c
index 27e2a5ef43..9c33b417d3 100644
--- a/plug-ins/file-raw/file-raw-utils.c
+++ b/plug-ins/file-raw/file-raw-utils.c
@@ -41,6 +41,7 @@ file_raw_get_executable_path (const gchar *main_executable,
                               const gchar *env_variable,
                               const gchar *mac_bundle_id,
                               const gchar *win32_registry_key_base,
+                              gboolean     win32_use_hkcu,
                               gboolean    *search_path)
 {
   /*
@@ -128,8 +129,12 @@ file_raw_get_executable_path (const gchar *main_executable,
       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);
+      if (win32_use_hkcu)
+        status = RegGetValue (HKEY_CURRENT_USER, registry_key, "", RRF_RT_ANY,
+                              NULL, (PVOID)&path, &buffer_size);
+      else
+        status = RegGetValue (HKEY_LOCAL_MACHINE, registry_key, "", RRF_RT_ANY,
+                              NULL, (PVOID)&path, &buffer_size);
 
       g_free (registry_key);
 
diff --git a/plug-ins/file-raw/file-raw-utils.h b/plug-ins/file-raw/file-raw-utils.h
index 0199f1f654..6cdf862cdc 100644
--- a/plug-ins/file-raw/file-raw-utils.h
+++ b/plug-ins/file-raw/file-raw-utils.h
@@ -27,6 +27,7 @@ gchar * file_raw_get_executable_path (const gchar *main_executable,
                                       const gchar *env_variable,
                                       const gchar *mac_bundle_id,
                                       const gchar *win32_registry_key_base,
+                                      gboolean     win32_use_hkcu,
                                       gboolean    *search_path);
 
 
diff --git a/plug-ins/file-raw/file-rawtherapee.c b/plug-ins/file-raw/file-rawtherapee.c
index 70afcd052f..c3fb11a653 100644
--- a/plug-ins/file-raw/file-rawtherapee.c
+++ b/plug-ins/file-raw/file-rawtherapee.c
@@ -33,6 +33,7 @@
 
 
 #define LOAD_THUMB_PROC "file-rawtherapee-load-thumb"
+#define REGISTRY_KEY_BASE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee"
 
 
 static void     init                 (void);
@@ -94,7 +95,8 @@ init (void)
   gchar    *exec_path        = file_raw_get_executable_path ("rawtherapee", NULL,
                                                              "RAWTHERAPEE_EXECUTABLE",
                                                              "com.rawtherapee.rawtherapee",
-                                                             NULL,
+                                                             REGISTRY_KEY_BASE,
+                                                             TRUE,
                                                              &search_path);
   gchar    *argv[]             = { exec_path, "-v", NULL };
   gchar    *rawtherapee_stdout = NULL;
@@ -297,7 +299,8 @@ load_image (const gchar  *filename,
   gchar    *exec_path          = file_raw_get_executable_path ("rawtherapee", NULL,
                                                                "RAWTHERAPEE_EXECUTABLE",
                                                                "com.rawtherapee.rawtherapee",
-                                                               NULL,
+                                                               REGISTRY_KEY_BASE,
+                                                               TRUE,
                                                                &search_path);
 
   /* linear sRGB for now as GIMP uses that internally in many places anyway */
@@ -403,7 +406,8 @@ load_thumbnail_image (const gchar   *filename,
   gchar    *exec_path   = file_raw_get_executable_path ("rawtherapee", "-cli",
                                                         "RAWTHERAPEE_EXECUTABLE",
                                                         "com.rawtherapee.rawtherapee",
-                                                        NULL,
+                                                        REGISTRY_KEY_BASE,
+                                                        TRUE,
                                                         &search_path);
   gchar *argv[] =
     {


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