[Libreoffice-commits] core.git: vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Sep 18 11:15:45 UTC 2018
vcl/unx/gtk3/gtk3gtkinst.cxx | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
New commits:
commit 2ba6e9d4979b622ce9e270b61ade4bee08c8259d
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 18 09:53:54 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Sep 18 13:15:23 2018 +0200
tdf#119929 ensure .ui translation domain is bound before translation attempt
Change-Id: Ib06b399f6c975c1c64594b0a294b10bc6a9f0a69
Reviewed-on: https://gerrit.libreoffice.org/60666
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 28492d27d0dc..f8d05e92782b 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -5172,6 +5172,7 @@ private:
GtkBuilder* m_pBuilder;
GSList* m_pObjectList;
GtkWidget* m_pParentWidget;
+ gulong m_nNotifySignalId;
std::vector<GtkButton*> m_aMnemonicButtons;
std::vector<GtkLabel*> m_aMnemonicLabels;
@@ -5257,6 +5258,28 @@ private:
}
}
+ //GtkBuilder sets translation domain during parse, and unsets it again afterwards.
+ //In order for GtkBuilder to find the translations bindtextdomain has to be called
+ //for the domain. So here on the first setting of "domain" we call Translate::Create
+ //to make sure that happens. Without this, if some other part of LibreOffice has
+ //used the translation machinery for this domain it will still work, but if it
+ //hasn't, e.g. tdf#119929, then the translation fails
+ void translation_domain_set()
+ {
+ Translate::Create(gtk_builder_get_translation_domain(m_pBuilder), LanguageTag(m_aUILang));
+ g_signal_handler_disconnect(m_pBuilder, m_nNotifySignalId);
+ }
+
+ static void signalNotify(GObject*, GParamSpec *pSpec, gpointer pData)
+ {
+ g_return_if_fail(pSpec != nullptr);
+ if (strcmp(pSpec->name, "translation-domain") == 0)
+ {
+ GtkInstanceBuilder* pBuilder = static_cast<GtkInstanceBuilder*>(pData);
+ pBuilder->translation_domain_set();
+ }
+ }
+
static void postprocess(gpointer data, gpointer user_data)
{
GObject* pObject = static_cast<GObject*>(data);
@@ -5271,14 +5294,10 @@ public:
, m_pStringReplace(Translate::GetReadStringHook())
, m_sHelpRoot(rUIFile)
, m_pParentWidget(pParent)
+ , m_nNotifySignalId(0)
{
ensure_intercept_drawing_area_accessibility();
- OUString aUri(rUIRoot + rUIFile);
- OUString aPath;
- osl::FileBase::getSystemPathFromFileURL(aUri, aPath);
- m_pBuilder = gtk_builder_new_from_file(OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).getStr());
-
sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.');
if (nIdx != -1)
m_sHelpRoot = m_sHelpRoot.copy(0, nIdx);
@@ -5287,6 +5306,13 @@ public:
m_aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
m_aUILang = Application::GetSettings().GetUILanguageTag().getBcp47();
+ OUString aUri(rUIRoot + rUIFile);
+ OUString aPath;
+ osl::FileBase::getSystemPathFromFileURL(aUri, aPath);
+ m_pBuilder = gtk_builder_new();
+ m_nNotifySignalId = g_signal_connect_data(G_OBJECT(m_pBuilder), "notify", G_CALLBACK(signalNotify), this, nullptr, G_CONNECT_AFTER);
+ gtk_builder_add_from_file(m_pBuilder, OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).getStr(), nullptr);
+
m_pObjectList = gtk_builder_get_objects(m_pBuilder);
g_slist_foreach(m_pObjectList, postprocess, this);
More information about the Libreoffice-commits
mailing list