| 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 // Xlib defines RootWindow | 10 // Xlib defines RootWindow |
| 11 #undef RootWindow | 11 #undef RootWindow |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
| 21 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | 21 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
| 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
| 23 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" | 23 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" |
| 24 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/shell_dialogs/select_file_dialog.h" | 26 #include "ui/shell_dialogs/select_file_dialog.h" |
| 27 #include "ui/strings/grit/ui_strings.h" | 27 #include "ui/strings/grit/ui_strings.h" |
| 28 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Makes sure that .jpg also shows .JPG. | 32 // Makes sure that .jpg also shows .JPG. |
| 32 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, | 33 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, |
| 33 std::string* file_extension) { | 34 std::string* file_extension) { |
| 34 return EndsWith(file_info->filename, *file_extension, false); | 35 return EndsWith(file_info->filename, *file_extension, false); |
| 35 } | 36 } |
| 36 | 37 |
| 37 // Deletes |data| when gtk_file_filter_add_custom() is done with it. | 38 // Deletes |data| when gtk_file_filter_add_custom() is done with it. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 G_CALLBACK(OnUpdatePreviewThunk), this); | 271 G_CALLBACK(OnUpdatePreviewThunk), this); |
| 271 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); | 272 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); |
| 272 | 273 |
| 273 params_map_[dialog] = params; | 274 params_map_[dialog] = params; |
| 274 | 275 |
| 275 // TODO(erg): Figure out how to fake GTK window-to-parent modality without | 276 // TODO(erg): Figure out how to fake GTK window-to-parent modality without |
| 276 // having the parent be a real GtkWindow. | 277 // having the parent be a real GtkWindow. |
| 277 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | 278 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
| 278 | 279 |
| 279 gtk_widget_show_all(dialog); | 280 gtk_widget_show_all(dialog); |
| 281 |
| 282 // We need to call gtk_window_present after making the widgets visible to make |
| 283 // sure window gets correctly raised and gets focus. |
| 284 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); |
| 285 gtk_window_present_with_time(GTK_WINDOW(dialog), time); |
| 280 } | 286 } |
| 281 | 287 |
| 282 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { | 288 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { |
| 283 for (size_t i = 0; i < file_types_.extensions.size(); ++i) { | 289 for (size_t i = 0; i < file_types_.extensions.size(); ++i) { |
| 284 GtkFileFilter* filter = NULL; | 290 GtkFileFilter* filter = NULL; |
| 285 std::set<std::string> fallback_labels; | 291 std::set<std::string> fallback_labels; |
| 286 | 292 |
| 287 for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) { | 293 for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) { |
| 288 const std::string& current_extension = file_types_.extensions[i][j]; | 294 const std::string& current_extension = file_types_.extensions[i][j]; |
| 289 if (!current_extension.empty()) { | 295 if (!current_extension.empty()) { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 g_free(filename); | 628 g_free(filename); |
| 623 if (pixbuf) { | 629 if (pixbuf) { |
| 624 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 630 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
| 625 g_object_unref(pixbuf); | 631 g_object_unref(pixbuf); |
| 626 } | 632 } |
| 627 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 633 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
| 628 pixbuf ? TRUE : FALSE); | 634 pixbuf ? TRUE : FALSE); |
| 629 } | 635 } |
| 630 | 636 |
| 631 } // namespace libgtk2ui | 637 } // namespace libgtk2ui |
| OLD | NEW |