summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-24 20:05:13 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-24 20:05:13 +0000
commitba6da1fa11a1d7635e8ad5ab282734f80e2effa2 (patch)
tree25ef44da05e764cb90e995e09b75e40387ae5ce2 /chrome/common
parentfc9e60e86ec510dcf50fa27b6d5c9bf29cb7976f (diff)
downloadchromium_src-ba6da1fa11a1d7635e8ad5ab282734f80e2effa2.zip
chromium_src-ba6da1fa11a1d7635e8ad5ab282734f80e2effa2.tar.gz
chromium_src-ba6da1fa11a1d7635e8ad5ab282734f80e2effa2.tar.bz2
GTK: Add modal cookies confirmation prompt.
BUG=35178,36183 TEST=none Review URL: http://codereview.chromium.org/652172 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/gtk_util.cc76
-rw-r--r--chrome/common/gtk_util.h10
2 files changed, 85 insertions, 1 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index a1537c0..66971b5 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -14,6 +14,8 @@
#include "app/resource_bundle.h"
#include "base/linux_util.h"
#include "base/logging.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_window.h"
#include "chrome/browser/gtk/cairo_cached_surface.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/common/renderer_preferences.h"
@@ -295,6 +297,80 @@ void CenterOverWindow(GtkWindow* window, GtkWindow* parent) {
}
}
+void MakeAppModalWindowGroup() {
+#if GTK_CHECK_VERSION(2, 14, 0)
+ // Older versions of GTK+ don't give us gtk_window_group_list() which is what
+ // we need to add current non-browser modal dialogs to the list. If
+ // we have 2.14+ we can do things the correct way.
+ GtkWindowGroup* window_group = gtk_window_group_new();
+ for (BrowserList::const_iterator it = BrowserList::begin();
+ it != BrowserList::end(); ++it) {
+ // List all windows in this current group
+ GtkWindowGroup* old_group =
+ gtk_window_get_group((*it)->window()->GetNativeHandle());
+
+ GList* all_windows = gtk_window_group_list_windows(old_group);
+ for (GList* window = all_windows; window; window = window->next) {
+ gtk_window_group_add_window(window_group, GTK_WINDOW(window->data));
+ }
+ g_list_free(all_windows);
+ }
+ g_object_unref(window_group);
+#else
+ // Otherwise just grab all browser windows and be slightly broken.
+ GtkWindowGroup* window_group = gtk_window_group_new();
+ for (BrowserList::const_iterator it = BrowserList::begin();
+ it != BrowserList::end(); ++it) {
+ gtk_window_group_add_window(window_group,
+ (*it)->window()->GetNativeHandle());
+ }
+ g_object_unref(window_group);
+#endif
+}
+
+void AppModalDismissedUngroupWindows() {
+#if GTK_CHECK_VERSION(2, 14, 0)
+ if (BrowserList::begin() != BrowserList::end()) {
+ std::vector<GtkWindow*> transient_windows;
+
+ // All windows should be part of one big modal group right now.
+ GtkWindowGroup* window_group = gtk_window_get_group(
+ (*BrowserList::begin())->window()->GetNativeHandle());
+ GList* windows = gtk_window_group_list_windows(window_group);
+
+ for (GList* item = windows; item; item = item->next) {
+ GtkWindow* window = GTK_WINDOW(item->data);
+ GtkWindow* transient_for = gtk_window_get_transient_for(window);
+ if (transient_for) {
+ transient_windows.push_back(window);
+ } else {
+ GtkWindowGroup* window_group = gtk_window_group_new();
+ gtk_window_group_add_window(window_group, window);
+ g_object_unref(window_group);
+ }
+ }
+
+ // Put each transient window in the same group as its transient parent.
+ for (std::vector<GtkWindow*>::iterator it = transient_windows.begin();
+ it != transient_windows.end(); ++it) {
+ GtkWindow* transient_parent = gtk_window_get_transient_for(*it);
+ GtkWindowGroup* group = gtk_window_get_group(transient_parent);
+ gtk_window_group_add_window(group, *it);
+ }
+ }
+#else
+ // This is slightly broken in the case where a different window had a dialog,
+ // but its the best we can do since we don't have newer gtk stuff.
+ for (BrowserList::const_iterator it = BrowserList::begin();
+ it != BrowserList::end(); ++it) {
+ GtkWindowGroup* window_group = gtk_window_group_new();
+ gtk_window_group_add_window(window_group,
+ (*it)->window()->GetNativeHandle());
+ g_object_unref(window_group);
+ }
+#endif
+}
+
void RemoveAllChildren(GtkWidget* container) {
gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container);
}
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index 1caf748..40cab80 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -59,7 +59,7 @@ const int kFormControlSpacing = 10;
// be NULL to get the system default.
//
// For example:
-// controls = CreateLabeledControlsGroup(NULL, &gfx::kGdkBlack,
+// controls = CreateLabeledControlsGroup(NULL,
// "Name:", title_entry_,
// "Folder:", folder_combobox_,
// NULL);
@@ -106,6 +106,14 @@ void SetWindowSizeFromResources(GtkWindow* window,
// transient_for.
void CenterOverWindow(GtkWindow* window, GtkWindow* parent);
+// Puts all browser windows in one window group; this will make any dialog
+// spawned app modal.
+void MakeAppModalWindowGroup();
+
+// Called after an app modal dialog that used MakeAppModalWindowGroup() was
+// dismissed. Returns each browser window to its own window group.
+void AppModalDismissedUngroupWindows();
+
// Remove all children from this container.
void RemoveAllChildren(GtkWidget* container);