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 <algorithm> |
| 8 |
7 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
8 #include "chrome/browser/gtk/gtk_expanded_container.h" | 10 #include "chrome/browser/gtk/gtk_expanded_container.h" |
9 #include "chrome/browser/gtk/gtk_floating_container.h" | 11 #include "chrome/browser/gtk/gtk_floating_container.h" |
10 #include "chrome/browser/gtk/status_bubble_gtk.h" | 12 #include "chrome/browser/gtk/status_bubble_gtk.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
12 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 14 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
13 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_source.h" |
14 #include "gfx/native_widget_types.h" | 16 #include "gfx/native_widget_types.h" |
15 | 17 |
16 TabContentsContainerGtk::TabContentsContainerGtk(StatusBubbleGtk* status_bubble) | 18 TabContentsContainerGtk::TabContentsContainerGtk(StatusBubbleGtk* status_bubble) |
17 : tab_contents_(NULL), | 19 : tab_contents_(NULL), |
18 preview_contents_(NULL), | 20 preview_contents_(NULL), |
19 status_bubble_(status_bubble) { | 21 status_bubble_(status_bubble) { |
20 Init(); | 22 Init(); |
21 } | 23 } |
22 | 24 |
23 TabContentsContainerGtk::~TabContentsContainerGtk() { | 25 TabContentsContainerGtk::~TabContentsContainerGtk() { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 147 |
146 void TabContentsContainerGtk::HideTabContents(TabContents* contents) { | 148 void TabContentsContainerGtk::HideTabContents(TabContents* contents) { |
147 if (!contents) | 149 if (!contents) |
148 return; | 150 return; |
149 | 151 |
150 gfx::NativeView widget = contents->GetNativeView(); | 152 gfx::NativeView widget = contents->GetNativeView(); |
151 if (widget) | 153 if (widget) |
152 gtk_widget_hide(widget); | 154 gtk_widget_hide(widget); |
153 | 155 |
154 contents->WasHidden(); | 156 contents->WasHidden(); |
155 | |
156 } | 157 } |
157 | 158 |
158 void TabContentsContainerGtk::DetachTabContents(TabContents* tab_contents) { | 159 void TabContentsContainerGtk::DetachTabContents(TabContents* tab_contents) { |
159 gfx::NativeView widget = tab_contents->GetNativeView(); | 160 gfx::NativeView widget = tab_contents->GetNativeView(); |
160 | 161 |
161 // It is possible to detach an unrealized, unparented TabContents if you | 162 // It is possible to detach an unrealized, unparented TabContents if you |
162 // slow things down enough in valgrind. Might happen in the real world, too. | 163 // slow things down enough in valgrind. Might happen in the real world, too. |
163 if (widget && widget->parent) { | 164 if (widget && widget->parent) { |
164 DCHECK_EQ(widget->parent, expanded_); | 165 DCHECK_EQ(widget->parent, expanded_); |
165 gtk_container_remove(GTK_CONTAINER(expanded_), widget); | 166 gtk_container_remove(GTK_CONTAINER(expanded_), widget); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 g_value_set_int(&value, allocation->width - requisition.width); | 235 g_value_set_int(&value, allocation->width - requisition.width); |
235 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 236 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
236 status->widget(), "x", &value); | 237 status->widget(), "x", &value); |
237 | 238 |
238 int child_y = std::max(allocation->height - requisition.height, 0); | 239 int child_y = std::max(allocation->height - requisition.height, 0); |
239 g_value_set_int(&value, child_y + status->y_offset()); | 240 g_value_set_int(&value, child_y + status->y_offset()); |
240 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 241 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
241 status->widget(), "y", &value); | 242 status->widget(), "y", &value); |
242 g_value_unset(&value); | 243 g_value_unset(&value); |
243 } | 244 } |
OLD | NEW |