From 1da3406a8e97934615b5b644cbb81bf3108143ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 6 Oct 2022 09:59:44 +0100 Subject: [PATCH] Related: tdf#150706 add OK and CANCEL to known controls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit which results that we can rename "Save" to "Export" in pdf export dialog Change-Id: I8186a9ea3d18bfb383b07ba54f2fd7a5cd71e7b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141004 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx | 29 +++++++++++++---------- vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx | 2 ++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx index 2c75546ff2b2..ec4601913af3 100644 --- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx @@ -1099,6 +1099,10 @@ GtkWidget *SalGtkFilePicker::getWidget( sal_Int16 nControlId, GType *pType ) pWidget = m_pToggles[elem]; tType = GTK_TYPE_CHECK_BUTTON; \ break #define MAP_BUTTON( elem ) \ + case CommonFilePickerElementIds::PUSHBUTTON_##elem: \ + pWidget = m_pButtons[elem]; tType = GTK_TYPE_BUTTON; \ + break +#define MAP_EXT_BUTTON( elem ) \ case ExtendedFilePickerElementIds::PUSHBUTTON_##elem: \ pWidget = m_pButtons[elem]; tType = GTK_TYPE_BUTTON; \ break @@ -1121,7 +1125,9 @@ GtkWidget *SalGtkFilePicker::getWidget( sal_Int16 nControlId, GType *pType ) MAP_TOGGLE( LINK ); MAP_TOGGLE( PREVIEW ); MAP_TOGGLE( SELECTION ); - MAP_BUTTON( PLAY ); + MAP_BUTTON( OK ); + MAP_BUTTON( CANCEL ); + MAP_EXT_BUTTON( PLAY ); MAP_LIST( VERSION ); MAP_LIST( TEMPLATE ); MAP_LIST( IMAGE_TEMPLATE ); @@ -1383,7 +1389,7 @@ void SAL_CALL SalGtkFilePicker::setLabel( sal_Int16 nControlId, const OUString& if( !( pWidget = getWidget( nControlId, &tType ) ) ) { - SAL_WARN( "vcl.gtk", "Set label on unknown control " << nControlId); + SAL_WARN( "vcl.gtk", "Set label '" << rLabel << "' on unknown control " << nControlId); return; } @@ -1775,18 +1781,17 @@ void SalGtkFilePicker::impl_initialize(GtkWidget* pParentWidget, sal_Int16 templ } gtk_file_chooser_set_action( GTK_FILE_CHOOSER( m_pDialog ), eAction); - gtk_dialog_add_button(GTK_DIALOG( m_pDialog ), - getCancelText().getStr(), - GTK_RESPONSE_CANCEL); - for( int nTVIndex = 0; nTVIndex < BUTTON_LAST; nTVIndex++ ) + m_pButtons[CANCEL] = gtk_dialog_add_button(GTK_DIALOG(m_pDialog), getCancelText().getStr(), GTK_RESPONSE_CANCEL); + mbButtonVisibility[CANCEL] = true; + + if (mbButtonVisibility[PLAY]) { - if( mbButtonVisibility[nTVIndex] ) - { - OString aPlay = OUStringToOString( getResString( PUSHBUTTON_PLAY ), RTL_TEXTENCODING_UTF8 ); - m_pButtons[ nTVIndex ] = gtk_dialog_add_button( GTK_DIALOG( m_pDialog ), aPlay.getStr(), 1 ); - } + OString aPlay = OUStringToOString(getResString(PUSHBUTTON_PLAY), RTL_TEXTENCODING_UTF8); + m_pButtons[PLAY] = gtk_dialog_add_button(GTK_DIALOG(m_pDialog), aPlay.getStr(), 1); } - gtk_dialog_add_button( GTK_DIALOG( m_pDialog ), first_button_text, GTK_RESPONSE_ACCEPT ); + + m_pButtons[OK] = gtk_dialog_add_button(GTK_DIALOG(m_pDialog), first_button_text, GTK_RESPONSE_ACCEPT); + mbButtonVisibility[OK] = true; gtk_dialog_set_default_response( GTK_DIALOG (m_pDialog), GTK_RESPONSE_ACCEPT ); diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx index c412478e8aab..fdc701a20384 100644 --- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx +++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx @@ -170,6 +170,8 @@ class SalGtkFilePicker : public SalGtkPicker, public SalGtkFilePicker_Base bool mbToggleVisibility[TOGGLE_LAST]; enum { + OK, + CANCEL, PLAY, BUTTON_LAST };