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

Side by Side Diff: chrome/browser/gtk/dialogs_gtk.cc

Issue 63093: Refactoring; switch the |filter| parameter into something that is more amenab... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <gtk/gtk.h> 5 #include <gtk/gtk.h>
6 #include <map> 6 #include <map>
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 explicit SelectFileDialogImpl(Listener* listener); 24 explicit SelectFileDialogImpl(Listener* listener);
25 virtual ~SelectFileDialogImpl(); 25 virtual ~SelectFileDialogImpl();
26 26
27 // BaseShellDialog implementation. 27 // BaseShellDialog implementation.
28 virtual bool IsRunning(gfx::NativeWindow parent_window) const; 28 virtual bool IsRunning(gfx::NativeWindow parent_window) const;
29 virtual void ListenerDestroyed(); 29 virtual void ListenerDestroyed();
30 30
31 // SelectFileDialog implementation. 31 // SelectFileDialog implementation.
32 // |params| is user data we pass back via the Listener interface. 32 // |params| is user data we pass back via the Listener interface.
33 virtual void SelectFile(Type type, const string16& title, 33 virtual void SelectFile(Type type,
34 const string16& title,
34 const FilePath& default_path, 35 const FilePath& default_path,
35 const std::wstring& filter, 36 const FileTypeInfo* file_types,
36 int filter_index, 37 int file_type_index,
37 const FilePath::StringType& default_extension, 38 const FilePath::StringType& default_extension,
38 gfx::NativeWindow parent_window, 39 gfx::NativeWindow owning_window,
39 void* params); 40 void* params);
40 41
41 private: 42 private:
42 // Notifies the listener that a single file was chosen. 43 // Notifies the listener that a single file was chosen.
43 void FileSelected(GtkWidget* dialog, const FilePath& path); 44 void FileSelected(GtkWidget* dialog, const FilePath& path);
44 45
45 // Notifies the listener that multiple files were chosen. 46 // Notifies the listener that multiple files were chosen.
46 void MultiFilesSelected(GtkWidget* dialog, 47 void MultiFilesSelected(GtkWidget* dialog,
47 const std::vector<FilePath>& files); 48 const std::vector<FilePath>& files);
48 49
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 108 }
108 109
109 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { 110 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const {
110 return parents_.find(parent_window) != parents_.end(); 111 return parents_.find(parent_window) != parents_.end();
111 } 112 }
112 113
113 void SelectFileDialogImpl::ListenerDestroyed() { 114 void SelectFileDialogImpl::ListenerDestroyed() {
114 listener_ = NULL; 115 listener_ = NULL;
115 } 116 }
116 117
117 // We ignore |filter| and |default_extension|. 118 // We ignore |file_types| and |default_extension|.
118 // TODO(estade): use |filter|. 119 // TODO(estade): use |file_types|.
119 void SelectFileDialogImpl::SelectFile( 120 void SelectFileDialogImpl::SelectFile(
120 Type type, 121 Type type,
121 const string16& title, 122 const string16& title,
122 const FilePath& default_path, 123 const FilePath& default_path,
123 const std::wstring& filter, 124 const FileTypeInfo* file_types,
124 int filter_index, 125 int file_type_index,
125 const FilePath::StringType& default_extension, 126 const FilePath::StringType& default_extension,
126 gfx::NativeWindow parent_window, 127 gfx::NativeWindow owning_window,
127 void* params) { 128 void* params) {
128 // TODO(estade): on windows, parent_window may be null. But I'm not sure when 129 // TODO(estade): on windows, parent_window may be null. But I'm not sure when
129 // that's used and how to deal with it here. For now, don't allow it. 130 // that's used and how to deal with it here. For now, don't allow it.
130 DCHECK(parent_window); 131 DCHECK(owning_window);
131 parents_.insert(parent_window); 132 parents_.insert(owning_window);
132 133
133 std::string title_string = UTF16ToUTF8(title); 134 std::string title_string = UTF16ToUTF8(title);
134 135
135 GtkWidget* dialog = NULL; 136 GtkWidget* dialog = NULL;
136 switch (type) { 137 switch (type) {
137 case SELECT_OPEN_FILE: 138 case SELECT_OPEN_FILE:
138 DCHECK(default_path.empty()); 139 DCHECK(default_path.empty());
139 dialog = CreateFileOpenDialog(title_string, parent_window); 140 dialog = CreateFileOpenDialog(title_string, owning_window);
140 break; 141 break;
141 case SELECT_OPEN_MULTI_FILE: 142 case SELECT_OPEN_MULTI_FILE:
142 DCHECK(default_path.empty()); 143 DCHECK(default_path.empty());
143 dialog = CreateMultiFileOpenDialog(title_string, parent_window); 144 dialog = CreateMultiFileOpenDialog(title_string, owning_window);
144 break; 145 break;
145 case SELECT_SAVEAS_FILE: 146 case SELECT_SAVEAS_FILE:
146 dialog = CreateSaveAsDialog(title_string, default_path, parent_window); 147 dialog = CreateSaveAsDialog(title_string, default_path, owning_window);
147 break; 148 break;
148 default: 149 default:
149 NOTIMPLEMENTED() << "Dialog type " << type << " not implemented."; 150 NOTIMPLEMENTED() << "Dialog type " << type << " not implemented.";
150 return; 151 return;
151 } 152 }
152 153
153 params_map_[dialog] = params; 154 params_map_[dialog] = params;
154 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); 155 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
155 gtk_widget_show_all(dialog); 156 gtk_widget_show_all(dialog);
156 } 157 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); 283 GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
283 std::vector<FilePath> filenames_fp; 284 std::vector<FilePath> filenames_fp;
284 for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) { 285 for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) {
285 filenames_fp.push_back(FilePath(static_cast<char*>(iter->data))); 286 filenames_fp.push_back(FilePath(static_cast<char*>(iter->data)));
286 g_free(iter->data); 287 g_free(iter->data);
287 } 288 }
288 289
289 g_slist_free(filenames); 290 g_slist_free(filenames);
290 dialog_impl->MultiFilesSelected(dialog, filenames_fp); 291 dialog_impl->MultiFilesSelected(dialog, filenames_fp);
291 } 292 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_package.cc ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698