mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
Merge branch 'tooltip-size-simplification' into 'main'
tooltip: Don't play games with max-width-chars Closes #4470 and #5521 See merge request GNOME/gtk!5455
This commit is contained in:
commit
034a8a5501
@ -401,36 +401,12 @@ gtk_tooltip_window_new (void)
|
||||
return g_object_new (GTK_TYPE_TOOLTIP_WINDOW, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
update_label_width (GtkLabel *label)
|
||||
{
|
||||
const char *text;
|
||||
|
||||
text = gtk_label_get_text (label);
|
||||
if (strchr (text, '\n'))
|
||||
{
|
||||
gtk_label_set_wrap (label, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
int len;
|
||||
|
||||
len = g_utf8_strlen (text, -1);
|
||||
|
||||
gtk_label_set_max_width_chars (label, MIN (len, 50));
|
||||
gtk_label_set_wrap (label, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_tooltip_window_set_label_markup (GtkTooltipWindow *window,
|
||||
const char *markup)
|
||||
{
|
||||
if (markup != NULL)
|
||||
{
|
||||
gtk_label_set_markup (GTK_LABEL (window->label), markup);
|
||||
update_label_width (GTK_LABEL (window->label));
|
||||
}
|
||||
gtk_label_set_markup (GTK_LABEL (window->label), markup);
|
||||
|
||||
gtk_widget_set_visible (window->label, markup != NULL);
|
||||
}
|
||||
@ -440,10 +416,7 @@ gtk_tooltip_window_set_label_text (GtkTooltipWindow *window,
|
||||
const char *text)
|
||||
{
|
||||
if (text != NULL)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (window->label), text);
|
||||
update_label_width (GTK_LABEL (window->label));
|
||||
}
|
||||
gtk_label_set_text (GTK_LABEL (window->label), text);
|
||||
|
||||
gtk_widget_set_visible (window->label, text != NULL);
|
||||
}
|
||||
|
@ -13,7 +13,9 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
Loading…
Reference in New Issue
Block a user