[Libreoffice-commits] .: fpicker/source

Caolán McNamara caolan at kemper.freedesktop.org
Thu Feb 24 12:52:05 PST 2011


 fpicker/source/unx/gnome/SalGtkFilePicker.cxx |   37 ++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 5 deletions(-)

New commits:
commit 5f389ebc3ea68db6245c60423e5c219d2b54f8c7
Author: Kevin Hunter <hunteke at earlham.edu>
Date:   Thu Feb 24 14:23:10 2011 -0500

    Fix GTK dialog replacement of $filename$
    
    When using GTK dialogs on a *nix system, the dialog box was displaying
    "Overwrite '$filename$'?" instead of replacing '$filename$' with an
    actual file name.  This ammends that to be in league with out the
    "native" LibreOffice dialogs do it.

diff --git a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
index aebb2df..e91d5d2 100644
--- a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
+++ b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
@@ -51,6 +51,7 @@
 #include <SalGtkFilePicker.hxx>
 
 #include <tools/string.hxx>
+#include <tools/urlobj.hxx>
 
 #include <algorithm>
 #include <set>
@@ -1001,14 +1002,40 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute() throw( uno::RuntimeException )
                         {
                             CResourceProvider aResProvider;
                             GtkWidget *dlg;
-            
-                            dlg = gtk_message_dialog_new( NULL, 
+
+
+                            INetURLObject aFileObj( sFileName );
+
+                            OString baseName(
+                              OUStringToOString(
+                                aFileObj.getName(
+                                  INetURLObject::LAST_SEGMENT,
+                                  true,
+                                  INetURLObject::DECODE_WITH_CHARSET
+                                ),
+                                RTL_TEXTENCODING_UTF8
+                              )
+                            );
+                            OString aMsg(
+                              OUStringToOString(
+                                aResProvider.getResString( FILE_PICKER_OVERWRITE ),
+                                RTL_TEXTENCODING_UTF8
+                              )
+                            );
+                            OString toReplace( RTL_CONSTASCII_STRINGPARAM( "$filename$" ));
+
+                            aMsg = aMsg.replaceAt(
+                              aMsg.indexOf( toReplace ),
+                              toReplace.getLength(),
+                              baseName
+                            );
+
+                            dlg = gtk_message_dialog_new( NULL,
                                 GTK_DIALOG_MODAL,
                                 GTK_MESSAGE_QUESTION,
                                 GTK_BUTTONS_YES_NO,
-                                  OUStringToOString(
-                                    aResProvider.getResString( FILE_PICKER_OVERWRITE ),
-                                    RTL_TEXTENCODING_UTF8 ).getStr() );
+                                aMsg.getStr()
+                            );
 
                             gtk_window_set_title( GTK_WINDOW( dlg ),
                                 OUStringToOString(aResProvider.getResString(FILE_PICKER_TITLE_SAVE ),


More information about the Libreoffice-commits mailing list