From 5316993fa832907b1e831ae56221c57f02ffbb4f Mon Sep 17 00:00:00 2001 From: "zork@chromium.org" Date: Wed, 11 Nov 2009 00:08:24 +0000 Subject: Update GtkChromeLinkButton to provide an accessor for changing the label. BUG=none TEST=Create a GtkChromeLinkButton, and then use gtk_chrome_link_button_set_label() to change the text. The displayed text should be the new text. Review URL: http://codereview.chromium.org/391005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31618 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/gtk/gtk_chrome_link_button.cc | 24 ++++++++++++++++++++++++ chrome/browser/gtk/gtk_chrome_link_button.h | 4 ++++ 2 files changed, 28 insertions(+) (limited to 'chrome/browser/gtk') diff --git a/chrome/browser/gtk/gtk_chrome_link_button.cc b/chrome/browser/gtk/gtk_chrome_link_button.cc index 886da8e..0534a76 100644 --- a/chrome/browser/gtk/gtk_chrome_link_button.cc +++ b/chrome/browser/gtk/gtk_chrome_link_button.cc @@ -213,4 +213,28 @@ void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, } } +void gtk_chrome_link_button_set_label(GtkChromeLinkButton* button, + const char* text) { + if (button->text) { + free(button->text); + } + button->text = strdup(text); + + // Clear the markup so we can redraw. + if (button->native_markup && (button->native_markup != button->blue_markup)) + g_free(button->native_markup); + button->native_markup = NULL; + if (button->blue_markup) { + g_free(button->blue_markup); + button->blue_markup = NULL; + } + if (button->red_markup) { + g_free(button->red_markup); + button->red_markup = NULL; + } + + if (GTK_WIDGET_VISIBLE(button)) + gtk_widget_queue_draw(GTK_WIDGET(button)); +} + G_END_DECLS diff --git a/chrome/browser/gtk/gtk_chrome_link_button.h b/chrome/browser/gtk/gtk_chrome_link_button.h index adc6771..565eae1 100644 --- a/chrome/browser/gtk/gtk_chrome_link_button.h +++ b/chrome/browser/gtk/gtk_chrome_link_button.h @@ -62,6 +62,10 @@ GtkWidget* gtk_chrome_link_button_new_with_markup(const char* markup); void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, gboolean use_gtk); +// Set the label text of the link. +void gtk_chrome_link_button_set_label(GtkChromeLinkButton* button, + const char* text); + GType gtk_chrome_link_button_get_type(); G_END_DECLS -- cgit v1.1