Bug 1769547 - Do not MOZ_CRASH() on missing process r=nika
[gecko.git] / widget / gtk / nsFilePicker.h
blob9b3110aa00487ae90aab2b9170e2ddd791032382
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsFilePicker_h__
7 #define nsFilePicker_h__
9 #include <gtk/gtk.h>
11 #include "nsBaseFilePicker.h"
12 #include "nsString.h"
13 #include "nsTArray.h"
14 #include "nsCOMArray.h"
16 class nsIWidget;
17 class nsIFile;
19 class nsFilePicker : public nsBaseFilePicker {
20 public:
21 nsFilePicker();
23 NS_DECL_ISUPPORTS
25 // nsIFilePicker (less what's in nsBaseFilePicker)
26 NS_IMETHOD Open(nsIFilePickerShownCallback* aCallback) override;
27 NS_IMETHOD AppendFilters(int32_t aFilterMask) override;
28 NS_IMETHOD AppendFilter(const nsAString& aTitle,
29 const nsAString& aFilter) override;
30 NS_IMETHOD SetDefaultString(const nsAString& aString) override;
31 NS_IMETHOD GetDefaultString(nsAString& aString) override;
32 NS_IMETHOD SetDefaultExtension(const nsAString& aExtension) override;
33 NS_IMETHOD GetDefaultExtension(nsAString& aExtension) override;
34 NS_IMETHOD GetFilterIndex(int32_t* aFilterIndex) override;
35 NS_IMETHOD SetFilterIndex(int32_t aFilterIndex) override;
36 NS_IMETHOD GetFile(nsIFile** aFile) override;
37 NS_IMETHOD GetFileURL(nsIURI** aFileURL) override;
38 NS_IMETHOD GetFiles(nsISimpleEnumerator** aFiles) override;
40 // nsBaseFilePicker
41 virtual void InitNative(nsIWidget* aParent, const nsAString& aTitle) override;
43 static void Shutdown();
45 protected:
46 virtual ~nsFilePicker();
48 nsresult Show(int16_t* aReturn) override;
49 void ReadValuesFromFileChooser(void* file_chooser);
51 static void OnResponse(void* file_chooser, gint response_id,
52 gpointer user_data);
53 static void OnDestroy(GtkWidget* file_chooser, gpointer user_data);
54 void Done(void* file_chooser, gint response_id);
56 nsCOMPtr<nsIWidget> mParentWidget;
57 nsCOMPtr<nsIFilePickerShownCallback> mCallback;
58 nsCOMArray<nsIFile> mFiles;
60 int16_t mSelectedType;
61 int16_t mResult;
62 bool mRunning;
63 bool mAllowURLs;
64 nsCString mFileURL;
65 nsString mTitle;
66 nsString mDefault;
67 nsString mDefaultExtension;
69 nsTArray<nsCString> mFilters;
70 nsTArray<nsCString> mFilterNames;
72 private:
73 static nsIFile* mPrevDisplayDirectory;
75 void* GtkFileChooserNew(const gchar* title, GtkWindow* parent,
76 GtkFileChooserAction action,
77 const gchar* accept_label);
78 void GtkFileChooserShow(void* file_chooser);
79 void GtkFileChooserDestroy(void* file_chooser);
80 void GtkFileChooserSetModal(void* file_chooser, GtkWindow* parent_widget,
81 gboolean modal);
83 GtkFileChooserWidget* mFileChooserDelegate;
84 bool mUseNativeFileChooser;
87 #endif