Add a test for overlay blur

This commit is contained in:
Matthias Clasen 2017-09-02 20:43:42 -04:00
parent 31349e71d3
commit 93c67eaf6d
2 changed files with 66 additions and 0 deletions

BIN
tests/portland-rose.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 KiB

View File

@ -534,6 +534,68 @@ test_child_order (void)
}
static GtkWidget *
test_effect (void)
{
GtkWidget *win;
GtkWidget *overlay;
GtkWidget *button;
GtkWidget *image;
GtkWidget *sw;
GtkWidget *box;
GtkWidget *label;
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (win), 600, 400);
gtk_window_set_title (GTK_WINDOW (win), "Fancy Effect");
overlay = gtk_overlay_new ();
gtk_container_add (GTK_CONTAINER (win), overlay);
button = gtk_button_new_with_label ("Don't click this button!");
label = gtk_bin_get_child (GTK_BIN (button));
g_object_set (label, "margin", 50, NULL);
gtk_widget_set_opacity (button, 0.7);
gtk_widget_set_halign (button, GTK_ALIGN_FILL);
gtk_widget_set_valign (button, GTK_ALIGN_START);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), button);
gtk_container_child_set (GTK_CONTAINER (overlay), button, "blur", 5.0, NULL);
button = gtk_button_new_with_label ("Maybe this one?");
label = gtk_bin_get_child (GTK_BIN (button));
g_object_set (label, "margin", 50, NULL);
gtk_widget_set_opacity (button, 0.7);
gtk_widget_set_halign (button, GTK_ALIGN_FILL);
gtk_widget_set_valign (button, GTK_ALIGN_END);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), button);
gtk_container_child_set (GTK_CONTAINER (overlay), button, "blur", 5.0, NULL);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (overlay), sw);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (sw), box);
image = gtk_image_new ();
if (g_file_test ("portland-rose.jpg", G_FILE_TEST_EXISTS))
gtk_image_set_from_file (GTK_IMAGE (image), "portland-rose.jpg");
else if (g_file_test ("tests/portland-rose.jpg", G_FILE_TEST_EXISTS))
gtk_image_set_from_file (GTK_IMAGE (image), "tests/portland-rose.jpg");
else if (g_file_test ("../tests/portland-rose.jpg", G_FILE_TEST_EXISTS))
gtk_image_set_from_file (GTK_IMAGE (image), "../tests/portland-rose.jpg");
else
g_error ("portland-rose.jpg not found. No rose for you!\n");
gtk_container_add (GTK_CONTAINER (box), image);
return win;
}
int
main (int argc, char *argv[])
{
@ -546,6 +608,7 @@ main (int argc, char *argv[])
GtkWidget *win7;
GtkWidget *win8;
GtkWidget *win9;
GtkWidget *win10;
GtkCssProvider *css_provider;
gtk_init ();
@ -586,6 +649,9 @@ main (int argc, char *argv[])
win9 = test_child_order ();
gtk_widget_show (win9);
win10 = test_effect ();
gtk_widget_show (win10);
gtk_main ();
return 0;