summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 21:29:08 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 21:29:08 +0000
commitff281d4f40f94356c025014f321ad480a6411655 (patch)
tree48f0adc4805f14155c3d4afe7e6e7ba6f4398ec6
parentfc48db85fecb5889fbfc5de5c9b8951dce547546 (diff)
downloadchromium_src-ff281d4f40f94356c025014f321ad480a6411655.zip
chromium_src-ff281d4f40f94356c025014f321ad480a6411655.tar.gz
chromium_src-ff281d4f40f94356c025014f321ad480a6411655.tar.bz2
Linux: Make the findbar hang over the render view.
BUG=10948 Review URL: http://codereview.chromium.org/100077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14785 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc1
-rw-r--r--chrome/browser/gtk/tab_contents_container_gtk.cc31
-rw-r--r--chrome/browser/gtk/tab_contents_container_gtk.h11
3 files changed, 39 insertions, 4 deletions
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index e30da63..54bf690 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -102,7 +102,6 @@ void FindBarGtk::InitWidgets() {
GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(centering_vbox), border_bin, TRUE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, 0);
-
}
void FindBarGtk::Show() {
diff --git a/chrome/browser/gtk/tab_contents_container_gtk.cc b/chrome/browser/gtk/tab_contents_container_gtk.cc
index 086d5c0..71c2b5f 100644
--- a/chrome/browser/gtk/tab_contents_container_gtk.cc
+++ b/chrome/browser/gtk/tab_contents_container_gtk.cc
@@ -12,8 +12,14 @@
TabContentsContainerGtk::TabContentsContainerGtk()
: tab_contents_(NULL),
- vbox_(gtk_vbox_new(FALSE, 0)) {
- gtk_widget_show(vbox_);
+ vbox_(gtk_vbox_new(FALSE, 0)),
+ fixed_(gtk_fixed_new()),
+ findbar_(NULL) {
+ gtk_widget_set_size_request(fixed_, -1, 0);
+ gtk_box_pack_start(GTK_BOX(vbox_), fixed_, FALSE, FALSE, 0);
+ gtk_widget_show_all(vbox_);
+ g_signal_connect(fixed_, "size-allocate",
+ G_CALLBACK(OnSizeAllocate), this);
}
TabContentsContainerGtk::~TabContentsContainerGtk() {
@@ -26,7 +32,9 @@ void TabContentsContainerGtk::AddContainerToBox(GtkWidget* box) {
}
void TabContentsContainerGtk::AddFindBar(GtkWidget* findbar) {
- gtk_box_pack_start(GTK_BOX(vbox_), findbar, FALSE, FALSE, 0);
+ findbar_ = findbar;
+ // We will reposition it later (when we get a size-allocate event).
+ gtk_fixed_put(GTK_FIXED(fixed_), findbar, 0, 0);
}
void TabContentsContainerGtk::SetTabContents(TabContents* tab_contents) {
@@ -114,3 +122,20 @@ void TabContentsContainerGtk::TabContentsDestroyed(TabContents* contents) {
DCHECK(contents == tab_contents_);
SetTabContents(NULL);
}
+
+void TabContentsContainerGtk::OnSizeAllocate(GtkWidget* fixed,
+ GtkAllocation* allocation, TabContentsContainerGtk* contents_container) {
+ GtkWidget* findbar = contents_container->findbar_;
+ DCHECK(findbar);
+ if (!GTK_WIDGET_VISIBLE(findbar))
+ return;
+
+ // TODO(port): Logic for the positioning of the find bar should be factored
+ // out of here and browser/views/* and into FindBarController.
+ int xposition = allocation->width - findbar->allocation.width - 50;
+ if (xposition == findbar->allocation.x) {
+ return;
+ } else {
+ gtk_fixed_move(GTK_FIXED(fixed), findbar, xposition, 0);
+ }
+}
diff --git a/chrome/browser/gtk/tab_contents_container_gtk.h b/chrome/browser/gtk/tab_contents_container_gtk.h
index 6bef9a4..bb914d0 100644
--- a/chrome/browser/gtk/tab_contents_container_gtk.h
+++ b/chrome/browser/gtk/tab_contents_container_gtk.h
@@ -48,6 +48,11 @@ class TabContentsContainerGtk : public NotificationObserver {
// get notified.
void TabContentsDestroyed(TabContents* contents);
+ // Called when |fixed_| changes sizes. Used to position the findbar.
+ static void OnSizeAllocate(GtkWidget* fixed,
+ GtkAllocation* allocation,
+ TabContentsContainerGtk* contents_container);
+
// The currently visible TabContents.
TabContents* tab_contents_;
@@ -56,6 +61,12 @@ class TabContentsContainerGtk : public NotificationObserver {
// vbox_.
GtkWidget* vbox_;
+ // This GtkFixed widget helps us position the find bar.
+ GtkWidget* fixed_;
+
+ // The findbar widget. We do not own it.
+ GtkWidget* findbar_;
+
DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk);
};