summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/tab_contents_container_gtk.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk/tab_contents_container_gtk.cc')
-rw-r--r--chrome/browser/gtk/tab_contents_container_gtk.cc31
1 files changed, 28 insertions, 3 deletions
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);
+ }
+}