diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 21:33:42 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 21:33:42 +0000 |
commit | 4ea809e23e15b81ac87933b600d330b5ea908a2e (patch) | |
tree | d4847f589630c1c14d7aac4c292421839eb01cbc /chrome/browser | |
parent | 13895daf8c9a82ae677d4294b27c472856f592c2 (diff) | |
download | chromium_src-4ea809e23e15b81ac87933b600d330b5ea908a2e.zip chromium_src-4ea809e23e15b81ac87933b600d330b5ea908a2e.tar.gz chromium_src-4ea809e23e15b81ac87933b600d330b5ea908a2e.tar.bz2 |
Make GTK file dialog box modal for parent window, instead of for the entire
application.
This works by adding the GtkWindow in BrowserWindowGtk to its own
GtkWindowGroup and adding the SelectFile dialog to the same group. The
following call to gtk_grab_add(...) makes the SelectFile dialog modal, but
only to the windows within the same group.
Similarly, the bookmark manager window is also added to its own unique
GtkWindowGroup, so the import/export dialogs behave correctly.
If I'm understanding things correctly, the GtkWindowGroup objects are
reference counted once the have windows attached to them, and will delete
themselves after all references to them are destroyed. I'm not sure how to
verify this.
Test:
- Open two new chrome window: A and B
- Open "Save file as..." dialog in window A
- Verify that window A does not respond to keyboard or mouse events.
- Verify that window B does responde to keyboard and mouse events.
- Open "Save file as..." dialog in window B
- Verify that window B does not respond to keyboard or mouse events.
- Cancel dialog on window A.
- Verify that window A starts responding to keyboard and mouse events.
- Cancel dialog on window B.
- Verify that window B starts responding to keyboard and mouse events.
BUG=8727
patch by Mohit Muthanna <mmuthanna@google.com>
original review URL: http://codereview.chromium.org/149548
Review URL: http://codereview.chromium.org/155518
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/dialogs_gtk.cc | 14 |
3 files changed, 18 insertions, 6 deletions
diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index dab3508..e1c43ae 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -328,6 +328,11 @@ void BookmarkManagerGtk::InitWidgets() { gtk_window_set_title(GTK_WINDOW(window_), l10n_util::GetStringUTF8(IDS_BOOKMARK_MANAGER_TITLE).c_str()); + // Add this window to its own unique window group to allow for + // window-to-parent modality. + gtk_window_group_add_window(gtk_window_group_new(), GTK_WINDOW(window_)); + g_object_unref(gtk_window_get_group(GTK_WINDOW(window_))); + // Set the default size of the bookmark manager. int width, height; gtk_util::GetWidgetSizeFromResources(window_, diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index de819b0..e716d79 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -385,6 +385,11 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser) gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK); + // Add this window to its own unique window group to allow for + // window-to-parent modality. + gtk_window_group_add_window(gtk_window_group_new(), window_); + g_object_unref(gtk_window_get_group(window_)); + SetWindowIcon(); SetBackgroundColor(); SetGeometryHints(); diff --git a/chrome/browser/gtk/dialogs_gtk.cc b/chrome/browser/gtk/dialogs_gtk.cc index 62de9ce6..3a32526 100644 --- a/chrome/browser/gtk/dialogs_gtk.cc +++ b/chrome/browser/gtk/dialogs_gtk.cc @@ -27,11 +27,7 @@ static const int kPreviewHeight = 512; // Implementation of SelectFileDialog that shows a Gtk common dialog for // choosing a file or folder. -// This acts as a modal dialog. Ideally we want to only act modally for the -// parent window and allow other toplevel chrome windows to still function while -// the dialog is showing, but we need the GtkWindowGroup or something similar to -// get that, and that API is only available in more recent versions of GTK. -// TODO(port): fix modality: crbug.com/8727 +// This acts as a modal dialog. class SelectFileDialogImpl : public SelectFileDialog { public: explicit SelectFileDialogImpl(Listener* listener); @@ -208,7 +204,13 @@ void SelectFileDialogImpl::SelectFile( gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); params_map_[dialog] = params; - gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); + + // Set window-to-parent modality by adding the dialog to the same window + // group as the parent, and calling gtk_grab_add(...) + gtk_window_group_add_window(gtk_window_get_group(owning_window), + GTK_WINDOW(dialog)); + gtk_grab_add(dialog); + gtk_widget_show_all(dialog); } |