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> |
(...skipping 14 matching lines...) Expand all Loading... |
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" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/shell_dialogs/select_file_dialog.h" | 33 #include "ui/shell_dialogs/select_file_dialog.h" |
34 #include "ui/strings/grit/ui_strings.h" | 34 #include "ui/strings/grit/ui_strings.h" |
35 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | |
36 | 35 |
37 namespace { | 36 namespace { |
38 | 37 |
39 // Makes sure that .jpg also shows .JPG. | 38 // Makes sure that .jpg also shows .JPG. |
40 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, | 39 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, |
41 std::string* file_extension) { | 40 std::string* file_extension) { |
42 return base::EndsWith(file_info->filename, *file_extension, | 41 return base::EndsWith(file_info->filename, *file_extension, |
43 base::CompareCase::INSENSITIVE_ASCII); | 42 base::CompareCase::INSENSITIVE_ASCII); |
44 } | 43 } |
45 | 44 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 params_map_[dialog] = params; | 161 params_map_[dialog] = params; |
163 | 162 |
164 // TODO(erg): Figure out how to fake GTK window-to-parent modality without | 163 // TODO(erg): Figure out how to fake GTK window-to-parent modality without |
165 // having the parent be a real GtkWindow. | 164 // having the parent be a real GtkWindow. |
166 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | 165 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
167 | 166 |
168 gtk_widget_show_all(dialog); | 167 gtk_widget_show_all(dialog); |
169 | 168 |
170 // We need to call gtk_window_present after making the widgets visible to make | 169 // We need to call gtk_window_present after making the widgets visible to make |
171 // sure window gets correctly raised and gets focus. | 170 // sure window gets correctly raised and gets focus. |
172 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); | 171 gtk_window_present(GTK_WINDOW(dialog)); |
173 gtk_window_present_with_time(GTK_WINDOW(dialog), time); | |
174 } | 172 } |
175 | 173 |
176 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { | 174 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { |
177 for (size_t i = 0; i < file_types_.extensions.size(); ++i) { | 175 for (size_t i = 0; i < file_types_.extensions.size(); ++i) { |
178 GtkFileFilter* filter = NULL; | 176 GtkFileFilter* filter = NULL; |
179 std::set<std::string> fallback_labels; | 177 std::set<std::string> fallback_labels; |
180 | 178 |
181 for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) { | 179 for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) { |
182 const std::string& current_extension = file_types_.extensions[i][j]; | 180 const std::string& current_extension = file_types_.extensions[i][j]; |
183 if (!current_extension.empty()) { | 181 if (!current_extension.empty()) { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 g_free(filename); | 529 g_free(filename); |
532 if (pixbuf) { | 530 if (pixbuf) { |
533 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 531 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
534 g_object_unref(pixbuf); | 532 g_object_unref(pixbuf); |
535 } | 533 } |
536 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 534 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
537 pixbuf ? TRUE : FALSE); | 535 pixbuf ? TRUE : FALSE); |
538 } | 536 } |
539 | 537 |
540 } // namespace libgtk2ui | 538 } // namespace libgtk2ui |
OLD | NEW |