diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-06-07 22:33:16 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-06-07 22:33:16 +0800 |
commit | ee90d2e1b9f44d3064b23f8a8641a05235161ab7 (patch) | |
tree | e95d1115c1622a0dd58386d5ce40958231186be9 | |
parent | 9d5255e6b6966ca13d4d9b767992631371390732 (diff) | |
download | gsoc2013-epiphany-ee90d2e1b9f44d3064b23f8a8641a05235161ab7.tar gsoc2013-epiphany-ee90d2e1b9f44d3064b23f8a8641a05235161ab7.tar.gz gsoc2013-epiphany-ee90d2e1b9f44d3064b23f8a8641a05235161ab7.tar.bz2 gsoc2013-epiphany-ee90d2e1b9f44d3064b23f8a8641a05235161ab7.tar.lz gsoc2013-epiphany-ee90d2e1b9f44d3064b23f8a8641a05235161ab7.tar.xz gsoc2013-epiphany-ee90d2e1b9f44d3064b23f8a8641a05235161ab7.tar.zst gsoc2013-epiphany-ee90d2e1b9f44d3064b23f8a8641a05235161ab7.zip |
Fix setting the default filename in the !modeSave case. (Backported from
2004-06-07 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/FilePicker.cpp:
* embed/mozilla/FilePicker.h:
Fix setting the default filename in the !modeSave case.
(Backported from HEAD.)
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | embed/mozilla/FilePicker.cpp | 49 | ||||
-rw-r--r-- | embed/mozilla/FilePicker.h | 2 |
3 files changed, 37 insertions, 22 deletions
@@ -1,3 +1,11 @@ +2004-06-07 Christian Persch <chpe@cvs.gnome.org> + + * embed/mozilla/FilePicker.cpp: + * embed/mozilla/FilePicker.h: + + Fix setting the default filename in the !modeSave case. + (Backported from HEAD.) + 2004-06-05 Christian Persch <chpe@cvs.gnome.org> * configure.in: diff --git a/embed/mozilla/FilePicker.cpp b/embed/mozilla/FilePicker.cpp index c9c7fa357..595ebe003 100644 --- a/embed/mozilla/FilePicker.cpp +++ b/embed/mozilla/FilePicker.cpp @@ -270,24 +270,13 @@ NS_IMETHODIMP GFilePicker::GetDefaultString(PRUnichar **aDefaultString) NS_IMETHODIMP GFilePicker::GetDefaultString(nsAString& aDefaultString) #endif { - char *filename, *converted; - LOG ("GFilePicker::GetDefaultString") - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (mDialog)); - if (filename != NULL) - { - converted = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); - #if MOZILLA_SNAPSHOT < 18 - *aDefaultString = ToNewUnicode (NS_ConvertUTF8toUTF16 (converted)); + *aDefaultString = ToNewUnicode (mDefaultString); #else - CopyUTF8toUTF16 (converted, aDefaultString); + aDefaultString = mDefaultString; #endif - - g_free (filename); - g_free (converted); - } return NS_OK; } @@ -301,21 +290,19 @@ NS_IMETHODIMP GFilePicker::SetDefaultString(const nsAString& aDefaultString) LOG ("GFilePicker::SetDefaultString to %s", NS_ConvertUCS2toUTF8 (aDefaultString).get()) -#if MOZILLA_SNAPSHOT < 18 - if (aDefaultString) -#else - if (aDefaultString.Length()) -#endif + mDefaultString.Assign (aDefaultString); + + if (mMode == nsIFilePicker::modeSave) { /* set_current_name takes UTF-8, not a filename */ #if MOZILLA_SNAPSHOT < 13 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (mDialog), - NS_ConvertUCS2toUTF8 (aDefaultString).get()); + NS_ConvertUCS2toUTF8 (mDefaultString).get()); #else gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (mDialog), - NS_ConvertUTF16toUTF8 (aDefaultString).get()); + NS_ConvertUTF16toUTF8 (mDefaultString).get()); #endif } @@ -389,8 +376,26 @@ NS_IMETHODIMP GFilePicker::SetDisplayDirectory(nsILocalFile *aDisplayDirectory) LOG ("GFilePicker::SetDisplayDirectory to %s", dir.get()) - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (mDialog), - dir.get()); + if (!mDefaultString.IsEmpty() && mMode != nsIFilePicker::modeSave) + { + char *defaultString, *filename; + + defaultString = g_filename_from_utf8 (NS_ConvertUCS2toUTF8(mDefaultString).get(), + -1, NULL, NULL, NULL); + if (defaultString) + { + filename = g_build_filename (dir.get(), defaultString, NULL); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (mDialog), filename); + g_free (filename); + } + g_free (defaultString); + + } + else + { + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (mDialog), + dir.get()); + } return NS_OK; } diff --git a/embed/mozilla/FilePicker.h b/embed/mozilla/FilePicker.h index cf6a7f68f..417ef5701 100644 --- a/embed/mozilla/FilePicker.h +++ b/embed/mozilla/FilePicker.h @@ -24,6 +24,7 @@ #include <nsIFilePicker.h> #include <nsISupports.h> +#include <nsString.h> #include "ephy-file-chooser.h" @@ -54,6 +55,7 @@ public: private: EphyFileChooser *mDialog; PRInt16 mMode; + nsAutoString mDefaultString; }; #endif |