[gtk+/overlay] Some additions to testoverlay
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/overlay] Some additions to testoverlay
- Date: Sat, 11 Jun 2011 02:46:33 +0000 (UTC)
commit 6342e7ee35b8d27b0c511bba3735dad73bad0944
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 10 22:46:02 2011 -0400
Some additions to testoverlay
tests/testoverlay.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/tests/testoverlay.c b/tests/testoverlay.c
index de8f726..1ebb9c6 100644
--- a/tests/testoverlay.c
+++ b/tests/testoverlay.c
@@ -1,6 +1,9 @@
#include <string.h>
#include <gtk/gtk.h>
+/* test that margins and non-zero allocation x/y
+ * of the main widget are handled correctly
+ */
static GtkWidget *
test_nonzerox (void)
{
@@ -9,11 +12,16 @@ test_nonzerox (void)
GtkWidget *overlay;
GtkWidget *text;
GtkWidget *child;
+ GdkRGBA color;
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (win), "Non-zero X");
grid = gtk_grid_new ();
+ gtk_widget_set_margin_top (grid, 5);
+ gtk_widget_set_margin_bottom (grid, 5);
+ gtk_widget_set_margin_left (grid, 5);
+ gtk_widget_set_margin_right (grid, 5);
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);
@@ -21,6 +29,8 @@ test_nonzerox (void)
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Right"), 2, 1, 1, 1);
overlay = gtk_overlay_new ();
+ gdk_rgba_parse (&color, "red");
+ gtk_widget_override_background_color (overlay, 0, &color);
gtk_grid_attach (GTK_GRID (grid), overlay, 1, 1, 1, 1);
text = gtk_text_view_new ();
@@ -35,7 +45,7 @@ test_nonzerox (void)
gtk_overlay_add (GTK_OVERLAY (overlay), child);
gtk_overlay_set_offset (GTK_OVERLAY (overlay), child, 1, 1);
- child = gtk_label_new ("Me too");
+ child = gtk_label_new ("No, I'm the overlay");
gtk_widget_set_halign (child, GTK_ALIGN_END);
gtk_widget_set_valign (child, GTK_ALIGN_END);
gtk_overlay_add (GTK_OVERLAY (overlay), child);
@@ -44,6 +54,9 @@ test_nonzerox (void)
return win;
}
+/* test that margins and non-zero allocation x/y
+ * of the relative widget are handled correctly
+ */
static GtkWidget *
test_relative (void)
{
@@ -52,11 +65,14 @@ test_relative (void)
GtkWidget *overlay;
GtkWidget *text;
GtkWidget *child;
+ GdkRGBA color;
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (win), "Relative positioning");
overlay = gtk_overlay_new ();
+ gdk_rgba_parse (&color, "yellow");
+ gtk_widget_override_background_color (overlay, 0, &color);
gtk_container_add (GTK_CONTAINER (win), overlay);
grid = gtk_grid_new ();
@@ -68,6 +84,10 @@ test_relative (void)
text = gtk_text_view_new ();
gtk_widget_set_size_request (text, 200, 200);
+ gtk_widget_set_margin_top (text, 5);
+ gtk_widget_set_margin_bottom (text, 5);
+ gtk_widget_set_margin_left (text, 5);
+ gtk_widget_set_margin_right (text, 5);
gtk_widget_set_hexpand (text, TRUE);
gtk_widget_set_vexpand (text, TRUE);
gtk_grid_attach (GTK_GRID (grid), text, 1, 1, 1, 1);
@@ -88,6 +108,7 @@ test_relative (void)
return win;
}
+/* test GTK_ALIGN_FILL handling */
static GtkWidget *
test_fullwidth (void)
{
@@ -117,6 +138,7 @@ test_fullwidth (void)
return win;
}
+/* test that scrolling works as expected */
static GtkWidget *
test_scrolling (void)
{
@@ -222,6 +244,7 @@ static const gchar *buffer =
" </object>"
"</interface>";
+/* test that overlays can be constructed with GtkBuilder */
static GtkWidget *
test_builder (void)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]