[gtk+/grid-widget] Some more tests



commit a0e677bf60fccc83fa3bf562100f880dac2669ca
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 10 01:15:19 2010 -0400

    Some more tests

 tests/testgrid.c |  121 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 117 insertions(+), 4 deletions(-)
---
diff --git a/tests/testgrid.c b/tests/testgrid.c
index b4b9ffe..4355df0 100644
--- a/tests/testgrid.c
+++ b/tests/testgrid.c
@@ -28,15 +28,13 @@ toggle_orientation (GtkWidget *window, GdkEventButton *event, GtkGrid *grid)
   return FALSE;
 }
 
-int
-main (int argc, char *argv[])
+static void
+open_simple_grid (void)
 {
   GtkWidget *window;
   GtkWidget *grid;
   GtkWidget *child;
 
-  gtk_init (&argc, &argv);
-
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   grid = gtk_grid_new ();
   gtk_container_add (GTK_CONTAINER (window), grid);
@@ -56,6 +54,121 @@ main (int argc, char *argv[])
   gtk_container_child_set (GTK_CONTAINER (grid), child, "hexpand", TRUE, NULL);
 
   gtk_widget_show_all (window);
+}
+
+static void
+open_text_grid (void)
+{
+  GtkWidget *window;
+  GtkWidget *grid;
+  GtkWidget *paned1;
+  GtkWidget *box;
+  GtkWidget *label;
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  paned1 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+  gtk_container_add (GTK_CONTAINER (window), paned1);
+
+  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0);
+  gtk_paned_pack1 (GTK_PANED (paned1), box, TRUE, FALSE);
+  gtk_paned_pack2 (GTK_PANED (paned1), gtk_label_new ("Space"), TRUE, FALSE);
+
+  grid = gtk_grid_new ();
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
+  gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("Above"));
+  gtk_container_add (GTK_CONTAINER (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+  gtk_container_add (GTK_CONTAINER (box), grid);
+  gtk_container_add (GTK_CONTAINER (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+  gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("Below"));
+
+  label = gtk_label_new ("Some text that may wrap if it has to");
+  gtk_label_set_width_chars (GTK_LABEL (label), 10);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
+
+  gtk_grid_attach (GTK_GRID (grid), test_widget ("1", "red"), 1, 0, 1, 1);
+  gtk_grid_attach (GTK_GRID (grid), test_widget ("2", "blue"), 0, 1, 1, 1);
+
+  label = gtk_label_new ("Some text that may wrap if it has to");
+  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+  gtk_label_set_width_chars (GTK_LABEL (label), 10);
+  gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
+
+  gtk_widget_show_all (window);
+}
+
+static void
+open_box_comparison (void)
+{
+  GtkWidget *window;
+  GtkWidget *vbox;
+  GtkWidget *box;
+  GtkWidget *label;
+  GtkWidget *grid;
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 5);
+  gtk_container_add (GTK_CONTAINER (window), vbox);
+
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Above"));
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
+  gtk_container_add (GTK_CONTAINER (vbox), box);
+
+  gtk_box_pack_start (GTK_BOX (box), test_widget ("1", "white"), FALSE, FALSE, 0);
+
+  label = gtk_label_new ("Some ellipsizing text");
+  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+  gtk_label_set_width_chars (GTK_LABEL (label), 10);
+  gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);
+
+  gtk_box_pack_start (GTK_BOX (box), test_widget ("2", "green"), FALSE, FALSE, 0);
+
+  label = gtk_label_new ("Some text that may wrap if needed");
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_width_chars (GTK_LABEL (label), 10);
+  gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);
+
+  gtk_box_pack_start (GTK_BOX (box), test_widget ("3", "red"), FALSE, FALSE, 0);
+
+  grid = gtk_grid_new ();
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+  gtk_container_add (GTK_CONTAINER (vbox), grid);
+
+  gtk_grid_attach (GTK_GRID (grid), test_widget ("1", "white"), 0, 0, 1, 1);
+
+  label = gtk_label_new ("Some ellipsizing text");
+  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+  gtk_label_set_width_chars (GTK_LABEL (label), 10);
+  gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
+  gtk_container_child_set (GTK_CONTAINER (grid), label, "hexpand", TRUE, NULL);
+
+  gtk_grid_attach (GTK_GRID (grid), test_widget ("2", "green"), 2, 0, 1, 1);
+
+  label = gtk_label_new ("Some text that may wrap if needed");
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_width_chars (GTK_LABEL (label), 10);
+  gtk_grid_attach (GTK_GRID (grid), label, 3, 0, 1, 1);
+  gtk_container_child_set (GTK_CONTAINER (grid), label, "hexpand", TRUE, NULL);
+
+  gtk_grid_attach (GTK_GRID (grid), test_widget ("3", "red"), 4, 0, 1, 1);
+
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+  gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Below"));
+
+  gtk_widget_show_all (window);
+}
+
+int
+main (int argc, char *argv[])
+{
+  gtk_init (NULL, NULL);
+
+  open_simple_grid ();
+  open_text_grid ();
+  open_box_comparison ();
 
   gtk_main ();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]