summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2011-04-01 11:18:49 (GMT)
committerMichael Meeks <michael.meeks@novell.com>2011-04-01 11:19:18 (GMT)
commit58f16ff09672f3e37156d0fc5e79e310b2c49c08 (patch)
treeafc2517eaf0f08089fa4fa449cc3089ecaf144ec
parentaba0b8e42dabe1727899cf10d4daeda99bf013af (diff)
add accelerators to Unix 'Ok'/'Cancel' dialog buttons
-rw-r--r--vcl/source/control/button.cxx10
-rw-r--r--vcl/unx/gtk/app/gtksys.cxx15
2 files changed, 21 insertions, 4 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 7efaf73..7926ee3 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -180,8 +180,16 @@ XubString Button::GetStandardText( StandardButtonType eButton )
ResMgr* pResMgr = ImplGetResMgr();
if( pResMgr )
{
- ResId aResId( aResIdAry[(sal_uInt16)eButton].nResId, *pResMgr );
+ sal_uInt32 nResId = aResIdAry[(sal_uInt16)eButton].nResId;
+ ResId aResId( nResId, *pResMgr );
aText = String( aResId );
+
+ // Windows (apparently) has some magic auto-accelerator evil around
+ // ok / cancel so add this only for Unix
+#ifdef UNX
+ if( nResId == SV_BUTTONTEXT_OK || nResId == SV_BUTTONTEXT_CANCEL )
+ aText.Insert( String::CreateFromAscii("~"), 0 );
+#endif
}
else
{
diff --git a/vcl/unx/gtk/app/gtksys.cxx b/vcl/unx/gtk/app/gtksys.cxx
index 91d40f0..db90edf 100644
--- a/vcl/unx/gtk/app/gtksys.cxx
+++ b/vcl/unx/gtk/app/gtksys.cxx
@@ -53,6 +53,14 @@ GtkSalSystem::~GtkSalSystem()
{
}
+// convert ~ to indicate mnemonic to '_'
+static ByteString MapToGtkAccelerator (const String &rStr)
+{
+ String aRet( rStr );
+ aRet.SearchAndReplaceAscii("~", String::CreateFromAscii("_"));
+ return ByteString( aRet, RTL_TEXTENCODING_UTF8 );
+}
+
int GtkSalSystem::ShowNativeDialog( const String& rTitle,
const String& rMessage,
const std::list< String >& rButtons,
@@ -81,15 +89,16 @@ int GtkSalSystem::ShowNativeDialog( const String& rTitle,
int nButton = 0;
for( std::list< String >::const_iterator it = rButtons.begin(); it != rButtons.end(); ++it )
{
- ByteString aLabel( *it, RTL_TEXTENCODING_UTF8 );
-
if( nButton == nDefButton )
{
- gtk_dialog_add_button( GTK_DIALOG( mainwin ), aLabel.GetBuffer(), nButtons );
+ gtk_dialog_add_button( GTK_DIALOG( mainwin ), MapToGtkAccelerator(*it).GetBuffer(), nButtons );
gtk_dialog_set_default_response( GTK_DIALOG( mainwin ), nButtons );
}
else
+ {
+ ByteString aLabel( *it, RTL_TEXTENCODING_UTF8 );
gtk_dialog_add_button( GTK_DIALOG( mainwin ), aLabel.GetBuffer(), nButtons );
+ }
nButtons++;
}