Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Side by Side Diff: chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.cc

Issue 7227027: GTK: More 2.18 goodness. Move from macros to real accessor functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove views/ Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
11 namespace { 11 namespace {
12 12
13 enum { 13 enum {
14 PROP_0, 14 PROP_0,
15 PROP_HIDE_CHILD_DIRECTLY 15 PROP_HIDE_CHILD_DIRECTLY
16 }; 16 };
17 17
18 struct SizeAllocateData { 18 struct SizeAllocateData {
19 GtkChromeShrinkableHBox* box; 19 GtkChromeShrinkableHBox* box;
20 GtkAllocation* allocation; 20 GtkAllocation* allocation;
21 GtkTextDirection direction; 21 GtkTextDirection direction;
22 bool homogeneous; 22 bool homogeneous;
23 int border_width; 23 int border_width;
24 24
25 // Maximum child width when |homogeneous| is TRUE. 25 // Maximum child width when |homogeneous| is TRUE.
26 int homogeneous_child_width; 26 int homogeneous_child_width;
27 }; 27 };
28 28
29 void CountVisibleChildren(GtkWidget* child, gpointer userdata) { 29 void CountVisibleChildren(GtkWidget* child, gpointer userdata) {
30 if (GTK_WIDGET_VISIBLE(child)) 30 if (gtk_widget_get_visible(child))
31 ++(*reinterpret_cast<int*>(userdata)); 31 ++(*reinterpret_cast<int*>(userdata));
32 } 32 }
33 33
34 void SumChildrenWidthRequisition(GtkWidget* child, gpointer userdata) { 34 void SumChildrenWidthRequisition(GtkWidget* child, gpointer userdata) {
35 if (GTK_WIDGET_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) { 42 void ShowInvisibleChildren(GtkWidget* child, gpointer userdata) {
43 if (!GTK_WIDGET_VISIBLE(child)) { 43 if (!gtk_widget_get_visible(child)) {
44 gtk_widget_show(child); 44 gtk_widget_show(child);
45 ++(*reinterpret_cast<int*>(userdata)); 45 ++(*reinterpret_cast<int*>(userdata));
46 } 46 }
47 } 47 }
48 48
49 void ChildSizeAllocate(GtkWidget* child, gpointer userdata) { 49 void ChildSizeAllocate(GtkWidget* child, gpointer userdata) {
50 if (!GTK_WIDGET_VISIBLE(child)) 50 if (!gtk_widget_get_visible(child))
51 return; 51 return;
52 52
53 SizeAllocateData* data = reinterpret_cast<SizeAllocateData*>(userdata); 53 SizeAllocateData* data = reinterpret_cast<SizeAllocateData*>(userdata);
54 GtkAllocation child_allocation = child->allocation; 54 GtkAllocation child_allocation = child->allocation;
55 55
56 if (data->homogeneous) { 56 if (data->homogeneous) {
57 // Make sure the child is not overlapped with others' boundary. 57 // Make sure the child is not overlapped with others' boundary.
58 if (child_allocation.width > data->homogeneous_child_width) { 58 if (child_allocation.width > data->homogeneous_child_width) {
59 child_allocation.x += 59 child_allocation.x +=
60 (child_allocation.width - data->homogeneous_child_width) / 2; 60 (child_allocation.width - data->homogeneous_child_width) / 2;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 gint gtk_chrome_shrinkable_hbox_get_visible_child_count( 275 gint gtk_chrome_shrinkable_hbox_get_visible_child_count(
276 GtkChromeShrinkableHBox* box) { 276 GtkChromeShrinkableHBox* box) {
277 gint visible_children_count = 0; 277 gint visible_children_count = 0;
278 gtk_container_foreach(GTK_CONTAINER(box), CountVisibleChildren, 278 gtk_container_foreach(GTK_CONTAINER(box), CountVisibleChildren,
279 &visible_children_count); 279 &visible_children_count);
280 return visible_children_count; 280 return visible_children_count;
281 } 281 }
282 282
283 G_END_DECLS 283 G_END_DECLS
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_chrome_link_button.cc ('k') | chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698