[gtk+/grid-widget] Add a GtkGrid testcase involving scrolling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/grid-widget] Add a GtkGrid testcase involving scrolling
- Date: Sun, 10 Oct 2010 18:53:24 +0000 (UTC)
commit b017a3337890f942def51599d165e9193916d1a8
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 10 14:41:11 2010 -0400
Add a GtkGrid testcase involving scrolling
tests/testgrid.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 58 insertions(+), 1 deletions(-)
---
diff --git a/tests/testgrid.c b/tests/testgrid.c
index 0d0b8f3..eba15f2 100644
--- a/tests/testgrid.c
+++ b/tests/testgrid.c
@@ -1,13 +1,14 @@
#include <gtk/gtk.h>
static GtkWidget *
-test_widget (const gchar *label, const gchar *color)
+oriented_test_widget (const gchar *label, const gchar *color, gdouble angle)
{
GtkWidget *box;
GtkWidget *widget;
GdkColor c;
widget = gtk_label_new (label);
+ gtk_label_set_angle (GTK_LABEL (widget), angle);
box = gtk_event_box_new ();
gdk_color_parse (color, &c);
gtk_widget_modify_bg (box, GTK_STATE_NORMAL, &c);
@@ -16,6 +17,12 @@ test_widget (const gchar *label, const gchar *color)
return box;
}
+static GtkWidget *
+test_widget (const gchar *label, const gchar *color)
+{
+ return oriented_test_widget (label, color, 0.0);
+}
+
static GtkOrientation o;
static gboolean
@@ -190,6 +197,55 @@ empty_line (void)
gtk_widget_show_all (window);
}
+static void
+scrolling (void)
+{
+ GtkWidget *window;
+ GtkWidget *sw;
+ GtkWidget *viewport;
+ GtkWidget *grid;
+ GtkWidget *child;
+ gint i;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ viewport = gtk_viewport_new (NULL, NULL);
+ grid = gtk_grid_new ();
+
+ gtk_container_add (GTK_CONTAINER (window), sw);
+ gtk_container_add (GTK_CONTAINER (sw), viewport);
+ gtk_container_add (GTK_CONTAINER (viewport), grid);
+
+ child = oriented_test_widget ("#800080", "#800080", -45.0);
+ gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1);
+ gtk_container_child_set (GTK_CONTAINER (grid), child,
+ "hexpand", TRUE,
+ "vexpand", TRUE,
+ NULL);
+
+ for (i = 1; i < 16; i++)
+ {
+ gchar *color;
+ color = g_strdup_printf ("#%02x00%02x", 128 + 8*i, 128 - 8*i);
+ child = test_widget (color, color);
+ gtk_grid_attach (GTK_GRID (grid), child, 0, i, i + 1, 1);
+ gtk_container_child_set (GTK_CONTAINER (grid), child, "hexpand", TRUE, NULL);
+ g_free (color);
+ }
+
+ for (i = 1; i < 16; i++)
+ {
+ gchar *color;
+ color = g_strdup_printf ("#%02x00%02x", 128 - 8*i, 128 + 8*i);
+ child = oriented_test_widget (color, color, -90.0);
+ gtk_grid_attach (GTK_GRID (grid), child, i, 0, 1, i);
+ gtk_container_child_set (GTK_CONTAINER (grid), child, "vexpand", TRUE, NULL);
+ g_free (color);
+ }
+
+ gtk_widget_show_all (window);
+}
+
int
main (int argc, char *argv[])
{
@@ -199,6 +255,7 @@ main (int argc, char *argv[])
text_grid ();
box_comparison ();
empty_line ();
+ scrolling ();
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]