summaryrefslogtreecommitdiffstats
path: root/chrome/common/gtk_util.cc
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 18:59:04 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 18:59:04 +0000
commit2a8ae3d8d34d9848688fa13dcf14e3c0325614a1 (patch)
treea44e48e0dc373471ca591d304f4ed4b8869f5c59 /chrome/common/gtk_util.cc
parent27ac03eefb96c503b417a1a3e545eb3499b1f9e5 (diff)
downloadchromium_src-2a8ae3d8d34d9848688fa13dcf14e3c0325614a1.zip
chromium_src-2a8ae3d8d34d9848688fa13dcf14e3c0325614a1.tar.gz
chromium_src-2a8ae3d8d34d9848688fa13dcf14e3c0325614a1.tar.bz2
Set the initial sizes of several dialogs based on font information.
BUG=19622 TEST=none Review URL: http://codereview.chromium.org/180031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/gtk_util.cc')
-rw-r--r--chrome/common/gtk_util.cc29
1 files changed, 16 insertions, 13 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 83ddddd..5446a3d 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -121,25 +121,28 @@ GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color,
return ebox;
}
-bool GetWidgetSizeFromResources(GtkWidget* widget, int width_chars,
+void GetWidgetSizeFromResources(GtkWidget* widget, int width_chars,
int height_lines, int* width, int* height) {
PangoContext* context = gtk_widget_create_pango_context(widget);
PangoFontMetrics* metrics = pango_context_get_metrics(context,
widget->style->font_desc, pango_context_get_language(context));
- double chars = 0;
- StringToDouble(l10n_util::GetStringUTF8(width_chars), &chars);
- *width =
- pango_font_metrics_get_approximate_char_width(metrics) *
- static_cast<int>(chars) / PANGO_SCALE;
- double lines = 0;
- StringToDouble(l10n_util::GetStringUTF8(height_lines), &lines);
- *height =
- (pango_font_metrics_get_ascent(metrics) +
- pango_font_metrics_get_descent(metrics)) *
- static_cast<int>(lines) / PANGO_SCALE;
+ if (width) {
+ double chars = 0;
+ StringToDouble(l10n_util::GetStringUTF8(width_chars), &chars);
+ *width = static_cast<int>(
+ pango_font_metrics_get_approximate_char_width(metrics) *
+ chars / PANGO_SCALE);
+ }
+ if (height) {
+ double lines = 0;
+ StringToDouble(l10n_util::GetStringUTF8(height_lines), &lines);
+ *height = static_cast<int>(
+ (pango_font_metrics_get_ascent(metrics) +
+ pango_font_metrics_get_descent(metrics)) *
+ lines / PANGO_SCALE);
+ }
pango_font_metrics_unref(metrics);
g_object_unref(context);
- return true;
}
void RemoveAllChildren(GtkWidget* container) {