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 <gdk/gdkx.h> | |
5 #include <gtk/gtk.h> | 6 #include <gtk/gtk.h> |
6 #include <map> | 7 #include <map> |
7 #include <set> | 8 #include <set> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 // Xlib defines RootWindow | 11 // Xlib defines RootWindow |
11 #undef RootWindow | 12 #undef RootWindow |
12 | 13 |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 | 266 |
266 preview_ = gtk_image_new(); | 267 preview_ = gtk_image_new(); |
267 g_signal_connect(dialog, "destroy", | 268 g_signal_connect(dialog, "destroy", |
268 G_CALLBACK(OnFileChooserDestroyThunk), this); | 269 G_CALLBACK(OnFileChooserDestroyThunk), this); |
269 g_signal_connect(dialog, "update-preview", | 270 g_signal_connect(dialog, "update-preview", |
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 // Disable input events handling in the host window to make the dialog modal. |
276 // having the parent be a real GtkWindow. | 277 views::X11DesktopHandler::get()->SetModalDialog(GDK_WINDOW_XID( |
277 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | 278 gtk_widget_get_window(dialog))); |
sadrul
2015/04/21 19:50:01
This makes it modal for all chrome windows. Should
joone
2015/04/22 19:44:33
Yes, dialog should be only modal to a particular c
| |
278 | 279 |
279 gtk_widget_show_all(dialog); | 280 gtk_widget_show_all(dialog); |
280 | 281 |
281 // We need to call gtk_window_present after making the widgets visible to make | 282 // We need to call gtk_window_present after making the widgets visible to make |
282 // sure window gets correctly raised and gets focus. | 283 // sure window gets correctly raised and gets focus. |
283 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); | 284 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); |
284 gtk_window_present_with_time(GTK_WINDOW(dialog), time); | 285 gtk_window_present_with_time(GTK_WINDOW(dialog), time); |
285 } | 286 } |
286 | 287 |
287 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { | 288 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 dialogs_.erase(dialog); | 519 dialogs_.erase(dialog); |
519 | 520 |
520 // Parent may be NULL in a few cases: 1) on shutdown when | 521 // Parent may be NULL in a few cases: 1) on shutdown when |
521 // AllBrowsersClosed() trigger this handler after all the browser | 522 // AllBrowsersClosed() trigger this handler after all the browser |
522 // windows got destroyed, or 2) when the parent tab has been opened by | 523 // windows got destroyed, or 2) when the parent tab has been opened by |
523 // 'Open Link in New Tab' context menu on a downloadable item and | 524 // 'Open Link in New Tab' context menu on a downloadable item and |
524 // the tab has no content (see the comment in SelectFile as well). | 525 // the tab has no content (see the comment in SelectFile as well). |
525 aura::Window* parent = GetAuraTransientParent(dialog); | 526 aura::Window* parent = GetAuraTransientParent(dialog); |
526 if (!parent) | 527 if (!parent) |
527 return; | 528 return; |
529 | |
530 views::X11DesktopHandler::get()->SetModalDialog(None); | |
528 std::set<aura::Window*>::iterator iter = parents_.find(parent); | 531 std::set<aura::Window*>::iterator iter = parents_.find(parent); |
529 if (iter != parents_.end()) { | 532 if (iter != parents_.end()) { |
530 (*iter)->RemoveObserver(this); | 533 (*iter)->RemoveObserver(this); |
531 parents_.erase(iter); | 534 parents_.erase(iter); |
532 } else { | 535 } else { |
533 NOTREACHED(); | 536 NOTREACHED(); |
534 } | 537 } |
535 } | 538 } |
536 | 539 |
537 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) { | 540 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 g_free(filename); | 630 g_free(filename); |
628 if (pixbuf) { | 631 if (pixbuf) { |
629 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 632 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
630 g_object_unref(pixbuf); | 633 g_object_unref(pixbuf); |
631 } | 634 } |
632 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 635 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
633 pixbuf ? TRUE : FALSE); | 636 pixbuf ? TRUE : FALSE); |
634 } | 637 } |
635 | 638 |
636 } // namespace libgtk2ui | 639 } // namespace libgtk2ui |
OLD | NEW |