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_util.h" | 5 #include "chrome/browser/ui/gtk/gtk_util.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "ui/base/gtk/gtk_compat.h" | 38 #include "ui/base/gtk/gtk_compat.h" |
39 #include "ui/base/gtk/gtk_hig_constants.h" | 39 #include "ui/base/gtk/gtk_hig_constants.h" |
40 #include "ui/base/gtk/gtk_screen_util.h" | 40 #include "ui/base/gtk/gtk_screen_util.h" |
41 #include "ui/base/gtk/menu_label_accelerator_util.h" | 41 #include "ui/base/gtk/menu_label_accelerator_util.h" |
42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
44 #include "ui/base/text/text_elider.h" | 44 #include "ui/base/text/text_elider.h" |
45 #include "ui/base/x/x11_util.h" | 45 #include "ui/base/x/x11_util.h" |
46 #include "ui/gfx/image/cairo_cached_surface.h" | 46 #include "ui/gfx/image/cairo_cached_surface.h" |
47 #include "ui/gfx/image/image.h" | 47 #include "ui/gfx/image/image.h" |
| 48 #include "ui/gfx/pango_util.h" |
48 | 49 |
49 // These conflict with base/tracked_objects.h, so need to come last. | 50 // These conflict with base/tracked_objects.h, so need to come last. |
50 #include <gdk/gdkx.h> // NOLINT | 51 #include <gdk/gdkx.h> // NOLINT |
51 #include <gtk/gtk.h> // NOLINT | 52 #include <gtk/gtk.h> // NOLINT |
52 | 53 |
53 using content::RenderWidgetHost; | 54 using content::RenderWidgetHost; |
54 using content::WebContents; | 55 using content::WebContents; |
55 | 56 |
56 namespace { | 57 namespace { |
57 | 58 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 gtk_window_group_add_window(group, *it); | 496 gtk_window_group_add_window(group, *it); |
496 } | 497 } |
497 } | 498 } |
498 } | 499 } |
499 | 500 |
500 void RemoveAllChildren(GtkWidget* container) { | 501 void RemoveAllChildren(GtkWidget* container) { |
501 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); | 502 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); |
502 } | 503 } |
503 | 504 |
504 void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { | 505 void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { |
505 PangoFontDescription* font_desc = pango_font_description_new(); | 506 gfx::ScopedPangoFontDescription font_desc(pango_font_description_new()); |
506 // pango_font_description_set_absolute_size sets the font size in device | 507 // pango_font_description_set_absolute_size sets the font size in device |
507 // units, which for us is pixels. | 508 // units, which for us is pixels. |
508 pango_font_description_set_absolute_size(font_desc, | 509 pango_font_description_set_absolute_size(font_desc.get(), |
509 PANGO_SCALE * size_pixels); | 510 PANGO_SCALE * size_pixels); |
510 gtk_widget_modify_font(widget, font_desc); | 511 gtk_widget_modify_font(widget, font_desc.get()); |
511 pango_font_description_free(font_desc); | |
512 } | 512 } |
513 | 513 |
514 void UndoForceFontSize(GtkWidget* widget) { | 514 void UndoForceFontSize(GtkWidget* widget) { |
515 gtk_widget_modify_font(widget, NULL); | 515 gtk_widget_modify_font(widget, NULL); |
516 } | 516 } |
517 | 517 |
518 gfx::Size GetWidgetSize(GtkWidget* widget) { | 518 gfx::Size GetWidgetSize(GtkWidget* widget) { |
519 GtkRequisition size; | 519 GtkRequisition size; |
520 gtk_widget_size_request(widget, &size); | 520 gtk_widget_size_request(widget, &size); |
521 return gfx::Size(size.width, size.height); | 521 return gfx::Size(size.width, size.height); |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 | 1169 |
1170 void DoCopy(BrowserWindow* window) { | 1170 void DoCopy(BrowserWindow* window) { |
1171 DoCutCopyPaste(window, &RenderWidgetHost::Copy, "copy-clipboard"); | 1171 DoCutCopyPaste(window, &RenderWidgetHost::Copy, "copy-clipboard"); |
1172 } | 1172 } |
1173 | 1173 |
1174 void DoPaste(BrowserWindow* window) { | 1174 void DoPaste(BrowserWindow* window) { |
1175 DoCutCopyPaste(window, &RenderWidgetHost::Paste, "paste-clipboard"); | 1175 DoCutCopyPaste(window, &RenderWidgetHost::Paste, "paste-clipboard"); |
1176 } | 1176 } |
1177 | 1177 |
1178 } // namespace gtk_util | 1178 } // namespace gtk_util |
OLD | NEW |