| OLD | NEW |
| 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 15 matching lines...) Expand all Loading... |
| 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 std::wstring& title, | 33 virtual void SelectFile(Type type, const std::wstring& title, |
| 34 const std::wstring& default_path, | 34 const std::wstring& default_path, |
| 35 const std::wstring& filter, | 35 const std::wstring& filter, |
| 36 int filter_index, |
| 36 const std::wstring& default_extension, | 37 const std::wstring& default_extension, |
| 37 gfx::NativeWindow parent_window, | 38 gfx::NativeWindow parent_window, |
| 38 void* params); | 39 void* params); |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 // Notifies the listener that a single file was chosen. | 42 // Notifies the listener that a single file was chosen. |
| 42 void FileSelected(GtkWidget* dialog, const FilePath& path); | 43 void FileSelected(GtkWidget* dialog, const FilePath& path); |
| 43 | 44 |
| 44 // Notifies the listener that multiple files were chosen. | 45 // Notifies the listener that multiple files were chosen. |
| 45 // TODO(estade): this should deal in FilePaths. | 46 // TODO(estade): this should deal in FilePaths. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 listener_ = NULL; | 115 listener_ = NULL; |
| 115 } | 116 } |
| 116 | 117 |
| 117 // We ignore |filter| and |default_extension|. | 118 // We ignore |filter| and |default_extension|. |
| 118 // TODO(estade): use |filter|. | 119 // TODO(estade): use |filter|. |
| 119 void SelectFileDialogImpl::SelectFile( | 120 void SelectFileDialogImpl::SelectFile( |
| 120 Type type, | 121 Type type, |
| 121 const std::wstring& title, | 122 const std::wstring& title, |
| 122 const std::wstring& default_path, | 123 const std::wstring& default_path, |
| 123 const std::wstring& filter, | 124 const std::wstring& filter, |
| 125 int filter_index, |
| 124 const std::wstring& default_extension, | 126 const std::wstring& default_extension, |
| 125 gfx::NativeWindow parent_window, | 127 gfx::NativeWindow parent_window, |
| 126 void* params) { | 128 void* params) { |
| 127 // 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 |
| 128 // 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. |
| 129 DCHECK(parent_window); | 131 DCHECK(parent_window); |
| 130 parents_.insert(parent_window); | 132 parents_.insert(parent_window); |
| 131 | 133 |
| 132 // TODO(port): get rid of these conversions when the parameter types are | 134 // TODO(port): get rid of these conversions when the parameter types are |
| 133 // ported. | 135 // ported. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 155 | 157 |
| 156 params_map_[dialog] = params; | 158 params_map_[dialog] = params; |
| 157 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | 159 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
| 158 gtk_widget_show_all(dialog); | 160 gtk_widget_show_all(dialog); |
| 159 } | 161 } |
| 160 | 162 |
| 161 void SelectFileDialogImpl::FileSelected(GtkWidget* dialog, | 163 void SelectFileDialogImpl::FileSelected(GtkWidget* dialog, |
| 162 const FilePath& path) { | 164 const FilePath& path) { |
| 163 void* params = PopParamsForDialog(dialog); | 165 void* params = PopParamsForDialog(dialog); |
| 164 if (listener_) | 166 if (listener_) |
| 165 listener_->FileSelected(path.ToWStringHack(), params); | 167 listener_->FileSelected(path.ToWStringHack(), 0, params); |
| 166 RemoveParentForDialog(dialog); | 168 RemoveParentForDialog(dialog); |
| 167 gtk_widget_destroy(dialog); | 169 gtk_widget_destroy(dialog); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void SelectFileDialogImpl::MultiFilesSelected(GtkWidget* dialog, | 172 void SelectFileDialogImpl::MultiFilesSelected(GtkWidget* dialog, |
| 171 const std::vector<std::wstring>& files) { | 173 const std::vector<std::wstring>& files) { |
| 172 void* params = PopParamsForDialog(dialog); | 174 void* params = PopParamsForDialog(dialog); |
| 173 if (listener_) | 175 if (listener_) |
| 174 listener_->MultiFilesSelected(files, params); | 176 listener_->MultiFilesSelected(files, params); |
| 175 RemoveParentForDialog(dialog); | 177 RemoveParentForDialog(dialog); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 std::vector<std::wstring> filenames_w; | 288 std::vector<std::wstring> filenames_w; |
| 287 for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) { | 289 for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) { |
| 288 filenames_w.push_back(base::SysNativeMBToWide( | 290 filenames_w.push_back(base::SysNativeMBToWide( |
| 289 static_cast<char*>(iter->data))); | 291 static_cast<char*>(iter->data))); |
| 290 g_free(iter->data); | 292 g_free(iter->data); |
| 291 } | 293 } |
| 292 | 294 |
| 293 g_slist_free(filenames); | 295 g_slist_free(filenames); |
| 294 dialog_impl->MultiFilesSelected(dialog, filenames_w); | 296 dialog_impl->MultiFilesSelected(dialog, filenames_w); |
| 295 } | 297 } |
| OLD | NEW |