OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" | 5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 | 12 |
13 #include <map> | 13 #include <map> |
| 14 #include <memory> |
14 #include <set> | 15 #include <set> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 // Xlib defines RootWindow | 18 // Xlib defines RootWindow |
18 #undef RootWindow | 19 #undef RootWindow |
19 | 20 |
20 #include "base/logging.h" | 21 #include "base/logging.h" |
21 #include "base/memory/scoped_ptr.h" | |
22 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/sys_string_conversions.h" | 24 #include "base/strings/sys_string_conversions.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
27 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
28 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | 28 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
29 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 29 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
30 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" | 30 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" |
31 #include "ui/aura/window_observer.h" | 31 #include "ui/aura/window_observer.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { | 179 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { |
180 for (size_t i = 0; i < file_types_.extensions.size(); ++i) { | 180 for (size_t i = 0; i < file_types_.extensions.size(); ++i) { |
181 GtkFileFilter* filter = NULL; | 181 GtkFileFilter* filter = NULL; |
182 std::set<std::string> fallback_labels; | 182 std::set<std::string> fallback_labels; |
183 | 183 |
184 for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) { | 184 for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) { |
185 const std::string& current_extension = file_types_.extensions[i][j]; | 185 const std::string& current_extension = file_types_.extensions[i][j]; |
186 if (!current_extension.empty()) { | 186 if (!current_extension.empty()) { |
187 if (!filter) | 187 if (!filter) |
188 filter = gtk_file_filter_new(); | 188 filter = gtk_file_filter_new(); |
189 scoped_ptr<std::string> file_extension( | 189 std::unique_ptr<std::string> file_extension( |
190 new std::string("." + current_extension)); | 190 new std::string("." + current_extension)); |
191 fallback_labels.insert(std::string("*").append(*file_extension)); | 191 fallback_labels.insert(std::string("*").append(*file_extension)); |
192 gtk_file_filter_add_custom( | 192 gtk_file_filter_add_custom( |
193 filter, | 193 filter, |
194 GTK_FILE_FILTER_FILENAME, | 194 GTK_FILE_FILTER_FILENAME, |
195 reinterpret_cast<GtkFileFilterFunc>(FileFilterCaseInsensitive), | 195 reinterpret_cast<GtkFileFilterFunc>(FileFilterCaseInsensitive), |
196 file_extension.release(), | 196 file_extension.release(), |
197 reinterpret_cast<GDestroyNotify>(OnFileFilterDataDestroyed)); | 197 reinterpret_cast<GDestroyNotify>(OnFileFilterDataDestroyed)); |
198 } | 198 } |
199 } | 199 } |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 g_free(filename); | 541 g_free(filename); |
542 if (pixbuf) { | 542 if (pixbuf) { |
543 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 543 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
544 g_object_unref(pixbuf); | 544 g_object_unref(pixbuf); |
545 } | 545 } |
546 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 546 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
547 pixbuf ? TRUE : FALSE); | 547 pixbuf ? TRUE : FALSE); |
548 } | 548 } |
549 | 549 |
550 } // namespace libgtk2ui | 550 } // namespace libgtk2ui |
OLD | NEW |