diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-17 13:08:14 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-17 16:51:50 +0200 |
commit | a418c365644a4bfb0e40621d1b36b1708978a500 (patch) | |
tree | bed522b639b3dce8e2ae4cb5a1aad3ca1409f6c3 | |
parent | 8b843c5aac1ed8c5922b5ef4d36daa13538dd02f (diff) |
let's just run ResHookProc over everything
Change-Id: I1c675ffbfd4737a6c618c2b4d548e27c1ec295b7
Reviewed-on: https://gerrit.libreoffice.org/53038
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/appl/sfxhelp.cxx | 6 | ||||
-rw-r--r-- | uui/source/secmacrowarnings.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 148 |
5 files changed, 102 insertions, 62 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index b38468b5bfa7..1c19d40fecd9 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -313,13 +313,10 @@ namespace class LicenseDialog : public weld::GenericDialogController { - std::unique_ptr<weld::Label> m_xLabel; public: LicenseDialog(weld::Window* pParent) : GenericDialogController(pParent, "sfx/ui/licensedialog.ui", "LicenseDialog") - , m_xLabel(m_xBuilder->weld_label("label")) { - m_xLabel->set_label(Translate::GetReadStringHook()(m_xLabel->get_label())); } short execute() @@ -337,7 +334,6 @@ namespace SafeModeQueryDialog(weld::Window* pParent) : MessageDialogController(pParent, "sfx/ui/safemodequerydialog.ui", "SafeModeQueryDialog") { - m_xDialog->set_primary_text(Translate::GetReadStringHook()(m_xDialog->get_primary_text())); } short execute() diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index d0cc5248264b..a45f2ac62b6d 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -909,8 +909,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const LanguageTag aLangTag = Application::GetSettings().GetUILanguageTag(); OUString sLocaleString = SvtLanguageTable::GetLanguageString( aLangTag.getLanguageType() ); OUString sPrimText = xQueryBox->get_primary_text(); - xQueryBox->set_primary_text(Translate::GetReadStringHook()(sPrimText).replaceAll("$UILOCALE", sLocaleString)); - xQueryBox->set_title(Translate::GetReadStringHook()(xQueryBox->get_title())); + xQueryBox->set_primary_text(sPrimText.replaceAll("$UILOCALE", sLocaleString)); short OnlineHelpBox = xQueryBox->run(); if(OnlineHelpBox == RET_OK) @@ -1056,8 +1055,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt LanguageTag aLangTag = Application::GetSettings().GetUILanguageTag(); OUString sLocaleString = SvtLanguageTable::GetLanguageString( aLangTag.getLanguageType() ); OUString sPrimText = xQueryBox->get_primary_text(); - xQueryBox->set_primary_text(Translate::GetReadStringHook()(sPrimText).replaceAll("$UILOCALE", sLocaleString)); - xQueryBox->set_title(Translate::GetReadStringHook()(xQueryBox->get_title())); + xQueryBox->set_primary_text(sPrimText.replaceAll("$UILOCALE", sLocaleString)); xQueryBox->connect_help(LINK(nullptr, NoHelpErrorBox, HelpRequestHdl)); short OnlineHelpBox = xQueryBox->run(); xQueryBox->hide(); diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx index 9363db6a0265..e90b2520d865 100644 --- a/uui/source/secmacrowarnings.cxx +++ b/uui/source/secmacrowarnings.cxx @@ -74,8 +74,6 @@ MacroWarning::MacroWarning(weld::Window* pParent, bool _bWithSignatures) , mbShowSignatures ( _bWithSignatures ) , mnActSecLevel ( 0 ) { - m_xDialog->set_title(Translate::GetReadStringHook()(m_xDialog->get_title())); - InitControls(); mxEnableBtn->connect_clicked(LINK(this, MacroWarning, EnableBtnHdl)); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index db9bfef526e2..167094a3abe1 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2604,7 +2604,7 @@ std::vector<OUString> VclBuilder::handleItems(xmlreader::XmlReader &reader) cons else sFinalValue = OUString::fromUtf8(sValue); - if (m_bLegacy && m_pStringReplace) + if (m_pStringReplace) sFinalValue = (*m_pStringReplace)(sFinalValue); aItems.push_back(sFinalValue); @@ -3349,7 +3349,7 @@ void VclBuilder::collectProperty(xmlreader::XmlReader &reader, stringmap &rMap) if (!sProperty.isEmpty()) { sProperty = sProperty.replace('_', '-'); - if (m_bLegacy && m_pStringReplace) + if (m_pStringReplace) sFinalValue = (*m_pStringReplace)(sFinalValue); rMap[sProperty] = sFinalValue; } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 183d61075b18..2e5bb0083199 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -31,6 +31,7 @@ #include <rtl/bootstrap.hxx> #include <tools/fract.hxx> #include <tools/stream.hxx> +#include <unotools/resmgr.hxx> #include <vcl/mnemonic.hxx> #include <vcl/pngwrite.hxx> #include <vcl/weld.hxx> @@ -1636,6 +1637,75 @@ weld::Container* GtkInstanceWidget::weld_parent() const return pParent ? new GtkInstanceContainer(GTK_CONTAINER(pParent), false) : nullptr; } +namespace +{ + OString MapToGtkAccelerator(const OUString &rStr) + { + return OUStringToOString(rStr.replaceFirst("~", "_"), RTL_TEXTENCODING_UTF8); + } + + OUString get_label(GtkLabel* pLabel) + { + const gchar* pStr = gtk_label_get_label(pLabel); + return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + } + + void set_label(GtkLabel* pLabel, const OUString& rText) + { + gtk_label_set_label(pLabel, MapToGtkAccelerator(rText).getStr()); + } + + OUString get_label(GtkButton* pButton) + { + const gchar* pStr = gtk_button_get_label(pButton); + return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + } + + void set_label(GtkButton* pButton, const OUString& rText) + { + gtk_button_set_label(pButton, MapToGtkAccelerator(rText).getStr()); + } + + OUString get_title(GtkWindow* pWindow) + { + const gchar* pStr = gtk_window_get_title(pWindow); + return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + } + + void set_title(GtkWindow* pWindow, const OUString& rTitle) + { + gtk_window_set_title(pWindow, OUStringToOString(rTitle, RTL_TEXTENCODING_UTF8).getStr()); + } + + OUString get_primary_text(GtkMessageDialog* pMessageDialog) + { + gchar* pText = nullptr; + g_object_get(G_OBJECT(pMessageDialog), "text", &pText, nullptr); + return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); + } + + void set_primary_text(GtkMessageDialog* pMessageDialog, const OUString& rText) + { + g_object_set(G_OBJECT(pMessageDialog), "text", + OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), + nullptr); + } + + void set_secondary_text(GtkMessageDialog* pMessageDialog, const OUString& rText) + { + g_object_set(G_OBJECT(pMessageDialog), "secondary-text", + OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), + nullptr); + } + + OUString get_secondary_text(GtkMessageDialog* pMessageDialog) + { + gchar* pText = nullptr; + g_object_get(G_OBJECT(pMessageDialog), "secondary-text", &pText, nullptr); + return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); + } +} + class GtkInstanceWindow : public GtkInstanceContainer, public virtual weld::Window { private: @@ -1663,13 +1733,12 @@ public: virtual void set_title(const OUString& rTitle) override { - gtk_window_set_title(m_pWindow, OUStringToOString(rTitle, RTL_TEXTENCODING_UTF8).getStr()); + ::set_title(m_pWindow, rTitle); } virtual OUString get_title() const override { - const gchar* pStr = gtk_window_get_title(m_pWindow); - return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + return ::get_title(m_pWindow); } virtual css::uno::Reference<css::awt::XWindow> GetXWindow() override @@ -1790,11 +1859,6 @@ namespace } } -static OString MapToGtkAccelerator(const OUString &rStr) -{ - return OUStringToOString(rStr.replaceFirst("~", "_"), RTL_TEXTENCODING_UTF8); -} - class GtkInstanceDialog : public GtkInstanceWindow, public virtual weld::Dialog { private: @@ -1949,30 +2013,22 @@ public: virtual void set_primary_text(const OUString& rText) override { - g_object_set(G_OBJECT(m_pMessageDialog), "text", - OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), - nullptr); + ::set_primary_text(m_pMessageDialog, rText); } virtual OUString get_primary_text() const override { - gchar* pText = nullptr; - g_object_get(G_OBJECT(m_pMessageDialog), "text", &pText, nullptr); - return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); + return ::get_primary_text(m_pMessageDialog); } virtual void set_secondary_text(const OUString& rText) override { - g_object_set(G_OBJECT(m_pMessageDialog), "secondary-text", - OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), - nullptr); + ::set_secondary_text(m_pMessageDialog, rText); } virtual OUString get_secondary_text() const override { - gchar* pText = nullptr; - g_object_get(G_OBJECT(m_pMessageDialog), "secondary-text", &pText, nullptr); - return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); + return ::get_secondary_text(m_pMessageDialog); } virtual Container* weld_message_area() override @@ -2354,31 +2410,6 @@ public: } }; -namespace -{ - OUString get_label(GtkLabel* pLabel) - { - const gchar* pStr = gtk_label_get_label(pLabel); - return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); - } - - void set_label(GtkLabel* pLabel, const OUString& rText) - { - gtk_label_set_label(pLabel, MapToGtkAccelerator(rText).getStr()); - } - - OUString get_label(GtkButton* pButton) - { - const gchar* pStr = gtk_button_get_label(pButton); - return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); - } - - void set_label(GtkButton* pButton, const OUString& rText) - { - gtk_button_set_label(pButton, MapToGtkAccelerator(rText).getStr()); - } -} - class GtkInstanceButton : public GtkInstanceContainer, public virtual weld::Button { private: @@ -4022,6 +4053,7 @@ void ensure_intercept_drawing_area_accessibility() class GtkInstanceBuilder : public weld::Builder { private: + ResHookProc m_pStringReplace; OUString m_sHelpRoot; OString m_aUtf8HelpRoot; GtkBuilder* m_pBuilder; @@ -4080,16 +4112,31 @@ private: g_signal_connect(pWidget, "query-tooltip", G_CALLBACK(signalTooltipQuery), nullptr); } - //missing mnemonics + // expand placeholder and collect potentially missing mnemonics if (GTK_IS_BUTTON(pWidget)) { - if (gtk_button_get_use_underline(GTK_BUTTON(pWidget))) - m_aMnemonicButtons.push_back(GTK_BUTTON(pWidget)); + GtkButton* pButton = GTK_BUTTON(pWidget); + set_label(pButton, (*m_pStringReplace)(get_label(pButton))); + if (gtk_button_get_use_underline(pButton)) + m_aMnemonicButtons.push_back(pButton); } else if (GTK_IS_LABEL(pWidget)) { - if (gtk_label_get_use_underline(GTK_LABEL(pWidget))) - m_aMnemonicLabels.push_back(GTK_LABEL(pWidget)); + GtkLabel* pLabel = GTK_LABEL(pWidget); + set_label(pLabel, (*m_pStringReplace)(get_label(pLabel))); + if (gtk_label_get_use_underline(pLabel)) + m_aMnemonicLabels.push_back(pLabel); + } + else if (GTK_IS_WINDOW(pWidget)) + { + GtkWindow* pWindow = GTK_WINDOW(pWidget); + set_title(pWindow, (*m_pStringReplace)(get_title(pWindow))); + if (GTK_IS_MESSAGE_DIALOG(pWindow)) + { + GtkMessageDialog* pMessageDialog = GTK_MESSAGE_DIALOG(pWindow); + set_primary_text(pMessageDialog, (*m_pStringReplace)(get_primary_text(pMessageDialog))); + set_secondary_text(pMessageDialog, (*m_pStringReplace)(get_secondary_text(pMessageDialog))); + } } } @@ -4104,6 +4151,7 @@ private: public: GtkInstanceBuilder(GtkWidget* pParent, const OUString& rUIRoot, const OUString& rUIFile) : weld::Builder(rUIFile) + , m_pStringReplace(Translate::GetReadStringHook()) , m_sHelpRoot(rUIFile) , m_pParentWidget(pParent) { |