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 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 | 9 |
10 #include <cstdarg> | 10 #include <cstdarg> |
| 11 #include <map> |
11 | 12 |
12 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
13 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
14 #include "base/linux_util.h" | 15 #include "base/linux_util.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "chrome/browser/gtk/cairo_cached_surface.h" | 17 #include "chrome/browser/gtk/cairo_cached_surface.h" |
17 #include "chrome/browser/gtk/gtk_theme_provider.h" | 18 #include "chrome/browser/gtk/gtk_theme_provider.h" |
18 #include "chrome/common/renderer_preferences.h" | 19 #include "chrome/common/renderer_preferences.h" |
19 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (height) { | 217 if (height) { |
217 *height = static_cast<int>( | 218 *height = static_cast<int>( |
218 (pango_font_metrics_get_ascent(metrics) + | 219 (pango_font_metrics_get_ascent(metrics) + |
219 pango_font_metrics_get_descent(metrics)) * | 220 pango_font_metrics_get_descent(metrics)) * |
220 height_lines / PANGO_SCALE); | 221 height_lines / PANGO_SCALE); |
221 } | 222 } |
222 pango_font_metrics_unref(metrics); | 223 pango_font_metrics_unref(metrics); |
223 g_object_unref(context); | 224 g_object_unref(context); |
224 } | 225 } |
225 | 226 |
226 void SetWindowWidthFromResources(GtkWindow* window, int resource_id, | 227 void SetWindowSizeFromResources(GtkWindow* window, |
227 bool resizable) { | 228 int width_id, int height_id, bool resizable) { |
228 int width; | 229 int width = -1; |
229 gtk_util::GetWidgetSizeFromResources(GTK_WIDGET(window), resource_id, 0, | 230 int height = -1; |
230 &width, NULL); | 231 gtk_util::GetWidgetSizeFromResources(GTK_WIDGET(window), width_id, height_id, |
| 232 (width_id != -1) ? &width : NULL, |
| 233 (height_id != -1) ? &height : NULL); |
| 234 |
231 if (resizable) { | 235 if (resizable) { |
232 gtk_window_set_default_size(window, width, -1); | 236 gtk_window_set_default_size(window, width, height); |
233 } else { | 237 } else { |
234 gtk_widget_set_size_request(GTK_WIDGET(window), width, -1); | 238 gtk_widget_set_size_request(GTK_WIDGET(window), width, height); |
235 } | 239 } |
236 gtk_window_set_resizable(window, resizable ? TRUE : FALSE); | 240 gtk_window_set_resizable(window, resizable ? TRUE : FALSE); |
237 } | 241 } |
238 | 242 |
239 void RemoveAllChildren(GtkWidget* container) { | 243 void RemoveAllChildren(GtkWidget* container) { |
240 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); | 244 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); |
241 } | 245 } |
242 | 246 |
243 void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { | 247 void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { |
244 GtkStyle* style = widget->style; | 248 GtkStyle* style = widget->style; |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 g_signal_connect(container, "expose-event", | 712 g_signal_connect(container, "expose-event", |
709 G_CALLBACK(PaintNoBackground), NULL); | 713 G_CALLBACK(PaintNoBackground), NULL); |
710 } | 714 } |
711 | 715 |
712 void WrapLabelAtAllocationHack(GtkWidget* label) { | 716 void WrapLabelAtAllocationHack(GtkWidget* label) { |
713 g_signal_connect(label, "size-allocate", | 717 g_signal_connect(label, "size-allocate", |
714 G_CALLBACK(OnLabelAllocate), NULL); | 718 G_CALLBACK(OnLabelAllocate), NULL); |
715 } | 719 } |
716 | 720 |
717 } // namespace gtk_util | 721 } // namespace gtk_util |
OLD | NEW |