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

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

Issue 1243503002: Revert of Make File-Picker modal on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months 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 | ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h » ('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 <gdk/gdkx.h>
6 #include <gtk/gtk.h> 5 #include <gtk/gtk.h>
7 #include <map> 6 #include <map>
8 #include <set> 7 #include <set>
9 #include <vector> 8 #include <vector>
10 9
11 // Xlib defines RootWindow 10 // Xlib defines RootWindow
12 #undef RootWindow 11 #undef RootWindow
13 12
14 #include "base/logging.h" 13 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
17 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
18 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
19 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
20 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
21 #include "base/threading/thread_restrictions.h" 20 #include "base/threading/thread_restrictions.h"
22 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" 21 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
23 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
24 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" 23 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h"
25 #include "ui/aura/window_observer.h" 24 #include "ui/aura/window_observer.h"
26 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/shell_dialogs/select_file_dialog.h" 26 #include "ui/shell_dialogs/select_file_dialog.h"
28 #include "ui/strings/grit/ui_strings.h" 27 #include "ui/strings/grit/ui_strings.h"
29 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
30 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" 28 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
31 29
32 namespace { 30 namespace {
33 31
34 // Makes sure that .jpg also shows .JPG. 32 // Makes sure that .jpg also shows .JPG.
35 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, 33 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
36 std::string* file_extension) { 34 std::string* file_extension) {
37 return base::EndsWith(file_info->filename, *file_extension, false); 35 return base::EndsWith(file_info->filename, *file_extension, false);
38 } 36 }
39 37
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 265
268 preview_ = gtk_image_new(); 266 preview_ = gtk_image_new();
269 g_signal_connect(dialog, "destroy", 267 g_signal_connect(dialog, "destroy",
270 G_CALLBACK(OnFileChooserDestroyThunk), this); 268 G_CALLBACK(OnFileChooserDestroyThunk), this);
271 g_signal_connect(dialog, "update-preview", 269 g_signal_connect(dialog, "update-preview",
272 G_CALLBACK(OnUpdatePreviewThunk), this); 270 G_CALLBACK(OnUpdatePreviewThunk), this);
273 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); 271 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_);
274 272
275 params_map_[dialog] = params; 273 params_map_[dialog] = params;
276 274
277 // Disable input events handling in the host window to make this dialog modal. 275 // TODO(erg): Figure out how to fake GTK window-to-parent modality without
278 views::DesktopWindowTreeHostX11* host = 276 // having the parent be a real GtkWindow.
279 views::DesktopWindowTreeHostX11::GetHostForXID( 277 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
280 owning_window->GetHost()->GetAcceleratedWidget());
281 host->DisableEventListening(GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
282 278
283 gtk_widget_show_all(dialog); 279 gtk_widget_show_all(dialog);
284 280
285 // We need to call gtk_window_present after making the widgets visible to make 281 // We need to call gtk_window_present after making the widgets visible to make
286 // sure window gets correctly raised and gets focus. 282 // sure window gets correctly raised and gets focus.
287 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); 283 int time = views::X11DesktopHandler::get()->wm_user_time_ms();
288 gtk_window_present_with_time(GTK_WINDOW(dialog), time); 284 gtk_window_present_with_time(GTK_WINDOW(dialog), time);
289 } 285 }
290 286
291 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { 287 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 dialogs_.erase(dialog); 518 dialogs_.erase(dialog);
523 519
524 // Parent may be NULL in a few cases: 1) on shutdown when 520 // Parent may be NULL in a few cases: 1) on shutdown when
525 // AllBrowsersClosed() trigger this handler after all the browser 521 // AllBrowsersClosed() trigger this handler after all the browser
526 // windows got destroyed, or 2) when the parent tab has been opened by 522 // windows got destroyed, or 2) when the parent tab has been opened by
527 // 'Open Link in New Tab' context menu on a downloadable item and 523 // 'Open Link in New Tab' context menu on a downloadable item and
528 // the tab has no content (see the comment in SelectFile as well). 524 // the tab has no content (see the comment in SelectFile as well).
529 aura::Window* parent = GetAuraTransientParent(dialog); 525 aura::Window* parent = GetAuraTransientParent(dialog);
530 if (!parent) 526 if (!parent)
531 return; 527 return;
532
533 views::DesktopWindowTreeHostX11* host =
534 views::DesktopWindowTreeHostX11::GetHostForXID(
535 parent->GetHost()->GetAcceleratedWidget());
536 host->EnableEventListening();
537
538 std::set<aura::Window*>::iterator iter = parents_.find(parent); 528 std::set<aura::Window*>::iterator iter = parents_.find(parent);
539 if (iter != parents_.end()) { 529 if (iter != parents_.end()) {
540 (*iter)->RemoveObserver(this); 530 (*iter)->RemoveObserver(this);
541 parents_.erase(iter); 531 parents_.erase(iter);
542 } else { 532 } else {
543 NOTREACHED(); 533 NOTREACHED();
544 } 534 }
545 } 535 }
546 536
547 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) { 537 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 g_free(filename); 627 g_free(filename);
638 if (pixbuf) { 628 if (pixbuf) {
639 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 629 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
640 g_object_unref(pixbuf); 630 g_object_unref(pixbuf);
641 } 631 }
642 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 632 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
643 pixbuf ? TRUE : FALSE); 633 pixbuf ? TRUE : FALSE);
644 } 634 }
645 635
646 } // namespace libgtk2ui 636 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698