OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/gtk_chrome_shrinkable_hbox.h" | 5 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 void SumChildrenWidthRequisition(GtkWidget* child, gpointer userdata) { | 34 void SumChildrenWidthRequisition(GtkWidget* child, gpointer userdata) { |
35 if (gtk_widget_get_visible(child)) { | 35 if (gtk_widget_get_visible(child)) { |
36 GtkRequisition req; | 36 GtkRequisition req; |
37 gtk_widget_get_child_requisition(child, &req); | 37 gtk_widget_get_child_requisition(child, &req); |
38 (*reinterpret_cast<int*>(userdata)) += std::max(req.width, 0); | 38 (*reinterpret_cast<int*>(userdata)) += std::max(req.width, 0); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 void ShowInvisibleChildren(GtkWidget* child, gpointer userdata) { | |
43 if (!gtk_widget_get_visible(child)) { | |
44 gtk_widget_show(child); | |
45 ++(*reinterpret_cast<int*>(userdata)); | |
46 } | |
47 } | |
48 | |
49 void ChildSizeAllocate(GtkWidget* child, gpointer userdata) { | 42 void ChildSizeAllocate(GtkWidget* child, gpointer userdata) { |
50 if (!gtk_widget_get_visible(child)) | 43 if (!gtk_widget_get_visible(child)) |
51 return; | 44 return; |
52 | 45 |
53 SizeAllocateData* data = reinterpret_cast<SizeAllocateData*>(userdata); | 46 SizeAllocateData* data = reinterpret_cast<SizeAllocateData*>(userdata); |
54 GtkAllocation child_allocation; | 47 GtkAllocation child_allocation; |
55 gtk_widget_get_allocation(child, &child_allocation); | 48 gtk_widget_get_allocation(child, &child_allocation); |
56 | 49 |
57 if (data->homogeneous) { | 50 if (data->homogeneous) { |
58 // Make sure the child is not overlapped with others' boundary. | 51 // Make sure the child is not overlapped with others' boundary. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 274 |
282 gint gtk_chrome_shrinkable_hbox_get_visible_child_count( | 275 gint gtk_chrome_shrinkable_hbox_get_visible_child_count( |
283 GtkChromeShrinkableHBox* box) { | 276 GtkChromeShrinkableHBox* box) { |
284 gint visible_children_count = 0; | 277 gint visible_children_count = 0; |
285 gtk_container_foreach(GTK_CONTAINER(box), CountVisibleChildren, | 278 gtk_container_foreach(GTK_CONTAINER(box), CountVisibleChildren, |
286 &visible_children_count); | 279 &visible_children_count); |
287 return visible_children_count; | 280 return visible_children_count; |
288 } | 281 } |
289 | 282 |
290 G_END_DECLS | 283 G_END_DECLS |
OLD | NEW |