diff options
author | altimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-30 16:21:55 +0000 |
---|---|---|
committer | altimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-30 16:21:55 +0000 |
commit | ad94b004ea85fa82e0f1a67b89a79fddb8885241 (patch) | |
tree | 31ef296db4aa4c10302e1e59bdb58ee974ffdd26 | |
parent | c85c424f309f1b1d53cd54d4828ee1b2f5089ac4 (diff) | |
download | chromium_src-ad94b004ea85fa82e0f1a67b89a79fddb8885241.zip chromium_src-ad94b004ea85fa82e0f1a67b89a79fddb8885241.tar.gz chromium_src-ad94b004ea85fa82e0f1a67b89a79fddb8885241.tar.bz2 |
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
-rw-r--r-- | views/controls/button/native_button_gtk.cc | 22 |
1 files 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); |