From ad94b004ea85fa82e0f1a67b89a79fddb8885241 Mon Sep 17 00:00:00 2001 From: "altimofeev@chromium.org" Date: Sat, 30 Oct 2010 16:21:55 +0000 Subject: Adds GtkLabel to GtkButton to allow font changing. BUG=chromeos:8234 TEST=none Review URL: http://codereview.chromium.org/4136006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64549 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/button/native_button_gtk.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/views/controls/button/native_button_gtk.cc b/views/controls/button/native_button_gtk.cc index 6720a50..d49f38b 100644 --- a/views/controls/button/native_button_gtk.cc +++ b/views/controls/button/native_button_gtk.cc @@ -33,8 +33,14 @@ void NativeButtonGtk::UpdateLabel() { if (!native_view()) return; - gtk_button_set_label(GTK_BUTTON(native_view()), + GtkWidget* label = gtk_bin_get_child(GTK_BIN(native_view())); + if (!label) { + gtk_button_set_label(GTK_BUTTON(native_view()), + WideToUTF8(native_button_->label()).c_str()); + } else { + gtk_label_set_text(GTK_LABEL(label), WideToUTF8(native_button_->label()).c_str()); + } preferred_size_ = gfx::Size(); } @@ -42,10 +48,13 @@ void NativeButtonGtk::UpdateFont() { if (!native_view()) return; - PangoFontDescription* pfd = native_button_->font().GetNativeFont(); - gtk_widget_modify_font(native_view(), pfd); - pango_font_description_free(pfd); - preferred_size_ = gfx::Size(); + GtkWidget* label = gtk_bin_get_child(GTK_BIN(native_view())); + if (label) { + PangoFontDescription* pfd = native_button_->font().GetNativeFont(); + gtk_widget_modify_font(label, pfd); + pango_font_description_free(pfd); + preferred_size_ = gfx::Size(); + } } void NativeButtonGtk::UpdateEnabled() { @@ -93,7 +102,8 @@ gfx::Size NativeButtonGtk::GetPreferredSize() { } void NativeButtonGtk::CreateNativeControl() { - GtkWidget* widget = gtk_button_new(); + GtkWidget* widget = gtk_button_new_with_label(""); + g_signal_connect(widget, "clicked", G_CALLBACK(CallClickedThunk), this); -- cgit v1.1