vcl/source/window/layout.cxx |   32 ++++++++++++++++----------------
 vcl/unx/gtk3/gtkdata.cxx     |   36 ++++++++++++++++++------------------
 vcl/unx/gtk3/gtkinst.cxx     |    3 ++-
 vcl/unx/gtk4/convert3to4.cxx |    4 ++--
 4 files changed, 38 insertions(+), 37 deletions(-)

New commits:
commit da1e9cba89128de05b8681469cdbc154f7624aad
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Oct 8 10:20:52 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Oct 8 12:52:01 2021 +0200

    sort buttons using id instead of HelpId
    
    when created from the builder a widget's HelpId is the patch to the
    widget and always ends in the widget id so this is no change for that
    case, but when created directly by vcl for e.g. a MessageDialog while
    the id is set the helpid is empty, so this means that Yes/No
    MessageDialogs have their buttons sorted the same as if the Yes/No
    buttons were explicitly spelled out in a builder .ui
    
    Change-Id: Iee1a7146d2b6da76804856b1c4df8849ddd91a0c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123253
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index e49396313449..16a49d300d23 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -746,33 +746,33 @@ namespace {
 
 struct ButtonOrder
 {
-    const char* m_aType;
+    std::u16string_view m_aType;
     int m_nPriority;
 };
 
 }
 
-static int getButtonPriority(std::string_view rType)
+static int getButtonPriority(std::u16string_view rType)
 {
     static const size_t N_TYPES = 6;
     static const ButtonOrder aDiscardCancelSave[N_TYPES] =
     {
-        { "/discard", 0 },
-        { "/cancel", 1 },
-        { "/no", 2 },
-        { "/save", 3 },
-        { "/yes", 3 },
-        { "/ok", 3 }
+        { u"discard", 0 },
+        { u"cancel", 1 },
+        { u"no", 2 },
+        { u"save", 3 },
+        { u"yes", 3 },
+        { u"ok", 3 }
     };
 
     static const ButtonOrder aSaveDiscardCancel[N_TYPES] =
     {
-        { "/save", 0 },
-        { "/yes", 0 },
-        { "/ok", 0 },
-        { "/discard", 1 },
-        { "/no", 1 },
-        { "/cancel", 2 }
+        { u"save", 0 },
+        { u"yes", 0 },
+        { u"ok", 0 },
+        { u"discard", 1 },
+        { u"no", 1 },
+        { u"cancel", 2 }
     };
 
     const ButtonOrder* pOrder = &aDiscardCancelSave[0];
@@ -788,7 +788,7 @@ static int getButtonPriority(std::string_view rType)
 
     for (size_t i = 0; i < N_TYPES; ++i, ++pOrder)
     {
-        if (o3tl::ends_with(rType, pOrder->m_aType))
+        if (rType == pOrder->m_aType)
             return pOrder->m_nPriority;
     }
 
@@ -839,7 +839,7 @@ bool sortButtons::operator()(const vcl::Window *pA, const 
vcl::Window *pB) const
     }
 
     //now order within groups according to platform rules
-    return getButtonPriority(pA->GetHelpId()) < 
getButtonPriority(pB->GetHelpId());
+    return getButtonPriority(pA->get_id()) < getButtonPriority(pB->get_id());
 }
 
 void sort_native_button_order(const VclBox& rContainer)
diff --git a/vcl/unx/gtk3/gtkdata.cxx b/vcl/unx/gtk3/gtkdata.cxx
index c1381fe89daf..8f2afb4dc5a4 100644
--- a/vcl/unx/gtk3/gtkdata.cxx
+++ b/vcl/unx/gtk3/gtkdata.cxx
@@ -872,7 +872,7 @@ namespace {
 
 struct ButtonOrder
 {
-    const char * m_aType;
+    std::string_view m_aType;
     int m_nPriority;
 };
 
@@ -883,26 +883,26 @@ int getButtonPriority(std::string_view rType)
     static const size_t N_TYPES = 8;
     static const ButtonOrder aDiscardCancelSave[N_TYPES] =
     {
-        { "/discard", 0 },
-        { "/cancel", 1 },
-        { "/close", 1 },
-        { "/no", 2 },
-        { "/open", 3 },
-        { "/save", 3 },
-        { "/yes", 3 },
-        { "/ok", 3 }
+        { "discard", 0 },
+        { "cancel", 1 },
+        { "close", 1 },
+        { "no", 2 },
+        { "open", 3 },
+        { "save", 3 },
+        { "yes", 3 },
+        { "ok", 3 }
     };
 
     static const ButtonOrder aSaveDiscardCancel[N_TYPES] =
     {
-        { "/open", 0 },
-        { "/save", 0 },
-        { "/yes", 0 },
-        { "/ok", 0 },
-        { "/discard", 1 },
-        { "/no", 1 },
-        { "/cancel", 2 },
-        { "/close", 2 }
+        { "open", 0 },
+        { "save", 0 },
+        { "yes", 0 },
+        { "ok", 0 },
+        { "discard", 1 },
+        { "no", 1 },
+        { "cancel", 2 },
+        { "close", 2 }
     };
 
     const ButtonOrder* pOrder = &aDiscardCancelSave[0];
@@ -918,7 +918,7 @@ int getButtonPriority(std::string_view rType)
 
     for (size_t i = 0; i < N_TYPES; ++i, ++pOrder)
     {
-        if (o3tl::ends_with(rType, pOrder->m_aType))
+        if (rType == pOrder->m_aType)
             return pOrder->m_nPriority;
     }
 
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 3cd60a2777a6..ec87c2785741 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -5732,7 +5732,8 @@ namespace {
 bool sortButtons(const GtkWidget* pA, const GtkWidget* pB)
 {
     //order within groups according to platform rules
-    return getButtonPriority(::get_help_id(pA)) < 
getButtonPriority(::get_help_id(pB));
+    return getButtonPriority(get_buildable_id(GTK_BUILDABLE(pA))) <
+           getButtonPriority(get_buildable_id(GTK_BUILDABLE(pB)));
 }
 
 void sort_native_button_order(GtkBox* pContainer)
diff --git a/vcl/unx/gtk4/convert3to4.cxx b/vcl/unx/gtk4/convert3to4.cxx
index d7a881f8f7d5..29b51a747ff7 100644
--- a/vcl/unx/gtk4/convert3to4.cxx
+++ b/vcl/unx/gtk4/convert3to4.cxx
@@ -23,8 +23,8 @@ typedef std::pair<css::uno::Reference<css::xml::dom::XNode>, 
OUString> named_nod
 
 bool sortButtonNodes(const named_node& rA, const named_node& rB)
 {
-    OString sA("/" + rA.second.toUtf8());
-    OString sB("/" + rB.second.toUtf8());
+    OString sA(rA.second.toUtf8());
+    OString sB(rB.second.toUtf8());
     //order within groups according to platform rules
     return getButtonPriority(sA) < getButtonPriority(sB);
 }

Reply via email to