[gtk+] Add a test for overlay blur
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a test for overlay blur
- Date: Mon, 4 Sep 2017 18:29:07 +0000 (UTC)
commit 93c67eaf6dde850714014213425cf12fe7667725
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 2 20:43:42 2017 -0400
Add a test for overlay blur
tests/portland-rose.jpg | Bin 0 -> 469879 bytes
tests/testoverlay.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/tests/portland-rose.jpg b/tests/portland-rose.jpg
new file mode 100644
index 0000000..89974da
Binary files /dev/null and b/tests/portland-rose.jpg differ
diff --git a/tests/testoverlay.c b/tests/testoverlay.c
index 9c3b001..a29b82f 100644
--- a/tests/testoverlay.c
+++ b/tests/testoverlay.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]