Notebook: Don’t show raw underline/markup in popup

If @menu_label == NULL, we create a default page->menu_label. This took
@tab_label.get_label() and passed that to page->menu_label.set_text().
This is wrong because we set the plain text of the menu_label from the
rich text of @tab_label. So, if @tab_label used mnemonics or markup, our
menu_label got the raw underline or markup tags shown in it as raw text.

As we call set_text() on the menu Label, the fix is to be symmetric: use
@tab_label’s get_text() as source, as that strips underlines and markup.

It’s not worth making the default Label ‘inherit’ :use-underline/markup;
that’s a slippery slope, and users wanting such things can just create a
fully fledged GtkLabel to pass as @menu_label to suppress the default.

https://bugzilla.gnome.org/show_bug.cgi?id=705509
This commit is contained in:
Daniel Boles 2018-03-16 22:11:58 +00:00
parent b64a403100
commit 146082d464

View File

@ -4332,7 +4332,7 @@ gtk_notebook_update_labels (GtkNotebook *notebook)
{ {
if (GTK_IS_LABEL (page->tab_label)) if (GTK_IS_LABEL (page->tab_label))
gtk_label_set_text (GTK_LABEL (page->menu_label), gtk_label_set_text (GTK_LABEL (page->menu_label),
gtk_label_get_label (GTK_LABEL (page->tab_label))); gtk_label_get_text (GTK_LABEL (page->tab_label)));
else else
gtk_label_set_text (GTK_LABEL (page->menu_label), string); gtk_label_set_text (GTK_LABEL (page->menu_label), string);
} }
@ -5560,7 +5560,7 @@ gtk_notebook_menu_item_create (GtkNotebook *notebook,
if (page->default_menu) if (page->default_menu)
{ {
if (GTK_IS_LABEL (page->tab_label)) if (GTK_IS_LABEL (page->tab_label))
page->menu_label = gtk_label_new (gtk_label_get_label (GTK_LABEL (page->tab_label))); page->menu_label = gtk_label_new (gtk_label_get_text (GTK_LABEL (page->tab_label)));
else else
page->menu_label = gtk_label_new (""); page->menu_label = gtk_label_new ("");
gtk_widget_set_halign (page->menu_label, GTK_ALIGN_START); gtk_widget_set_halign (page->menu_label, GTK_ALIGN_START);