diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2011-07-15 17:24:01 +0100 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2011-07-23 00:09:30 +0100 |
commit | 0b4d8433d49b596b2d7bb4a97c0b44cf412d3953 (patch) | |
tree | d4f77c70ccfe79ee6b93212d050912f826102ee1 /gtk/gtkprogressbar.c | |
parent | 71a70a7d5cbf7750149702dd7aea67f2f3af45b9 (diff) | |
download | gtk+-0b4d8433d49b596b2d7bb4a97c0b44cf412d3953.tar.gz |
Bug 654266 — No longer possible to set empty text on a GtkProgressBar
Change the semantics of GtkProgressBar:text slightly so that it behaves as
it did before GTK+ 3.
Closes: bgo#654266
Diffstat (limited to 'gtk/gtkprogressbar.c')
-rw-r--r-- | gtk/gtkprogressbar.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index a11f53c5cd..bbf5509c95 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -186,6 +186,10 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class) * the #GtkProgressBar::text property or, if that is %NULL, * the #GtkProgressBar::fraction value, as a percentage. * + * To make a progress bar that is styled and sized suitably for containing + * text (even if the actual text is blank), set #GtkProgressBar:show-text to + * %TRUE and #GtkProgressBar:text to the empty string (not %NULL). + * * Since: 3.0 */ g_object_class_install_property (gobject_class, @@ -1099,6 +1103,14 @@ gtk_progress_bar_pulse (GtkProgressBar *pbar) * @text: (allow-none): a UTF-8 string, or %NULL * * Causes the given @text to appear superimposed on the progress bar. + * + * If @text is %NULL and #GtkProgressBar:show-text is %TRUE, the current + * value of #GtkProgressBar:fraction will be displayed as a percentage. + * + * If @text is non-%NULL and #GtkProgressBar:show-text is %TRUE, the text will + * be displayed. In this case, it will not display the progress percentage. + * If @text is the empty string, the progress bar will still be styled and sized + * suitably for containing text, as long as #GtkProgressBar:show-text is %TRUE. **/ void gtk_progress_bar_set_text (GtkProgressBar *pbar, @@ -1110,8 +1122,12 @@ gtk_progress_bar_set_text (GtkProgressBar *pbar, priv = pbar->priv; + /* Don't notify again if nothing's changed. */ + if (g_strcmp0 (priv->text, text) == 0) + return; + g_free (priv->text); - priv->text = text && *text ? g_strdup (text) : NULL; + priv->text = g_strdup (text); gtk_widget_queue_resize (GTK_WIDGET (pbar)); @@ -1128,6 +1144,10 @@ gtk_progress_bar_set_text (GtkProgressBar *pbar, * the #GtkProgressBar::text property or, if that is %NULL, * the #GtkProgressBar::fraction value, as a percentage. * + * To make a progress bar that is styled and sized suitably for containing + * text (even if the actual text is blank), set #GtkProgressBar:show-text to + * %TRUE and #GtkProgressBar:text to the empty string (not %NULL). + * * Since: 3.0 */ void |