summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 18:58:54 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 18:58:54 +0000
commitd8e7a54e37ed11d60f7d8dd8f5d5732cffe94b95 (patch)
tree8912ce2d6acc77fda0119d872283268390eeef15 /chrome/common
parent13044cdc2b1e8fb304af65a7913c083f52c623bc (diff)
downloadchromium_src-d8e7a54e37ed11d60f7d8dd8f5d5732cffe94b95.zip
chromium_src-d8e7a54e37ed11d60f7d8dd8f5d5732cffe94b95.tar.gz
chromium_src-d8e7a54e37ed11d60f7d8dd8f5d5732cffe94b95.tar.bz2
GTK: Implements the content settings window and the minor changes to the options dialog.
The "Exceptions" dialogs are still not implemented; they're the next step but this changelist is already getting pretty huge. BUG=35178 TEST=none Review URL: http://codereview.chromium.org/602005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/gtk_util.cc42
-rw-r--r--chrome/common/gtk_util.h6
2 files changed, 48 insertions, 0 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index c175330..7972edb 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/gtk/cairo_cached_surface.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/common/renderer_preferences.h"
+#include "chrome/common/x11_util.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -237,6 +238,47 @@ void SetWindowSizeFromResources(GtkWindow* window,
gtk_window_set_resizable(window, resizable ? TRUE : FALSE);
}
+void CenterOverWindow(GtkWindow* window, GtkWindow* parent) {
+ gfx::Rect frame_bounds = gtk_util::GetWidgetScreenBounds(GTK_WIDGET(parent));
+ gfx::Point origin = frame_bounds.origin();
+ gfx::Size size = gtk_util::GetWidgetSize(GTK_WIDGET(window));
+ origin.Offset(
+ (frame_bounds.width() - size.width()) / 2,
+ (frame_bounds.height() - size.height()) / 2);
+
+ // Prevent moving window out of monitor bounds.
+ GdkScreen* screen = gtk_window_get_screen(parent);
+ if (screen) {
+ // It would be better to check against workarea for given monitor
+ // but getting workarea for particular monitor is tricky.
+ gint monitor = gdk_screen_get_monitor_at_window(screen,
+ GTK_WIDGET(parent)->window);
+ GdkRectangle rect;
+ gdk_screen_get_monitor_geometry(screen, monitor, &rect);
+
+ // Check the right bottom corner.
+ if (origin.x() > rect.x + rect.width - size.width())
+ origin.set_x(rect.x + rect.width - size.width());
+ if (origin.y() > rect.y + rect.height - size.height())
+ origin.set_y(rect.y + rect.height - size.height());
+
+ // Check the left top corner.
+ if (origin.x() < rect.x)
+ origin.set_x(rect.x);
+ if (origin.y() < rect.y)
+ origin.set_y(rect.y);
+ }
+
+ gtk_window_move(window, origin.x(), origin.y());
+
+ // Move to user expected desktop if window is already visible.
+ if (GTK_WIDGET(window)->window) {
+ x11_util::ChangeWindowDesktop(
+ x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(window)),
+ x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(parent)));
+ }
+}
+
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 f1bc1b6..93533fd 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -94,6 +94,12 @@ void GetWidgetSizeFromCharacters(GtkWidget* widget, double width_chars,
void SetWindowSizeFromResources(GtkWindow* window,
int width_id, int height_id, bool resizable);
+// Places |window| approximately over center of |parent|, it also moves window
+// to parent's desktop. Use this only for non-modal dialogs, such as the
+// options window and content settings window; otherwise you should be using
+// transient_for.
+void CenterOverWindow(GtkWindow* window, GtkWindow* parent);
+
// Remove all children from this container.
void RemoveAllChildren(GtkWidget* container);