[gtk+/overlay: 26/34] Add a small GtkOverlay testcase
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/overlay: 26/34] Add a small GtkOverlay testcase
- Date: Sat, 11 Jun 2011 01:00:50 +0000 (UTC)
commit f215745e50facda6d09d3fc7efa2fdec2c096065
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 10 19:45:16 2011 -0400
Add a small GtkOverlay testcase
tests/Makefile.am | 6 +++++
tests/testoverlay.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fe07779..e01124a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,6 +70,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testoffscreen \
testoffscreenwindow \
testorientable \
+ testoverlay \
testprint \
testrecentchooser \
testrecentchoosermenu \
@@ -172,6 +173,7 @@ testoffscreenwindow_DEPENDENCIES = $(TEST_DEPS)
testappchooser_DEPENDENCIES = $(TEST_DEPS)
testappchooserbutton_DEPENDENCIES = $(TEST_DEPS)
testorientable_DEPENDENCIES = $(TEST_DEPS)
+testoverlay_DEPENDENCIES = $(TEST_DEPS)
testprint_DEPENDENCIES = $(TEST_DEPS)
testrecentchooser_DEPENDENCIES = $(TEST_DEPS)
testrecentchoosermenu_DEPENDENCIES = $(TEST_DEPS)
@@ -256,6 +258,7 @@ testoffscreenwindow_LDADD = $(LDADDS)
testappchooser_LDADD = $(LDADDS)
testappchooserbutton_LDADD = $(LDADDS)
testorientable_LDADD = $(LDADDS)
+testoverlay_LDADD = $(LDADDS)
testprint_LDADD = $(LDADDS)
testrecentchooser_LDADD = $(LDADDS)
testrecentchoosermenu_LDADD = $(LDADDS)
@@ -423,6 +426,9 @@ testoffscreen_SOURCES = \
testoffscreenwindow_SOURCES = \
testoffscreenwindow.c
+testoverlay_SOURCES = \
+ testoverlay.c
+
testappchooser_SOURCES = \
testappchooser.c
diff --git a/tests/testoverlay.c b/tests/testoverlay.c
new file mode 100644
index 0000000..5c47dcb
--- /dev/null
+++ b/tests/testoverlay.c
@@ -0,0 +1,59 @@
+#include <gtk/gtk.h>
+
+static GtkWidget *
+test_nonzerox (void)
+{
+ GtkWidget *win;
+ GtkWidget *grid;
+ GtkWidget *overlay;
+ GtkWidget *text;
+ GtkWidget *child;
+
+ win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (win), "Non-zero X");
+
+ grid = gtk_grid_new ();
+ gtk_container_add (GTK_CONTAINER (win), grid);
+ gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Above"), 1, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Below"), 1, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Left"), 0, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Right"), 2, 1, 1, 1);
+
+ overlay = gtk_overlay_new ();
+ gtk_widget_set_hexpand (overlay, TRUE);
+ gtk_widget_set_vexpand (overlay, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), overlay, 1, 1, 1, 1);
+
+ text = gtk_text_view_new ();
+ gtk_widget_set_size_request (text, 200, 200);
+ gtk_container_add (GTK_CONTAINER (overlay), text);
+
+ child = gtk_label_new ("I'm the overlay");
+ gtk_widget_set_halign (child, GTK_ALIGN_START);
+ gtk_widget_set_valign (child, GTK_ALIGN_START);
+ gtk_overlay_add (GTK_OVERLAY (overlay), child);
+ gtk_overlay_set_offset (GTK_OVERLAY (overlay), child, 1, 1);
+
+ child = gtk_label_new ("Me too");
+ gtk_widget_set_halign (child, GTK_ALIGN_END);
+ gtk_widget_set_valign (child, GTK_ALIGN_END);
+ gtk_overlay_add (GTK_OVERLAY (overlay), child);
+ gtk_overlay_set_offset (GTK_OVERLAY (overlay), child, -1, -1);
+
+ return win;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *win;
+
+ gtk_init (&argc, &argv);
+
+ win = test_nonzerox ();
+ gtk_widget_show_all (win);
+
+ gtk_main ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]