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 <gdk/gdkx.h> | |
7 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
8 #include <stddef.h> | 9 #include <stddef.h> |
9 #include <sys/stat.h> | 10 #include <sys/stat.h> |
10 #include <sys/types.h> | 11 #include <sys/types.h> |
11 #include <unistd.h> | 12 #include <unistd.h> |
12 | 13 |
13 #include <map> | 14 #include <map> |
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/memory/scoped_ptr.h" |
22 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
23 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
24 #include "base/strings/sys_string_conversions.h" | 25 #include "base/strings/sys_string_conversions.h" |
25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
26 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
27 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
28 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | 29 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
29 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 30 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
30 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" | 31 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" |
31 #include "ui/aura/window_observer.h" | 32 #include "ui/aura/window_observer.h" |
32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/shell_dialogs/select_file_dialog.h" | 34 #include "ui/shell_dialogs/select_file_dialog.h" |
34 #include "ui/strings/grit/ui_strings.h" | 35 #include "ui/strings/grit/ui_strings.h" |
36 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | |
35 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 37 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
36 | 38 |
37 namespace { | 39 namespace { |
38 | 40 |
39 // Makes sure that .jpg also shows .JPG. | 41 // Makes sure that .jpg also shows .JPG. |
40 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, | 42 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, |
41 std::string* file_extension) { | 43 std::string* file_extension) { |
42 return base::EndsWith(file_info->filename, *file_extension, | 44 return base::EndsWith(file_info->filename, *file_extension, |
43 base::CompareCase::INSENSITIVE_ASCII); | 45 base::CompareCase::INSENSITIVE_ASCII); |
44 } | 46 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 | 159 |
158 preview_ = gtk_image_new(); | 160 preview_ = gtk_image_new(); |
159 g_signal_connect(dialog, "destroy", | 161 g_signal_connect(dialog, "destroy", |
160 G_CALLBACK(OnFileChooserDestroyThunk), this); | 162 G_CALLBACK(OnFileChooserDestroyThunk), this); |
161 g_signal_connect(dialog, "update-preview", | 163 g_signal_connect(dialog, "update-preview", |
162 G_CALLBACK(OnUpdatePreviewThunk), this); | 164 G_CALLBACK(OnUpdatePreviewThunk), this); |
163 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); | 165 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); |
164 | 166 |
165 params_map_[dialog] = params; | 167 params_map_[dialog] = params; |
166 | 168 |
167 // TODO(erg): Figure out how to fake GTK window-to-parent modality without | 169 // Disable input events handling in the host window to make this dialog modal. |
168 // having the parent be a real GtkWindow. | 170 views::DesktopWindowTreeHostX11* host = |
169 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | 171 views::DesktopWindowTreeHostX11::GetHostForXID( |
172 owning_window->GetHost()->GetAcceleratedWidget()); | |
173 scoped_ptr<views::ScopedHandle> scope_handle = | |
174 host->DisableEventListening( | |
175 GDK_WINDOW_XID(gtk_widget_get_window(dialog))); | |
176 g_object_set_data(G_OBJECT(dialog), "scope_handle", scope_handle.get()); | |
joone
2016/03/02 23:40:28
g_object_set_data can't retain the scoped_handle s
sadrul
2016/04/15 09:26:15
You would have to do scope_handle.release() there,
| |
170 | 177 |
171 gtk_widget_show_all(dialog); | 178 gtk_widget_show_all(dialog); |
172 | 179 |
173 // We need to call gtk_window_present after making the widgets visible to make | 180 // We need to call gtk_window_present after making the widgets visible to make |
174 // sure window gets correctly raised and gets focus. | 181 // sure window gets correctly raised and gets focus. |
175 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); | 182 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); |
176 gtk_window_present_with_time(GTK_WINDOW(dialog), time); | 183 gtk_window_present_with_time(GTK_WINDOW(dialog), time); |
177 } | 184 } |
178 | 185 |
179 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { | 186 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 g_free(filename); | 548 g_free(filename); |
542 if (pixbuf) { | 549 if (pixbuf) { |
543 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 550 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
544 g_object_unref(pixbuf); | 551 g_object_unref(pixbuf); |
545 } | 552 } |
546 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 553 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
547 pixbuf ? TRUE : FALSE); | 554 pixbuf ? TRUE : FALSE); |
548 } | 555 } |
549 | 556 |
550 } // namespace libgtk2ui | 557 } // namespace libgtk2ui |
OLD | NEW |