summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-27 16:45:44 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-28 21:25:51 +0100
commitc456ce855ac1ee4775489485f9107bd43a0f1371 (patch)
tree696e4e7deb93d5cd112c2a5a081b081bdf018824 /vcl
parentdc10b663a50adf4c9ea268f123169c7caf0b75c4 (diff)
use ok, cancel under kde vs cancel, ok under gnome
for the native welded dialogs Change-Id: I34663616826c1eb084262ea1c830f8580785d50c Reviewed-on: https://gerrit.libreoffice.org/50458 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/salvtables.cxx3
-rw-r--r--vcl/source/window/layout.cxx6
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx74
3 files changed, 81 insertions, 2 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index d2f648a696c1..a2b5b13d15fc 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -404,6 +404,9 @@ public:
virtual int run() override
{
+ VclButtonBox* pActionArea = m_xDialog->get_action_area();
+ if (pActionArea)
+ pActionArea->sort_native_button_order();
return m_xDialog->Execute();
}
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index ae3663c9c75f..2839ab356385 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -829,20 +829,22 @@ struct ButtonOrder
static int getButtonPriority(const OString &rType)
{
- static const size_t N_TYPES = 5;
+ static const size_t N_TYPES = 6;
static const ButtonOrder aDiscardCancelSave[N_TYPES] =
{
{ "/discard", 0 },
{ "/no", 0 },
{ "/cancel", 1 },
{ "/save", 2 },
- { "/yes", 2 }
+ { "/yes", 2 },
+ { "/ok", 2 }
};
static const ButtonOrder aSaveDiscardCancel[N_TYPES] =
{
{ "/save", 0 },
{ "/yes", 0 },
+ { "/ok", 0 },
{ "/discard", 1 },
{ "/no", 1 },
{ "/cancel", 2 }
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index e31606fffbad..c36895fffce1 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1378,6 +1378,79 @@ public:
}
};
+namespace
+{
+ struct ButtonOrder
+ {
+ OString m_aType;
+ int m_nPriority;
+ };
+
+ int getButtonPriority(const OString &rType)
+ {
+ static const size_t N_TYPES = 6;
+ static const ButtonOrder aDiscardCancelSave[N_TYPES] =
+ {
+ { "/discard", 0 },
+ { "/no", 0 },
+ { "/cancel", 1 },
+ { "/save", 2 },
+ { "/yes", 2 },
+ { "/ok", 2 }
+ };
+
+ static const ButtonOrder aSaveDiscardCancel[N_TYPES] =
+ {
+ { "/save", 0 },
+ { "/yes", 0 },
+ { "/ok", 0 },
+ { "/discard", 1 },
+ { "/no", 1 },
+ { "/cancel", 2 }
+ };
+
+ const ButtonOrder* pOrder = &aDiscardCancelSave[0];
+
+ const OUString &rEnv = Application::GetDesktopEnvironment();
+
+ if (rEnv.equalsIgnoreAsciiCase("windows") ||
+ rEnv.equalsIgnoreAsciiCase("tde") ||
+ rEnv.startsWithIgnoreAsciiCase("kde"))
+ {
+ pOrder = &aSaveDiscardCancel[0];
+ }
+
+ for (size_t i = 0; i < N_TYPES; ++i, ++pOrder)
+ {
+ if (rType.endsWith(pOrder->m_aType))
+ return pOrder->m_nPriority;
+ }
+
+ return -1;
+ }
+
+ 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));
+ }
+
+ void sort_native_button_order(GtkBox* pContainer)
+ {
+ std::vector<GtkWidget*> aChildren;
+ GList* pChildren = gtk_container_get_children(GTK_CONTAINER(pContainer));
+ for (GList* pChild = g_list_first(pChildren); pChild; pChild = g_list_next(pChild))
+ aChildren.push_back(static_cast<GtkWidget*>(pChild->data));
+ g_list_free(pChildren);
+
+ //sort child order within parent so that we match the platform button order
+ std::stable_sort(aChildren.begin(), aChildren.end(), sortButtons);
+
+ for (size_t pos = 0; pos < aChildren.size(); ++pos)
+ gtk_box_reorder_child(pContainer, aChildren[pos], pos);
+ }
+}
+
class GtkInstanceDialog : public GtkInstanceWindow, public virtual weld::Dialog
{
private:
@@ -1399,6 +1472,7 @@ public:
virtual int run() override
{
+ sort_native_button_order(GTK_BOX(gtk_dialog_get_action_area(m_pDialog)));
int ret;
while (true)
{