diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 20:36:06 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 20:36:06 +0000 |
commit | 0a963192af67150d29a5749d52b1fcf279efb7f3 (patch) | |
tree | e15e92771cf268dd4e754ee4804b4c8978def97d | |
parent | e133f95e6e64a5d9bf8bf0d1a435958efbe94cce (diff) | |
download | chromium_src-0a963192af67150d29a5749d52b1fcf279efb7f3.zip chromium_src-0a963192af67150d29a5749d52b1fcf279efb7f3.tar.gz chromium_src-0a963192af67150d29a5749d52b1fcf279efb7f3.tar.bz2 |
Adds gtk_util::ParentWindow to find the parent window of a GtkWidget.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/113919
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17019 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/gtk_util.cc | 9 | ||||
-rw-r--r-- | chrome/common/gtk_util.h | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index 01d952e..1deb58f 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -122,4 +122,13 @@ void InitRCStyles() { gtk_rc_parse_string(kRCText); } +GtkWindow* ParentWindow(GtkWidget* widget) { + while (widget) { + if (GTK_IS_WINDOW(widget)) + return GTK_WINDOW(widget); + widget = gtk_widget_get_parent(widget); + } + return NULL; +} + } // namespace gtk_util diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h index d72045b..5770030 100644 --- a/chrome/common/gtk_util.h +++ b/chrome/common/gtk_util.h @@ -44,6 +44,10 @@ gfx::Rect GetWidgetScreenBounds(GtkWidget* widget); // Initialize some GTK settings so that our dialogs are consistent. void InitRCStyles(); +// Returns the closest ancestor of |widget| which is a top level window or NULL +// if there is no such ancestor. The search starts at |widget|. +GtkWindow* ParentWindow(GtkWidget* widget); + } // namespace gtk_util #endif // CHROME_COMMON_GTK_UTIL_H_ |