Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h

Issue 2449243002: Gtk3 ui: Add libgtk3ui as a separate build component (Closed)
Patch Set: Add theme_properties dep to //chrome/browser/ui Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_SELECT_FILE_DIALOG_IMPL_GTK2_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_SELECT_FILE_DIALOG_IMPL_GTK2_H_
7
8 #include "base/macros.h"
9 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
10 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
11 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h"
12
13 namespace libgtk2ui {
14
15 // Implementation of SelectFileDialog that shows a Gtk common dialog for
16 // choosing a file or folder. This acts as a modal dialog.
17 class SelectFileDialogImplGTK : public SelectFileDialogImpl,
18 public aura::WindowObserver {
19 public:
20 SelectFileDialogImplGTK(Listener* listener,
21 ui::SelectFilePolicy* policy);
22
23 protected:
24 ~SelectFileDialogImplGTK() override;
25
26 // BaseShellDialog implementation:
27 bool IsRunning(gfx::NativeWindow parent_window) const override;
28
29 // SelectFileDialog implementation.
30 // |params| is user data we pass back via the Listener interface.
31 void SelectFileImpl(Type type,
32 const base::string16& title,
33 const base::FilePath& default_path,
34 const FileTypeInfo* file_types,
35 int file_type_index,
36 const base::FilePath::StringType& default_extension,
37 gfx::NativeWindow owning_window,
38 void* params) override;
39
40 private:
41 friend class FilePicker;
42 bool HasMultipleFileTypeChoicesImpl() override;
43
44 // Overridden from aura::WindowObserver:
45 void OnWindowDestroying(aura::Window* window) override;
46
47 // Add the filters from |file_types_| to |chooser|.
48 void AddFilters(GtkFileChooser* chooser);
49
50 // Notifies the listener that a single file was chosen.
51 void FileSelected(GtkWidget* dialog, const base::FilePath& path);
52
53 // Notifies the listener that multiple files were chosen.
54 void MultiFilesSelected(GtkWidget* dialog,
55 const std::vector<base::FilePath>& files);
56
57 // Notifies the listener that no file was chosen (the action was canceled).
58 // Dialog is passed so we can find that |params| pointer that was passed to
59 // us when we were told to show the dialog.
60 void FileNotSelected(GtkWidget* dialog);
61
62 GtkWidget* CreateSelectFolderDialog(
63 Type type,
64 const std::string& title,
65 const base::FilePath& default_path,
66 gfx::NativeWindow parent);
67
68 GtkWidget* CreateFileOpenDialog(const std::string& title,
69 const base::FilePath& default_path, gfx::NativeWindow parent);
70
71 GtkWidget* CreateMultiFileOpenDialog(const std::string& title,
72 const base::FilePath& default_path, gfx::NativeWindow parent);
73
74 GtkWidget* CreateSaveAsDialog(const std::string& title,
75 const base::FilePath& default_path, gfx::NativeWindow parent);
76
77 // Removes and returns the |params| associated with |dialog| from
78 // |params_map_|.
79 void* PopParamsForDialog(GtkWidget* dialog);
80
81 // Check whether response_id corresponds to the user cancelling/closing the
82 // dialog. Used as a helper for the below callbacks.
83 bool IsCancelResponse(gint response_id);
84
85 // Common function for OnSelectSingleFileDialogResponse and
86 // OnSelectSingleFolderDialogResponse.
87 void SelectSingleFileHelper(GtkWidget* dialog,
88 gint response_id,
89 bool allow_folder);
90
91 // Common function for CreateFileOpenDialog and CreateMultiFileOpenDialog.
92 GtkWidget* CreateFileOpenHelper(const std::string& title,
93 const base::FilePath& default_path,
94 gfx::NativeWindow parent);
95
96 // Callback for when the user responds to a Save As or Open File dialog.
97 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
98 OnSelectSingleFileDialogResponse, int);
99
100 // Callback for when the user responds to a Select Folder dialog.
101 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
102 OnSelectSingleFolderDialogResponse, int);
103
104 // Callback for when the user responds to a Open Multiple Files dialog.
105 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
106 OnSelectMultiFileDialogResponse, int);
107
108 // Callback for when the file chooser gets destroyed.
109 CHROMEGTK_CALLBACK_0(SelectFileDialogImplGTK, void, OnFileChooserDestroy);
110
111 // Callback for when we update the preview for the selection.
112 CHROMEGTK_CALLBACK_0(SelectFileDialogImplGTK, void, OnUpdatePreview);
113
114 // A map from dialog windows to the |params| user data associated with them.
115 std::map<GtkWidget*, void*> params_map_;
116
117 // The GtkImage widget for showing previews of selected images.
118 GtkWidget* preview_;
119
120 // All our dialogs.
121 std::set<GtkWidget*> dialogs_;
122
123 // The set of all parent windows for which we are currently running dialogs.
124 std::set<aura::Window*> parents_;
125
126 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplGTK);
127 };
128
129 } // namespace libgtk2ui
130
131 #endif // CHROME_BROWSER_UI_LIBGTK2UI_SELECT_FILE_DIALOG_IMPL_GTK2_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/select_file_dialog_impl.cc ('k') | chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698