diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 00:08:24 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 00:08:24 +0000 |
commit | 5316993fa832907b1e831ae56221c57f02ffbb4f (patch) | |
tree | d9c0c6dda514bf11aadedbb60ddbdc33d0a15a82 /chrome/browser/gtk | |
parent | 5bbb746bf65898d6a77fc2337c4265f4774349d8 (diff) | |
download | chromium_src-5316993fa832907b1e831ae56221c57f02ffbb4f.zip chromium_src-5316993fa832907b1e831ae56221c57f02ffbb4f.tar.gz chromium_src-5316993fa832907b1e831ae56221c57f02ffbb4f.tar.bz2 |
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
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_link_button.cc | 24 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_link_button.h | 4 |
2 files changed, 28 insertions, 0 deletions
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 |