From e56eb7b17b40ee4a1e16a3964b72feddbecea032 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Dec 2019 23:16:57 -0500 Subject: [PATCH] testtooltips: Test tooltips on popovers They do not currently work right. --- tests/testtooltips.c | 68 ++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/tests/testtooltips.c b/tests/testtooltips.c index 04eda125e1..0f9af5ce05 100644 --- a/tests/testtooltips.c +++ b/tests/testtooltips.c @@ -69,17 +69,6 @@ query_tooltip_cb (GtkWidget *widget, return TRUE; } -static gboolean -query_tooltip_custom_cb (GtkWidget *widget, - gint x, - gint y, - gboolean keyboard_tip, - GtkTooltip *tooltip, - gpointer data) -{ - return TRUE; -} - static gboolean query_tooltip_text_view_cb (GtkWidget *widget, gint x, @@ -278,11 +267,10 @@ main (int argc, char *argv[]) GtkWidget *box; GtkWidget *drawing_area; GtkWidget *button; - GtkWidget *label; GtkWidget *tooltip; - - GtkWidget *tooltip_window; - GtkWidget *tooltip_button; + GtkWidget *popover; + GtkWidget *box2; + GtkWidget *custom; GtkWidget *tree_view; GtkTreeViewColumn *column; @@ -352,25 +340,6 @@ main (int argc, char *argv[]) g_assert (g_str_equal ("Another Label tooltip", markup)); g_free (text); g_free (markup); - /* Another one, with a custom tooltip window */ - button = gtk_check_button_new_with_label ("This one has a custom tooltip window!"); - gtk_container_add (GTK_CONTAINER (box), button); - - tooltip_window = gtk_window_new (GTK_WINDOW_POPUP); - tooltip_button = gtk_label_new ("blaat!"); - gtk_container_add (GTK_CONTAINER (tooltip_window), tooltip_button); - gtk_widget_show (tooltip_button); - - gtk_widget_set_tooltip_window (button, GTK_WINDOW (tooltip_window)); - gtk_window_set_type_hint (GTK_WINDOW (tooltip_window), - GDK_SURFACE_TYPE_HINT_TOOLTIP); - gtk_window_set_transient_for (GTK_WINDOW (tooltip_window), - GTK_WINDOW (window)); - - g_signal_connect (button, "query-tooltip", - G_CALLBACK (query_tooltip_custom_cb), NULL); - g_object_set (button, "has-tooltip", TRUE, NULL); - /* An insensitive button */ button = gtk_button_new_with_label ("This one is insensitive"); gtk_widget_set_sensitive (button, FALSE); @@ -435,21 +404,34 @@ main (int argc, char *argv[]) G_CALLBACK (query_tooltip_drawing_area_cb), NULL); gtk_container_add (GTK_CONTAINER (box), drawing_area); - button = gtk_label_new ("Custom tooltip I"); - label = gtk_label_new ("See, custom"); - g_object_ref_sink (label); + button = gtk_menu_button_new (); + gtk_widget_set_halign (button, GTK_ALIGN_CENTER); + gtk_menu_button_set_label (GTK_MENU_BUTTON (button), "Custom tooltip I"); + gtk_container_add (GTK_CONTAINER (box), button); + popover = gtk_popover_new (NULL); + gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover); + box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_container_add (GTK_CONTAINER (popover), box2); + + button = gtk_label_new ("Hidden here"); + custom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); + gtk_container_add (GTK_CONTAINER (custom), gtk_label_new ("See, custom")); + gtk_container_add (GTK_CONTAINER (custom), g_object_new (GTK_TYPE_SPINNER, "active", TRUE, NULL)); + g_object_ref_sink (custom); g_object_set (button, "has-tooltip", TRUE, NULL); + gtk_container_add (GTK_CONTAINER (box2), button); g_signal_connect (button, "query-tooltip", - G_CALLBACK (query_tooltip_label_cb), label); - gtk_container_add (GTK_CONTAINER (box), button); + G_CALLBACK (query_tooltip_label_cb), custom); button = gtk_label_new ("Custom tooltip II"); - label = gtk_label_new ("See, custom, too"); - g_object_ref_sink (label); + custom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); + gtk_container_add (GTK_CONTAINER (custom), gtk_label_new ("See, custom too")); + gtk_container_add (GTK_CONTAINER (custom), g_object_new (GTK_TYPE_SPINNER, "active", TRUE, NULL)); + g_object_ref_sink (custom); g_object_set (button, "has-tooltip", TRUE, NULL); - gtk_container_add (GTK_CONTAINER (box), button); g_signal_connect (button, "query-tooltip", - G_CALLBACK (query_tooltip_label_cb), label); + G_CALLBACK (query_tooltip_label_cb), custom); + gtk_container_add (GTK_CONTAINER (box), button); /* Done! */ gtk_widget_show (window); -- 2.30.2