| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/gtk/tab_contents_container_gtk.h" | 5 #include "chrome/browser/gtk/tab_contents_container_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/gfx/native_widget_types.h" | 8 #include "base/gfx/native_widget_types.h" |
| 9 #include "chrome/browser/gtk/gtk_floating_container.h" | 9 #include "chrome/browser/gtk/gtk_floating_container.h" |
| 10 #include "chrome/browser/gtk/status_bubble_gtk.h" | 10 #include "chrome/browser/gtk/status_bubble_gtk.h" |
| 11 #include "chrome/browser/gtk/view_id_util.h" | |
| 12 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 13 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 12 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
| 14 #include "chrome/common/notification_service.h" | 13 #include "chrome/common/notification_service.h" |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 // Allocates all normal tab contents views to the size of the passed in | 17 // Allocates all normal tab contents views to the size of the passed in |
| 19 // |allocation|. | 18 // |allocation|. |
| 20 void ResizeChildren(GtkWidget* widget, void* param) { | 19 void ResizeChildren(GtkWidget* widget, void* param) { |
| 21 GtkAllocation* allocation = reinterpret_cast<GtkAllocation*>(param); | 20 GtkAllocation* allocation = reinterpret_cast<GtkAllocation*>(param); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (status_bubble_) { | 62 if (status_bubble_) { |
| 64 gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()), | 63 gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()), |
| 65 status_bubble_->widget()); | 64 status_bubble_->widget()); |
| 66 g_signal_connect(floating_.get(), "set-floating-position", | 65 g_signal_connect(floating_.get(), "set-floating-position", |
| 67 G_CALLBACK(OnSetFloatingPosition), this); | 66 G_CALLBACK(OnSetFloatingPosition), this); |
| 68 } | 67 } |
| 69 | 68 |
| 70 gtk_widget_show(fixed_); | 69 gtk_widget_show(fixed_); |
| 71 gtk_widget_show(floating_.get()); | 70 gtk_widget_show(floating_.get()); |
| 72 | 71 |
| 73 ViewIDUtil::SetID(widget(), VIEW_ID_TAB_CONTAINER); | 72 ViewIDUtil::SetDelegateForWidget(widget(), this); |
| 74 } | 73 } |
| 75 | 74 |
| 76 void TabContentsContainerGtk::SetTabContents(TabContents* tab_contents) { | 75 void TabContentsContainerGtk::SetTabContents(TabContents* tab_contents) { |
| 77 if (tab_contents_) { | 76 if (tab_contents_) { |
| 78 gfx::NativeView widget = tab_contents_->GetNativeView(); | 77 gfx::NativeView widget = tab_contents_->GetNativeView(); |
| 79 if (widget) | 78 if (widget) |
| 80 gtk_widget_hide(widget); | 79 gtk_widget_hide(widget); |
| 81 | 80 |
| 82 tab_contents_->WasHidden(); | 81 tab_contents_->WasHidden(); |
| 83 | 82 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // issues, and I'm not entirely convinced that this isn't necessary. | 151 // issues, and I'm not entirely convinced that this isn't necessary. |
| 153 } | 152 } |
| 154 | 153 |
| 155 void TabContentsContainerGtk::TabContentsDestroyed(TabContents* contents) { | 154 void TabContentsContainerGtk::TabContentsDestroyed(TabContents* contents) { |
| 156 // Sometimes, a TabContents is destroyed before we know about it. This allows | 155 // Sometimes, a TabContents is destroyed before we know about it. This allows |
| 157 // us to clean up our state in case this happens. | 156 // us to clean up our state in case this happens. |
| 158 DCHECK(contents == tab_contents_); | 157 DCHECK(contents == tab_contents_); |
| 159 SetTabContents(NULL); | 158 SetTabContents(NULL); |
| 160 } | 159 } |
| 161 | 160 |
| 161 // ----------------------------------------------------------------------------- |
| 162 // ViewIDUtil::Delegate implementation |
| 163 |
| 164 GtkWidget* TabContentsContainerGtk::GetWidgetForViewID(ViewID view_id) { |
| 165 if (view_id == VIEW_ID_TAB_CONTAINER || |
| 166 view_id == VIEW_ID_TAB_CONTAINER_FOCUS_VIEW) { |
| 167 return widget(); |
| 168 } |
| 169 |
| 170 return NULL; |
| 171 } |
| 172 |
| 173 // ----------------------------------------------------------------------------- |
| 174 |
| 162 // static | 175 // static |
| 163 void TabContentsContainerGtk::OnFixedSizeAllocate( | 176 void TabContentsContainerGtk::OnFixedSizeAllocate( |
| 164 GtkWidget* fixed, | 177 GtkWidget* fixed, |
| 165 GtkAllocation* allocation, | 178 GtkAllocation* allocation, |
| 166 TabContentsContainerGtk* container) { | 179 TabContentsContainerGtk* container) { |
| 167 // Set all the tab contents GtkWidgets to the size of the allocation. | 180 // Set all the tab contents GtkWidgets to the size of the allocation. |
| 168 gtk_container_foreach(GTK_CONTAINER(fixed), ResizeChildren, allocation); | 181 gtk_container_foreach(GTK_CONTAINER(fixed), ResizeChildren, allocation); |
| 169 } | 182 } |
| 170 | 183 |
| 171 // static | 184 // static |
| (...skipping 16 matching lines...) Expand all Loading... |
| 188 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 201 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 189 status, "x", &value); | 202 status, "x", &value); |
| 190 | 203 |
| 191 int child_y = std::max( | 204 int child_y = std::max( |
| 192 allocation->y + allocation->height - requisition.height, 0); | 205 allocation->y + allocation->height - requisition.height, 0); |
| 193 g_value_set_int(&value, child_y); | 206 g_value_set_int(&value, child_y); |
| 194 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 207 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 195 status, "y", &value); | 208 status, "y", &value); |
| 196 g_value_unset(&value); | 209 g_value_unset(&value); |
| 197 } | 210 } |
| OLD | NEW |