From 66ba9127acfa27e732c57587e2c12e8d4e8ed8a7 Mon Sep 17 00:00:00 2001 From: Hombre57 Date: Sun, 20 Aug 2017 00:57:30 +0200 Subject: [PATCH] Solving issue #3998 --- rtgui/main.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/rtgui/main.cc b/rtgui/main.cc index 455749fdd..731de81cd 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -261,8 +261,30 @@ RTWindow *create_rt_window() #endif Glib::RefPtr regex = Glib::Regex::create(THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); - Glib::ustring filename = Glib::build_filename(argv0, "themes", options.theme + ".css"); - if (!regex->match(options.theme + ".css") || !Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { + Glib::ustring filename; + Glib::MatchInfo mInfo; + bool match = regex->match(options.theme + ".css", mInfo); + if (match) { + // save old theme (name + version) + Glib::ustring initialTheme(options.theme); + + // update version + auto pos = options.theme.find("-GTK3-"); + Glib::ustring themeRootName(options.theme.substr(0, pos)); + if (GTK_MINOR_VERSION < 20) { + options.theme = themeRootName + "-GTK3-_19"; + } else { + options.theme = themeRootName + "-GTK3-20_"; + } + // check if this version exist + if (!Glib::file_test(Glib::build_filename(argv0, "themes", options.theme + ".css"), Glib::FILE_TEST_EXISTS)) { + // set back old theme version if the actual one doesn't exist yet + options.theme = initialTheme; + } + } + filename = Glib::build_filename(argv0, "themes", options.theme + ".css"); + + if (!match || !Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { options.theme = "RawTherapee-GTK"; // We're not testing GTK_MAJOR_VERSION == 3 here, since this branch requires Gtk3 only if (GTK_MINOR_VERSION < 20) {