[gtk+/wip/baseline: 7/7] Add tests/testbaseline



commit dba6649098a12d0a5c150e81e756e410daaff6ab
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Mar 5 15:23:31 2013 +0100

    Add tests/testbaseline

 tests/Makefile.am    |    5 ++
 tests/testbaseline.c |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 143f8e4..6800774 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -36,6 +36,7 @@ noinst_PROGRAMS =  $(TEST_PROGS)      \
        testappchooser                  \
        testappchooserbutton            \
        testassistant                   \
+       testbaseline                    \
        testbbox                        \
        testboxcss                      \
        testbuttons                     \
@@ -164,6 +165,7 @@ testiconview_DEPENDENCIES = $(TEST_DEPS)
 testaccel_DEPENDENCIES = $(TEST_DEPS)
 testadjustsize_DEPENDENCIES = $(TEST_DEPS)
 testassistant_DEPENDENCIES = $(TEST_DEPS)
+testbaseline_DEPENDENCIES = $(TEST_DEPS)
 testbbox_DEPENDENCIES = $(TEST_DEPS)
 testbuttons_DEPENDENCIES = $(TEST_DEPS)
 testcairo_DEPENDENCIES = $(TEST_DEPS)
@@ -354,6 +356,9 @@ testmerge_SOURCES =                 \
 testactions_SOURCES =          \
        testactions.c
 
+testbaseline_SOURCES =                 \
+       testbaseline.c
+
 testbbox_SOURCES =             \
        testbbox.c
 
diff --git a/tests/testbaseline.c b/tests/testbaseline.c
new file mode 100644
index 0000000..39e2634
--- /dev/null
+++ b/tests/testbaseline.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2006 Nokia Corporation.
+ * Author: Xan Lopez <xan lopez nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <gtk/gtk.h>
+
+int
+main (int    argc,
+      char **argv)
+{
+  GtkWidget *window, *label, *button;
+  GtkWidget *vbox, *hbox;
+  PangoFontDescription *font;
+  int i, j;
+
+  gtk_init (&argc, &argv);
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
+
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_container_add (GTK_CONTAINER (window), vbox);
+
+  for (j = 0; j < 5; j++)
+    {
+      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
+
+      char *aligns[] = { "FILL", "START", "END", "CENTER", "BASELINE" };
+      label = gtk_label_new (aligns[j]);
+      gtk_container_add (GTK_CONTAINER (hbox), label);
+
+      for (i = 0; i < 3; i++) {
+       label = gtk_label_new ("A string XYyj,Ö...");
+
+       font = pango_font_description_new ();
+       pango_font_description_set_size (font, 7*(i+1)* 1024);
+       gtk_widget_override_font (label, font);
+
+       gtk_widget_set_valign (label, j);
+
+       gtk_container_add (GTK_CONTAINER (hbox), label);
+      }
+    }
+
+  for (j = 0; j < 2; j++)
+    {
+      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
+
+      if (j == 0)
+       label = gtk_label_new ("Baseline:");
+      else
+       label = gtk_label_new ("Normal:");
+      gtk_container_add (GTK_CONTAINER (hbox), label);
+
+      for (i = 0; i < 3; i++)
+       {
+         button = gtk_button_new_with_label ("│Xyj,Ö");
+
+         font = pango_font_description_new ();
+         pango_font_description_set_size (font, 7*(i+1)* 1024);
+         gtk_widget_override_font (button, font);
+
+         if (j == 0)
+           gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
+
+         gtk_container_add (GTK_CONTAINER (hbox), button);
+       }
+
+      for (i = 0; i < 3; i++)
+       {
+         button = gtk_button_new_with_label ("│Xyj,Ö");
+
+         gtk_button_set_image (GTK_BUTTON (button),
+                               gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON));
+         gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);
+
+         font = pango_font_description_new ();
+         pango_font_description_set_size (font, 7*(i+1)* 1024);
+         gtk_widget_override_font (button, font);
+
+         if (j == 0)
+           gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
+
+         gtk_container_add (GTK_CONTAINER (hbox), button);
+       }
+    }
+
+  gtk_widget_show_all (window);
+
+  gtk_main ();
+
+  return 0;
+}


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