1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
|
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib.h>
#include <cairo.h>
#include <fontconfig/fontconfig.h>
#include <pango/pango.h>
#include <pango/pangoft2.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gexiv2/gexiv2.h>
#include <exiv2/exv_conf.h>
#include <gegl.h>
#ifndef GIMP_CONSOLE_COMPILATION
#include <gtk/gtk.h>
#endif
#include "libgimpbase/gimpbase.h"
#include "about.h"
#include "git-version.h"
#include "gimp-intl.h"
#include "gimp-version.h"
static gchar * gimp_library_version (const gchar *package,
gint build_time_major,
gint build_time_minor,
gint build_time_micro,
gint run_time_major,
gint run_time_minor,
gint run_time_micro,
gboolean localized);
static gchar * gimp_library_versions (gboolean localized);
static void gimp_version_get_release_info (gint *package_revision,
gboolean *package_check_update);
void
gimp_version_show (gboolean be_verbose)
{
gchar *version = gimp_version (be_verbose, TRUE);
g_print ("%s", version);
g_free (version);
}
gchar *
gimp_version (gboolean be_verbose,
gboolean localized)
{
gchar *version;
gchar *temp;
version = g_strdup_printf (localized ? _("%s version %s") : "%s version %s",
GIMP_NAME, GIMP_VERSION);;
temp = g_strconcat (version, "\n", NULL);
g_free (version);
version = temp;
if (be_verbose)
{
gchar *verbose_info;
gchar *lib_versions;
gchar *flatpak_info = NULL;
lib_versions = gimp_library_versions (localized);
verbose_info = g_strdup_printf ("git-describe: %s\n"
"Build: %s rev %d for %s\n"
"# C compiler #\n%s\n"
"# Libraries #\n%s",
GIMP_GIT_VERSION,
GIMP_BUILD_ID,
gimp_version_get_revision (),
GIMP_BUILD_PLATFORM_FAMILY,
CC_VERSION,
lib_versions);
g_free (lib_versions);
/* This file should be available at root path in a flatpak
* environment. Just add its contents to the verbose output if it
* exists. Silently ignore otherwise.
*/
if (g_file_get_contents ("/.flatpak-info", &flatpak_info, NULL, NULL))
{
temp = g_strdup_printf ("\n# Flatpak info #\n%s",
flatpak_info);
g_free (flatpak_info);
flatpak_info = temp;
}
temp = g_strconcat (version, verbose_info, flatpak_info, NULL);
g_free (version);
g_free (verbose_info);
g_free (flatpak_info);
version = temp;
}
return version;
}
gint
gimp_version_get_revision (void)
{
gint revision;
gimp_version_get_release_info (&revision, NULL);
return revision;
}
gboolean
gimp_version_check_update (void)
{
gboolean check_update;
gimp_version_get_release_info (NULL, &check_update);
return check_update;
}
static gchar *
gimp_library_version (const gchar *package,
gint build_time_major,
gint build_time_minor,
gint build_time_micro,
gint run_time_major,
gint run_time_minor,
gint run_time_micro,
gboolean localized)
{
gchar *lib_version;
gchar *build_time_version;
gchar *run_time_version;
build_time_version = g_strdup_printf ("%d.%d.%d",
build_time_major,
build_time_minor,
build_time_micro);
run_time_version = g_strdup_printf ("%d.%d.%d",
run_time_major,
run_time_minor,
run_time_micro);
/* show versions of libraries used by GIMP */
lib_version = g_strdup_printf (localized ?
_("using %s version %s (compiled against version %s)") :
"using %s version %s (compiled against version %s)",
package, run_time_version, build_time_version);
g_free (run_time_version);
g_free (build_time_version);
return lib_version;
}
static gchar *
gimp_library_versions (gboolean localized)
{
gchar *lib_versions;
gchar *lib_version;
gchar *temp;
gint babl_major_version;
gint babl_minor_version;
gint babl_micro_version;
gint gegl_major_version;
gint gegl_minor_version;
gint gegl_micro_version;
babl_get_version (&babl_major_version,
&babl_minor_version,
&babl_micro_version);
lib_versions = gimp_library_version ("babl",
BABL_MAJOR_VERSION,
BABL_MINOR_VERSION,
BABL_MICRO_VERSION,
babl_major_version,
babl_minor_version,
babl_micro_version,
localized);
gegl_get_version (&gegl_major_version,
&gegl_minor_version,
&gegl_micro_version);
lib_version = gimp_library_version ("GEGL",
GEGL_MAJOR_VERSION,
GEGL_MINOR_VERSION,
GEGL_MICRO_VERSION,
gegl_major_version,
gegl_minor_version,
gegl_micro_version,
localized);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
lib_version = gimp_library_version ("GLib",
GLIB_MAJOR_VERSION,
GLIB_MINOR_VERSION,
GLIB_MICRO_VERSION,
glib_major_version,
glib_minor_version,
glib_micro_version,
localized);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
lib_version = gimp_library_version ("GdkPixbuf",
GDK_PIXBUF_MAJOR,
GDK_PIXBUF_MINOR,
GDK_PIXBUF_MICRO,
gdk_pixbuf_major_version,
gdk_pixbuf_minor_version,
gdk_pixbuf_micro_version,
localized);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
#ifndef GIMP_CONSOLE_COMPILATION
lib_version = gimp_library_version ("GTK+",
GTK_MAJOR_VERSION,
GTK_MINOR_VERSION,
GTK_MICRO_VERSION,
gtk_major_version,
gtk_minor_version,
gtk_micro_version,
localized);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
#endif
lib_version = gimp_library_version ("Pango",
PANGO_VERSION_MAJOR,
PANGO_VERSION_MINOR,
PANGO_VERSION_MICRO,
pango_version () / 100 / 100,
pango_version () / 100 % 100,
pango_version () % 100,
localized);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
lib_version = gimp_library_version ("Fontconfig",
FC_MAJOR, FC_MINOR, FC_REVISION,
FcGetVersion () / 100 / 100,
FcGetVersion () / 100 % 100,
FcGetVersion () % 100,
localized);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
lib_version = g_strdup_printf (localized ?
_("using %s version %s (compiled against version %s)") :
"using %s version %s (compiled against version %s)",
"Cairo", cairo_version_string (), CAIRO_VERSION_STRING);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
lib_version = gimp_library_version ("gexiv2",
GEXIV2_MAJOR_VERSION,
GEXIV2_MINOR_VERSION,
GEXIV2_MICRO_VERSION,
gexiv2_get_version () / 100 / 100,
gexiv2_get_version () / 100 % 100,
gexiv2_get_version () % 100,
localized);
temp = g_strdup_printf ("%s\n%s", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
lib_version = g_strdup_printf (localized ?
_("using %s version %s") :
"using %s version %s",
"exiv2", EXV_PACKAGE_VERSION);
temp = g_strdup_printf ("%s\n%s\n", lib_versions, lib_version);
g_free (lib_versions);
g_free (lib_version);
lib_versions = temp;
return lib_versions;
}
static void
gimp_version_get_release_info (gint *package_revision,
gboolean *package_check_update)
{
static gint revision = -1;
static gboolean check_update = FALSE;
if (revision == -1)
{
GKeyFile *key_file;
gchar *gimp_release;
revision = 0;
key_file = g_key_file_new ();
/* The gimp-release file is inspired by /etc/os-release and similar
* distribution files. Right now its main use is to number the package
* revision. This information is not a build variable because a new
* package version does not necessarily imply a rebuild (maybe just
* installed data or dependencies change).
*/
gimp_release = g_build_filename (gimp_data_directory (), "gimp-release", NULL);
/* Absence of the file is not an error. Actually most third-party
* builds probably won't install such file.
*/
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", "revision", NULL))
revision = g_key_file_get_integer (key_file, "package", "revision", NULL);
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);
}
if (package_revision)
*package_revision = revision;
if (package_check_update)
*package_check_update = check_update;
}
|