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/common/gtk_util.h" | 5 #include "chrome/common/gtk_util.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/linux_util.h" | 9 #include "base/linux_util.h" |
| 10 #include "base/logging.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 // Callback used in RemoveAllChildren. | 15 // Callback used in RemoveAllChildren. |
15 void RemoveWidget(GtkWidget* widget, gpointer container) { | 16 void RemoveWidget(GtkWidget* widget, gpointer container) { |
16 gtk_container_remove(GTK_CONTAINER(container), widget); | 17 gtk_container_remove(GTK_CONTAINER(container), widget); |
17 } | 18 } |
18 | 19 |
19 } // namespace | 20 } // namespace |
(...skipping 27 matching lines...) Expand all Loading... |
47 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), top, bottom, left, right); | 48 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), top, bottom, left, right); |
48 gtk_container_add(GTK_CONTAINER(alignment), child); | 49 gtk_container_add(GTK_CONTAINER(alignment), child); |
49 gtk_container_add(GTK_CONTAINER(ebox), alignment); | 50 gtk_container_add(GTK_CONTAINER(ebox), alignment); |
50 return ebox; | 51 return ebox; |
51 } | 52 } |
52 | 53 |
53 void RemoveAllChildren(GtkWidget* container) { | 54 void RemoveAllChildren(GtkWidget* container) { |
54 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); | 55 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); |
55 } | 56 } |
56 | 57 |
| 58 void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { |
| 59 GtkStyle* style = widget->style; |
| 60 PangoFontDescription* font_desc = style->font_desc; |
| 61 // pango_font_description_set_absolute_size sets the font size in device |
| 62 // units, which for us is pixels. |
| 63 pango_font_description_set_absolute_size(font_desc, |
| 64 PANGO_SCALE * size_pixels); |
| 65 gtk_widget_modify_font(widget, font_desc); |
| 66 } |
| 67 |
57 } // namespace gtk_util | 68 } // namespace gtk_util |
OLD | NEW |