1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /** @file 3 * Consolidates version info for Inkscape, 4 * its various dependencies and the OS we're running on 5 *//* 6 * Authors: 7 * Patrick Storz <eduard.braun2@gmx.de> 8 * 9 * Copyright (C) 2021 Authors 10 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 11 */ 12 13 14 #include <ostream> 15 #include <string> 16 17 #include <hb.h> // not indirectly included via gtk.h on macOS 18 #include <glib.h> 19 #include <glibmm.h> 20 #include <gtk/gtk.h> 21 #include <gtkmm.h> 22 #include <libxml2/libxml/xmlversion.h> 23 #include <libxslt/xsltconfig.h> 24 25 #ifdef HAVE_POPPLER 26 #include <poppler-config.h> 27 #endif 28 29 #include "inkscape-version.h" // Inkscape version 30 31 32 namespace Inkscape { 33 34 /** 35 * Return Inkscape version string 36 * 37 * Returns the Inkscape version string including program name. 38 * 39 * @return version string 40 */ inkscape_version()41std::string inkscape_version() { 42 return std::string("Inkscape ") + Inkscape::version_string; 43 } 44 45 /** 46 * Return OS version string 47 * 48 * Returns the OS version string including OS name. 49 * 50 * Relies on glib's 'g_get_os_info'. 51 * Might be undefined on some OSs. "(unknown)" is returned in this case. 52 * 53 * @return version string 54 */ os_version()55std::string os_version() { 56 std::string os_version_string = "(unknown)"; 57 58 #if GLIB_CHECK_VERSION(2,64,0) 59 char *os_name = g_get_os_info(G_OS_INFO_KEY_NAME); 60 char *os_pretty_name = g_get_os_info(G_OS_INFO_KEY_PRETTY_NAME); 61 if (os_pretty_name) { 62 os_version_string = os_pretty_name; 63 } else if (os_name) { 64 os_version_string = os_name; 65 } 66 g_free(os_name); 67 g_free(os_pretty_name); 68 #endif 69 70 return os_version_string; 71 } 72 73 /** 74 * Return full debug info 75 * 76 * Returns full debug info including: 77 * - Inkscape version 78 * - versions of various dependencies 79 * - OS name and version 80 * 81 * @return debug info 82 */ debug_info()83std::string debug_info() { 84 std::stringstream ss; 85 86 ss << inkscape_version() << std::endl; 87 ss << std::endl; 88 ss << " GLib version: " << glib_major_version << "." << glib_minor_version << "." << glib_micro_version << std::endl; 89 ss << " GTK version: " << gtk_major_version << "." << gtk_minor_version << "." << gtk_micro_version << std::endl; 90 ss << " glibmm version: " << GLIBMM_MAJOR_VERSION << "." << GLIBMM_MINOR_VERSION << "." << GLIBMM_MICRO_VERSION << std::endl; 91 ss << " gtkmm version: " << GTKMM_MAJOR_VERSION << "." << GTKMM_MINOR_VERSION << "." << GTKMM_MICRO_VERSION << std::endl; 92 ss << " libxml2 version: " << LIBXML_DOTTED_VERSION << std::endl; 93 ss << " libxslt version: " << LIBXSLT_DOTTED_VERSION << std::endl; 94 ss << " Cairo version: " << cairo_version_string() << std::endl; 95 ss << " Pango version: " << pango_version_string() << std::endl; 96 ss << " HarfBuzz version: " << hb_version_string() << std::endl; 97 #ifdef HAVE_POPPLER 98 ss << " Poppler version: " << POPPLER_VERSION << std::endl; 99 #endif 100 ss << std::endl; 101 ss << " OS version: " << os_version(); 102 103 return ss.str(); 104 } 105 106 } // namespace Inkscape 107 108 109 /* 110 Local Variables: 111 mode:c++ 112 c-file-style:"stroustrup" 113 c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +)) 114 indent-tabs-mode:nil 115 fill-column:99 116 End: 117 */ 118 // vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99: