diff options
-rw-r--r-- | chrome/browser/gtk/first_run_bubble.cc | 14 | ||||
-rw-r--r-- | chrome/browser/gtk/first_run_dialog.cc | 2 | ||||
-rw-r--r-- | chrome/common/gtk_util.cc | 2 |
3 files changed, 13 insertions, 5 deletions
diff --git a/chrome/browser/gtk/first_run_bubble.cc b/chrome/browser/gtk/first_run_bubble.cc index 4711c6f..71ca985 100644 --- a/chrome/browser/gtk/first_run_bubble.cc +++ b/chrome/browser/gtk/first_run_bubble.cc @@ -109,14 +109,18 @@ FirstRunBubble::FirstRunBubble(Profile* profile, l10n_util::GetStringUTF8(IDS_FR_BUBBLE_CHANGE).c_str()); content_ = gtk_vbox_new(FALSE, 5); - int width, height; - gtk_util::GetWidgetSizeFromResources(content_, + + // We compute the widget's size using the parent window -- |content_| is + // unrealized at this point. + int width = -1, height = -1; + gtk_util::GetWidgetSizeFromResources( + GTK_WIDGET(parent_), IDS_FIRSTRUNBUBBLE_DIALOG_WIDTH_CHARS, IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES, &width, &height); - // TODO(estade): for now, don't set the height explicitly. The bubble is way - // too large for the text it contains. - gtk_widget_set_size_request(content_, width, -1); + // Resize the labels so that they don't wrap more than necessary. We leave + // |content_| unsized so that it'll expand as needed to hold the other + // widgets -- the buttons may be wider than |width| on high-DPI displays. gtk_widget_set_size_request(label1, width, -1); gtk_widget_set_size_request(label2, width, -1); gtk_widget_set_size_request(label3, width, -1); diff --git a/chrome/browser/gtk/first_run_dialog.cc b/chrome/browser/gtk/first_run_dialog.cc index b8797c9..aab26cb 100644 --- a/chrome/browser/gtk/first_run_dialog.cc +++ b/chrome/browser/gtk/first_run_dialog.cc @@ -43,6 +43,8 @@ FirstRunDialog::FirstRunDialog(Profile* profile, int& response) GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE); + + gtk_widget_realize(dialog_); int width, height; gtk_util::GetWidgetSizeFromResources(dialog_, IDS_FIRSTRUN_DIALOG_WIDTH_CHARS, diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index e88ceb7..2c42f7d 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -159,6 +159,8 @@ GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, void GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, int height_lines, int* width, int* height) { + DCHECK(GTK_WIDGET_REALIZED(widget)) + << " widget must be realized to compute font metrics correctly"; PangoContext* context = gtk_widget_create_pango_context(widget); PangoFontMetrics* metrics = pango_context_get_metrics(context, widget->style->font_desc, pango_context_get_language(context)); |