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> |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 if (height) { | 212 if (height) { |
213 *height = static_cast<int>( | 213 *height = static_cast<int>( |
214 (pango_font_metrics_get_ascent(metrics) + | 214 (pango_font_metrics_get_ascent(metrics) + |
215 pango_font_metrics_get_descent(metrics)) * | 215 pango_font_metrics_get_descent(metrics)) * |
216 height_lines / PANGO_SCALE); | 216 height_lines / PANGO_SCALE); |
217 } | 217 } |
218 pango_font_metrics_unref(metrics); | 218 pango_font_metrics_unref(metrics); |
219 g_object_unref(context); | 219 g_object_unref(context); |
220 } | 220 } |
221 | 221 |
222 void SetWindowWidthFromResources(GtkWindow* window, int resource_id, | |
223 bool resizable) { | |
224 int width; | |
225 gtk_util::GetWidgetSizeFromResources(GTK_WIDGET(window), resource_id, 0, | |
226 &width, NULL); | |
227 if (resizable) { | |
228 gtk_window_set_default_size(window, width, -1); | |
229 } else { | |
230 gtk_widget_set_size_request(GTK_WIDGET(window), width, -1); | |
231 } | |
232 gtk_window_set_resizable(window, resizable ? TRUE : FALSE); | |
mattm
2010/01/09 00:06:36
hm,is this tenary bool->gboolean conversion really
Evan Martin
2010/01/09 00:08:28
I figured it couldn't hurt; the compiler can remov
| |
233 } | |
234 | |
222 void RemoveAllChildren(GtkWidget* container) { | 235 void RemoveAllChildren(GtkWidget* container) { |
223 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); | 236 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); |
224 } | 237 } |
225 | 238 |
226 void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { | 239 void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { |
227 GtkStyle* style = widget->style; | 240 GtkStyle* style = widget->style; |
228 PangoFontDescription* font_desc = style->font_desc; | 241 PangoFontDescription* font_desc = style->font_desc; |
229 // pango_font_description_set_absolute_size sets the font size in device | 242 // pango_font_description_set_absolute_size sets the font size in device |
230 // units, which for us is pixels. | 243 // units, which for us is pixels. |
231 pango_font_description_set_absolute_size(font_desc, | 244 pango_font_description_set_absolute_size(font_desc, |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 g_signal_connect(container, "expose-event", | 650 g_signal_connect(container, "expose-event", |
638 G_CALLBACK(PaintNoBackground), NULL); | 651 G_CALLBACK(PaintNoBackground), NULL); |
639 } | 652 } |
640 | 653 |
641 void WrapLabelAtAllocationHack(GtkWidget* label) { | 654 void WrapLabelAtAllocationHack(GtkWidget* label) { |
642 g_signal_connect(label, "size-allocate", | 655 g_signal_connect(label, "size-allocate", |
643 G_CALLBACK(OnLabelAllocate), NULL); | 656 G_CALLBACK(OnLabelAllocate), NULL); |
644 } | 657 } |
645 | 658 |
646 } // namespace gtk_util | 659 } // namespace gtk_util |
OLD | NEW |