Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Side by Side Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc

Issue 1233913009: Make File-Picker modal on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove the test infrastructure and rebase on master Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/libgtk2ui/select_file_dialog_interactive_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <sys/stat.h> 9 #include <sys/stat.h>
9 #include <sys/types.h> 10 #include <sys/types.h>
10 #include <unistd.h> 11 #include <unistd.h>
11 12
12 #include <map> 13 #include <map>
13 #include <set> 14 #include <set>
14 #include <vector> 15 #include <vector>
15 16
16 // Xlib defines RootWindow 17 // Xlib defines RootWindow
17 #undef RootWindow 18 #undef RootWindow
18 19
19 #include "base/logging.h" 20 #include "base/logging.h"
20 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
21 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
22 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
23 #include "base/strings/sys_string_conversions.h" 24 #include "base/strings/sys_string_conversions.h"
24 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
25 #include "base/threading/thread.h" 26 #include "base/threading/thread.h"
26 #include "base/threading/thread_restrictions.h" 27 #include "base/threading/thread_restrictions.h"
27 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" 28 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
28 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 29 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
29 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" 30 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h"
30 #include "ui/aura/window_observer.h" 31 #include "ui/aura/window_observer.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/shell_dialogs/select_file_dialog.h" 33 #include "ui/shell_dialogs/select_file_dialog.h"
33 #include "ui/strings/grit/ui_strings.h" 34 #include "ui/strings/grit/ui_strings.h"
35 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
34 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" 36 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
35 37
36 namespace { 38 namespace {
37 39
38 // Makes sure that .jpg also shows .JPG. 40 // Makes sure that .jpg also shows .JPG.
39 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, 41 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
40 std::string* file_extension) { 42 std::string* file_extension) {
41 return base::EndsWith(file_info->filename, *file_extension, 43 return base::EndsWith(file_info->filename, *file_extension,
42 base::CompareCase::INSENSITIVE_ASCII); 44 base::CompareCase::INSENSITIVE_ASCII);
43 } 45 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 158
157 preview_ = gtk_image_new(); 159 preview_ = gtk_image_new();
158 g_signal_connect(dialog, "destroy", 160 g_signal_connect(dialog, "destroy",
159 G_CALLBACK(OnFileChooserDestroyThunk), this); 161 G_CALLBACK(OnFileChooserDestroyThunk), this);
160 g_signal_connect(dialog, "update-preview", 162 g_signal_connect(dialog, "update-preview",
161 G_CALLBACK(OnUpdatePreviewThunk), this); 163 G_CALLBACK(OnUpdatePreviewThunk), this);
162 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); 164 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_);
163 165
164 params_map_[dialog] = params; 166 params_map_[dialog] = params;
165 167
166 // TODO(erg): Figure out how to fake GTK window-to-parent modality without 168 // Disable input events handling in the host window to make this dialog modal.
167 // having the parent be a real GtkWindow. 169 views::DesktopWindowTreeHostX11* host =
168 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); 170 views::DesktopWindowTreeHostX11::GetHostForXID(
171 owning_window->GetHost()->GetAcceleratedWidget());
172 host->DisableEventListening(GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
169 173
170 gtk_widget_show_all(dialog); 174 gtk_widget_show_all(dialog);
171 175
172 // We need to call gtk_window_present after making the widgets visible to make 176 // We need to call gtk_window_present after making the widgets visible to make
173 // sure window gets correctly raised and gets focus. 177 // sure window gets correctly raised and gets focus.
174 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); 178 int time = views::X11DesktopHandler::get()->wm_user_time_ms();
175 gtk_window_present_with_time(GTK_WINDOW(dialog), time); 179 gtk_window_present_with_time(GTK_WINDOW(dialog), time);
176 } 180 }
177 181
178 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { 182 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 dialogs_.erase(dialog); 421 dialogs_.erase(dialog);
418 422
419 // Parent may be NULL in a few cases: 1) on shutdown when 423 // Parent may be NULL in a few cases: 1) on shutdown when
420 // AllBrowsersClosed() trigger this handler after all the browser 424 // AllBrowsersClosed() trigger this handler after all the browser
421 // windows got destroyed, or 2) when the parent tab has been opened by 425 // windows got destroyed, or 2) when the parent tab has been opened by
422 // 'Open Link in New Tab' context menu on a downloadable item and 426 // 'Open Link in New Tab' context menu on a downloadable item and
423 // the tab has no content (see the comment in SelectFile as well). 427 // the tab has no content (see the comment in SelectFile as well).
424 aura::Window* parent = GetAuraTransientParent(dialog); 428 aura::Window* parent = GetAuraTransientParent(dialog);
425 if (!parent) 429 if (!parent)
426 return; 430 return;
431
432 views::DesktopWindowTreeHostX11* host =
433 views::DesktopWindowTreeHostX11::GetHostForXID(
434 parent->GetHost()->GetAcceleratedWidget());
435 host->EnableEventListening();
436
427 std::set<aura::Window*>::iterator iter = parents_.find(parent); 437 std::set<aura::Window*>::iterator iter = parents_.find(parent);
428 if (iter != parents_.end()) { 438 if (iter != parents_.end()) {
429 (*iter)->RemoveObserver(this); 439 (*iter)->RemoveObserver(this);
430 parents_.erase(iter); 440 parents_.erase(iter);
431 } else { 441 } else {
432 NOTREACHED(); 442 NOTREACHED();
433 } 443 }
434 } 444 }
435 445
436 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) { 446 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 g_free(filename); 550 g_free(filename);
541 if (pixbuf) { 551 if (pixbuf) {
542 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 552 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
543 g_object_unref(pixbuf); 553 g_object_unref(pixbuf);
544 } 554 }
545 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 555 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
546 pixbuf ? TRUE : FALSE); 556 pixbuf ? TRUE : FALSE);
547 } 557 }
548 558
549 } // namespace libgtk2ui 559 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/libgtk2ui/select_file_dialog_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698