[gtk/modelbutton-tooltip: 2/2] modelbutton: Set up tooltips
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/modelbutton-tooltip: 2/2] modelbutton: Set up tooltips
- Date: Wed, 19 Oct 2022 02:36:35 +0000 (UTC)
commit 55ccaf9df9af4322266fa79cfad144575c16f23d
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Oct 18 22:35:28 2022 -0400
modelbutton: Set up tooltips
Use the text of iconic model buttons as tooltip.
Fixes: #5220
gtk/gtkmodelbutton.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index c24115dd1a..c6565af843 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -640,6 +640,22 @@ update_visibility (GtkModelButton *self)
}
}
+static void
+update_tooltip (GtkModelButton *self)
+{
+ if (self->iconic)
+ {
+ if (gtk_label_get_use_markup (GTK_LABEL (self->label)))
+ gtk_widget_set_tooltip_markup (GTK_WIDGET (self), gtk_label_get_text (GTK_LABEL (self->label)));
+ else
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), gtk_label_get_text (GTK_LABEL (self->label)));
+ }
+ else
+ {
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), NULL);
+ }
+}
+
static void
gtk_model_button_set_icon (GtkModelButton *self,
GIcon *icon)
@@ -662,6 +678,8 @@ gtk_model_button_set_icon (GtkModelButton *self,
}
update_visibility (self);
+ update_tooltip (self);
+
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
}
@@ -669,9 +687,9 @@ static void
gtk_model_button_set_text (GtkModelButton *button,
const char *text)
{
- gtk_label_set_text_with_mnemonic (GTK_LABEL (button->label),
- text ? text : "");
+ gtk_label_set_text_with_mnemonic (GTK_LABEL (button->label), text ? text : "");
update_visibility (button);
+ update_tooltip (button);
gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_RELATION_LABELLED_BY, button->label, NULL,
@@ -690,6 +708,8 @@ gtk_model_button_set_use_markup (GtkModelButton *button,
gtk_label_set_use_markup (GTK_LABEL (button->label), use_markup);
update_visibility (button);
+ update_tooltip (button);
+
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_USE_MARKUP]);
}
@@ -769,6 +789,7 @@ gtk_model_button_set_iconic (GtkModelButton *self,
update_node_name (self);
update_visibility (self);
+ update_tooltip (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICONIC]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]