[gtk+/wip/matthiasc/fancy-overlay] Make the example slighly more fancy
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/fancy-overlay] Make the example slighly more fancy
- Date: Sun, 3 Sep 2017 01:07:17 +0000 (UTC)
commit 6076bd2e3906aaba3e4a1a66c034e21c05059371
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 2 21:06:54 2017 -0400
Make the example slighly more fancy
tests/portland-rose.jpg | Bin 0 -> 469879 bytes
tests/testoverlay.c | 29 ++++++++++++++++++++++-------
2 files changed, 22 insertions(+), 7 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 199380b..7b0ae47 100644
--- a/tests/testoverlay.c
+++ b/tests/testoverlay.c
@@ -541,10 +541,12 @@ test_effect (void)
GtkWidget *overlay;
GtkWidget *button;
GtkWidget *image;
+ GtkWidget *sw;
+ GtkWidget *box;
GtkWidget *label;
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (win), 600, 400);
gtk_window_set_title (GTK_WINDOW (win), "Fancy Effect");
overlay = gtk_overlay_new ();
@@ -552,20 +554,33 @@ test_effect (void)
button = gtk_button_new_with_label ("Don't click this button!");
label = gtk_bin_get_child (GTK_BIN (button));
- g_object_set (label, "margin", 20, NULL);
+ 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_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_START);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), button);
gtk_container_child_set (GTK_CONTAINER (overlay), button, "effect", TRUE, 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 ();
- gtk_image_set_from_file (GTK_IMAGE (image), "/home/mclasen/Pictures/tiny-ele.png");
- gtk_widget_set_halign (image, GTK_ALIGN_FILL);
- gtk_widget_set_valign (image, GTK_ALIGN_FILL);
- gtk_container_add (GTK_CONTAINER (overlay), image);
+ 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]