[Libreoffice-commits] core.git: .git-hooks/pre-commit vcl/inc vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 15 11:44:54 UTC 2021


 .git-hooks/pre-commit         |    4 +
 vcl/inc/strings.hrc           |    7 ---
 vcl/source/window/builder.cxx |   96 +-----------------------------------------
 vcl/unx/gtk3/gtk3gtkinst.cxx  |    2 
 4 files changed, 8 insertions(+), 101 deletions(-)

New commits:
commit e93267693fb66b48f92843bb6dab346e6212f683
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jan 11 16:22:43 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jan 15 12:44:03 2021 +0100

    remove newly unused use-stock support
    
    Change-Id: I235cf19e703be0a7ca9fdeeda0662c8e0ec54b63
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109198
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index 75d217f3f453..1a8e2b12bd44 100755
--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -113,6 +113,10 @@ sub check_whitespaces($)
             {
                 bad_line("use margin-start (etc) on child instead of a GtkAlignment", $_, "ui");
             }
+            if (/<property name="use[-_]stock"/ )
+            {
+                bad_line("use translation context 'stock' and the English string as button label instead", $_, "ui");
+            }
             if ((/translatable="yes"/) and not(/context=/))
             {
                 bad_line("translatable .ui file line without context", $_, "ui");
diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc
index 72de1fead32d..56437a7325e8 100644
--- a/vcl/inc/strings.hrc
+++ b/vcl/inc/strings.hrc
@@ -59,13 +59,6 @@
 #define SV_BUTTONTEXT_IGNORE                         NC_("SV_BUTTONTEXT_IGNORE", "~Ignore")
 #define SV_BUTTONTEXT_ABORT                          NC_("SV_BUTTONTEXT_ABORT", "~Abort")
 #define SV_BUTTONTEXT_LESS                           NC_("SV_BUTTONTEXT_LESS", "~Less")
-#define SV_BUTTONTEXT_RESET                          NC_("SV_BUTTONTEXT_RESET", "R~eset")
-#define SV_BUTTONTEXT_ADD                            NC_("SV_BUTTONTEXT_ADD", "~Add")
-#define SV_BUTTONTEXT_DELETE                         NC_("SV_BUTTONTEXT_DELETE", "~Delete")
-#define SV_BUTTONTEXT_REMOVE                         NC_("SV_BUTTONTEXT_REMOVE", "~Remove")
-#define SV_BUTTONTEXT_NEW                            NC_("SV_BUTTONTEXT_NEW", "~New")
-#define SV_BUTTONTEXT_EDIT                           NC_("SV_BUTTONTEXT_EDIT", "~Edit")
-#define SV_BUTTONTEXT_APPLY                          NC_("SV_BUTTONTEXT_APPLY", "~Apply")
 #define SV_BUTTONTEXT_SAVE                           NC_("SV_BUTTONTEXT_SAVE", "~Save")
 #define SV_BUTTONTEXT_OPEN                           NC_("SV_BUTTONTEXT_OPEN", "~Open")
 #define SV_BUTTONTEXT_SCREENSHOT                     NC_("SV_BUTTONTEXT_SCREENSHOT", "~Screenshot")
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 9371a9b1eca7..a24e7b93182d 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1104,50 +1104,6 @@ namespace
         return sIconName;
     }
 
-    OUString getStockText(const OUString &rType)
-    {
-        if (rType == "gtk-ok")
-            return VclResId(SV_BUTTONTEXT_OK);
-        else if (rType == "gtk-cancel")
-            return VclResId(SV_BUTTONTEXT_CANCEL);
-        else if (rType == "gtk-help")
-            return VclResId(SV_BUTTONTEXT_HELP);
-        else if (rType == "gtk-close")
-            return VclResId(SV_BUTTONTEXT_CLOSE);
-        else if (rType == "gtk-revert-to-saved")
-            return VclResId(SV_BUTTONTEXT_RESET);
-        else if (rType == "gtk-add")
-            return VclResId(SV_BUTTONTEXT_ADD);
-        else if (rType == "gtk-delete")
-            return VclResId(SV_BUTTONTEXT_DELETE);
-        else if (rType == "gtk-remove")
-            return VclResId(SV_BUTTONTEXT_REMOVE);
-        else if (rType == "gtk-new")
-            return VclResId(SV_BUTTONTEXT_NEW);
-        else if (rType == "gtk-edit")
-            return VclResId(SV_BUTTONTEXT_EDIT);
-        else if (rType == "gtk-apply")
-            return VclResId(SV_BUTTONTEXT_APPLY);
-        else if (rType == "gtk-yes")
-            return VclResId(SV_BUTTONTEXT_YES);
-        else if (rType == "gtk-no")
-            return VclResId(SV_BUTTONTEXT_NO);
-        SAL_WARN("vcl.builder", "unknown stock type: " << rType);
-        return OUString();
-    }
-
-    bool extractStock(VclBuilder::stringmap &rMap)
-    {
-        bool bIsStock = false;
-        VclBuilder::stringmap::iterator aFind = rMap.find(OString("use-stock"));
-        if (aFind != rMap.end())
-        {
-            bIsStock = toBool(aFind->second);
-            rMap.erase(aFind);
-        }
-        return bIsStock;
-    }
-
     WinBits extractRelief(VclBuilder::stringmap &rMap)
     {
         WinBits nBits = WB_3DLOOK;
@@ -1317,7 +1273,7 @@ namespace
         pButton->SetCommandHandler(aCommand);
     }
 
-    VclPtr<Button> extractStockAndBuildPushButton(vcl::Window *pParent, VclBuilder::stringmap &rMap, bool bToggle, bool bLegacy)
+    VclPtr<Button> extractStockAndBuildPushButton(vcl::Window *pParent, VclBuilder::stringmap &rMap, bool bToggle)
     {
         WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER;
         if (bToggle)
@@ -1325,31 +1281,7 @@ namespace
 
         nBits |= extractRelief(rMap);
 
-        VclPtr<Button> xWindow;
-
-        if (extractStock(rMap))
-        {
-            OUString sType = extractLabel(rMap);
-            if (bLegacy)
-            {
-                if (sType == "gtk-ok")
-                    xWindow = VclPtr<OKButton>::Create(pParent, nBits);
-                else if (sType == "gtk-cancel")
-                    xWindow = VclPtr<CancelButton>::Create(pParent, nBits);
-                else if (sType == "gtk-close")
-                    xWindow = VclPtr<CloseButton>::Create(pParent, nBits);
-                else if (sType == "gtk-help")
-                    xWindow = VclPtr<HelpButton>::Create(pParent, nBits);
-            }
-            if (!xWindow)
-            {
-                xWindow = VclPtr<PushButton>::Create(pParent, nBits);
-                xWindow->SetText(getStockText(sType));
-            }
-        }
-
-        if (!xWindow)
-            xWindow = VclPtr<PushButton>::Create(pParent, nBits);
+        VclPtr<Button> xWindow = VclPtr<PushButton>::Create(pParent, nBits);
         return xWindow;
     }
 
@@ -1360,12 +1292,6 @@ namespace
         nBits |= extractRelief(rMap);
 
         VclPtr<MenuButton> xWindow = VclPtr<MenuButton>::Create(pParent, nBits);
-
-        if (extractStock(rMap))
-        {
-            xWindow->SetText(getStockText(extractLabel(rMap)));
-        }
-
         return xWindow;
     }
 
@@ -1376,12 +1302,6 @@ namespace
         nBits |= extractRelief(rMap);
 
         VclPtr<MenuButton> xWindow = VclPtr<MenuToggleButton>::Create(pParent, nBits);
-
-        if (extractStock(rMap))
-        {
-            xWindow->SetText(getStockText(extractLabel(rMap)));
-        }
-
         return xWindow;
     }
 
@@ -1853,7 +1773,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
         VclPtr<Button> xButton;
         OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
         if (sMenu.isEmpty())
-            xButton = extractStockAndBuildPushButton(pParent, rMap, name == "GtkToggleButton", m_bLegacy);
+            xButton = extractStockAndBuildPushButton(pParent, rMap, name == "GtkToggleButton");
         else
         {
             assert(m_bLegacy && "use GtkMenuButton");
@@ -1909,11 +1829,6 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
         VclPtr<RadioButton> xButton = VclPtr<RadioButton>::Create(pParent, nBits);
         xButton->SetImageAlign(ImageAlign::Left); //default to left
         xWindow = xButton;
-
-        if (::extractStock(rMap))
-        {
-            xWindow->SetText(getStockText(extractLabel(rMap)));
-        }
     }
     else if (name == "GtkCheckButton")
     {
@@ -1928,11 +1843,6 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
         xCheckBox->SetImageAlign(ImageAlign::Left); //default to left
 
         xWindow = xCheckBox;
-
-        if (::extractStock(rMap))
-        {
-            xWindow->SetText(getStockText(extractLabel(rMap)));
-        }
     }
     else if (name == "GtkSpinButton")
     {
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 0ef2b33239cf..58940896d4b9 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -16658,7 +16658,7 @@ private:
                 if (!aLabel.isEmpty())
                     set_label(pButton, (*m_pStringReplace)(aLabel));
             }
-            if (gtk_button_get_use_underline(pButton) && !gtk_button_get_use_stock(pButton))
+            if (gtk_button_get_use_underline(pButton))
                 m_aMnemonicButtons.push_back(pButton);
         }
         else if (GTK_IS_LABEL(pWidget))


More information about the Libreoffice-commits mailing list