libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx | 6 ++++ libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx | 15 ++++++++++++ libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx | 2 + libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx | 6 ++++ 4 files changed, 27 insertions(+), 2 deletions(-)
New commits: commit 2eb7e152baddf08d4c91a8e2fc0e36e180108f57 Author: Aron Budea <[email protected]> AuthorDate: Wed Feb 4 21:56:15 2026 +1030 Commit: Aron Budea <[email protected]> CommitDate: Thu Feb 5 07:20:46 2026 +0100 gtktiledviewer: look for .ui file in relative path if absolute fails So it doesn't depend on where it was built. This way they can be added to a bibisect repo. Change-Id: I5e2a3710fb0c68e37ab35b67e20f4e9a0ba7942a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198669 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Aron Budea <[email protected]> diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx index e2fcf16de69c..dcbec50e2407 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx @@ -9,6 +9,7 @@ #include <gtk/gtk.h> +#include <filesystem> #include <memory> #include <LibreOfficeKit/LibreOfficeKitGtk.h> @@ -67,7 +68,10 @@ getPrivate(GtvApplicationWindow* win) static void gtv_application_window_init(GtvApplicationWindow* win) { - const std::string uiFilePath = GtvHelpers::getDirPath(__FILE__) + std::string(UI_FILE_NAME); + std::string uiFilePath = GtvHelpers::getDirPath(__FILE__) + std::string(UI_FILE_NAME); + if (!std::filesystem::exists(uiFilePath)) + uiFilePath = GtvHelpers::getRelativePath(uiFilePath); + GtvGtkWrapper<GtkBuilder> builder(gtk_builder_new_from_file(uiFilePath.c_str()), [](GtkBuilder* pBuilder) { g_object_unref(pBuilder); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx index 3f205d5706e2..a5d623d31b36 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx @@ -10,10 +10,13 @@ #include <gtk/gtk.h> #include <cstring> +#include <filesystem> #include "gtv-helpers.hxx" #include "gtv-signal-handlers.hxx" +#include <config_folders.h> + #include <boost/property_tree/ptree.hpp> void GtvHelpers::userPromptDialog(GtkWindow* pWindow, const std::string& aTitle, std::map<std::string, std::string>& aEntries) @@ -147,4 +150,16 @@ std::string GtvHelpers::getDirPath(const std::string& filePath) return filePath.substr(0, position + 1); } +std::string GtvHelpers::getRelativePath(const std::string& aFilePath) +{ + std::filesystem::path aBaseDir(SRC_ROOT); + std::filesystem::path aFullPath(aFilePath); + std::error_code err; + std::filesystem::path aRelPath = std::filesystem::relative(aFullPath, aBaseDir, err); + if (err) + return aFilePath; + + return aRelPath.string(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx index 46d6ff5c7da8..2c89567412e3 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx @@ -39,6 +39,8 @@ namespace GtvHelpers std::string getDirPath(const std::string& filePath); + std::string getRelativePath(const std::string& aFilePath); + template<typename T> std::vector<T> split(const std::string& aPayload, const std::string& aDelim, const int nItems) { diff --git a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx index 636da3f27ae4..36cda87d2eea 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx @@ -17,6 +17,7 @@ #include <LibreOfficeKit/LibreOfficeKitGtk.h> #include <algorithm> +#include <filesystem> #include <fstream> #include <map> #include <memory> @@ -94,7 +95,10 @@ gtv_main_toolbar_init(GtvMainToolbar* toolbar) GtvMainToolbarPrivate& priv = getPrivate(toolbar); priv.m_pImpl = new GtvMainToolbarPrivateImpl(); - const std::string uiFilePath = GtvHelpers::getDirPath(__FILE__) + std::string(UI_FILE_NAME); + std::string uiFilePath = GtvHelpers::getDirPath(__FILE__) + std::string(UI_FILE_NAME); + if (!std::filesystem::exists(uiFilePath)) + uiFilePath = GtvHelpers::getRelativePath(uiFilePath); + GtvGtkWrapper<GtkBuilder> builder(gtk_builder_new_from_file(uiFilePath.c_str()), [](GtkBuilder* pBuilder) { g_object_unref(pBuilder);
