summaryrefslogtreecommitdiff
path: root/tests/testtooltips.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2020-04-22 19:32:17 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2020-06-05 20:32:26 +0100
commit6b096e5c5bfffab6cf3a3c2de305826bc2ea03da (patch)
tree6545f91f32efcde23848535cd61d63479b1f3244 /tests/testtooltips.c
parent9ac1eacdc898b4b0277f591810a41794b382f5ad (diff)
downloadgtk+-6b096e5c5bfffab6cf3a3c2de305826bc2ea03da.tar.gz
Make tooltip properties idiomatic
The tooltip handling in GtkWidget is "special": - the string is stored inside the qdata instead of the private instance data - the accessors call g_object_set() and g_object_get(), and the logic is all inside the property implementation, instead of being the other way around - the getters return a copy of the string - the setters don't really notify all the involved properties The GtkWidgetAccessible uses the (escaped) tooltip text as a source for the accessible object description, which means it has to store the tooltip inside the object qdata, and update its copy at construction and property notification time. We can simplify this whole circus by making the tooltip properties (text and markup) more idiomatic: - notify all side-effect properties - return a constant string from the getter - if tooltip-text is set: - store the text as is - escape the markup and store it separately for the markup getter - if tooltip-markup is set: - store the markup as is - parse the markup and store it separately for the text getter The part of the testtooltips interactive test that checks that the getters are doing the right thing is now part of the gtk testsuite, so we ensure we don't regress in behaviour.
Diffstat (limited to 'tests/testtooltips.c')
-rw-r--r--tests/testtooltips.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/testtooltips.c b/tests/testtooltips.c
index 10d4ca4083..e7a91889ff 100644
--- a/tests/testtooltips.c
+++ b/tests/testtooltips.c
@@ -293,7 +293,7 @@ main (int argc, char *argv[])
GtkTextIter iter;
GtkTextTag *tag;
- gchar *text, *markup;
+ const char *text, *markup;
gboolean done = FALSE;
gtk_init ();
@@ -319,9 +319,8 @@ main (int argc, char *argv[])
text = gtk_widget_get_tooltip_text (button);
markup = gtk_widget_get_tooltip_markup (button);
- g_assert (g_str_equal ("Hello, I am a static tooltip.", text));
- g_assert (g_str_equal ("Hello, I am a static tooltip.", markup));
- g_free (text); g_free (markup);
+ g_assert_true (g_str_equal ("Hello, I am a static tooltip.", text));
+ g_assert_true (g_str_equal ("Hello, I am a static tooltip.", markup));
/* A check button using the query-tooltip signal */
button = gtk_check_button_new_with_label ("I use the query-tooltip signal");
@@ -338,9 +337,8 @@ main (int argc, char *argv[])
text = gtk_widget_get_tooltip_text (button);
markup = gtk_widget_get_tooltip_markup (button);
- g_assert (g_str_equal ("Label & and tooltip", text));
- g_assert (g_str_equal ("Label &amp; and tooltip", markup));
- g_free (text); g_free (markup);
+ g_assert_true (g_str_equal ("Label & and tooltip", text));
+ g_assert_true (g_str_equal ("Label &amp; and tooltip", markup));
/* A selectable label */
button = gtk_label_new ("I am a selectable label");
@@ -350,9 +348,8 @@ main (int argc, char *argv[])
text = gtk_widget_get_tooltip_text (button);
markup = gtk_widget_get_tooltip_markup (button);
- g_assert (g_str_equal ("Another Label tooltip", text));
- g_assert (g_str_equal ("<b>Another</b> Label tooltip", markup));
- g_free (text); g_free (markup);
+ g_assert_true (g_str_equal ("Another Label tooltip", text));
+ g_assert_true (g_str_equal ("<b>Another</b> Label tooltip", markup));
/* An insensitive button */
button = gtk_button_new_with_label ("This one is insensitive");