[gimp/gimp-2-10] app: allow to disable the new version check altogether through a key…



commit 20b218e5a2d17b215a13415551abd6f8a13b76d8
Author: Jehan <jehan girinstud io>
Date:   Mon Jun 6 01:05:30 2022 +0200

    app: allow to disable the new version check altogether through a key…
    
    … in the gimp-release file.
    
    This will be useful to disable the update check for the Windows Store
    even though we use the same build as the installer. All it will take
    will be to append the line `check-update=false` to the file
    `share/gimp/2.10/gimp-release` and it will behave as though the update
    check is disabled (even though it is actually built-in).
    
    (cherry picked from commit 9ef10c8764df53207cabe5e323c50588307547da)
    
    Conflicts fixed:
            app/dialogs/preferences-dialog.c

 app/dialogs/preferences-dialog.c | 15 ++++++++++-----
 app/gimp-update.c                |  9 ++++++++-
 app/gimp-version.c               | 23 +++++++++++++++++++++++
 app/gimp-version.h               | 11 +++++++----
 4 files changed, 48 insertions(+), 10 deletions(-)
---
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 0bbf675d95..cde1576b4c 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -29,6 +29,8 @@
 
 #include "dialogs-types.h"
 
+#include "gimp-version.h"
+
 #include "config/gimprc.h"
 
 #include "core/gimp.h"
@@ -1203,12 +1205,15 @@ prefs_dialog_new (Gimp       *gimp,
 
   /*  Internet access  */
 #ifdef CHECK_UPDATE
-  vbox2 = prefs_frame_new (_("Network access"), GTK_CONTAINER (vbox),
-                           FALSE);
+  if (gimp_version_check_update ())
+    {
+      vbox2 = prefs_frame_new (_("Network access"), GTK_CONTAINER (vbox),
+                               FALSE);
 
-  prefs_check_button_add (object, "check-updates",
-                          _("Check for updates (requires internet)"),
-                          GTK_BOX (vbox2));
+      prefs_check_button_add (object, "check-updates",
+                              _("Check for updates (requires internet)"),
+                              GTK_BOX (vbox2));
+    }
 #endif
 
   /*  Image Thumbnails  */
diff --git a/app/gimp-update.c b/app/gimp-update.c
index cee1d53842..31eed04ed7 100644
--- a/app/gimp-update.c
+++ b/app/gimp-update.c
@@ -407,7 +407,14 @@ gimp_update_auto_check (GimpCoreConfig *config)
 
   /* Builds with update check deactivated just always return FALSE. */
 #ifdef CHECK_UPDATE
-  if (! config->check_updates)
+  /* Allows to disable updates at package level with a build having the
+   * version check code built-in.
+   * For instance, it would allow to use the same Windows installer for
+   * the Windows Store (with update check disabled because it comes with
+   * its own update channel).
+   */
+  if (! gimp_version_check_update () ||
+      ! config->check_updates)
 #endif
     return FALSE;
 
diff --git a/app/gimp-version.c b/app/gimp-version.c
index 6e311c8252..e56149a487 100644
--- a/app/gimp-version.c
+++ b/app/gimp-version.c
@@ -286,3 +286,26 @@ gimp_version_get_revision (void)
 
   return revision;
 }
+
+gboolean
+gimp_version_check_update (void)
+{
+  GKeyFile *key_file;
+  gchar    *gimp_release;
+  gboolean  check_update = FALSE;
+
+  key_file = g_key_file_new ();
+
+  gimp_release = g_build_filename (gimp_data_directory (), "gimp-release", NULL);
+  if (g_key_file_load_from_file (key_file, gimp_release, G_KEY_FILE_NONE, NULL))
+    {
+      check_update = TRUE;
+
+      if (g_key_file_has_key (key_file, "package", "check-update", NULL))
+        check_update = g_key_file_get_boolean (key_file, "package", "check-update", NULL);
+    }
+  g_key_file_free (key_file);
+  g_free (gimp_release);
+
+  return check_update;
+}
diff --git a/app/gimp-version.h b/app/gimp-version.h
index ec6bb09ecc..556a41a8c7 100644
--- a/app/gimp-version.h
+++ b/app/gimp-version.h
@@ -19,10 +19,13 @@
 #define __APP_GIMP_VERSION_H__
 
 
-void    gimp_version_show         (gboolean be_verbose);
-gchar * gimp_version              (gboolean be_verbose,
-                                   gboolean localized);
+void       gimp_version_show         (gboolean be_verbose);
+gchar    * gimp_version              (gboolean be_verbose,
+                                      gboolean localized);
+
+gint       gimp_version_get_revision (void);
+
+gboolean   gimp_version_check_update (void);
 
-gint    gimp_version_get_revision (void);
 
 #endif /* __APP_GIMP_VERSION_H__ */


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