mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-15 05:00:09 +00:00
Merge branch 'label-underline-markup' into 'master'
label: Fix mnemonic handling Closes #4041 See merge request GNOME/gtk!3670
This commit is contained in:
commit
0a9d2f248e
@ -2981,8 +2981,18 @@ gtk_label_recalculate (GtkLabel *self)
|
||||
gtk_label_clear_layout (self);
|
||||
gtk_label_clear_select_info (self);
|
||||
|
||||
if (self->use_markup || self->use_underline)
|
||||
gtk_label_set_markup_internal (self, self->label, self->use_underline);
|
||||
if (self->use_markup)
|
||||
{
|
||||
gtk_label_set_markup_internal (self, self->label, self->use_underline);
|
||||
}
|
||||
else if (self->use_underline)
|
||||
{
|
||||
char *text;
|
||||
|
||||
text = g_markup_escape_text (self->label, -1);
|
||||
gtk_label_set_markup_internal (self, text, TRUE);
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_clear_pointer (&self->markup_attrs, pango_attr_list_unref);
|
||||
|
@ -196,12 +196,35 @@ test_label_markup (void)
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
static void
|
||||
test_label_underline (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *label;
|
||||
|
||||
window = gtk_window_new ();
|
||||
|
||||
label = gtk_label_new ("");
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), label);
|
||||
gtk_window_set_mnemonics_visible (GTK_WINDOW (window), TRUE);
|
||||
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), FALSE);
|
||||
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_label (GTK_LABEL (label), "tes_t & no markup <<");
|
||||
|
||||
g_assert_cmpint (gtk_label_get_mnemonic_keyval (GTK_LABEL (label)), ==, GDK_KEY_t);
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/label/markup-parse", test_label_markup);
|
||||
g_test_add_func ("/label/underline-parse", test_label_underline);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user