diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 01:09:41 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 01:09:41 +0000 |
commit | fcf5346e913e6484bc3ece6222af57da21db5b5b (patch) | |
tree | 84de36cd6c9a1f71ffc63ac9c3f1bb14761c1741 /chrome/browser/gtk | |
parent | 844550002b16a17c6b5d4e9bd406117e9ec6d9b2 (diff) | |
download | chromium_src-fcf5346e913e6484bc3ece6222af57da21db5b5b.zip chromium_src-fcf5346e913e6484bc3ece6222af57da21db5b5b.tar.gz chromium_src-fcf5346e913e6484bc3ece6222af57da21db5b5b.tar.bz2 |
Set the label for a chrome link button when the text is set, not when
the expose event fires. This avoids a relayout that happens when the
label is set the first time the link is exposed.
TEST=Put a breakpoint in gtk_chrome_link_button_expose and open the
about dialog. You should hit the breakpoint twice, not four times.
Review URL: http://codereview.chromium.org/411007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_link_button.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/chrome/browser/gtk/gtk_chrome_link_button.cc b/chrome/browser/gtk/gtk_chrome_link_button.cc index 562336f..f62aa71 100644 --- a/chrome/browser/gtk/gtk_chrome_link_button.cc +++ b/chrome/browser/gtk/gtk_chrome_link_button.cc @@ -105,8 +105,6 @@ static gboolean gtk_chrome_link_button_expose(GtkWidget* widget, GtkChromeLinkButton* button = GTK_CHROME_LINK_BUTTON(widget); GtkWidget* label = button->label; - gtk_chrome_link_button_set_text(button); - if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE && button->is_normal) { gtk_label_set_markup(GTK_LABEL(label), button->pressed_markup); button->is_normal = FALSE; @@ -195,6 +193,9 @@ GtkWidget* gtk_chrome_link_button_new(const char* text) { GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); GTK_CHROME_LINK_BUTTON(lb)->text = g_strdup(text); GTK_CHROME_LINK_BUTTON(lb)->uses_markup = FALSE; + + gtk_chrome_link_button_set_text(GTK_CHROME_LINK_BUTTON(lb)); + return lb; } @@ -202,6 +203,9 @@ GtkWidget* gtk_chrome_link_button_new_with_markup(const char* markup) { GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); GTK_CHROME_LINK_BUTTON(lb)->text = g_strdup(markup); GTK_CHROME_LINK_BUTTON(lb)->uses_markup = TRUE; + + gtk_chrome_link_button_set_text(GTK_CHROME_LINK_BUTTON(lb)); + return lb; } @@ -220,14 +224,20 @@ void gtk_chrome_link_button_set_label(GtkChromeLinkButton* button, gtk_chrome_link_button_destroy_text_resources(button); button->text = g_strdup(text); + gtk_chrome_link_button_set_text(button); + if (GTK_WIDGET_VISIBLE(button)) gtk_widget_queue_draw(GTK_WIDGET(button)); } void gtk_chrome_link_button_set_normal_color(GtkChromeLinkButton* button, const GdkColor* color) { + g_free(button->native_markup); + button->native_markup = NULL; g_free(button->normal_markup); button->normal_markup = NULL; + g_free(button->pressed_markup); + button->pressed_markup = NULL; if (color) { snprintf(button->normal_color, 9, "#%02X%02X%02X", color->red / 257, @@ -236,6 +246,8 @@ void gtk_chrome_link_button_set_normal_color(GtkChromeLinkButton* button, strncpy(button->normal_color, "blue", 9); } + gtk_chrome_link_button_set_text(button); + if (GTK_WIDGET_VISIBLE(button)) gtk_widget_queue_draw(GTK_WIDGET(button)); } |