[gtk+/overlay: 28/34] Add a test for relative widget support in GtkOverlay
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/overlay: 28/34] Add a test for relative widget support in GtkOverlay
- Date: Sat, 11 Jun 2011 01:01:00 +0000 (UTC)
commit 0de6a5b357e083622fe90ee59c72c3114c4fae5a
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 10 20:12:43 2011 -0400
Add a test for relative widget support in GtkOverlay
tests/testoverlay.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 53 insertions(+), 5 deletions(-)
---
diff --git a/tests/testoverlay.c b/tests/testoverlay.c
index 5c47dcb..a641b8c 100644
--- a/tests/testoverlay.c
+++ b/tests/testoverlay.c
@@ -20,12 +20,12 @@ test_nonzerox (void)
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_widget_set_hexpand (text, TRUE);
+ gtk_widget_set_vexpand (text, TRUE);
gtk_container_add (GTK_CONTAINER (overlay), text);
child = gtk_label_new ("I'm the overlay");
@@ -43,15 +43,63 @@ test_nonzerox (void)
return win;
}
+static GtkWidget *
+test_relative (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), "Relative positioning");
+
+ overlay = gtk_overlay_new ();
+ gtk_container_add (GTK_CONTAINER (win), overlay);
+
+ grid = gtk_grid_new ();
+ gtk_container_add (GTK_CONTAINER (overlay), 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);
+
+ text = gtk_text_view_new ();
+ gtk_widget_set_size_request (text, 200, 200);
+ gtk_widget_set_hexpand (text, TRUE);
+ gtk_widget_set_vexpand (text, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), text, 1, 1, 1, 1);
+ gtk_overlay_set_relative_widget (GTK_OVERLAY (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;
+ GtkWidget *win1;
+ GtkWidget *win2;
gtk_init (&argc, &argv);
- win = test_nonzerox ();
- gtk_widget_show_all (win);
+ win1 = test_nonzerox ();
+ gtk_widget_show_all (win1);
+
+ win2 = test_relative ();
+ gtk_widget_show_all (win2);
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]