Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsFilePicker_h__ |
michael@0 | 7 | #define nsFilePicker_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include <gtk/gtk.h> |
michael@0 | 10 | |
michael@0 | 11 | #include "nsBaseFilePicker.h" |
michael@0 | 12 | #include "nsString.h" |
michael@0 | 13 | #include "nsTArray.h" |
michael@0 | 14 | #include "nsCOMArray.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsIWidget; |
michael@0 | 17 | class nsIFile; |
michael@0 | 18 | |
michael@0 | 19 | class nsFilePicker : public nsBaseFilePicker |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | nsFilePicker(); |
michael@0 | 23 | virtual ~nsFilePicker(); |
michael@0 | 24 | |
michael@0 | 25 | NS_DECL_ISUPPORTS |
michael@0 | 26 | |
michael@0 | 27 | // nsIFilePicker (less what's in nsBaseFilePicker) |
michael@0 | 28 | NS_IMETHOD Open(nsIFilePickerShownCallback *aCallback); |
michael@0 | 29 | NS_IMETHODIMP AppendFilters(int32_t aFilterMask); |
michael@0 | 30 | NS_IMETHODIMP AppendFilter(const nsAString& aTitle, const nsAString& aFilter); |
michael@0 | 31 | NS_IMETHODIMP SetDefaultString(const nsAString& aString); |
michael@0 | 32 | NS_IMETHODIMP GetDefaultString(nsAString& aString); |
michael@0 | 33 | NS_IMETHODIMP SetDefaultExtension(const nsAString& aExtension); |
michael@0 | 34 | NS_IMETHODIMP GetDefaultExtension(nsAString& aExtension); |
michael@0 | 35 | NS_IMETHODIMP GetFilterIndex(int32_t *aFilterIndex); |
michael@0 | 36 | NS_IMETHODIMP SetFilterIndex(int32_t aFilterIndex); |
michael@0 | 37 | NS_IMETHODIMP GetFile(nsIFile **aFile); |
michael@0 | 38 | NS_IMETHODIMP GetFileURL(nsIURI **aFileURL); |
michael@0 | 39 | NS_IMETHODIMP GetFiles(nsISimpleEnumerator **aFiles); |
michael@0 | 40 | NS_IMETHODIMP Show(int16_t *aReturn); |
michael@0 | 41 | |
michael@0 | 42 | // nsBaseFilePicker |
michael@0 | 43 | virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle); |
michael@0 | 44 | |
michael@0 | 45 | static void Shutdown(); |
michael@0 | 46 | |
michael@0 | 47 | protected: |
michael@0 | 48 | |
michael@0 | 49 | void ReadValuesFromFileChooser(GtkWidget *file_chooser); |
michael@0 | 50 | |
michael@0 | 51 | static void OnResponse(GtkWidget* dialog, gint response_id, |
michael@0 | 52 | gpointer user_data); |
michael@0 | 53 | static void OnDestroy(GtkWidget* dialog, gpointer user_data); |
michael@0 | 54 | void Done(GtkWidget* dialog, gint response_id); |
michael@0 | 55 | |
michael@0 | 56 | nsCOMPtr<nsIWidget> mParentWidget; |
michael@0 | 57 | nsCOMPtr<nsIFilePickerShownCallback> mCallback; |
michael@0 | 58 | nsCOMArray<nsIFile> mFiles; |
michael@0 | 59 | |
michael@0 | 60 | int16_t mSelectedType; |
michael@0 | 61 | int16_t mResult; |
michael@0 | 62 | bool mRunning; |
michael@0 | 63 | bool mAllowURLs; |
michael@0 | 64 | nsCString mFileURL; |
michael@0 | 65 | nsString mTitle; |
michael@0 | 66 | nsString mDefault; |
michael@0 | 67 | nsString mDefaultExtension; |
michael@0 | 68 | |
michael@0 | 69 | nsTArray<nsCString> mFilters; |
michael@0 | 70 | nsTArray<nsCString> mFilterNames; |
michael@0 | 71 | |
michael@0 | 72 | private: |
michael@0 | 73 | static nsIFile *mPrevDisplayDirectory; |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | #endif |